#include "TFile.h" #include "TCanvas.h" #include "TStyle.h" #include "TH1.h" #include "TH2.h" #include "TH3.h" #include "TGaxis.h" #include "TRandom.h" #include "TLegend.h" #include "TPaveStats.h" #include "TGraph.h" #include "TSystem.h" #include "TTree.h" #include "TTreePlayer.h" #include "TF1.h" #include "TCut.h" #include "TPaletteAxis.h" void caloeff() { int ifile=500596; //Root File number name. To change each time int a=9; //First subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int b=12; //Second subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int c=13; //Third subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int d=14; //Fourth subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int e=15; //Fifth subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int f=0; //Sixth subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int g=1; //Seventh subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int h=2; //Eightth subdetector name to analyze. To change each time //TO USE FOR FILES WITH THE TARGET int csig=3;//Sigma const int p1p2=2; //a,b int p13subp23sub=2; //a,c int p14subp24sub=2; //a,d int p15subp25sub=2; //a,e int p16subp26sub=1; //a,f int p17subp27sub=1; //a,g int p18subp28sub=1; //a,h float p1; float p2; float p03sub; float p13sub; float p23sub; float p04sub; float p14sub; float p24sub; float p05sub; float p15sub; float p25sub; float p06sub; float p16sub; float p26sub; float p07sub; float p17sub; float p27sub; float p08sub; float p18sub; float p28sub; char dirin[50];//Directory where there is the input root file char dirout[50];//Main Directory where to save the output files char htempname[50]; char htempabname[50]; char heneabname[50]; char fobject[50]; char cdenename[50]; char cddeltatimeXname[50]; char cddeltatimeYname[50]; char cdtempXnameab[50]; char cdtempYnameab[50]; char cdeneXnameab[50]; char cdeneYnameab[50]; char particletype[200]; char timenamesuba[50]; char timeenergynamesuba[50]; char timenamesubb[50]; char timeenergynamesubb[50]; char timenamesubc[50]; char timeenergynamesubc[50]; char timenamesubd[50]; char timeenergynamesubd[50]; char timenamesube[50]; char timeenergynamesube[50]; char timenamesubf[50]; char timeenergynamesubf[50]; char timenamesubg[50]; char timeenergynamesubg[50]; char timenamesubh[50]; char timeenergynamesubh[50]; char energyunit[50]; sprintf(dirin, "C:/si-calo-sep18/"); //TO USE FOR FILES WITH THE TARGET //sprintf(dirin, "D:/data_calib/"); //TO USE FOR FILES WITHOUT THE TARGET sprintf(dirout, "C:/"); sprintf(htempname, "#DeltaTime"); sprintf(htempabname, "Time"); sprintf(heneabname, "Energy"); sprintf(fobject, "lemma"); sprintf(cdenename, "Energy"); sprintf(cddeltatimeXname, "#DeltaTime (ns)"); sprintf(cddeltatimeYname, "# Counts"); sprintf(cdtempXnameab, "Time (ns)"); sprintf(cdtempYnameab, "# Counts"); sprintf(cdeneXnameab, "Energy (ADC counts)"); sprintf(cdeneYnameab, "# Counts/ADC counts"); sprintf(particletype, "si-%d, #mu^{+}_{22GeV}:",ifile); sprintf(energyunit, "ADC counts"); if (a==8 || a==9 || a==6 || a==7 ) { sprintf(timenamesuba, "Scintillator"); //First subdetector tipology name for time plot. sprintf(timeenergynamesuba, "Scintillator"); //First subdetector tipology name for energy plot. } else if (a==0 || a==1 || a==2 || a==3 || a==4 || a==5) { sprintf(timenamesuba, "Lead"); //First subdetector tipology name for time plot. sprintf(timeenergynamesuba, "Lead"); //First subdetector tipology name for energy plot. } else if (a==12 || a==13 || a==14 || a==15 ) { sprintf(timenamesuba, "Horsa"); //First subdetector tipology name for time plot. sprintf(timeenergynamesuba, "Horsa"); //First subdetector tipology name for energy plot. } else if (a==16 || a==17 || a==18 || a==19 || a==10 || a==11 || a==20 || a==21 || a==22 || a==23 ) { sprintf(timenamesuba, "Versa"); //First subdetector tipology name for time plot. sprintf(timeenergynamesuba, "Versa"); //First subdetector tipology name for energy plot. } if (b==8 || b==9 || b==6 || b==7){ sprintf(timenamesubb, "Scintillator"); //Second subdetector tipology name for time plot. sprintf(timeenergynamesubb, "Scintillator"); //Second subdetector tipology name for energy plot. } else if (b==0 || b==1 || b==2 || b==3 || b==4 || b==5) { sprintf(timenamesubb, "Lead"); //Second subdetector tipology name for time plot. sprintf(timeenergynamesubb, "Lead"); //Second subdetector tipology name for energy plot. } else if (b==12 || b==13 || b==14 || b==15 ){ sprintf(timenamesubb, "Horsa"); //Second subdetector tipology name for time plot. sprintf(timeenergynamesubb, "Horsa"); //Second subdetector tipology name for energy plot. } else if (b==16 || b==17 || b==18 || b==19 || b==10 || b==11 || b==20 || b==21 || b==22 || b==23 ){ sprintf(timenamesubb, "Versa"); //Second subdetector tipology name for time plot. sprintf(timeenergynamesubb, "Versa"); //Second subdetector tipology name for energy plot. } if (c==8 || c==9 || c==6 || c==7){ sprintf(timenamesubc, "Scintillator"); //Third subdetector tipology name for time plot. sprintf(timeenergynamesubc, "Scintillator"); //Third subdetector tipology name for energy plot. } else if (c==0 || c==1 || c==2 || c==3 || c==4 || c==5) { sprintf(timenamesubc, "Lead"); //Third subdetector tipology name for time plot. sprintf(timeenergynamesubc, "Lead"); //Third subdetector tipology name for energy plot. } else if (c==12 || c==13 || c==14 || c==15 ){ sprintf(timenamesubc, "Horsa"); //Third subdetector tipology name for time plot. sprintf(timeenergynamesubc, "Horsa"); //Third subdetector tipology name for energy plot. } else if (c==16 || c==17 || c==18 || c==19 || c==10 || c==11 || c==20 || c==21 || c==22 || c==23 ){ sprintf(timenamesubc, "Versa"); //Third subdetector tipology name for time plot. sprintf(timeenergynamesubc, "Versa"); //Third subdetector tipology name for energy plot. } if (d==8 || d==9 || d==6 || d==7){ sprintf(timenamesubd, "Scintillator"); //Fourth subdetector tipology name for time plot. sprintf(timeenergynamesubd, "Scintillator"); //Fourth subdetector tipology name for energy plot. } else if (d==0 || d==1 || d==2 || d==3 || d==4 || d==5) { sprintf(timenamesubd, "Lead"); //Fourth subdetector tipology name for time plot. sprintf(timeenergynamesubd, "Lead"); //Fourth subdetector tipology name for energy plot. } else if (d==12 || d==13 || d==14 || d==15 ){ sprintf(timenamesubd, "Horsa"); //Fourth subdetector tipology name for time plot. sprintf(timeenergynamesubd, "Horsa"); //Fourth subdetector tipology name for energy plot. } else if (d==16 || d==17 || d==18 || d==19 || d==10 || d==11 || d==20 || d==21 || d==22 || d==23 ){ sprintf(timenamesubd, "Versa"); //Fourth subdetector tipology name for time plot. sprintf(timeenergynamesubd, "Versa"); //Fourth subdetector tipology name for energy plot. } if (e==8 || e==9 || e==6 || e==7){ sprintf(timenamesube, "Scintillator"); //Fifth subdetector tipology name for time plot. sprintf(timeenergynamesube, "Scintillator"); //Fifth subdetector tipology name for energy plot. } else if (e==0 || e==1 || e==2 || e==3 || e==4 || e==5) { sprintf(timenamesube, "Lead"); //Fifth subdetector tipology name for time plot. sprintf(timeenergynamesube, "Lead"); //Fifth subdetector tipology name for energy plot. } else if (e==12 || e==13 || e==14 || e==15 ){ sprintf(timenamesube, "Horsa"); //Fifth subdetector tipology name for time plot. sprintf(timeenergynamesube, "Horsa"); //Fifth subdetector tipology name for energy plot. } else if (e==16 || e==17 || e==18 || e==19 || e==10 || e==11 || e==20 || e==21 || e==22 || e==23 ){ sprintf(timenamesube, "Versa"); //Fifth subdetector tipology name for time plot. sprintf(timeenergynamesube, "Versa"); //Fifth subdetector tipology name for energy plot. } if (f==8 || f==9 || f==6 || f==7){ sprintf(timenamesubf, "Scintillator"); //Sixth subdetector tipology name for time plot. sprintf(timeenergynamesubf, "Scintillator"); //Sixth subdetector tipology name for energy plot. } else if (f==0 || f==1 || f==2 || f==3 || f==4 || f==5) { sprintf(timenamesubf, "Lead"); //Sixth subdetector tipology name for time plot. sprintf(timeenergynamesubf, "Lead"); //Fifth subdetector tipology name for energy plot. } else if (f==12 || f==13 || f==14 || f==15 ){ sprintf(timenamesubf, "Horsa"); //Sixth subdetector tipology name for time plot. sprintf(timeenergynamesubf, "Horsa"); //Fifth subdetector tipology name for energy plot. } else if (f==16 || f==17 || f==18 || f==19 || f==10 || f==11 || f==20 || f==21 || f==22 || f==23 ){ sprintf(timenamesubf, "Versa"); //Sixth subdetector tipology name for time plot. sprintf(timeenergynamesubf, "Versa"); //Sixth subdetector tipology name for energy plot. } if (g==8 || g==9 || g==6 || g==7){ sprintf(timenamesubg, "Scintillator"); //Seventh subdetector tipology name for time plot. sprintf(timeenergynamesubg, "Scintillator"); //Seventh subdetector tipology name for energy plot. } else if (g==0 || g==1 || g==2 || g==3 || g==4 || g==5) { sprintf(timenamesubg, "Lead"); //Seventh subdetector tipology name for time plot. sprintf(timeenergynamesubg, "Lead"); //Seventh subdetector tipology name for energy plot. } else if (g==12 || g==13 || g==14 || g==15 ){ sprintf(timenamesubg, "Horsa"); //Seventh subdetector tipology name for time plot. sprintf(timeenergynamesubg, "Horsa"); //Seventh subdetector tipology name for energy plot. } else if (g==16 || g==17 || g==18 || g==19 || g==10 || g==11 || g==20 || g==21 || g==22 || g==23 ){ sprintf(timenamesubg, "Versa"); //Seventh subdetector tipology name for time plot. sprintf(timeenergynamesubg, "Versa"); //Seventh subdetector tipology name for energy plot. } if (h==8 || h==9 || h==6 || h==7){ sprintf(timenamesubh, "Scintillator"); //Sixth subdetector tipology name for time plot. sprintf(timeenergynamesubh, "Scintillator"); //Sixth subdetector tipology name for energy plot. } else if (h==0 || h==1 || h==2 || h==3 || h==4 || h==5) { sprintf(timenamesubh, "Lead"); //Eighth subdetector tipology name for time plot. sprintf(timeenergynamesubh, "Lead"); //Eighth subdetector tipology name for energy plot. } else if (h==12 || h==13 || h==14 || h==15 ){ sprintf(timenamesubh, "Horsa"); //Eighth subdetector tipology name for time plot. sprintf(timeenergynamesubh, "Horsa"); //Eighth subdetector tipology name for energy plot. } else if (h==16 || h==17 || h==18 || h==19 || h==10 || h==11 || h==20 || h==21 || h==22 || h==23 ){ sprintf(timenamesubh, "Versa"); //Eighth subdetector tipology name for time plot. sprintf(timeenergynamesubh, "Versa"); //Eighth subdetector tipology name for energy plot. } int n=3; int c_YTitleSize=25; int c_YTitleFont=43; double c_YTitleOffset=1; int c_YLabelFont=43; int c_YLabelSize=25; int c_XTitleSize=25; int c_XTitleFont=43; int c_XTitleOffset=2; int c_XLabelFont=43; int c_XLabelSize=25; int c1_YTitleSize=25; int c1_YTitleFont=43; double c1_YTitleOffset=1.5; int c1_YLabelFont=43; int c1_YLabelSize=25; int c1_XTitleSize=25; int c1_XTitleFont=43; int c1_XTitleOffset=2; int c1_XLabelFont=43; int c1_XLabelSize=15; int c2_YTitleSize=15; int c2_YTitleFont=43; double c2_YTitleOffset=1.5; int c2_YLabelFont=43; int c2_YLabelSize=25; int c2_XTitleSize=25; int c2_XTitleFont=43; int c2_XTitleOffset=2; int c2_XLabelFont=43; int c2_XLabelSize=25; int c2_XSetRangem=0; int c2_XSetRangeMa=4000; int c2_XSetRangeMb=2000; float heneabfillcolor=0.35; float htimeabfillcolor=0.35; float hdeltatimeabfillcolor=0.35; TString myfilein = TString::Format("%ssi-%d.root",dirin,ifile); gSystem->mkdir(TString::Format("%stestbeam/", dirout), kTRUE); gSystem->mkdir(TString::Format("%stestbeam/si-%d/", dirout,ifile), kTRUE); gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/",dirout,ifile, a,b), kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d",dirout,ifile, a,b,c),kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d),kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/",dirout,ifile,a,b,c,d,e),kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile,a,b,c,d,e,f),kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile,a,b,c,d,e,g),kTRUE); // TO USE FOR FILES WITH TARGET gSystem->mkdir(TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile,a,b,c,d,e,h),kTRUE); // TO USE FOR FILES WITH TARGET TString outfolder=TString::Format("%stestbeam/si-%d/sub_%d-%d/",dirout,ifile, a,b); // TO USE FOR FILES WITH TARGET TString outfolder3sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/",dirout,ifile, a,b,c); // TO USE FOR FILES WITH TARGET TString outfolder4sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d); // TO USE FOR FILES WITH TARGET TString outfolder5sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d,e); // TO USE FOR FILES WITH TARGET TString outfolder6sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d,e,f); // TO USE FOR FILES WITH TARGET TString outfolder7sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d,e,g); // TO USE FOR FILES WITH TARGE TString outfolder8sub=TString::Format("%stestbeam/si-%d/sub_%d-%d/sub_%d/sub_%d/sub_%d/sub_%d/",dirout,ifile, a,b,c,d,e,h); // TO USE FOR FILES WITH TARGE TString myplotdeltatimeout = TString::Format("%ssi-%d_deltatime%d-%d.pdf",outfolder.Data(),ifile,a,b); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout3sub = TString::Format("%ssi-%d_deltatime%d-%d-%d.pdf",outfolder3sub.Data(),ifile,a,b,c); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout4sub = TString::Format("%ssi-%d_deltatime%d-%d-%d-%d.pdf",outfolder4sub.Data(),ifile,a,b,c,d); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout5sub = TString::Format("%ssi-%d_deltatime%d-%d-%d-%d-%d.pdf",outfolder5sub.Data(),ifile,a,b,c,d,e); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout6sub = TString::Format("%ssi-%d_deltatime%d-%d-%d-%d-%d-%d.pdf",outfolder6sub.Data(),ifile,a,b,c,d,e,f); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout7sub = TString::Format("%ssi-%d_deltatime%d-%d-%d-%d-%d-%d.pdf",outfolder7sub.Data(),ifile,a,b,c,d,e,g); // TO USE FOR FILES WITH TARGET TString myplotdeltatimeout8sub = TString::Format("%ssi-%d_deltatime%d-%d-%d-%d-%d-%d.pdf",outfolder8sub.Data(),ifile,a,b,c,d,e,h); // TO USE FOR FILES WITH TARGET TString myploteneout5sub = TString::Format("%ssi-%d_ene%d-%d-%d-%d-%d.pdf",outfolder5sub.Data(),ifile,a,b,c,d,e); // TO USE FOR FILES WHIT TARGET TString myploteneout6sub = TString::Format("%ssi-%d_ene%d-%d-%d-%d-%d-%d.pdf",outfolder6sub.Data(),ifile,a,b,c,d,e,f); // TO USE FOR FILES WHIT TARGET TString myploteneout7sub = TString::Format("%ssi-%d_ene%d-%d-%d-%d-%d-%d.pdf",outfolder7sub.Data(),ifile,a,b,c,d,e,g); // TO USE FOR FILES WHIT TARGET TString myploteneout8sub = TString::Format("%ssi-%d_ene%d-%d-%d-%d-%d-%d.pdf",outfolder8sub.Data(),ifile,a,b,c,d,e,h); // TO USE FOR FILES WHIT TARGET TString cdname = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype,timenamesuba,a,timenamesubb,b); // TO USE FOR FILES WITH TARGET TString cdname3sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesubc,c); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdname4sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesubd,d); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdname5sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesube,e); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdname6sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesubf,f); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdname7sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesubg,g); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdname8sub = TString::Format("%s Time_{%s}_{%d}-Time_{%s}_{%d}", particletype, timenamesuba,a,timenamesubh,h); // TO USE FOR FILES WITH TARGET METHOD 2 TString cdenenamee = TString::Format("%s Energy_{%s}_{%d}", particletype,timeenergynamesube,e); // TO USE FOR FILES WITH TARGET TString cdenenamef = TString::Format("%s Energy_{%s}_{%d}", particletype,timeenergynamesubf,f); // TO USE FOR FILES WITH TARGET TString cdenenameg = TString::Format("%s Energy_{%s}_{%d}", particletype,timeenergynamesube,g); // TO USE FOR FILES WITH TARGET TString cdenenameh = TString::Format("%s Energy_{%s}_{%d}", particletype,timeenergynamesube,h); // TO USE FOR FILES WITH TARGET TString canvtitle = TString::Format("si-%d",ifile); TString myfileout = TString::Format("%sselected_events.txt",outfolder8sub.Data()); // TO USE FOR FILES WITH TARGET TFile *fin = TFile::Open(myfilein); fin->ls (); TGaxis::SetMaxDigits(n); if (fin == 0) { printf("Error: cannot open the file!\n"); } else { TTree *t=0; fin->GetObject(fobject,t); t->SetScanField(0); ((TTreePlayer*)(t->GetPlayer()))->SetScanRedirect(true); // ((TTreePlayer*)(t->GetPlayer()))->SetScanFileName(myfileout); TCanvas *c0 = new TCanvas("c0",canvtitle,1280,1024); gStyle->SetOptFit(); gStyle->SetOptStat(111110); t->SetLineColor(kBlue); t->Draw(Form("Calo_Time[%d]-Calo_Time[%d] >> htemp(500, -400., 100.)", a, b)); t->GetHistogram()->SetTitle(cdname); t->SetScanField(0); TH1F *htemp = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g1 = new TF1 ("m1", "gaus", -140, -110); g1->SetLineColor(kYellow); TF1 *g2 = new TF1 ("m2", "gaus", -140, 110); g2->SetLineColor(kGreen); TF1 *f1 = new TF1("double_gaus", "gaus(0) + gaus(3)", -400, 100); f1->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f1->SetLineColor(kRed); htemp->Fit(g1, "R"); htemp->Fit(g2, "R"); Double_t par[6]; g1->GetParameters(&par[0]); g2->GetParameters(&par[3]); f1->SetParameters(par); htemp->Fit(f1, "R"); htemp->Draw("e1"); g1->Draw("SAME"); g2->Draw("SAME"); f1->Draw("SAME"); if (p1p2==1) { p1=f1->GetParameter(1); p2=f1->GetParameter(2); } else if (p1p2==2) { p1=f1->GetParameter(4); p2=f1->GetParameter(5); } htemp->GetXaxis()->SetTitle(cddeltatimeXname); htemp->GetYaxis()->SetTitle(cddeltatimeYname); htemp->GetYaxis()->SetTitleSize(c_YTitleSize); htemp->GetYaxis()->SetTitleFont(c_YTitleFont); htemp->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp->GetYaxis()->SetLabelFont(c_YLabelFont); htemp->GetYaxis()->SetLabelSize(c_YLabelSize); htemp->GetXaxis()->SetTitleSize(c_XTitleSize); htemp->GetXaxis()->SetTitleFont(c_XTitleFont); htemp->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp->GetXaxis()->SetLabelFont(c_XLabelFont); htemp->GetXaxis()->SetLabelSize(c_XLabelSize); htemp->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp->Draw(); htemp->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c0->Update(); TLegend* leg = new TLegend(0.15, 0.7, .25, .75); leg->SetHeader("Legend"); leg->SetNColumns(1); leg->AddEntry(htemp, "Data", "l"); leg->AddEntry(f1, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg->Draw(); c0->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime = (TPaveStats*)htemp->GetListOfFunctions()->FindObject("stats"); statsgdeltatime->SetTextColor(kBlue); statsgdeltatime->SetX1NDC(0.80); statsgdeltatime->SetX2NDC(0.98); statsgdeltatime->SetY1NDC(0.77); statsgdeltatime->SetY2NDC(0.92); statsgdeltatime->AddText(TString::Format("Mean = %g", p1)); statsgdeltatime->AddText(TString::Format("Sigma = %g", p2)); statsgdeltatime->DrawClone(); gPad->Update(); c0->Print(myplotdeltatimeout); delete c0; /*----------------------------------SECTION FOR 3 SUBDETECTORS COINCIDENCE 1----------------------------------*/ TCanvas *c17 = new TCanvas("c17",canvtitle,1280,1024); t->SetLineColor(kBlue); TCut cut = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, b, p1, csig, p2).Data(); TString htemp3substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(100., -50., 50.)", a,c); //700., -400., 300. t->Draw(htemp3substring, cut); t->GetHistogram()->SetTitle(cdname3sub); t->SetScanField(0); TH1F *htemp3sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g13sub = new TF1 ("m13sub", "gaus", -10, 0); //-10, 0 g13sub->SetLineColor(kYellow); TF1 *g23sub = new TF1 ("m23sub", "gaus", 0, 10); //0,10 g23sub->SetLineColor(kGreen); TF1 *f13sub = new TF1("double_gaus3sub", "gaus(0) + gaus(3)", -400, 300); //-400,300 f13sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f13sub->SetLineColor(kRed); htemp3sub->Fit(g13sub, "R"); htemp3sub->Fit(g23sub, "R"); Double_t par3sub[6]; g13sub->GetParameters(&par3sub[0]); g23sub->GetParameters(&par3sub[3]); f13sub->SetParameters(par3sub); htemp3sub->Fit(f13sub, "R"); htemp3sub->Draw("e1"); g13sub->Draw("SAME"); g23sub->Draw("SAME"); f13sub->Draw("SAME"); if (p13subp23sub==1) { p13sub=f13sub->GetParameter(1); p23sub=f13sub->GetParameter(2); } else if (p13subp23sub==2) { p13sub=f13sub->GetParameter(4); p23sub=f13sub->GetParameter(5); } htemp3sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp3sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp3sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp3sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp3sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp3sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp3sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp3sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp3sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp3sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp3sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp3sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp3sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp3sub->Draw(); htemp3sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c17->Update(); TLegend* leg3sub = new TLegend(0.15, 0.7, .25, .75); leg3sub->SetHeader("Legend"); leg3sub->SetNColumns(1); leg3sub->AddEntry(htemp3sub, "Data", "l"); leg3sub->AddEntry(f13sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg3sub->Draw(); c17->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime3sub = (TPaveStats*)htemp3sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime3sub->SetTextColor(kBlue); statsgdeltatime3sub->SetX1NDC(0.80); statsgdeltatime3sub->SetX2NDC(0.98); statsgdeltatime3sub->SetY1NDC(0.77); statsgdeltatime3sub->SetY2NDC(0.92); statsgdeltatime3sub->AddText(TString::Format("Mean = %g", p13sub)); statsgdeltatime3sub->AddText(TString::Format("Sigma = %g", p23sub)); statsgdeltatime3sub->DrawClone(); gPad->Update(); c17->Print(myplotdeltatimeout3sub); delete c17; /*----------------------------------SECTION FOR 4 SUBDETECTORS COINCIDENCE METHOD 2----------------------------------*/ TCanvas *c8 = new TCanvas("c8",canvtitle,1280,1024); gStyle->SetOptFit(); t->SetLineColor(kBlue); TString htemp4substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(40., -20., 20.)", a,d); //700., -400., 300. TCut cut3sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, c, p13sub, csig, p23sub).Data(); t->Draw(htemp4substring, cut && cut3sub ); t->GetHistogram()->SetTitle(cdname4sub); t->SetScanField(0); TH1F *htemp4sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g14sub = new TF1 ("m14sub", "gaus", -20, 10); g14sub->SetLineColor(kYellow); TF1 *g24sub = new TF1 ("m24sub", "gaus", -10, 20); g24sub->SetLineColor(kGreen); TF1 *f14sub = new TF1("double_gaus4sub", "gaus(0) + gaus(3)", -400, 100); f14sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f14sub->SetLineColor(kRed); f14sub->SetParLimits(2,0,100); htemp4sub->Fit(g14sub, "R"); htemp4sub->Fit(g24sub, "R"); Double_t par4sub[6]; g14sub->GetParameters(&par4sub[0]); g24sub->GetParameters(&par4sub[3]); f14sub->SetParameters(par4sub); htemp4sub->Fit(f14sub, "R"); htemp4sub->Draw("e1"); g14sub->Draw("SAME"); g24sub->Draw("SAME"); f14sub->Draw("SAME"); if (p14subp24sub==1) { p14sub=f14sub->GetParameter(1); p24sub=f14sub->GetParameter(2); } else if (p14subp24sub==2) { p14sub=f14sub->GetParameter(4); p24sub=f14sub->GetParameter(5); } htemp4sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp4sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp4sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp4sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp4sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp4sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp4sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp4sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp4sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp4sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp4sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp4sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp4sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp4sub->Draw(); htemp4sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c8->Update(); TLegend* leg4sub = new TLegend(0.15, 0.7, .25, .75); leg4sub->SetHeader("Legend"); leg4sub->SetNColumns(1); leg4sub->AddEntry(htemp4sub, "Data", "l"); leg4sub->AddEntry(f14sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg4sub->Draw(); c8->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime4sub = (TPaveStats*)htemp4sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime4sub->SetTextColor(kBlue); statsgdeltatime4sub->SetX1NDC(0.80); statsgdeltatime4sub->SetX2NDC(0.98); statsgdeltatime4sub->SetY1NDC(0.77); statsgdeltatime4sub->SetY2NDC(0.92); statsgdeltatime4sub->AddText(TString::Format("Mean = %g", p14sub)); statsgdeltatime4sub->AddText(TString::Format("Sigma = %g", p24sub)); statsgdeltatime4sub->DrawClone(); gPad->Update(); c8->Print(myplotdeltatimeout4sub); delete c8; /*----------------------------------SECTION FOR 5 SUBDETECTORS COINCIDENCE ----------------------------------*/ TCanvas *c13 = new TCanvas("c13",canvtitle,1280,1024); t->SetLineColor(kBlue); TString htemp5substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(40., -20., 20.)", a,e);//700., -400., 300. TCut cut4sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ",a, d, p14sub, csig, p24sub).Data(); t->Draw(htemp5substring, cut && cut3sub && cut4sub); t->GetHistogram()->SetTitle(cdname5sub); t->SetScanField(0); TH1F *htemp5sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g15sub = new TF1 ("m15sub", "gaus", -20, 10); g15sub->SetLineColor(kYellow); TF1 *g25sub = new TF1 ("m25sub", "gaus", -10, 20); g25sub->SetLineColor(kGreen); TF1 *f15sub = new TF1("double_gaus5sub", "gaus(0) + gaus(3)", -20, 20); f15sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f15sub->SetLineColor(kRed); htemp5sub->Fit(g15sub, "R"); htemp5sub->Fit(g25sub, "R"); Double_t par5sub[6]; g15sub->GetParameters(&par5sub[0]); g25sub->GetParameters(&par5sub[3]); f15sub->SetParameters(par5sub); htemp5sub->Fit(f15sub, "R"); htemp5sub->Draw("e1"); g15sub->Draw("SAME"); g25sub->Draw("SAME"); f15sub->Draw("SAME"); if (p15subp25sub==1) { p15sub=f15sub->GetParameter(1); p25sub=f15sub->GetParameter(2); } else if (p15subp25sub==2) { p15sub=f15sub->GetParameter(4); p25sub=f15sub->GetParameter(5); } htemp5sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp5sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp5sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp5sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp5sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp5sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp5sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp5sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp5sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp5sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp5sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp5sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp5sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp5sub->Draw(); htemp5sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c13->Update(); TLegend* leg5sub = new TLegend(0.15, 0.7, .25, .75); leg5sub->SetHeader("Legend"); leg5sub->SetNColumns(1); leg5sub->AddEntry(htemp5sub, "Data", "l"); leg5sub->AddEntry(f15sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg5sub->Draw(); c13->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime5sub = (TPaveStats*)htemp5sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime5sub->SetTextColor(kBlue); statsgdeltatime5sub->SetX1NDC(0.80); statsgdeltatime5sub->SetX2NDC(0.98); statsgdeltatime5sub->SetY1NDC(0.77); statsgdeltatime5sub->SetY2NDC(0.92); statsgdeltatime5sub->AddText(TString::Format("Mean = %g", p15sub)); statsgdeltatime5sub->AddText(TString::Format("Sigma = %g", p25sub)); statsgdeltatime5sub->DrawClone(); gPad->Update(); c13->Print(myplotdeltatimeout5sub); delete c13; TCanvas *c15 = new TCanvas("c15",canvtitle,1280,1024); t->SetLineColor(kBlue); TCut cut5sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, e, p15sub, csig, p25sub).Data(); TString henea5substring = TString::Format("Calo_EnDep[%d] > htemp(15000, 0., 15000.)", e); t->Draw(henea5substring, cut && cut3sub && cut4sub && cut5sub); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(cdenenamee); TH1F *henea5sub = (TH1F*)gPad->GetPrimitive("htemp"); henea5sub->GetXaxis()->SetTitle(cdeneXnameab); henea5sub->GetYaxis()->SetTitle(cdeneYnameab); henea5sub->GetYaxis()->SetTitleSize(c2_YTitleSize); henea5sub->GetYaxis()->SetTitleFont(c2_YTitleFont); henea5sub->GetYaxis()->SetTitleOffset(c2_YTitleOffset); henea5sub->GetYaxis()->SetLabelFont(c2_YLabelFont); henea5sub->GetYaxis()->SetLabelSize(c2_YLabelSize); henea5sub->GetXaxis()->SetTitleSize(c2_XTitleSize); henea5sub->GetXaxis()->SetTitleFont(c2_XTitleFont); henea5sub->GetXaxis()->SetTitleOffset(c2_XTitleOffset); henea5sub->GetXaxis()->SetLabelFont(c2_XLabelFont); henea5sub->GetXaxis()->SetLabelSize(c2_XLabelSize); henea5sub->SetFillColorAlpha(kBlue, heneabfillcolor); henea5sub->Draw(); henea5sub->SetName(heneabname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn TLegend* legenea5sub = new TLegend(0.65, 0.7, .75, .75); legenea5sub->SetHeader("Legend"); legenea5sub->SetNColumns(1); legenea5sub->AddEntry(henea5sub, "Data", "l"); legenea5sub->Draw(); gPad->Update(); TPaveStats *statsgenea5sub = (TPaveStats*)henea5sub->GetListOfFunctions()->FindObject("stats"); statsgenea5sub->SetTextColor(kBlue); statsgenea5sub->SetX1NDC(0.80); statsgenea5sub->SetX2NDC(0.98); statsgenea5sub->SetY1NDC(0.77); statsgenea5sub->SetY2NDC(0.92); gPad->Update(); c15->Print(myploteneout5sub); delete c15; /*----------------------------------SECTION FOR 6 SUBDETECTORS COINCIDENCE 1----------------------------------*/ TCanvas *c17b = new TCanvas("c17b",canvtitle,1280,1024); t->SetLineColor(kBlue); TString htemp6substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(50., -150., -100.)", a,f); //700., -400., 300. t->Draw(htemp6substring, cut && cut3sub && cut4sub && cut5sub); t->GetHistogram()->SetTitle(cdname6sub); t->SetScanField(0); TH1F *htemp6sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g16sub = new TF1 ("m16sub", "gaus", -150, -100); g16sub->SetLineColor(kYellow); TF1 *g26sub = new TF1 ("m26sub", "gaus", -150, -100); g26sub->SetLineColor(kGreen); TF1 *f16sub = new TF1("double_gaus6sub", "gaus(0) + gaus(3)", -150, -100); //-300,100 f16sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f16sub->SetLineColor(kRed); htemp6sub->Fit(g16sub, "R"); htemp6sub->Fit(g26sub, "R"); Double_t par6sub[6]; g16sub->GetParameters(&par6sub[0]); g26sub->GetParameters(&par6sub[3]); f16sub->SetParameters(par6sub); htemp6sub->Fit(f16sub, "R"); htemp6sub->Draw("e1"); g16sub->Draw("SAME"); g26sub->Draw("SAME"); f16sub->Draw("SAME"); if (p16subp26sub==1) { p16sub=f16sub->GetParameter(1); p26sub=f16sub->GetParameter(2); } else if (p16subp26sub==2) { p16sub=f16sub->GetParameter(4); p26sub=f16sub->GetParameter(5); } htemp6sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp6sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp6sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp6sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp6sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp6sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp6sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp6sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp6sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp6sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp6sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp6sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp6sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp6sub->Draw(); htemp6sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c17b->Update(); TLegend* leg6sub = new TLegend(0.15, 0.7, .25, .75); leg6sub->SetHeader("Legend"); leg6sub->SetNColumns(1); leg6sub->AddEntry(htemp6sub, "Data", "l"); leg6sub->AddEntry(f16sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg6sub->Draw(); c17b->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime6sub = (TPaveStats*)htemp6sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime6sub->SetTextColor(kBlue); statsgdeltatime6sub->SetX1NDC(0.80); statsgdeltatime6sub->SetX2NDC(0.98); statsgdeltatime6sub->SetY1NDC(0.77); statsgdeltatime6sub->SetY2NDC(0.92); statsgdeltatime6sub->AddText(TString::Format("Mean = %g", p16sub)); statsgdeltatime6sub->AddText(TString::Format("Sigma = %g", p26sub)); statsgdeltatime6sub->DrawClone(); gPad->Update(); c17b->Print(myplotdeltatimeout6sub); delete c17b; TCanvas *c19b = new TCanvas("c19b",canvtitle,1280,1024); t->SetLineColor(kBlue); TCut cut6sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, f, p16sub, csig, p26sub).Data(); TString henea6substring = TString::Format("Calo_EnDep[%d] >> htemp(15000., 0., 15000.)", f); t->Draw(henea6substring, cut && cut3sub && cut4sub && cut5sub && cut6sub); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(cdenenamef); TH1F *henea6sub = (TH1F*)gPad->GetPrimitive("htemp"); henea6sub->GetXaxis()->SetTitle(cdeneXnameab); henea6sub->GetYaxis()->SetTitle(cdeneYnameab); henea6sub->GetYaxis()->SetTitleSize(c2_YTitleSize); henea6sub->GetYaxis()->SetTitleFont(c2_YTitleFont); henea6sub->GetYaxis()->SetTitleOffset(c2_YTitleOffset); henea6sub->GetYaxis()->SetLabelFont(c2_YLabelFont); henea6sub->GetYaxis()->SetLabelSize(c2_YLabelSize); henea6sub->GetXaxis()->SetTitleSize(c2_XTitleSize); henea6sub->GetXaxis()->SetTitleFont(c2_XTitleFont); henea6sub->GetXaxis()->SetTitleOffset(c2_XTitleOffset); henea6sub->GetXaxis()->SetLabelFont(c2_XLabelFont); henea6sub->GetXaxis()->SetLabelSize(c2_XLabelSize); henea6sub->SetFillColorAlpha(kBlue, heneabfillcolor); henea6sub->Draw(); henea6sub->SetName(heneabname); gPad->Modified(); gPad->Update(); TLegend* legenea6sub = new TLegend(0.65, 0.7, .75, .75); legenea6sub->SetHeader("Legend"); legenea6sub->SetNColumns(1); legenea6sub->AddEntry(henea6sub, "Data", "l"); legenea6sub->Draw(); gPad->Update(); TPaveStats *statsgenea6sub = (TPaveStats*)henea6sub->GetListOfFunctions()->FindObject("stats"); statsgenea6sub->SetTextColor(kBlue); statsgenea6sub->SetX1NDC(0.80); statsgenea6sub->SetX2NDC(0.98); statsgenea6sub->SetY1NDC(0.77); statsgenea6sub->SetY2NDC(0.92); gPad->Update(); c19b->Print(myploteneout6sub); delete c19b; /*----------------------------------SECTION FOR 7 SUBDETECTORS COINCIDENCE---------------------------------*/ TCanvas *c27 = new TCanvas("c27",canvtitle,1280,1024); t->SetLineColor(kBlue); TString htemp7substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(700., -400., 300.)", a,g);//700., -400., 300. t->Draw(htemp7substring, cut && cut3sub && cut4sub && cut5sub); t->GetHistogram()->SetTitle(cdname7sub); //t->SetScanField(0); TH1F *htemp7sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g17sub = new TF1 ("m17sub", "gaus", -150, -100); g17sub->SetLineColor(kYellow); TF1 *g27sub = new TF1 ("m27sub", "gaus", -150, -100); g27sub->SetLineColor(kGreen); TF1 *f17sub = new TF1("double_gaus7sub", "gaus(0) + gaus(3)", -150, -100); f17sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f17sub->SetLineColor(kRed); htemp7sub->Fit(g17sub, "R"); htemp7sub->Fit(g27sub, "R"); Double_t par7sub[6]; g17sub->GetParameters(&par7sub[0]); g27sub->GetParameters(&par7sub[3]); f17sub->SetParameters(par7sub); htemp7sub->Fit(f17sub, "R"); htemp7sub->Draw("e1"); g17sub->Draw("SAME"); g27sub->Draw("SAME"); f17sub->Draw("SAME"); if (p17subp27sub==1) { p17sub=f17sub->GetParameter(1); p27sub=f17sub->GetParameter(2); } else if (p17subp27sub==2) { p17sub=f17sub->GetParameter(4); p27sub=f17sub->GetParameter(5); } htemp7sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp7sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp7sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp7sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp7sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp7sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp7sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp7sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp7sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp7sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp7sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp7sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp7sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp7sub->Draw(); htemp7sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c27->Update(); TLegend* leg7sub = new TLegend(0.15, 0.7, .25, .75); leg7sub->SetHeader("Legend"); leg7sub->SetNColumns(1); leg7sub->AddEntry(htemp7sub, "Data", "l"); leg7sub->AddEntry(f17sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT //leg7sub->AddEntry(htemp7sub->GetFunction("gaus"), "Fit", "l"); //TO USE FOR 1 GAUSSIAN FIT leg7sub->Draw(); c27->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime7sub = (TPaveStats*)htemp7sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime7sub->SetTextColor(kBlue); statsgdeltatime7sub->SetX1NDC(0.80); statsgdeltatime7sub->SetX2NDC(0.98); statsgdeltatime7sub->SetY1NDC(0.77); statsgdeltatime7sub->SetY2NDC(0.92); statsgdeltatime7sub->AddText(TString::Format("Mean = %g", p17sub)); statsgdeltatime7sub->AddText(TString::Format("Sigma = %g", p27sub)); statsgdeltatime7sub->DrawClone(); gPad->Update(); c27->Print(myplotdeltatimeout7sub); delete c27; TCanvas *c28 = new TCanvas("c28",canvtitle,1280,1024); TCut cut7sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f) ", a, g, p17sub, csig, p27sub).Data(); t->SetLineColor(kBlue); TString henea7subcutstring = TString::Format("Calo_EnDep[%d] >> htemp(15000., 0., 15000.)", g); t->Draw(henea7subcutstring, cut && cut3sub && cut4sub && cut5sub && cut7sub); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(cdenenameg); TH1F *henea7sub = (TH1F*)gPad->GetPrimitive("htemp"); henea7sub->GetXaxis()->SetTitle(cdeneXnameab); henea7sub->GetYaxis()->SetTitle(cdeneYnameab); henea7sub->GetYaxis()->SetTitleSize(c2_YTitleSize); henea7sub->GetYaxis()->SetTitleFont(c2_YTitleFont); henea7sub->GetYaxis()->SetTitleOffset(c2_YTitleOffset); henea7sub->GetYaxis()->SetLabelFont(c2_YLabelFont); henea7sub->GetYaxis()->SetLabelSize(c2_YLabelSize); henea7sub->GetXaxis()->SetTitleSize(c2_XTitleSize); henea7sub->GetXaxis()->SetTitleFont(c2_XTitleFont); henea7sub->GetXaxis()->SetTitleOffset(c2_XTitleOffset); henea7sub->GetXaxis()->SetLabelFont(c2_XLabelFont); henea7sub->GetXaxis()->SetLabelSize(c2_XLabelSize); henea7sub->SetFillColorAlpha(kBlue, heneabfillcolor); henea7sub->Draw(); henea7sub->SetName(heneabname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn TLegend* legenea7sub = new TLegend(0.65, 0.7, .75, .75); legenea7sub->SetHeader("Legend"); legenea7sub->SetNColumns(1); legenea7sub->AddEntry(henea7sub, "Data", "l"); legenea7sub->Draw(); gPad->Update(); TPaveStats *statsgenea7sub = (TPaveStats*)henea7sub->GetListOfFunctions()->FindObject("stats"); statsgenea7sub->SetTextColor(kBlue); statsgenea7sub->SetX1NDC(0.80); statsgenea7sub->SetX2NDC(0.98); statsgenea7sub->SetY1NDC(0.77); statsgenea7sub->SetY2NDC(0.92); gPad->Update(); c28->Print(myploteneout7sub); delete c28; /*----------------------------------SECTION FOR 8 SUBDETECTORS COINCIDENCE---------------------------------*/ TCanvas *c33 = new TCanvas("c33",canvtitle,1280,1024); t->SetLineColor(kBlue); TString htemp8substring = TString::Format("Calo_Time[%d] - Calo_Time[%d] >> htemp(50., -150., -100.)", a,h); // 700., -400., 300. t->Draw(htemp8substring, cut && cut3sub && cut4sub && cut5sub); t->GetHistogram()->SetTitle(cdname8sub); //t->SetScanField(0); TH1F *htemp8sub = (TH1F*)gPad->GetPrimitive("htemp"); TF1 *g18sub = new TF1 ("m18sub", "gaus", -150, -100); //-15, 14 -7,-4 g18sub->SetLineColor(kYellow); TF1 *g28sub = new TF1 ("m28sub", "gaus",-150, -100);// -14, 15 -4,-1 g28sub->SetLineColor(kGreen); TF1 *f18sub = new TF1("double_gaus8sub", "gaus(0) + gaus(3)", -150,-100); //-15, 15 f18sub->SetParNames("Constant 1", "Mean 1", "Sigma 1","Constant 2", "Mean 2", "Sigma 2"); f18sub->SetLineColor(kRed); htemp8sub->Fit(g18sub, "R"); htemp8sub->Fit(g28sub, "R"); Double_t par8sub[6]; g18sub->GetParameters(&par8sub[0]); g28sub->GetParameters(&par8sub[3]); f18sub->SetParameters(par8sub); htemp8sub->Fit(f18sub, "R"); htemp8sub->Draw("e1"); g18sub->Draw("SAME"); g28sub->Draw("SAME"); f18sub->Draw("SAME"); if (p18subp28sub==1) { p18sub=f18sub->GetParameter(1); p28sub=f18sub->GetParameter(2); } else if (p18subp28sub==2) { p18sub=f18sub->GetParameter(4); p28sub=f18sub->GetParameter(5); } htemp8sub->GetXaxis()->SetTitle(cddeltatimeXname); htemp8sub->GetYaxis()->SetTitle(cddeltatimeYname); htemp8sub->GetYaxis()->SetTitleSize(c_YTitleSize); htemp8sub->GetYaxis()->SetTitleFont(c_YTitleFont); htemp8sub->GetYaxis()->SetTitleOffset(c_YTitleOffset); htemp8sub->GetYaxis()->SetLabelFont(c_YLabelFont); htemp8sub->GetYaxis()->SetLabelSize(c_YLabelSize); htemp8sub->GetXaxis()->SetTitleSize(c_XTitleSize); htemp8sub->GetXaxis()->SetTitleFont(c_XTitleFont); htemp8sub->GetXaxis()->SetTitleOffset(c_XTitleOffset); htemp8sub->GetXaxis()->SetLabelFont(c_XLabelFont); htemp8sub->GetXaxis()->SetLabelSize(c_XLabelSize); htemp8sub->SetFillColorAlpha(kBlue, hdeltatimeabfillcolor); htemp8sub->Draw(); htemp8sub->SetName(htempname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn c33->Update(); TLegend* leg8sub = new TLegend(0.15, 0.7, .25, .75); leg8sub->SetHeader("Legend"); leg8sub->SetNColumns(1); leg8sub->AddEntry(htemp8sub, "Data", "l"); leg8sub->AddEntry(f18sub, "Fit", "l"); //TO USE FOR 2 GAUSSIAN FIT leg8sub->Draw(); c33->Update(); gPad->Modified(); gPad->Update(); TPaveStats *statsgdeltatime8sub = (TPaveStats*)htemp8sub->GetListOfFunctions()->FindObject("stats"); statsgdeltatime8sub->SetTextColor(kBlue); statsgdeltatime8sub->SetX1NDC(0.80); statsgdeltatime8sub->SetX2NDC(0.98); statsgdeltatime8sub->SetY1NDC(0.77); statsgdeltatime8sub->SetY2NDC(0.92); statsgdeltatime8sub->AddText(TString::Format("Mean = %g", p18sub)); statsgdeltatime8sub->AddText(TString::Format("Sigma = %g", p28sub)); statsgdeltatime8sub->DrawClone(); gPad->Update(); c33->Print(myplotdeltatimeout8sub); delete c33; TCanvas *c34b = new TCanvas("c34b",canvtitle,1280,1024); TCut cut8sub = TString::Format("TMath::Abs(Calo_Time[%d] - Calo_Time[%d] - (%f)) < (%d)*(%f)", a, h, p18sub, csig, p28sub).Data(); t->SetLineColor(kBlue); TString henea8substring = TString::Format("Calo_EnDep[%d] >> htemp(10000., 0., 10000.)", h); t->Draw(henea8substring, cut && cut3sub && cut4sub && cut5sub && cut8sub); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn t->GetHistogram()->SetTitle(cdenenameh); TH1F *henea8sub = (TH1F*)gPad->GetPrimitive("htemp"); henea8sub->GetXaxis()->SetTitle(cdeneXnameab); henea8sub->GetYaxis()->SetTitle(cdeneYnameab); henea8sub->GetYaxis()->SetTitleSize(c2_YTitleSize); henea8sub->GetYaxis()->SetTitleFont(c2_YTitleFont); henea8sub->GetYaxis()->SetTitleOffset(c2_YTitleOffset); henea8sub->GetYaxis()->SetLabelFont(c2_YLabelFont); henea8sub->GetYaxis()->SetLabelSize(c2_YLabelSize); henea8sub->GetXaxis()->SetTitleSize(c2_XTitleSize); henea8sub->GetXaxis()->SetTitleFont(c2_XTitleFont); henea8sub->GetXaxis()->SetTitleOffset(c2_XTitleOffset); henea8sub->GetXaxis()->SetLabelFont(c2_XLabelFont); henea8sub->GetXaxis()->SetLabelSize(c2_XLabelSize); henea8sub->SetFillColorAlpha(kBlue, heneabfillcolor); henea8sub->Draw(); henea8sub->SetName(heneabname); gPad->Modified(); gPad->Update(); // make sure it's really (re)drawn TLegend* legenea8sub = new TLegend(0.65, 0.7, .75, .75); legenea8sub->SetHeader("Legend"); legenea8sub->SetNColumns(1); legenea8sub->AddEntry(henea8sub, "Data", "l"); legenea8sub->Draw(); gPad->Update(); TPaveStats *statsgenea8sub = (TPaveStats*)henea8sub->GetListOfFunctions()->FindObject("stats"); statsgenea8sub->SetTextColor(kBlue); statsgenea8sub->SetX1NDC(0.80); statsgenea8sub->SetX2NDC(0.98); statsgenea8sub->SetY1NDC(0.77); statsgenea8sub->SetY2NDC(0.92); gPad->Update(); c34b->Print(myploteneout8sub); delete c34b; } }