6 #include "BprsCapPolygraph.h"
7 #include "StJanBarrelDbMaker.h"
8 #include "JanBarrelEvent.h"
13 BprsCapPolygraph::BprsCapPolygraph( TObjArray *HList,
StJanBarrelDbMaker* jdb,
int pedFlag) {
15 mJanDbMaker=jdb; assert(mJanDbMaker);
17 const char *fname=
"all";
20 hChiB=
new TH1F(
"bppg_chb",
"BprsPoly logN(chi2/dof), nominal capID ; logN(chi2/dof)",200,-1.,9.);
21 hChiGap=
new TH1F(
"bppg_chgI",
"BprsPoly chi2/dof (nominal - best_capID), any minimum; logN( nominal_chi2 - best_chi2 ) ",200,-6,10);
22 hChiGap2=
new TH1F(
"bppg_chgA",
"BprsPoly chi2/dof (nominal - best_capID), acceted; logN( nominal_chi2 - best_chi2 ) ",200,-6,10);
25 hCh2D=
new TH2F(
"bppg_ch2D",
"BprsPoly chi2/DOF(best capID.NE.nominalCapID) ; LogN( chi2/DOF), best; logN(chi2/DOF), nominal ",50,-1,10,50,-1,10);
26 sprintf(tt2,
"BprsPoly caps in sync, %s; nominal capID; BPRS crate ID",fname);
27 hCapGood=
new TH2F(
"bppg_capSyn",tt2, 128,-0.5,127.5,mxBprsCrate,-0.5,mxBprsCrate-0.5);
28 sprintf(tt2,
"BprsPoly caps NOT sync, %s; nominal capID; BPRS crateID",fname);
29 hCapCorr=
new TH2F(
"bppg_capDeSyn",tt2, 128,-0.5,127.5,mxBprsCrate,-0.5,mxBprsCrate-0.5);
33 HList->Add( hChiGap2);
42 hAdcGood=
new TH1F(
"bppg_adcGd",
"BprsPoly ADC for capID in sync; rawAdc - ped(nominal capID)",nb,adc1,adc2);
43 hAdcCorr=
new TH1F(
"bppg_adcCor",
"BprsPoly ADC for capID NOT in sync,fixed; rawAdc - ped(best capID)",nb,adc1,adc2);
44 hAdcCorr->SetLineColor(kRed);
47 HList->Add( hAdcCorr);
55 int crateID=bprsEve.crateID;
56 int capID=bprsEve.capID;
57 printf(
"doBaseline: bprsEve: %d rawADC, doCrate=%d nominalCapID=%d\n", bprsEve.raw.GetN(),crateID,capID);
61 for(
int i=0;i< bprsEve.raw.GetN();i++) {
63 bprsEve.raw.GetPoint(i,rawAdc,yid);
66 int stat =mJanDbMaker->statTile(ibp,
id);
68 float ped =mJanDbMaker->pedTile(ibp,
id,capID);
69 float sig =mJanDbMaker->sigPedTile(ibp,
id,capID);
70 double del=rawAdc-ped;
71 if(del> cut_adcMax)
continue;
76 res.SetPoint(res.GetN(),del,i);
80 int i2=(int)(res.GetN()*cut_fracSkip);
82 printf(
"res size=%d , use=[%d,%d]\n", res.GetN(),i1,i2);
86 for(
int i=i1; i<i2;i++) {
88 res.GetPoint(i,rdel,yj);
94 bprsEve.raw.GetPoint(j,rawAdc,yid);
95 bprsEve.addGoodValue(yid,rawAdc);
98 float chi2dof=sum/dof;
99 printf(
" base chi2=%f DOF=%d, chi/DOF=%f nGood=%d\n",sum,dof,chi2dof,bprsEve.good.GetN());
101 bprsEve.chi2dof=chi2dof;
102 hChiB->Fill(log(chi2dof));
109 printf(
"find BPRS bestCap: eve: %d good\n", bprsEve.good.GetN());
112 float minChi2dof=bprsEve.chi2dof-0.0001;
115 int cap1=bprsEve.capID-par_mxDelCap+mxBcap;
116 int cap2=bprsEve.capID+par_mxDelCap+mxBcap;
117 for(
int ic=cap1; ic<=cap2;ic++) {
121 for(
int i=0;i< bprsEve.good.GetN();i++) {
123 bprsEve.good.GetPoint(i,rawAdc,yid);
126 int stat =mJanDbMaker->statTile(ibp,
id);
129 float ped =mJanDbMaker->pedTile(ibp,
id,cap);
130 float sig =mJanDbMaker->sigPedTile(ibp,
id,cap);
131 double del=rawAdc-ped;
136 float chi2dof=sum/bprsEve.good.GetN();
137 printf(
" capID=%d chi2=%.1f DOF=%d, chi/DOF=%f\n",cap,sum, bprsEve.good.GetN(),chi2dof);
138 if(minChi2dof<=chi2dof)
continue;
146 if(bestCapID>=0)hChiGap->Fill(log(bprsEve.chi2dof-minChi2dof));
148 if( minChi2dof<bprsEve.chi2dof-cut_stepChi2dof) {
149 assert(bestCapID>=0);
151 hChiGap2->Fill(log(bprsEve.chi2dof-minChi2dof));
152 hCh2D->Fill(log(minChi2dof),log(bprsEve.chi2dof));
153 hCapCorr->Fill(bprsEve.capID,bprsEve.crateID);
154 printf(
"BETTER capID=%d\n",bestCapID);
155 bprsEve.bestCapID=bestCapID;
156 bprsEve.bestChi2dof=minChi2dof;
159 hCapGood->Fill(bprsEve.capID,bprsEve.crateID);
165 void BprsCapPolygraph::doPedResidua(
JanBprsEveA & bprsEve){
166 printf(
"doPedRes: eveID=%d: %d good\n", bprsEve.eveID,bprsEve.good.GetN());
168 int capID=bprsEve.capID;
173 case 1:
if(bprsEve.bestCapID>=0)
return;
175 case 2:
if(bprsEve.bestCapID<0)
return;
176 capID=bprsEve.bestCapID;
178 case 3:
if(bprsEve.bestCapID>=0) capID=bprsEve.bestCapID;
184 for(
int i=0;i< bprsEve.raw.GetN();i++) {
186 bprsEve.raw.GetPoint(i,rawAdc,yid);
189 int stat =mJanDbMaker->statTile(ibp,
id);
191 float ped =mJanDbMaker->pedTile(ibp,
id,capID);
192 double del=rawAdc-ped;
194 if(bprsEve.bestCapID<0) hAdcGood->Fill(del);
195 else hAdcCorr->Fill(del);
199 printf(
"nX=%d\n",nX);