3 #include "StEEmcDAQ2Ped.h"
4 #include "StEEmcUtil/database/StEEmcDb.h"
5 #include "StEEmcUtil/database/EEmcDbItem.h"
16 cout <<
"StEEmcDAQ2Ped::StEEmcDAQ2Ped()"<<endl;
23 StEEmcDAQ2Ped::~StEEmcDAQ2Ped()
25 cout <<
"StEEmcDAQ2Ped::~StEEmcDAQ2Ped()"<<endl;
33 StEEmcDAQ2Ped::Init() {
34 mEeDb = (
StEEmcDb*)this->GetDataSet(
"StEEmcDb");
42 Int_t StEEmcDAQ2Ped::InitRun(
int runNo){
53 for(icrate=0;icrate<MaxTwCrateID;icrate++) {
55 sprintf(tt0,
"ETOW_%d",icrate+1);
56 h2D=(TH2F*)mDAQHistos->Get(tt0); assert(h2D);
57 for (ichan=0;ichan<=MaxTwCrateCh;ichan++) {
58 const EEmcDbItem *x=mEeDb->getByCrate(icrate+1,ichan);
61 char tt1[100],tt2[200];
62 sprintf(tt1,
"a%s",x->
name);
63 sprintf(tt2,
"ADC for %s, cr/chan=%3.3d/%3.3d, tube=%s; ADC",x->
name,x->crate,x->
chan,x->
tube);
66 TH1F* h=
new TH1F(tt1,tt2,5000,-20.5,4979.5);
68 TAxis* axY=h2D->GetYaxis();
69 int nbY=axY->GetNbins();
72 for(
int i=1;i<=nbY;i++)
73 h->SetBinContent(i+20,h2D->GetBinContent(x->
chan+1,i));
78 float entries=h2D->GetEntries()/160;
79 float xInt1=0;
float xInt2=0;
int xbin=-1;
80 int xHigh = -1;
int xLow = -1;
81 for(xbin=h2D->GetNbinsY();xbin>0;xbin--){
82 xInt1 += h2D->GetBinContent(ichan+1,xbin);
84 if(xInt1 > 0.00036*entries){
87 for(xbin=h2D->GetNbinsY();xbin>0;xbin--){
88 xInt2 += h2D->GetBinContent(ichan+1,xbin);
89 if(xInt2 > 0.0027*entries){
92 float ped=x->ped;
float sigPed=x->sigPed;
93 if(xLow < (ped+(5*sigPed)))
94 cout<<
"ichan= "<<ichan<<
" x->name= "<<x->
name<<
" x->tube= "<<x->
tube<<endl;
95 xLowEtow->Fill(xLow-ped);
96 xHighEtow->Fill(xHigh-ped);
97 xDiffEtow->Fill(xHigh-xLow);
98 xCorrEtow->Fill(xLow-ped,xHigh-ped);
99 TF1* f1=
new TF1(
"f1",
"exp([0]+[1]*x)",xLow,xHigh);
101 h->Fit(f1,
"Q",
"",xLow,xHigh);
102 float slope = f1->GetParameter(1);
103 float slopeErr = f1->GetParError(1);
105 etow[icrate]->SetBinContent(ichan+1,slope);
106 etow[icrate]->SetBinError(ichan+1,slopeErr);
113 ofstream outfile(mappingFile.Data());
116 for(icrate=MinMapmtCrateID;icrate<=MaxMapmtCrateID;icrate++) {
118 sprintf(tt0,
"ESMD_%d",icrate-63);
119 h2D=(TH2F*)mDAQHistos->Get(tt0); assert(h2D);
120 for (ichan=0;ichan<MaxMapmtCrateCh;ichan++) {
121 const EEmcDbItem *x=mEeDb->getByCrate(icrate,ichan);
124 char tt1[100],tt2[200];
125 sprintf(tt1,
"a%s",x->
name);
126 sprintf(tt2,
"ADC for %s, cr/chan=%3.3d/%3.3d, tube=%s; ADC",x->
name,x->crate,x->
chan,x->
tube);
127 TH1F* h=
new TH1F(tt1,tt2,5000,-20.5,4979.5);
129 TAxis* axY=h2D->GetYaxis();
130 int nbY=axY->GetNbins();
131 for(
int i=1;i<=nbY;i++)
132 h->SetBinContent(i+20,h2D->GetBinContent(x->
chan+1,i));
135 outfile<<icrate<<
","<<ichan<<
","<<x->
name<<endl;
137 if(x->fail)
continue;
138 float entries=h2D->GetEntries()/192;
139 float xInt1=0;
float xInt2=0;
int xbin=-1;
140 int xHigh = -1;
int xLow = -1;
141 for(xbin=h2D->GetNbinsY();xbin>0;xbin--){
142 xInt1 += h2D->GetBinContent(ichan+1,xbin);
144 if(xInt1 > 0.0003*entries){
145 xHigh = xbin;
break;}
147 for(xbin=h2D->GetNbinsY();xbin>0;xbin--){
148 xInt2 += h2D->GetBinContent(ichan+1,xbin);
149 if(xInt2 > 0.0015*entries){
153 float stopper=ped; stopper +=25;
155 xTestEsmd->Fill(xLow-ped-stopper);
161 xDiffEsmd->Fill(xHigh-xLow);
162 if(xHigh - xLow < 10) {
166 xLowEsmd->Fill(xLow-ped);
167 xHighEsmd->Fill(xHigh-ped);
168 xCorrEsmd->Fill(xLow-ped,xHigh-ped);
169 TF1* f1=
new TF1(
"f1",
"exp([0]+[1]*x)",xLow,xHigh);
171 h->Fit(f1,
"Q",
"",xLow,xHigh);
172 float slope = f1->GetParameter(1);
173 float slopeErr = f1->GetParError(1);
175 int sec=x->sec;
int plane=3;
int strip=x->strip;
176 if(x->plane==
'U') plane=0;
177 if(x->plane==
'V') plane=1;
179 if(plane==0 || plane==1){
180 esmdSec[sec-1][plane]->SetBinContent(strip,slope);
181 esmdSec[sec-1][plane]->SetBinError(strip,slopeErr);
184 if(plane!=0 && plane !=1){
185 esmd[icrate-63]->SetBinContent(ichan+1,slope);
186 esmd[icrate-63]->SetBinError(ichan+1,slopeErr);
188 else if(strip<221 && strip>10){
189 esmd[icrate-63]->SetBinContent(ichan+1,slope);
190 esmd[icrate-63]->SetBinError(ichan+1,slopeErr);
197 printf(
"StEEmcDAQ2Ped::InitRun() \n");
205 StEEmcDAQ2Ped::initHistos()
209 for(icrate=MinMapmtCrateID;icrate<=MaxMapmtCrateID;icrate++){
211 char name[100];
char title[100];
212 sprintf(name,
"ESMD_%d",icrate-63);
213 sprintf(title,
"ESMD FEE %d",icrate);
214 esmd[icrate-63] =
new TH1F(name,title,192,-0.5,192-0.5);
215 esmd[icrate-63]->SetMarkerStyle(20+mSet);
216 esmd[icrate-63]->SetMarkerColor(mSet+1);
217 mHList->Add(esmd[icrate-63]);
219 for(icrate=0;icrate<MaxTwCrateID;icrate++) {
221 char nameT[100];
char titleT[100];
222 sprintf(nameT,
"ETOW_%d",icrate+1);
223 sprintf(titleT,
"ETOW FEE %d",icrate+1);
224 etow[icrate] =
new TH1F(nameT,titleT,120,-0.5,119.5);
225 etow[icrate]->SetMarkerStyle(20+mSet);
226 etow[icrate]->SetMarkerColor(mSet+1);
227 mHList->Add(etow[icrate]);
229 for(
int isector=0;isector<12;isector++){
230 for(
int iuv=0;iuv<2;iuv++){
232 char name[100];
char title[100];
233 sprintf(name,
"ESMD_sector%d_%cplane",isector+1,
'U'+iuv);
234 sprintf(title,
"ESMD Sector%d %c-Plane",isector+1,
'U'+iuv);
235 esmdSec[isector][iuv] =
new TH1F(name,title,288,0.5,288.5);
236 esmdSec[isector][iuv]->SetMarkerStyle(20+mSet);
237 esmdSec[isector][iuv]->SetMarkerColor(mSet+1);
238 mHList->Add(esmdSec[isector][iuv]);
241 xLowEtow =
new TH1F(
"xLowEtow",
"Fit range minimum ETOW;xLow",60,0.0,60.0); mHList->Add(xLowEtow);
242 xHighEtow =
new TH1F(
"xHighEtow",
"Fit range maximum ETOW;xHigh",100,0.0,100.0); mHList->Add(xHighEtow);
243 xDiffEtow =
new TH1F(
"xDiffEtow",
"Fit range difference ETOW;xHigh-xLow",80,0.0,80.0); mHList->Add(xDiffEtow);
244 xLowEsmd =
new TH1F(
"xLowEsmd",
"Fit range minimum ESMD;xLow",150,0.0,150.0); mHList->Add(xLowEsmd);
245 xHighEsmd =
new TH1F(
"xHighEsmd",
"Fit range maximum ESMD;xHigh",300,0.0,300.0); mHList->Add(xHighEsmd);
246 xDiffEsmd =
new TH1F(
"xDiffEsmd",
"Fit range difference ESMD;xHigh-xLow",200,0.0,200.0); mHList->Add(xDiffEsmd);
247 xCorrEtow =
new TH2F(
"xCorrEtow",
"ETOW xHigh vs xLow;xLow;xHigh",60,0.0,60.0,100,0.0,100.0); mHList->Add(xCorrEtow);
248 xCorrEsmd =
new TH2F(
"xCorrEsmd",
"ESMD xHigh vs xLow;xLow;xHigh",50,0.0,200.0,100,0.0,400.0); mHList->Add(xCorrEsmd);
249 xTestEsmd =
new TH1F(
"xTestEsmd",
"ESMD xLow - (ped+5*sigPed)",60,-3.0,3.0); mHList->Add(xTestEsmd);
261 TH1F* hSlope =
new TH1F(
"hSlope",
"Average slope by crate;Crate;Slope",48,63.5,111.5);
262 hSlope->SetMarkerStyle(20+mSet);
263 hSlope->SetMarkerColor(mSet+1);
265 for(icrate=MinMapmtCrateID;icrate<=MaxMapmtCrateID;icrate++){
266 TF1* f=
new TF1(
"f",
"[0]");
267 f->SetLineColor(5+mSet);
268 if((icrate-63)%4 != 0)
269 esmd[icrate-63]->Fit(f,
"Q",
"",0,192);
271 esmd[icrate-63]->Fit(f,
"Q",
"",60,192);
274 float constant = f->GetParameter(0);
275 float constantErr = f->GetParError(0);
276 hSlope->SetBinContent(icrate-63,constant);
277 hSlope->SetBinError(icrate-63,constantErr);
char name[StEEmcNameLen]
ASCII name of the channel, see Readme.
char tube[StEEmcNameLen]
name of PMT or MAPMT pixel