2 const int mxBTiles=4800;
9 char *crun=
"calib-nov-8-2008/sum-swapB";
11 gStyle->SetPalette(1,0);
12 gStyle->SetOptStat(0);
16 char *pathOut=
"ourX/";
17 char txt[1000], txt2[1000];
19 sprintf(txt,
"%s/%s.hist.root",pathIn,crun);
20 fd1=
new TFile(txt); assert(fd1->IsOpen());
21 printf(
"Opened: %s\n",fd1->GetName());
22 h2scan= (TH2F *)fd1->Get(
"swapScan"); assert(h2scan);
26 c=
new TCanvas(
"aa",
"aa",1400,300);
28 TH1F *h1=findBest(h2scan, id1,id2,crun );
39 TH1F* findBest( TH2F *h2,
int id1,
int id2,
char *crun) {
41 char txt[1000], txt2[1000];
43 sprintf(txt,
"mapCor");
44 sprintf(txt2,
"mapping crection %d; old soft ID; new soft ID", crun);
45 hMapCor=
new TH1I(txt,txt2,mxBTiles,0.5,mxBTiles+0.5);
49 float x1=axX->GetXmin();
50 float x2=axX->GetXmax();
51 int nbX=axX->GetNbins();
52 printf(
"X-axis range --> [%.1f, %.1f], nb=%d %s\n",x1,x2,nbX,axX->GetTitle());
55 float y1=axY->GetXmin();
56 float y2=axY->GetXmax();
57 int nbY=axY->GetNbins();
58 printf(
"Y-axis range --> [%.1f, %.1f], nb=%d\n",y1,y2,nbY);
60 TH1F*h1=
new TH1F(
"h1",
"h1",nbX,x1,x2);
63 for(
int iy=id1; iy<=id2; iy++) {
64 char txt1[100], txt2[1000];
65 sprintf(txt1,
"id%d",iy);
66 sprintf(txt2,
"soft id=%d; %s",iy,axX->GetTitle());
71 for(i=1;i<=nbX;i++) h1->SetBinContent(i,h2->GetBinContent(i,iy));
72 float peakX=h1->GetMaximumBin();
73 float peakZ=h1->GetMaximum();
74 float yield=h1->Integral();
75 h1->SetEntries(yield);
76 printf(
" work on %s peakX=%.1f peakZ=%.1f\n",txt1,peakX,peakZ);
79 h1->SetAxisRange( idL,idH);
80 float yieldR=h1->Integral();
82 float r1=peakZ/yieldR;
83 h1->SetAxisRange( 0,5000);
85 printf(
" ID range=%d,%d r1=%.3f yieldR=%.1f\n",idL,idH,r1,yieldR);
86 int idBest=(int)peakX;
87 if(peakZ<cut_minZ) { printf(
"## DEAD/MISSING softID %d ",iy);
88 }
else if(idBest==iy) { printf(
"# OK softID %d ",iy);
90 printf(
"ss hReMap->SetBinContent( %4d, %4d); // nMIP=%.0f, PDF page=%d\n",idBest,iy,peakZ, 1+((iy-1)/200));
91 printf(
"## CHANGE old softID %d --> %d , nMIP=%.0f-->",idBest,iy,h1->GetBinContent(iy));
94 printf(
" nMIP=%.0f\n",peakZ);
102 if(yield<cut_yield0) { hStat->SetBinContent(ih,kBad);
continue; }
105 if(isSticky(h,mean)) { hStat->SetBinContent(ih,kBad);
continue; }
110 if(r1< cut_yieldR1) { hStat->SetBinContent(ih,kBad);
continue; }
113 h->Fit(
"gaus",
"Q",
"Rh", adc1, adc2);
114 TF1 *ff=h->GetFunction(
"gaus"); assert(ff);
115 ff->SetLineColor(kRed);
116 ff->SetLineWidth(1.);
119 float ped=ff->GetParameter(1);
120 float pedErr=ff->GetParError(1);
121 float sig=ff->GetParameter(2);
122 float chi2=ff->GetChisquare();
123 float ndf=ff->GetNDF();