1 plGainBprs(
int page=1,
int box0=0) {
2 gStyle->SetOptStat(1110);
4 gStyle->SetPalette(1,0);
6 char *fnameO=
"calib-nov-21-2008/barrelMipSpectV6ok.hist.root";
7 fd=
new TFile(fnameO); assert(fd->IsOpen());
8 printf(
"Read %s\n", fd->GetName());
11 char *fname1=
"mipGainBprs+Btow_v6.hist.root";
12 fout=
new TFile(fname1,
"update"); assert(fout->IsOpen());
13 printf(
"Write output to %s\n", fout->GetName());
19 c=
new TCanvas(
"aa",
"aa",1000,600); c->Divide(5,4);
21 for(
int box=1; box<=4; box++)
22 for(
int pmt=1;pmt<=5;pmt++)
24 sprintf(tt,
"gainBPM%d_%d",box+box0,pmt);
27 if(h==0) { printf(
"missing=%s \n",tt); k++;
continue;}
29 h->Draw(); h->SetMaximum(10);
39 float cut_minYield=20;
42 gStyle->SetOptStat(0);
45 TString tt1=
"bprsMipGain2D", tt3=
"bprsMipGain", tt4=
"bprsMipSig", tt5=
"bprsMipStat";
48 tt1=
"btowMipGain2D"; tt3=
"btowMipGain"; tt4=
"btowMipSig"; tt5=
"btowMipStat";
53 c=
new TCanvas(tt1,tt1,1200,800);
54 h2g=
new TH2F(tt1,tt1+
" Z=MIP position(ADC); phiBin, X=1+(softID-1)/20 ; etaBin, Y=1+(softID-1)%20",240,0.5,240.5,20,0.5,20.5);
55 h1g=
new TH1F(tt3,tt3+
" ; softID; MIP ADC",4800,0.5,4800.5);
56 h1sig=
new TH1F(tt4,tt4+
"; softID; MIP sigma",4800,0.5,4800.5);
57 h1stat=
new TH1F(tt5,tt5+
"; softID; MIP status",4800,0.5,4800.5);
58 h1g->GetYaxis()->SetTitleSize(0.055);
59 h1sig->GetYaxis()->SetTitleSize(0.055);
60 h1stat->GetYaxis()->SetTitleSize(0.055);
62 pad=
new TPad(
"pad2",
"apd2",0.0,0.7,1.,1.); pad->Draw();
63 pad->cd();h2g->Draw(
"colz"); h2g->SetMaximum(gMax); gPad->SetGrid();
64 if(page==3) markBtow2D();
65 if(page==2) markBprs2D();
67 c->cd(); pad=
new TPad(
"pad1",
"apd1",0.0,0.0,1.,0.7); pad->Draw();
69 pad->cd(1);h1g->Draw();
if(page==2) markBprs1D();
70 pad->cd(2);h1sig->Draw();gPad->SetGrid();
if(page==2) markBprs1D();
74 for(
int id=1;
id<=4800;
id++) {
76 sprintf(txt,
"%s%dm",core1,
id);
78 if(h==0) { h1stat->Fill(
id,1); printf(
"missing=%s \n",txt);
continue;}
80 float yield=h->GetEntries();
81 if(yield<cut_minYield) {h1stat->Fill(
id,2); printf(
" low MIP yield=%s %d \n",txt,yield);
continue;}
83 TF1 *ff=h->GetFunction(
"gaus");
84 float mean=ff->GetParameter(1);
85 float meanE=ff->GetParError(1);
86 float sig=ff->GetParameter(2);
87 float mpvRE=fabs(meanE/mean);
89 if( (mpvRE>cut_mpvRE) ||
90 (mean<1 || mean>40) ) {
93 if(mean< cut_mipL || mean>40) { h1stat->Fill(
id,4); printf(
" too low2 MIP=%s %f\n",txt,mean);
continue;}
95 meanE=sig/sqrt(yield);
96 mpvRE=fabs(meanE/mean);
97 printf(
" %s bad fit, use mean/RMS\n", txt);
99 if( mpvRE>cut_mpvRE) { h1stat->Fill(
id,8); printf(
" bad mpvRE=%s %f\n",txt,mpvRE);
continue;}
100 printf(
"id=%d yield=%d MIP=%.1f +/- %.1f\n",
id,yield, mean,sig);
103 h2g->Fill(ix,iy,mean);
104 h1g->SetBinContent(
id,mean);
105 h1g->SetBinError(
id,meanE);
106 h1sig->SetBinContent(
id,sig);
108 int nKill=(int) h1stat->GetEntries();
109 tt5=
"nKilled="; tt5+=nKill; tx=
new TText(-500,26,tt5); tx->Draw(); tx->SetTextSize(0.08);tx->SetTextColor(kRed);
126 lnEW=
new TLine(120.5,0, 120.5,23); lnEW->Draw(); lnEW->SetLineColor(kBlue);
127 tx=
new TText(100,21.7,
"West"); tx->Draw(); tx->SetTextColor(kBlue);
128 tx=
new TText(140,21.7,
"East"); tx->Draw(); tx->SetTextColor(kBlue);
130 tx=
new TText(-5,-1.5,
"module=1"); tx->Draw(); tx->SetTextColor(kBlue);
131 tx=
new TText(108,-1.5,
"module=60,61"); tx->Draw(); tx->SetTextColor(kBlue);
132 tx=
new TText(240,-1.5,
"module=120"); tx->Draw(); tx->SetTextColor(kBlue);
136 lnEW=
new TLine(120.5,-2, 120.5,23); lnEW->Draw(); lnEW->SetLineColor(kBlue);
137 tx=
new TText(100,21.7,
"West"); tx->Draw(); tx->SetTextColor(kBlue);
138 tx=
new TText(140,21.7,
"East"); tx->Draw(); tx->SetTextColor(kBlue);
140 lnEW=
new TLine(17.5,-2, 17.5,21); lnEW->Draw(); lnEW->SetLineColor(kBlue);
141 lnEW=
new TLine(77.5,-2, 77.5,21); lnEW->Draw(); lnEW->SetLineColor(kBlue);
143 lnEW=
new TLine(145.5,-2, 145.5,21); lnEW->Draw(); lnEW->SetLineColor(kBlue);
144 lnEW=
new TLine(205.5,-2, 205.5,21); lnEW->Draw(); lnEW->SetLineColor(kBlue);
146 tx=
new TText(1,-1.5,
"PSD-1W"); tx->Draw(); tx->SetTextColor(kBlue);
147 tx=
new TText(80,-1.5,
"PSD-1W"); tx->Draw(); tx->SetTextColor(kBlue);
148 tx=
new TText(40,-1.5,
"PSD-19W"); tx->Draw(); tx->SetTextColor(kBlue);
150 tx=
new TText(206,-0.5,
"PSD-1E"); tx->Draw(); tx->SetTextColor(kBlue);
151 tx=
new TText(130,-1.5,
"PSD-1E"); tx->Draw(); tx->SetTextColor(kBlue);
152 tx=
new TText(180,-1.5,
"PSD-20E"); tx->Draw(); tx->SetTextColor(kBlue);
159 lnEW=
new TLine(2400,-2, 2400,y); lnEW->Draw(); lnEW->SetLineColor(kBlue);
163 lnEW=
new TLine(340,0,340,y); lnEW->Draw(); lnEW->SetLineColor(kBlue);
164 lnEW=
new TLine(1540,0,1540,y); lnEW->Draw(); lnEW->SetLineColor(kBlue);
166 lnEW=
new TLine(2900,0,2900,y); lnEW->Draw(); lnEW->SetLineColor(kBlue);
167 lnEW=
new TLine(4100,0,4100,y); lnEW->Draw(); lnEW->SetLineColor(kBlue);
169 tx=
new TText(10,-2,
"PSD-1W"); tx->Draw(); tx->SetTextColor(kBlue);
170 tx=
new TText(1600,-2,
"PSD-1W"); tx->Draw(); tx->SetTextColor(kBlue);
171 tx=
new TText(1000,-2,
"PSD-19W"); tx->Draw(); tx->SetTextColor(kBlue);
173 tx=
new TText(2600,-2,
"PSD-1E"); tx->Draw(); tx->SetTextColor(kBlue);
174 tx=
new TText(3200,-2.,
"PSD-1E"); tx->Draw(); tx->SetTextColor(kBlue);
175 tx=
new TText(4200,-2.,
"PSD-20E"); tx->Draw(); tx->SetTextColor(kBlue);