1 PlotTimeShape_ps(Int_t runnum=0)
5 gStyle->SetOptFit(1111);
6 gStyle->SetCanvasColor(0);
7 gStyle->SetPadColor(0);
8 gStyle->SetFillColor(0);
9 gStyle->SetStatBorderSize(0);
18 sprintf(tname,
"run%d.*tree.root",runnum);
20 TChain* tFgt=
new TChain(
"tFgt");
50 tFgt->SetBranchAddress(
"iEvt",&iEvt);
51 tFgt->SetBranchAddress(
"rdo",&rdo);
52 tFgt->SetBranchAddress(
"arm",&arm);
53 tFgt->SetBranchAddress(
"apv",&apv);
54 tFgt->SetBranchAddress(
"chn",&chn);
55 tFgt->SetBranchAddress(
"disk",&disk);
56 tFgt->SetBranchAddress(
"quad",&quad);
57 tFgt->SetBranchAddress(
"strip",&strip);
58 tFgt->SetBranchAddress(
"stat",&stat);
59 tFgt->SetBranchAddress(
"ordinate",&ordinate);
60 tFgt->SetBranchAddress(
"lowerSpan",&lowerSpan);
61 tFgt->SetBranchAddress(
"upperSpan",&upperSpan);
62 tFgt->SetBranchAddress(
"layer",&layer);
63 tFgt->SetBranchAddress(
"adc",adc);
64 tFgt->SetBranchAddress(
"ped",&ped);
65 tFgt->SetBranchAddress(
"pedSig",&pedSig);
66 tFgt->SetBranchAddress(
"adcmax",&adcmax);
67 tFgt->SetBranchAddress(
"mmin",&mmin);
68 tFgt->SetBranchAddress(
"mmax",&mmax);
69 tFgt->SetBranchAddress(
"chi2",&chi2);
70 tFgt->SetBranchAddress(
"fmax",&fmax);
71 tFgt->SetBranchAddress(
"norm",&norm);
72 tFgt->SetBranchAddress(
"tau",&tau);
73 tFgt->SetBranchAddress(
"t0",&t0);
74 tFgt->SetBranchAddress(
"offset",&offset);
75 tFgt->SetBranchAddress(
"errCode",&errCode);
77 TH2F htauapv(
"htauapv",
"tau (width) Parameter per APV;binAPV;tau (width)",240,0,240,100,0,5);
78 TH2F ht0apv(
"ht0apv",
"t0 (rise point) Parameter per APV;binAPV;t0 (time offset)",240,0,240,120,-5,7);
79 TH2F ht0apv2(
"ht0apv2",
"t0 (rise point) Parameter per APV;iapv;t0 (time offset)",288,0,288,120,-5,7);
80 TH2F htmapv2(
"htmapv2",
"t-mean per APV;iapv;t-mean",288,0,288,120,-5,7);
81 TH2F hoffapv(
"hoffapv",
"Y-offset per APV;binAPV;Y-offset",240,0,240,200,-1000,1000);
83 TH2F hch2apv(
"hch2apv",
"Chi2/dof per APV;binAPV;chi2/dof",240,0,240,200,0,40);
84 TH2F hfmxapv(
"hfmxapv",
"Time of Maximum per APV;binAPV;fmax (time of maximum)",240,0,240,120,-2,10);
85 TH2F hintapv(
"hintapv",
"Integral of Fit Funtion per APV;binAPV;Integral of Fit Function",240,0,240,200,0,20000);
87 TH2F hamxapv(
"hamxapv",
"ADCMAX per APV;binAPV;ADCMAX",240,0,240,400,0,4000);
88 TH2F hpedapv(
"hpedapv",
"Pedestal per APV;binAPV;Pedestal",240,0,240,200,0,1000);
89 TH2F hsigapv(
"hsigapv",
"Pedestal Sigma per APV;binAPV;Pedestal Sigma",240,0,240,200,0,200);
90 TH2F herrapv(
"herrapv",
"Error Code Fraction per APV;binAPV;Error Code Type",240,0,240,5,0,5);
92 TH2F hmaxapv(
"hmaxapv",
"Max time bin per APV;binAPV;Max time bin",240,0,240,7,0,7);
93 TH2F hminapv(
"hminapv",
"Min time bin per APV;binAPV;Min time bin",240,0,240,7,0,7);
95 TH2F hxbquad(
"hxbquad",
"Quadrant diagnostic XBin;binQUAD;Xbin",24,0,24,5,0,5);
96 TH2F hamxquad(
"hamxquad",
"Maximum ADC per Quadrant;binQUAD;adcmax",24,0,24,400,0,4000);
97 TH2F hch2quad(
"hch2quad",
"Chi2/dof per Quadrant;binQUAD;chi2/dof",24,0,24,200,0,40);
98 TH2F hfmxquad(
"hfmxquad",
"Time of Maximum per Quadrant;binQUAD;fmax (time of maximum)",24,0,24,120,-2,10);
99 TH2F ht0quad(
"ht0quad",
"t0 (time offset) per Quadrant;binQUAD;t0 (time offset)",24,0,24,120,-5,7);
100 TH2F hintquad(
"hintquad",
"Integral of Fit Funtion per Quadrant;binQUAD;integral",24,0,24,200,0,20000);
102 TString quadname[48];
103 TString quadname2[24];
105 for(Int_t di=0;di<6;di++)
107 for(Int_t qu=0;qu<4;qu++)
110 quadname[2*(di*4 + qu)]+=di+1;
111 quadname[2*(di*4 + qu)]+=qc;
112 quadname[2*(di*4 + qu)]+=
'L';
113 quadname[2*(di*4 + qu)+1]+=di+1;
114 quadname[2*(di*4 + qu)+1]+=qc;
115 quadname[2*(di*4 + qu)+1]+=
'S';
116 quadname2[di*4 + qu]+=di+1;
117 quadname2[di*4 + qu]+=qc;
121 htauapv.GetXaxis()->SetTitleOffset(1.2);
122 ht0apv.GetXaxis()->SetTitleOffset(1.2);
123 hoffapv.GetXaxis()->SetTitleOffset(1.2);
125 hch2apv.GetXaxis()->SetTitleOffset(1.2);
126 hfmxapv.GetXaxis()->SetTitleOffset(1.2);
127 hintapv.GetXaxis()->SetTitleOffset(1.2);
129 hamxapv.GetXaxis()->SetTitleOffset(1.2);
130 hpedapv.GetXaxis()->SetTitleOffset(1.2);
131 hsigapv.GetXaxis()->SetTitleOffset(1.2);
132 herrapv.GetXaxis()->SetTitleOffset(1.2);
134 hmaxapv.GetXaxis()->SetTitleOffset(1.2);
135 hminapv.GetXaxis()->SetTitleOffset(1.2);
154 for(Int_t ib=0;ib<240;ib++)
158 htauapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
159 ht0apv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
160 hoffapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
162 hch2apv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
163 hfmxapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
164 hintapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
166 hamxapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
167 hpedapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
168 hsigapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
169 herrapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
171 hmaxapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
172 hminapv.GetXaxis()->SetBinLabel(ib+1,quadname[bcnt]);
177 herrapv.GetYaxis()->SetBinLabel(1,
"Good events");
178 herrapv.GetYaxis()->SetBinLabel(2,
"Oscillation");
179 herrapv.GetYaxis()->SetBinLabel(3,
"Saturation");
181 hxbquad.GetXaxis()->SetTitleOffset(1.);
182 hamxquad.GetXaxis()->SetTitleOffset(1.);
183 hch2quad.GetXaxis()->SetTitleOffset(1.);
184 hfmxquad.GetXaxis()->SetTitleOffset(1.);
185 hintquad.GetXaxis()->SetTitleOffset(1.);
191 for(Int_t ib=0;ib<24;ib++)
193 hxbquad.GetXaxis()->SetBinLabel(ib+1,quadname2[ib]);
194 hamxquad.GetXaxis()->SetBinLabel(ib+1,quadname2[ib]);
195 hch2quad.GetXaxis()->SetBinLabel(ib+1,quadname2[ib]);
196 hfmxquad.GetXaxis()->SetBinLabel(ib+1,quadname2[ib]);
197 hintquad.GetXaxis()->SetBinLabel(ib+1,quadname2[ib]);
200 c1=
new TCanvas(
"c1",
"c1",850,1100);
205 c10=
new TCanvas(
"c10",
"c10",850,1100);
207 c11=
new TCanvas(
"c11",
"c11",850,1100);
213 Int_t nevents=tFgt->GetEntries();
214 printf(
"nevents=%d \n",nevents);
215 Int_t evtCnt[10]={0,0,0,0,0,0,0,0,0,0};
219 sprintf(fname,
"runpdfs/pulses_run%d.ps(",runnum);
221 sprintf(fname,
"runpdfs/pulseschi2_run%d.ps(",runnum);
223 for(Int_t i=0;i<nevents;i++)
226 if(iEvt<evtCnt[jCnt])
231 if(i%10000==0)printf(
"evt=%d %d--------------------\n",iEvt,evtCnt[jCnt]);
232 Int_t binAPV = disk*40 + quad*10 + (apv%12);
233 Int_t binQUAD = disk*4 + quad;
235 if(adcmax>adcth && errCode==0 && stat==0 && plotCnt<1000)
237 sprintf(hname,
"hpulse_rdo%d_arm%d_apv%d_chn%d_%d",rdo,arm,apv,chn,plotCnt);
238 h=
new TH1F(hname,hname,7,0,7);
241 for(Int_t j=0;j<7;j++)
243 h->SetBinContent(j+1,adc[j]);
244 h->SetBinError(j+1,pedSig);
249 c10->cd(plotCnt%50+1);
254 sprintf(fname,
"runpdfs/pulses_run%d.ps",runnum);
260 c11->cd(plotCnt2%50+1);
264 sprintf(fname,
"runpdfs/pulseschi2_run%d.ps",runnum);
272 herrapv.Fill(binAPV,errCode);
275 hamxquad.Fill(binQUAD,adcmax);
276 hamxapv.Fill(binAPV,adcmax);
277 hmaxapv.Fill(binAPV,mmax);
278 hminapv.Fill(binAPV,mmin);
279 hpedapv.Fill(binAPV,ped);
280 hsigapv.Fill(binAPV,pedSig);
281 if(adcmax>adcth && chi2>0.)
283 hch2apv.Fill(binAPV,chi2);
284 hch2quad.Fill(binQUAD,chi2);
285 hxbquad.Fill(binQUAD,1);
289 Int_t iarm=arm+6*irdo;
290 Int_t iapv=apv+24*iarm;
291 htauapv.Fill(binAPV,tau);
292 ht0apv.Fill(binAPV,t0);
293 ht0apv2.Fill(iapv,t0);
294 htmapv2.Fill(iapv,tmean);
295 hoffapv.Fill(binAPV,offset);
296 hfmxapv.Fill(binAPV,fmax);
297 TF1 fs(
"fs",
"[0]*(x-[4])**[2]*exp(-(x-[4])/[1])+[3]",-100,100);
298 fs.SetParameter(0,norm);
299 fs.SetParameter(1,tau);
300 fs.SetParameter(2,2.);
301 fs.SetParameter(3,offset);
302 fs.SetParameter(4,t0);
303 Float_t integral=fs.Integral(t0,t0+10);
304 hintapv.Fill(binAPV,integral);
306 hfmxquad.Fill(binQUAD,fmax);
307 ht0quad.Fill(binQUAD,t0);
308 hxbquad.Fill(binQUAD,2);
309 if(t0>t0min && t0<t0max)
311 hintquad.Fill(binQUAD,integral);
312 hxbquad.Fill(binQUAD,3);
315 hxbquad.Fill(binQUAD,4);
324 sprintf(fname,
"runpdfs/pulses_run%d.ps)",runnum);
326 sprintf(fname,
"runpdfs/pulseschi2_run%d.ps)",runnum);
330 for(Int_t i=0;i<10;i++){printf(
"evtCnt = %d \n",evtCnt[i]);totCnt+=evtCnt[i];};
332 for(Int_t i=0;i<24;i++)
334 hxbquad.SetBinContent(i+1,1,totCnt);
337 for(Int_t i=0;i<240;i++)
339 Float_t Ntot=herrapv.Integral(i+1,i+1,1,5);
340 for(Int_t k=0;k<5;k++)
342 Float_t nn=herrapv.GetBinContent(i+1,k+1);
343 if(Ntot>0)herrapv.SetBinContent(i+1,k+1,nn/Ntot);
349 TPad *c=makeTitle(c1,
"APV Fit Parameters",runnum,0); c->cd();
352 c->GetPad(1)->SetLogz();
353 c->GetPad(1)->SetGridx();
354 htauapv.Draw(
"colz");
356 c->GetPad(2)->SetLogz();
357 c->GetPad(2)->SetGridx();
360 c->GetPad(3)->SetLogz();
361 c->GetPad(3)->SetGridx();
362 hoffapv.Draw(
"colz");
363 sprintf(fname,
"runpdfs/apv_run%d.ps(",runnum);
368 TPad *c=makeTitle(c1,
"APV Fit Results",runnum,1); c->cd();
371 c->GetPad(1)->SetLogz();
372 c->GetPad(1)->SetGridx();
373 hch2apv.Draw(
"colz");
375 c->GetPad(2)->SetLogz();
376 c->GetPad(2)->SetGridx();
377 hfmxapv.Draw(
"colz");
379 c->GetPad(3)->SetLogz();
380 c->GetPad(3)->SetGridx();
381 hintapv.Draw(
"colz");
382 sprintf(fname,
"runpdfs/apv_run%d.ps",runnum);
387 TPad *c=makeTitle(c1,
"APV Diagnostics",runnum,1); c->cd();
390 c->GetPad(1)->SetLogz();
391 c->GetPad(1)->SetGridx();
392 hamxapv.Draw(
"colz");
394 c->GetPad(2)->SetLogz();
395 c->GetPad(2)->SetGridx();
396 hpedapv.Draw(
"colz");
398 c->GetPad(3)->SetLogz();
399 c->GetPad(3)->SetGridx();
400 hsigapv.Draw(
"colz");
401 sprintf(fname,
"runpdfs/apv_run%d.ps",runnum);
405 TPad *c=makeTitle(c1,
"APV Diagnostics 2",runnum,1); c->cd();
408 c->GetPad(1)->SetLogz();
409 c->GetPad(1)->SetGridx();
410 hmaxapv.Draw(
"colz");
412 c->GetPad(2)->SetLogz();
413 c->GetPad(2)->SetGridx();
414 hminapv.Draw(
"colz");
416 c->GetPad(3)->SetLogz();
417 c->GetPad(3)->SetGridx();
418 herrapv.Draw(
"colz");
419 sprintf(fname,
"runpdfs/apv_run%d.ps)",runnum);
423 c2=
new TCanvas(
"c2",
"c2",850,1100);
424 sprintf(fname,
"runpdfs/quad_run%d.ps[",runnum);
429 for(Int_t i=0;i<24;i++)
432 pagetitle+=
"Quadrant ";
433 pagetitle+=quadname2[i];
434 TPad *c=makeTitle(c2,pagetitle,runnum,i+1); c->cd();
438 htemp=hxbquad.ProjectionY(quadname2[i],i+1,i+1);htemp->Draw();
439 htemp->GetXaxis()->SetBinLabel(1,
"Nevent");
440 sprintf(label,
"ADCMAX > %d",adcth);
441 htemp->GetXaxis()->SetBinLabel(2,label);
442 sprintf(label,
"chi2/dof < %d",ch2th);
443 htemp->GetXaxis()->SetBinLabel(3,label);
444 sprintf(label,
"%.1f < t0 < %.1f ",t0min,t0max);
445 htemp->GetXaxis()->SetBinLabel(4,label);
446 sprintf(label,
"Integral > %d",intth);
447 htemp->GetXaxis()->SetBinLabel(5,label);
448 htemp->GetXaxis()->SetLabelSize(.1);
449 if(htemp->GetEntries()>0)c->GetPad(1)->SetLogy();
452 htemp=hamxquad.ProjectionY(quadname2[i]+=
' ',i+1,i+1);htemp->Draw();
453 if(htemp->GetEntries()>0)c->GetPad(2)->SetLogy();
454 line =
new TLine(adcth,0.,adcth,2.*htemp->GetMaximum());
455 line->SetLineColor(2);
459 htemp=hch2quad.ProjectionY(quadname2[i]+=
' ',i+1,i+1);htemp->Draw();
461 line =
new TLine(ch2th,0.,ch2th,2.*htemp->GetMaximum());
462 line->SetLineColor(2);
466 htemp=ht0quad.ProjectionY(quadname2[i]+=
' ',i+1,i+1);htemp->Draw();
467 if(htemp->GetEntries()>0)c->GetPad(4)->SetLogy();
468 line =
new TLine(t0min,0.,t0min,2.*htemp->GetMaximum());
469 line->SetLineColor(2);
471 line =
new TLine(t0max,0.,t0max,2.*htemp->GetMaximum());
472 line->SetLineColor(2);
476 htemp=hintquad.ProjectionY(quadname2[i]+=
' ',i+1,i+1);htemp->Draw();
477 if(htemp->GetEntries()>0)c->GetPad(5)->SetLogy();
478 line =
new TLine(intth,0.,intth,2.*htemp->GetMaximum());
479 line->SetLineColor(2);
482 sprintf(fname,
"runpdfs/quad_run%d.ps",runnum);
485 sprintf(fname,
"runpdfs/quad_run%d.ps]",runnum);
489 sprintf(command,
"ps2pdf runpdfs/apv_run%d.ps runpdfs/pdfs/apv_run%d.pdf",runnum,runnum);
491 sprintf(command,
"ps2pdf runpdfs/quad_run%d.ps runpdfs/pdfs/quad_run%d.pdf",runnum,runnum);
493 sprintf(command,
"ps2pdf runpdfs/pulses_run%d.ps runpdfs/pdfs/pulses_run%d.pdf",runnum,runnum);
495 sprintf(command,
"ps2pdf runpdfs/pulseschi2_run%d.ps runpdfs/pdfs/pulseschi2_run%d.pdf",runnum,runnum);
498 sprintf(fname,
"hfgt_run%d.root",runnum);
499 TFile out(fname,
"recreate");
527 TPad *makeTitle(TCanvas *c,TString core,
int runnum,
int page) {
531 sprintf(pname,
"pad0_%d",page);
532 TPad *pad0 =
new TPad(pname,pname,0.0,0.96,1.,1.);
536 TPaveText *pt =
new TPaveText(0,0.,1,1,
"br");
555 sprintf(pname,
"pad1_%d",page);
556 pad =
new TPad(pname, pname,0.0,0.0,1,.95);