26 void Plot6(std::string filename=
"test.root",std::string prefix=
"test")
28 gStyle->SetOptStat(111111);
29 gStyle->SetOptDate(0);
31 TFile* infile = TFile::Open(filename.c_str());
32 if( infile==0 || infile->IsZombie() ){ std::cout <<
"ERROR:Unable to open: " << filename << std::endl;
return 0; }
33 else{ std::cout <<
"Opened file:"<<infile <<
" Named:"<<infile->GetName() << std::endl; }
35 TH1F* npeaks[7] = {0};
36 TH1F* npeaksfiltered[7] = {0};
38 TH1F* res0zoom[7] = {0};
39 TH1F* sum8res0[7] = {0};
40 TH1F* sum8res0zoom[7] = {0};
41 TH1F* fitres0[7] = {0};
42 TH1F* fitres0zoom[7] = {0};
43 TH2F* sum8vfit[7] = {0};
44 for( UInt_t i=0; i<7; ++i ){
47 sprintf(name,
"H1_NPeaks_%d",i);
48 npeaks[i] = (TH1F*)infile->Get(name);
49 npeaks[i]->SetTitle(
";number of peaks");
51 sprintf(name,
"H1_NPeaksFiltered_%d",i);
52 npeaksfiltered[i] = (TH1F*)infile->Get(name);
53 npeaksfiltered[i]->SetTitle(
";number of peaks");
55 sprintf(name,
"H1_Res0_%d",i);
56 res0[i] = (TH1F*)infile->Get(name);
57 res0[i]->SetTitle(
";ADC sum");
59 sprintf(name,
"H1_Res0Zoom_%d",i);
60 res0zoom[i] = (TH1F*)infile->Get(name);
61 res0zoom[i]->SetTitle(
";ADC sum");
63 sprintf(name,
"H1_Sum8Res0_%d",i);
64 sum8res0[i] = (TH1F*)infile->Get(name);
65 sum8res0[i]->SetTitle(
";ADC sum");
67 sprintf(name,
"H1_Sum8Res0Zoom_%d",i);
68 sum8res0zoom[i] = (TH1F*)infile->Get(name);
69 sum8res0zoom[i]->SetTitle(
";ADC sum");
71 sprintf(name,
"H1_FitRes0_%d",i);
72 fitres0[i] = (TH1F*)infile->Get(name);
73 fitres0[i]->SetTitle(
";ADC sum");
75 sprintf(name,
"H1_FitRes0Zoom_%d",i);
76 fitres0zoom[i] = (TH1F*)infile->Get(name);
77 fitres0zoom[i]->SetTitle(
";ADC sum");
79 sprintf(name,
"H2_Sum8vFit_%d",i);
80 sum8vfit[i] = (TH2F*)infile->Get(name);
81 sum8vfit[i]->SetTitle(
";Sum8;FitSum");
83 res0[i] ->SetLineColor(kBlack);
84 sum8res0[i] ->SetLineColor(kBlue);
85 fitres0[i] ->SetLineColor(kGreen);
86 res0zoom[i] ->SetLineColor(kBlack);
87 sum8res0zoom[i]->SetLineColor(kBlue);
88 fitres0zoom[i] ->SetLineColor(kGreen);
89 res0[i] ->SetStats(0);
90 sum8res0[i] ->SetStats(0);
91 fitres0[i] ->SetStats(0);
92 res0zoom[i] ->SetStats(0);
93 sum8res0zoom[i]->SetStats(0);
94 fitres0zoom[i] ->SetStats(0);
96 res0[6]->SetTitle(
"");
97 sum8res0[6]->SetTitle(
"");
98 fitres0[6]->SetTitle(
"");
99 res0zoom[6]->SetTitle(
"");
100 sum8res0zoom[6]->SetTitle(
"");
101 fitres0zoom[6]->SetTitle(
"");
115 TH1F* timefit = (TH1F*)infile->Get(
"H1_TimeFitPulse");
116 TH1F* measuretime = (TH1F*)infile->Get(
"FitTime");
122 TCanvas* canv =
new TCanvas(
"canv",
"",width,height);
123 npeaks[6]->SetTitle(
"");
124 npeaks[6]->SetStats(0);
125 npeaks[6]->GetXaxis()->SetTitle(
"Found number of peaks");
126 npeaks[6]->Draw(
"hist e");
127 canv->SaveAs( (prefix+
"_Npeaks.png").c_str() );
130 npeaksfiltered[6]->Draw(
"hist e");
131 canv->SaveAs( (prefix+
"_NpeaksFiltered.png").c_str() );
135 for( UInt_t i=0; i<6; ++i ){
137 npeaks[i]->Draw(
"hist e");
139 canv->SaveAs( (prefix+
"_detNpeaks.png").c_str() );
143 for( UInt_t i=0; i<6; ++i ){
145 npeaksfiltered[i]->Draw(
"hist e");
147 canv->SaveAs( (prefix+
"_detNpeaksFiltered.png").c_str() );
153 canv->cd(1)->SetLogy(1);
154 res0[6]->Draw(
"hist e");
155 res0[6]->GetXaxis()->SetTitle(
"Signal Integral");
156 sum8res0[6]->Draw(
"hist e sames");
157 fitres0[6]->Draw(
"hist e sames");
158 canv->cd(2)->SetLogy(1);
159 res0zoom[6]->Draw(
"hist e");
160 res0zoom[6]->GetXaxis()->SetTitle(
"Signal Integral");
161 sum8res0zoom[6]->Draw(
"hist e sames");
162 fitres0zoom[6]->Draw(
"hist e sames");
168 canv->SaveAs( (prefix+
"_res0.png").c_str() );
172 for( UInt_t i=0; i<6; ++i ){
173 canv->cd(i+1)->SetLogy(1);
174 res0[i]->Draw(
"hist e");
175 sum8res0[i]->Draw(
"hist e same");
176 fitres0[i]->Draw(
"hist e same");
178 canv->SaveAs( (prefix+
"_detres0.png").c_str() );
182 for( UInt_t i=0; i<6; ++i ){
183 canv->cd(i+1)->SetLogy(1);
184 res0zoom[i]->Draw(
"hist e");
185 sum8res0zoom[i]->Draw(
"hist e same");
186 fitres0zoom[i]->Draw(
"hist e same");
188 canv->SaveAs( (prefix+
"_detres0zoom.png").c_str() );
193 canv->cd(1)->SetLogy(1);
194 sum8res0[6]->Draw(
"hist e");
195 sum8res0[6]->GetXaxis()->SetTitle(
"Signal Integral");
196 fitres0[6]->Draw(
"hist e same");
197 fitres0[6]->GetXaxis()->SetTitle(
"Signal Integral");
198 canv->cd(2)->SetLogy(1);
199 sum8res0zoom[6]->Draw(
"hist e");
200 sum8res0zoom[6]->GetXaxis()->SetTitle(
"Signal Integral");
201 fitres0zoom[6]->Draw(
"hist e same");
202 fitres0zoom[6]->GetXaxis()->SetTitle(
"Signal Integral");
203 TLegend* legres2 = 0;
207 canv->SaveAs( (prefix+
"_s8fit.png").c_str() );
210 TF1* linfit[7] = {0};
211 linfit[6] =
new TF1(
"linfit",
"[0]+[1]*x",0,2000);
213 sum8vfit[6]->Fit(linfit[6]);
214 sum8vfit[6]->Draw(
"colz");
215 canv->SaveAs( (prefix+
"_sum8vfit.png").c_str() );
219 for( UInt_t i=0; i<6; ++i ){
220 linfit[i] =
new TF1(
"linfit",
"[0]+[1]*x",0,2000);
221 canv->cd(i+1)->SetLogz(1);
222 sum8vfit[i]->Fit(linfit[i]);
223 sum8vfit[i]->Draw(
"colz");
225 canv->SaveAs( (prefix+
"_detsum8vfit.png").c_str() );
229 timefit->SetLineColor(kBlue);
230 timefit->GetXaxis()->SetRangeUser(0,100);
231 timefit->GetXaxis()->SetTitle(
"time (ms)");
232 timefit->Draw(
"hist e");
233 double timeintegral = timefit->Integral(1,timefit->GetNbinsX());
235 TPaveStats* TPS_timefit = timefit->FindObject(
"stats");
236 TPS_timefit->SetName(
"timefitstats");
239 timefit->SetStats(0);
240 std::stringstream ss_tinttext;
241 ss_tinttext <<
"Integral = " << timeintegral;
242 TLatex* ttimeint =
new TLatex(0,0, ss_tinttext.str().c_str() );
244 ttimeint->SetTextSize(0.03);
245 TPS_timefit->GetListOfLines()->Add(ttimeint);
247 canv->SaveAs( (prefix+
"_timefit.png").c_str() );
249 if( measuretime!=0 ){
252 measuretime->SetLineColor(kBlue);
254 measuretime->GetXaxis()->SetTitle(
"time (ms)");
255 measuretime->Draw(
"hist e");
256 double totaltime = measuretime->Integral(1,measuretime->GetNbinsX());
258 TPaveStats* TPS_measuretime = measuretime->FindObject(
"stats");
259 TPS_measuretime->SetName(
"measuretimestats");
260 measuretime->SetStats(0);
261 std::stringstream ss_minttext;
262 ss_minttext <<
"Integral = " << totaltime;
263 TLatex* mtimeint =
new TLatex(0,0, ss_minttext.str().c_str() );
265 mtimeint->SetTextSize(0.03);
266 TPS_measuretime->GetListOfLines()->Add(mtimeint);
267 TPS_measuretime->Draw();
268 canv->SaveAs( (prefix+
"_measuretime.png").c_str() );