3 float x1=1+0.05, x2=x1+60;
5 TH1F *hBPMg=
new TH1F(
"bpmG",
"Average MIP position per PMB, err=RMS; X= PMB + pmt/10; MIP (adc)",nbx,x1,x2);
6 TH1F *hBPMu=
new TH1F(
"bpmU",
"Number of used pixels per PMB; X= PMB + pmt/10; number of tiles",nbx,x1,x2);
7 TH1F *hBPMq=
new TH1F(
"bpmQ",
"QA error flag per PMB (Y=0 is good); X= PMB_ID + pmt_ID/10;error code",nbx,x1,x2);
12 fcsv=fopen(
"bprsPMBmipGain.csv",
"w");
13 fprintf(fcsv,
"average MIP ADC over 16 (or less) working BPRS tiles; ver=1.6\n");
14 fprintf(fcsv,
"PMB,pmt, QAflag, nUsedPix, avrMIP (adc), rmsMIP (adc),PDF page # , all mapped softIDs\n");
16 for(
int b=1; b<=60;b++)
18 fprintf(fcsv,
"\nQAflag=0x0 : good MIP signal in this pmt \n");
19 fprintf(fcsv,
"QAflag bit=0x1 : no histo \n");
20 fprintf(fcsv,
"QAflag bit=0x2 : too few working pixels \n");
21 fprintf(fcsv,
"QAflag bit=0x4 : too narrow RMS \n");
22 fprintf(fcsv,
"QAflag bit=0x8 : too low mean ADC \n");
25 c=
new TCanvas(
"aa1",
"aa1",1300,800);
27 gStyle->SetOptStat(10);
28 c->cd(1); hBPMg->Draw(); gPad->SetGrid();
29 c->cd(3); hBPMu->Draw(); gPad->SetGrid();
30 c->cd(2); hBPMq->Draw(); gPad->SetGrid();
31 hBPMg->SetAxisRange(0.,100.); hBPMg->SetMarkerColor(kRed); hBPMg->SetMarkerStyle(5);
32 hBPMu->SetAxisRange(0.,100.); hBPMu->SetFillColor(kBlue);hBPMu->SetLineColor(kBlue);
33 hBPMq->SetAxisRange(0.,100.); hBPMq->SetFillColor(kRed);hBPMq->SetLineColor(kRed);
39 gStyle->SetOptStat(1110);
41 gStyle->SetPalette(1,0);
46 char *fnameO=
"calib-nov-21-2008/barrelMipSpectV6ok.hist.root";
47 fd=
new TFile(fnameO); assert(fd->IsOpen());
48 printf(
"Read %s\n", fd->GetName());
55 int box1=box0, box2=box0;
56 for(
int box=box1; box<=box2; box++) {
57 c=
new TCanvas(
"aa",
"aa",800,500); c->Divide(4,2);
58 c->cd(8); hBPMg->Draw();
59 c->cd(7); hBPMu->Draw();
60 c->cd(6); hBPMq->Draw();
61 hBPMg->SetAxisRange(box,box+1.);
62 hBPMu->SetAxisRange(box,box+1.);
63 hBPMq->SetAxisRange(box,box+1.);
65 for(
int pmt=1; pmt<=5; pmt++) {
66 sprintf(tt,
"gainBPM%d_%d",box,pmt);
67 printf(
" get:%s:\n",tt);
70 if(fcsv) fprintf(
"%d,%d, 0,1, noHisto",box,pmt);
71 printf(
"missing=%s \n",tt);
continue;}
72 float xVal=box+pmt/10.;
74 h->Draw(); h->SetMaximum(10);
75 float nUsed=h->GetEntries();
76 hBPMu->Fill(xVal,nUsed);
77 float mean=h->GetMean();
78 float rms=h->GetRMS();
80 if(nUsed<cut_nUsed) flag+=2;
81 if(rms<cut_rms) flag+=4;
82 if(mean<cut_adcL) flag+=8;
83 if(flag)hBPMq->Fill(xVal,flag);
84 if(flag==0) {
int bin=hBPMg->FindBin(xVal);
85 hBPMg->SetBinContent(bin,mean);
86 hBPMg->SetBinError(bin,rms);
89 fprintf(fcsv,
"%d,%d,%d, %d, %.2f, %.2f, %2d,",box,pmt,flag,nUsed,mean,rms,5*(box-1)+pmt);
90 printSoftList(box,pmt);
98 void printSoftList(
int box=11,
int pmt=1) {
99 fd1=
new TFile(
"calib-nov-8-2008/map-softID-bprsPmt-Rory.root"); assert(fd1->IsOpen());
101 TH1I * mapBprsPmt=(TH1I*) fd1->Get(
"bprsPmt"); assert(mapBprsPmt);
105 for(
int b=1;b<=4800;b++) {
106 if(y!=(
int)mapBprsPmt->GetBinContent(b))
continue;
107 if(fcsv)fprintf(fcsv,
"%d ",b);
109 if(fcsv) fprintf(fcsv,
"\n");