2 void getCluAvgEff(Char_t* signalFile=
"signalShapes.root", Int_t diskNr=3, Bool_t onlyQuadB=
false)
12 sprintf(buffer,
"allClusterCountsDisk_%d",diskNr);
13 TH2D* hEff=(TH2D*)f.Get(buffer);
15 sprintf(buffer,
"radioDiskNonEff_%d",diskNr-1);
16 TH2D* hNonEff=(TH2D*)f.Get(buffer);
20 Double_t max=hEff->GetXaxis()->GetXmax();
21 Double_t min=hEff->GetXaxis()->GetXmin();
25 TH2D OverallEff(
"overallEff",
"overallEff",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
26 TH2D OverallCounts(
"overallCounts",
"overallCounts",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
27 TH2D OverallFound(
"overallFound",
"overallFound",hEff->GetNbinsX(),min,max,hEff->GetNbinsY(),min,max);
28 OverallEff.GetXaxis()->SetTitle(
"x [cm]");
29 OverallEff.GetYaxis()->SetTitle(
"y [cm]");
30 OverallCounts.GetXaxis()->SetTitle(
"x [cm]");
31 OverallCounts.GetYaxis()->SetTitle(
"y [cm]");
32 OverallFound.GetXaxis()->SetTitle(
"x [cm]");
33 OverallFound.GetYaxis()->SetTitle(
"y [cm]");
43 Double_t overallErr=0;
44 for(Int_t i=1;i<hEff->GetNbinsX()+1;i++)
46 for(Int_t j=1;j<hEff->GetNbinsY()+1;j++)
51 if(i<(hEff->GetNbinsX()-1)/2|| j>(hEff->GetNbinsY()-1)/2)
61 Int_t numEff=hEff->GetBinContent(i,j);
62 Int_t numNonEff=hNonEff->GetBinContent(i,j);
63 Int_t numCounts=numEff+numNonEff;
65 Double_t efficiency=0;
66 if(numCounts>minCounts)
68 efficiency=(Double_t)numEff/(Double_t)numCounts;
75 OverallEff.SetBinContent(i,j,efficiency);
76 OverallCounts.SetBinContent(i,j,numCounts);
77 OverallFound.SetBinContent(i,j,numEff);
79 if(numCounts>minCounts)
86 relErr=sqrt((1/(Double_t)(numEff+numNonEff)+1/(Double_t)numEff));
87 err=relErr*efficiency;
92 err=1/sqrt(numNonEff);
94 eff+=efficiency/(err*err);
95 overallErr+=(1/(err*err));
102 Double_t avgEff=sumEff/(Double_t)(sumEff+sumNonEff);
104 Double_t errOnEffNum=sqrt(avgEff*(1-avgEff)*(sumEff+sumNonEff));
105 Double_t altErr= ((Double_t)1/(Double_t)(sumEff+sumNonEff))*sqrt(sumEff*(Double_t)(1-sumEff/(sumEff+sumNonEff)));
106 sprintf(buffer,
"Average Efficiency is %f +- %f",avgEff,altErr);
108 Float_t rotationRadians=-0.261799388;
109 Float_t rotationRadians2=-1.83259571;
110 Float_t rotation=-15;
113 TLatex t1(-30,0,buffer);
114 TArc outerA(0,0,outerR,90+rotation,-90+rotation);
115 TArc innerA(0,0,innerR,90+rotation,-90+rotation);
117 TLine l1(innerR*cos(rotationRadians),innerR*sin(rotationRadians),outerR*cos(rotationRadians),outerR*sin(rotationRadians));
118 TLine l2(innerR*cos(rotationRadians2),innerR*sin(rotationRadians2),outerR*cos(rotationRadians2),outerR*sin(rotationRadians2));
121 outerA.SetLineWidth(3);
122 innerA.SetLineWidth(3);
126 int apvMap[]={5,6,7,8,9,12,13,14,15,16};
128 TCanvas* c2=
new TCanvas(
"ceff",
"ceff",1,1,800,800);
129 for(
int i=0;i<10;i++)
135 sprintf(buffer2,
"overallEff_D%d.pdf(",diskNr);
137 sprintf(buffer3,
"overallEff_D%d.png",diskNr);
138 OverallEff.Draw(
"colz");
141 OverallEff.Draw(
"same colz");
151 sprintf(buffer2,
"overallEff_D%d.pdf)",diskNr);
153 sprintf(buffer2,
"overallEff_D%d.pdf",diskNr);
155 OverallEff.Draw(
"colz");
159 OverallEff.Draw(
"same colz");
163 sprintf(buffer,
"overallEff_D%d_APV%d.pdf",diskNr,apvMap[i]);
164 plAPV(apvMap[i],1,
'B');
166 cout <<
"printing to " << buffer2 <<endl;
167 c2->Print(buffer2,
"pdf");
169 TCanvas c(
"effs",
"effs",1,1,800,800);
174 TCanvas cC(
"counts",
"counts",1,1,800,800);
175 OverallCounts.Draw(
"colz");
179 OverallCounts.Draw(
"same colz");
182 cC.SaveAs(
"overallCounts.png");
185 TCanvas cf(
"found",
"found",1,1,800,800);
186 OverallFound.Draw(
"colz");
189 OverallFound.Draw(
"same colz");
192 cf.SaveAs(
"overallFound.png");
194 sprintf(buffer,
"overall found");
195 sprintf(buffer2,
"cFoundD",diskNr);
196 c2=
new TCanvas(buffer2,buffer2,1,1,800,800);
197 TLatex t2(-30,0,buffer);
198 for(
int i=0;i<10;i++)
202 sprintf(buffer2,
"overallFound_D%d.pdf(",diskNr);
204 sprintf(buffer3,
"overallFound_D%d.png",diskNr);
205 sprintf(buffer2,
"overallFound_D%d.pdf(",diskNr);
206 OverallFound.Draw(
"colz");
209 OverallFound.Draw(
"same colz");
217 sprintf(buffer2,
"overallFound_D%d.pdf)",diskNr);
219 sprintf(buffer2,
"overallFound_D%d.pdf",diskNr);
221 OverallEff.Draw(
"colz");
229 sprintf(buffer,
"overallFound_D%d_APV%d.png",diskNr,apvMap[i]);
230 plAPV(apvMap[i],1,
'B');
232 cout <<
"printing to " << buffer2 <<endl;
233 c2->Print(buffer2,
"pdf");
243 cout <<
"Hits found: " << sumEff <<
" Hits not found: " << sumNonEff<<
" efficiency: " <<avgEff<<
" +- " << altErr<<endl;
247 double pi=2.*acos(0.);
248 double rad2deg=pi/180.;
250 enum {mxFgtElect=30720, mxFgtApv=22, mxFgtPln=2, kFgtPlnP=0, kFgtPlnR=1 };
251 char *plnC[mxFgtPln]={
"Phi",
"R"};
256 int electId,geoId, rdo,arm,apv,chan, disc,strip;
257 float r1, r2, phi1, phi2;
272 void plFgtQuads_dbMap() {
273 memset(stripDb,0,
sizeof(stripDb));
274 readFgtStripMap_CSV(
"fgtMapDump-jan28.csv");
275 printf(
"reading of CSV done\n");
277 for(
int i=0;i<10;i++) {
278 if(stripDb[i].rdo<=0)
continue;
279 printStripItem(stripDb+i);
282 printf(
" execute: plAPV() , plPlane() , plGood(1) , plRstrips(1); \n");
293 void plGood(
int disc=1,
int ipl=-1 ) {
294 double par_fgtQuadMaxR=39.7;
297 TString canN=Form(
"fgt_disc%d_good",disc);
298 if(ipl>=0) canN=Form(
"fgt_%d_%s",disc,plnC[ipl]);
299 TH2F *hQuad=
new TH2F(
"aa",
"aa",20,-par_fgtQuadMaxR,par_fgtQuadMaxR,20,-par_fgtQuadMaxR,par_fgtQuadMaxR);
300 gStyle->SetOptStat(0) ;
301 gStyle->SetFillColor(kWhite);
302 c=
new TCanvas( canN,canN,700,720);
307 nstr+=plotStrips( -1, disc,
'A', ipl, -15);
308 nstr+=plotStrips( -1, disc,
'B', ipl, -15-90);
309 nstr+=plotStrips( -1, disc,
'D', ipl, 75);
310 nstr+=plotStrips( -1, disc,
'C', ipl, 75+90);
313 tit=Form(
"FGT: disc %d, good strips=%d ; STAR ref. X (cm); STAR ref. Y (cm)",disc, nstr);
315 if(ipl>=0) tit=Form(
"FGT: disc %d plane=%s, GOOD strip=%d ; local X (cm); local Y (cm)",disc, plnC[ipl], nstr);
317 hQuad->SetTitle(tit);
326 void plRstrips(
int ioct ) {
328 int disc=1;
char quad=
'A';
329 double par_fgtQuadMaxR=39.7;
332 TString canN=Form(
"fgt_%d%c_%s_str_oct%d",disc,quad,plnC[ipl],ioct);
333 TH2F *hQuad=
new TH2F(
"aa",
"aa",200,-0.5,par_fgtQuadMaxR,200,-0.5,par_fgtQuadMaxR);
334 gStyle->SetOptStat(0) ;
335 gStyle->SetFillColor(kWhite);
336 c=
new TCanvas( canN,canN,700,720);
341 nstr=plotStrips( 0+17*ioct, disc, quad, ipl,0,1);
342 nstr=plotStrips( 1+17*ioct, disc, quad, ipl,0,2);
343 nstr=plotStrips( 2+17*ioct, disc, quad, ipl,0,8);
344 nstr=plotStrips( 3+17*ioct, disc, quad, ipl,0,4);
345 nstr=plotStrips( 4+17*ioct, disc, quad, ipl,0,6);
348 tit=Form(
"FGT: quad %d%c, plane=%s, strip=%d ; local X (cm); local Y (cm)",disc, quad, plnC[ipl], nstr);
349 hQuad->SetTitle(tit);
356 void plPlane(
int ipl=0,
int disc=1,
char quad=
'A' ) {
357 double par_fgtQuadMaxR=39.7;
360 TString canN=Form(
"fgt_%d%c_%s",disc,quad,plnC[ipl]);
361 TH2F *hQuad=
new TH2F(
"aa",
"aa",200,-0.5,par_fgtQuadMaxR,200,-0.5,par_fgtQuadMaxR);
362 gStyle->SetOptStat(0) ;
363 gStyle->SetFillColor(kWhite);
364 c=
new TCanvas( canN,canN,700,720);
369 nstr=plotStrips( -1, disc, quad, ipl);
372 tit=Form(
"FGT: quad %d%c, plane=%s, strip=%d ; local X (cm); local Y (cm)",disc, quad, plnC[ipl], nstr);
373 hQuad->SetTitle(tit);
380 void plAPV(
int apv=0,
int disc=1,
char quad=
'A' ) {
382 double par_fgtQuadMaxR=39.7;
385 TString canN=Form(
"fgt_%d%c_apv%d",disc,quad,apv);
386 TH2F *hQuad=
new TH2F(
"aa",
"aa",200,-0.5,par_fgtQuadMaxR,200,-0.5,par_fgtQuadMaxR);
387 gStyle->SetOptStat(0) ;
388 gStyle->SetFillColor(kWhite);
400 nstr=plotStrips( apv, disc, quad,-1);
403 if( apv>=0) tit=Form(
"FGT: quad %d%c, APV=%d, Nstrip=%d ; local X (cm); local Y (cm)",disc, quad, apv, nstr);
404 hQuad->SetTitle(tit);
411 int plotStrips(
int apv,
int disc,
char quad,
int ipl,
int phiDeg=0,
int iCol0) {
414 Bool_t secondOct=
false;
423 for(
int i=0;i<mxFgtElect;i++) {
425 if(S->geoId<0)
continue;
426 if(S->disc!=disc)
continue;
427 if(S->quad!=quad)
continue;
429 if(S->layer!=plnC[ipl][0])
continue;
431 if(S->stat)
continue;
434 if(nstr<5) printStripItem(S);
437 if( S->strip <=360) iCol=kRed;
442 if(S->apv!=apv)
continue;
446 if(iCol0) iCol=iCol0;
450 tx=
new TText(42-(nstr%2)*2., 42.-(nstr+S->chan/32)/3., S->name+2);
451 if(S->layer==
'P') tx->SetTextColor(kBlue);
453 tx->SetTextSize(0.014);
454 if(nstr==1) { tx=
new TText(39.7, 42.9,
"by electID");
455 tx->SetTextSize(0.02);}
459 int keep= ( S->strip%720)==0;
460 if(S->strip%7!=0 && !keep)
continue;
470 double phi1=S->phi1+phiDeg*rad2deg, phi2=S->phi2+phiDeg*rad2deg;
474 cout <<
" phi1: " << phi1 <<
" phi2: " << phi2 <<endl;
475 double x1=S->r1*cos(phi1), x2=S->r2*cos(phi2);
476 double y1=S->r1*sin(phi1), y2=S->r2*sin(phi2);
479 ln=
new TLine(x1,y1,x2,y2);
480 ln->Draw(); ln->SetLineColor(iCol);
481 ln->SetLineWidth( lineWidth);
483 if(S->strip%35==0 || keep) {
484 double x3=x2+1., y3=y2+0.6;
485 ln=
new TLine(x2*1.005,y2*1.005,x3,y3);
486 ln->Draw(); ln->SetLineColor(iCol);
488 tx=
new TText(x3,y3,Form(
"%c%03d",S->layer,S->strip));
489 tx->Draw(); tx->SetTextColor(iCol); tx->SetTextSize(0.02);
490 tx->SetTextAngle(phiDeg+10.);
494 if( S->layer==
'R' ) {
496 if( S->strip <400) { kk=S->strip;}
497 else { kk=S->strip-400;}
498 int keep= (kk %279)==0;
499 if(kk%7!=0 && !keep)
continue;
501 double phi1Deg=S->phi1/rad2deg +phiDeg;
502 double phi2Deg=S->phi2/rad2deg+phiDeg;
507 TArc * ar=
new TArc(0.,0,S->r1, phi1Deg, phi2Deg);
508 ar->SetFillStyle(0); ar->SetLineColor(iCol);
510 ar->SetLineWidth( lineWidth);
512 if(kk%35==0 || keep) {
513 double x2,y2,x3,y3,dx,dy;
514 double phiAvr=(S->phi1+S->phi2)/2.;
516 double delPhi=phiDeg*rad2deg;
520 x2=S->r1*cos(phiAvr); y2=S->r2*sin(phiAvr);
521 x3=x2-0.3; y3=y2+0.6;
524 x3=x2+0.2; y3=y2+0.7;
527 ln=
new TLine(x2,y2,x3,y3);
528 ln->Draw(); ln->SetLineColor(iCol);
530 tx=
new TText(x3+dx,y3+dy,Form(
"%c%03d",S->layer,S->strip));
531 tx->Draw(); tx->SetTextSize(0.02);
532 tx->SetTextAngle(phiDeg-10.);
545 printf(
"%d%c_%c-plane strip=%d geo=%d elec=%d apv%d chan%d, R[%.1f, %.1f]cm Phi[%.2f, %.2f]deg %s stat=%d ped=%.1f\n",S->disc,S->quad,S->layer,S->strip, S->geoId,S->electId,S->apv, S->chan, S->r1, S->r2, S->phi1/rad2deg, S->phi2/rad2deg, S->name, S->stat, S->ped);
552 void readFgtStripMap_CSV(
char *fname){
553 FILE *fd=fopen(fname,
"r"); assert(fd);
559 float ord,lowSpan,upSpan;
563 char * ret=fgets(buf,mx,fd);
565 if(buf[0]==
'#')
continue;
567 char *item=strtok(buf,
",");
574 case 1: S.electId=atoi(item);
break;
575 case 2: S.geoId=atoi(item);
break;
577 case 3: S.rdo=atoi(item);
break;
578 case 4: S.arm=atoi(item);
break;
579 case 5: S.apv=atoi(item);
break;
580 case 6: S.chan=atoi(item);
break;
582 case 7: S.disc=atoi(item);
break;
583 case 8: S.quad=item[0];
break;
584 case 9: S.layer=item[0];
break;
585 case 10: S.strip=atoi(item);
break;
587 case 11: sscanf(item,
"%f",&ord);
break;
588 case 12: sscanf(item,
"%f",&lowSpan);
break;
589 case 13: sscanf(item,
"%f",&upSpan);
break;
591 case 14: sscanf(item,
"%s",S.name);
break;
593 case 15: S.stat=atoi(item);
break;
594 case 16: sscanf(item,
"%f",&S.ped);
break;
595 case 17: sscanf(item,
"%f",&S.sigPed);
break;
599 }
while (item=strtok(0,
","));
603 stripDb[S.electId].geoId=-1;
620 assert(S.electId>=0);
621 assert(S.electId<mxFgtElect);
623 stripDb[S.electId]=S;
627 printf (
"total # of APV channels mapped %d, see records %d\n",nok,k);
642 for(
int disc=1;disc<=6;disc++) plGood(disc);