10 gStyle->SetStatW(0.22);
11 gStyle->SetStatH(0.22);
15 TH1F *h1=
new TH1F(
"mpv",
"MPV MIP gated; MPV of ADC-ped",35,-5,65);
16 TH1F *h2=
new TH1F(
"mpvE",
"relative error of MPV , MIP gated; err(MPV)/MPV ",50,0,0.5);
17 TH1F *h3=
new TH1F(
"mpvS",
"relative width of L-peak, MIP gated; sigma/MPV",25,0.,1.);
18 TH2F *h4=
new TH2F(
"mpv2",
"MPV from ; gated w/ MIP ; inclusive spectrum;",25,0,50,25,0,25);
25 {1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
34 for(eta=1;eta<=12;eta++) {
36 float mpvL=999, mpvH=0;
37 h1->Reset(); h2->Reset(); h3->Reset(); h4->Reset();
38 fprintf(wfd,
" <tr> <th> %d <td> \n",eta);
39 gStyle->SetOptStat(1001111);
41 for(sec=1; sec<=12;sec++) {
43 for(sub=
'A';sub<=
'E';sub++) {
44 sprintf(core,
"%02d%c%c%02d",sec,cT,sub,eta);
46 ha=(TH1F*)f->Get(
"a"+coreT);
47 hd=(TH1F*)f->Get(
"d"+coreT);
48 c=
new TCanvas(
"aa",
"aa",400,400);
51 c->Print(coreT+
".ps");
52 TString errS=QaOne(ha,hd,cT);
53 printf(
"errS=%s=%d\n",errS.Data(),errS.Sizeof());
54 bool isBad=errS.Sizeof()>1;
56 fprintf(wfd,
" %s ,\n",(coreT+
"-"+errS).Data());
60 if(errS.Contains(
"mask"))
continue;
67 if(mpvL>mpv) mpvL=mpv;
68 if(mpvH<mpv) mpvH=mpv;
72 float fac=TMath::TanH(feta[ieta])/0.0009;
73 float err=sqrt(mpvEr*mpvEr+1);
76 fprintf(gfd,
"%s %.0f %.0f %.1f %.1f \n",core,gain,sig,mpv,mpvEr);
88 fprintf(wfd,
" <td> %d <td> %d\n",nOK,nErr);
90 char txt[100],sumN[100], pdfN[100];
91 sprintf(pdfN,
"%cfitEta%02d.pdf",cT,eta);
92 sprintf(txt,
"cat *%02d.ps | ps2pdf - %s",eta,pdfN);
95 sprintf(txt,
"mv %s /star/u/wissink/cal2006/tmp/",pdfN);
98 fprintf(wfd,
" <td> <a href=\"%s\"> PDF </a>\n",pdfN);
99 fprintf(wfd,
" <td> %.1f to %.1f \n",mpvL,mpvH);
101 gStyle->SetOptStat(1111111);
103 sprintf(sumN,
"mpv%c-eta%02d",cT,eta);
104 c=
new TCanvas(sumN,sumN,600,600);
106 c->cd(1); h1->Draw();
107 c->cd(2); h2->Draw();
108 c->cd(3); h3->Draw();
112 sprintf(txt,
"ps2pdf %s.ps %s.pdf",sumN,sumN);
115 sprintf(txt,
"mv %s.pdf /star/u/wissink/cal2006/tmp/",sumN);
118 fprintf(wfd,
" <td> <a href=\"%s.pdf\"> PDF </a>\n",sumN);
123 if(wfd!=stdout)fclose(wfd);
128 plotOne(TH1F *ha, TH1F *hd) {
134 hd->SetAxisRange(4,80);
135 float sum=hd->Integral();
136 float hdY=hd->GetMaximum();
137 printf(
"%s sum=%f\n",hd->GetName(),sum);
144 if(strstr(hd->GetName(),
"d12PB05")) hd->Rebin(2);
145 if(strstr(hd->GetName(),
"d12RC05")) hd->Rebin(2);
147 ha->SetAxisRange(5,50);
148 int kb=ha->GetMaximumBin();
149 float yMax=ha->GetBinContent(kb);
150 ha->SetAxisRange(-10,xMax);
151 hd->SetAxisRange(-10,xMax);
158 ha->Fit(
"gaus",
"R",
"",-2,3);
161 ha->SetMaximum(yMax*1.5);
165 hd->SetMaximum(2.5*hdY);
173 float fitGausPlusLand(TH1F *h) {
177 gF=
new TF1(
"gF",
"gaus",-2.,2.);
179 gF->SetLineColor(kBlue);
182 lF=
new TF1(
"lF",
"landau",3,xMax);
185 lF->SetLineColor(kRed);
187 glF=
new TF1(
"glF",
"gaus(0)+landau(3)",-2,xMax);
188 glF->SetLineWidth(1);
189 glF->SetLineColor(kGreen);
190 glF->SetParNames(
"ampl-G",
"mean-G",
"sig-G",
"const-L",
"MPV-L",
"sig-L");
199 gF->GetParameters(par+0);
200 lF->GetParameters(par+3);
201 glF->SetParameters(par);
203 glF->FixParameter(1,par[1]);
204 glF->FixParameter(2,par[2]);
210 glF->GetParameters(par);
211 epar= glF->GetParErrors();
213 gF->SetParameters(par+0);
214 lF->SetParameters(par+3);
219 lF->SetRange(0,xMax);
222 float yMax=lF->GetMaximum();
223 printf(
"max=%f\n",yMax);
228 TString QaOne(TH1F *ha, TH1F *hd,
char cT ) {
233 ha->SetAxisRange(-10,10);
234 int kb=ha->GetMaximumBin();
235 float xb=ha->GetBinCenter(kb);
237 if(fabs(xb)>1.)
return "ped";
238 if(ha->GetEntries() <=0)
return "empty";
240 if(ha->Integral()/ha->GetEntries()>0.9999)
return "mask";
248 if(par[4]<6. || par[4]>30.)
return "valL";
251 if(par[4]<10. || par[4]>75.)
return "valL";
254 if(fabs(epar[4])<0.35)
return "erL";
255 if(epar[4]/par[4]>0.5)
return "sigL";
257 hd->SetAxisRange(5,50);
258 float sum=hd->Integral();
259 if(sum<20)
return "lSum";
267 void openAll(
char cT) {
274 if(i<9) sprintf(txt,
"iter4-pp/sect0%d/sum-sect%d.hist.root",i+1,i+1);
275 if(i>8) sprintf(txt,
"iter4-pp/sect%d/sum-sect%d.hist.root",i+1,i+1);
276 fdA[i]=
new TFile(txt);
277 assert(fdA[i]->IsOpen());
279 sprintf(txt,
"/star/u/wissink/cal2006/iter4-pp/gains%c-allSect.dat",cT);
282 fprintf(gfd,
"# final %c-gains from MIP using UxV\n",cT);
283 fprintf(gfd,
"# format: gain (ch/GeV), errGain, LandauFit: MPV(ADC) sigMPV\n");
286 sprintf(txt,
"/star/u/wissink/cal2006/iter4-pp/gains%c.html",cT);
291 fprintf(wfd,
"MIP -- > <a href=\"gains%c-allSect.dat\"> final %c-gains</a> table \n",cT,cT);
292 fprintf(wfd,
"<table border=1>\n");
293 fprintf(wfd,
"<tr> <th> etaBin <th> problems <th> # of good<th> # of errors <th> spectra <br> (60 tiles)<th> MPV range <br>(ADC) <th> summary <br> plot\n");