7 #include "StFcsQaMaker.h"
9 #include "StRoot/StEvent/StEvent.h"
10 #include "StRoot/St_base/StMessMgr.h"
11 #include "StRoot/StEvent/StTriggerData.h"
12 #include "StRoot/StEvent/StFcsCollection.h"
13 #include "StRoot/StEvent/StFcsHit.h"
14 #include "StRoot/StEvent/StFcsCluster.h"
15 #include "StRoot/StFcsDbMaker/StFcsDb.h"
16 #include "StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.h"
27 StFcsQaMaker::StFcsQaMaker(
const Char_t* name) :
StMaker(name) {};
29 StFcsQaMaker::~StFcsQaMaker(){};
31 Int_t StFcsQaMaker::Init(){
32 mFcsDb =
static_cast<StFcsDb*
>(GetDataSet(
"fcsDb"));
34 LOG_FATAL <<
"Error finding StFcsDb"<< endm;
42 sprintf(mFilename,
"%d/%d.root",yday,mRun);
43 printf(
"StFcsQaMaker::Init - Opening %s\n",mFilename);
45 sprintf(mFilename,
"%s",mSetFile);
47 mFile=
new TFile(mFilename,
"RECREATE");
49 const char* nameEHP[kFcsEHP] = {
"Ecal",
"Hcal",
"Pres"};
50 const char* nameNS[kFcsNorthSouth] = {
"N",
"S"};
51 char t[100],t2[100],t3[100];
53 mDataSize =
new TH1F(
"DataSize",
"DataSize",100,-1.0,7.0);
54 mEsum[0] =
new TH1F(
"EcalESum",
"EcalESum",100,0.0,10.0);
55 mEsum[1] =
new TH1F(
"HcalESum",
"HcalESum",100,0.0,10.0);
56 mEsum[2] =
new TH1F(
"TotESum",
"TotESum", 100,0.0,10.0);
58 for(
int det=0; det<kFcsNDet; det++){
61 int maxid = mFcsDb->
maxId(det);
63 if(maxid==0)
continue;
65 sprintf(t,
"%4s_%1s_IdTbinAdc",nameEHP[ehp],nameNS[ns]);
66 sprintf(t2,
"%4s_%1s; Id; Tbin",nameEHP[ehp],nameNS[ns]);
67 mAdcTb2[det] =
new TH2F(t,t2,
68 maxid, 0.0,
float(maxid),
69 mNTimeBins, 0.0,
float(mNTimeBins));
71 for(
int id=0;
id<maxid;
id++){
73 int ehp2,ns2,crt,sub,dep,ch;
75 sprintf(t ,
"%4s_%1s_TbinAdc_id%03d",nameEHP[ehp],nameNS[ns],
id);
76 sprintf(t2,
"%s; TBin; ADC",t3);
78 mAdcTb[det][id] =
new TH2F(t,t2,
79 mNTimeBins, 0.0,
float(mNTimeBins),
80 512, 0.0,
float(mMaxAdc));
83 sprintf(t,
"%4s_%1s_Adc",nameEHP[ehp],nameNS[ns]);
84 sprintf(t2,
"%4s_%1s; DEP+ch/32; ADC",nameEHP[ehp],nameNS[ns]);
85 int maxdep = mFcsDb->
getNDep(ehp,ns);
86 int maxdepch = maxdep * kFcsMaxDepCh;
87 mAdcId[det] =
new TH2F(t,t2,
88 maxdepch, 0.0,
float(maxdep),
89 256, 0.0,
float(mMaxAdc));
90 mAdcId[det]->GetXaxis()->SetNdivisions(-maxdep);
92 sprintf(t,
"%4s_%1s_ped",nameEHP[ehp],nameNS[ns]);
93 sprintf(t2,
"%4s_%1s_Ped; DEP+ch/32; ADC",nameEHP[ehp],nameNS[ns]);
94 mAdcIdp[det] =
new TH2F(t,t2,
95 maxdepch, 0.0,
float(maxdep),
97 mAdcId[det]->GetXaxis()->SetNdivisions(-maxdep);
99 sprintf(t,
"%4s_%1s_IdSum",nameEHP[ehp],nameNS[ns]);
100 sprintf(t2,
"%4s_%1s; id; AdcSum(TB=%d-%d)",nameEHP[ehp],nameNS[ns],mMinTB,mMaxTB);
101 mAdcSumId[det] =
new TH2F(t,t2,
102 maxid, 0.0,
float(maxid),
103 200, 0.0,
float(mMaxAdcSum));
105 sprintf(t,
"%4s_%1s_IdTime",nameEHP[ehp],nameNS[ns]);
106 sprintf(t2,
"%4s_%1s; id; MeanTimeBin",nameEHP[ehp],nameNS[ns]);
107 mTimeId[det] =
new TH2F(t,t2,
108 maxid, 0.0,
float(maxid),
109 200, mMinTB, mMaxTB);
111 sprintf(t,
"%4s_%1s_FitIntg",nameEHP[ehp],nameNS[ns]);
112 sprintf(t2,
"%4s_%1s; DEP+ch/32; FitIntegral",nameEHP[ehp],nameNS[ns]);
113 mFitIntg[det] =
new TH2F(t,t2,
114 maxdepch, 0.0,
float(maxdep),
115 400, 0.0,
float(mMaxAdcSum));
117 sprintf(t,
"%4s_%1s_FitSigm",nameEHP[ehp],nameNS[ns]);
118 sprintf(t2,
"%4s_%1s; DEP+ch/32; FitSigma[TB]",nameEHP[ehp],nameNS[ns]);
119 mFitSigm[det] =
new TH2F(t,t2,
120 maxdepch, 0.0,
float(maxdep),
123 sprintf(t,
"%4s_%1s_FitTime",nameEHP[ehp],nameNS[ns]);
124 sprintf(t2,
"%4s_%1s; DEP+ch/32; FitPeakTime[TB]",nameEHP[ehp],nameNS[ns]);
125 mFitTime[det] =
new TH2F(t,t2,
126 maxdepch, 0.0,
float(maxdep),
127 200, mMinTB, mMaxTB);
129 sprintf(t,
"%4s_%1s_FitChi2",nameEHP[ehp],nameNS[ns]);
130 sprintf(t2,
"%4s_%1s; DEP+ch/32; FitChi2",nameEHP[ehp],nameNS[ns]);
131 mFitChi2[det] =
new TH2F(t,t2,
132 maxdepch, 0.0,
float(maxdep),
135 sprintf(t,
"%4s_%1s_NHit",nameEHP[ehp],nameNS[ns]);
136 sprintf(t2,
"%4s_%1s; NHit",nameEHP[ehp],nameNS[ns]);
137 mNHit[det] =
new TH1F(t,t2,maxid,0.0,
float(maxid+1));
140 sprintf(t,
"%4s_%1s_NCluster",nameEHP[ehp],nameNS[ns]);
141 mNClu[det] =
new TH1F(t,t,10,0.0,10.0);
143 sprintf(t,
"%4s_%1s_NTowClu",nameEHP[ehp],nameNS[ns]);
144 mNTowClu[det] =
new TH1F(t,t,10,0.0,10.0);
146 sprintf(t,
"%4s_%1s_NNeiClu",nameEHP[ehp],nameNS[ns]);
147 mNNeiClu[det] =
new TH1F(t,t,10,0.0,10.0);
149 for(
int id=0;
id<maxid;
id++){
151 sprintf(t ,
"%1s%1s%03d_NTowClu_E",nameEHP[ehp],nameNS[ns],
id);
152 sprintf(t2 ,
"%22s_NTowClu_E",t2);
153 mNTowEClu[det][id] =
new TH2F(t,t2,10,1.0,11.0,100,0.0,10.0);
155 sprintf(t ,
"%1s%1s%03d_NTowCluIso_E",nameEHP[ehp],nameNS[ns],
id);
156 sprintf(t2 ,
"%22s_NTowCluIso_E",t2);
157 mNTowECluIso[det][id] =
new TH2F(t,t2,10,1.0,11.0,100,0.0,10.0);
159 sprintf(t ,
"%1s%1s%03d_NTowCluIsoH_E",nameEHP[ehp],nameNS[ns],
id);
160 sprintf(t2 ,
"%22s_NTowCluIsoH_E",t2);
161 mNTowECluIsoH[det][id] =
new TH2F(t,t2,10,1.0,11.0,100,0.0,10.0);
165 mTimeEvt=
new TH2F(
"TimeEvt",
"TimeEvent; Event; Sector Avg MeanTB",100,0,100,500,mMinTB+1.5,mMaxTB-1.5);
166 memset(mTimeE,0,
sizeof(mTimeE));
168 int ecal_xmax = mFcsDb->
nColumn(0);
169 int ecal_ymax = mFcsDb->
nRow(0);
170 mHitMap[0] =
new TH2F(
"EcalView",
"Ecal View from Back; +-Col (North <-> South); -Row (Bottom <-> Top)",
171 ecal_xmax*2+1,-ecal_xmax-0.5,ecal_xmax+0.5,
172 ecal_ymax,-ecal_ymax-0.5,-0.5);
174 int hcal_xmax = mFcsDb->
nColumn(2);
175 int hcal_ymax = mFcsDb->
nRow(2);
176 mHitMap[1] =
new TH2F(
"HcalView",
"Hcal View from Back; +-Col (North <-> South); -Row (Bottom <-> Top)",
177 hcal_xmax*2+1,-hcal_xmax-0.5,hcal_xmax+0.5,
178 hcal_ymax,-hcal_ymax-0.5,-0.5);
180 int pres_xmax = mFcsDb->
nColumn(4);
181 int pres_ymax = mFcsDb->
nRow(4);
182 mHitMap[2] =
new TH2F(
"PresView",
"Pres View from Back; +-Radius (North <-> South); -Phi (Bottom <-> Top)",
183 pres_xmax*2+1,-pres_xmax-0.5,pres_xmax+0.5,
184 pres_ymax,-pres_ymax-0.5,-0.5);
198 trg = fcsraw->trgdata();
200 LOG_DEBUG <<
"Canot find Trigger Data from StFcsRawDaqReader" << endm;
203 trg=
event->triggerData();
205 LOG_DEBUG <<
"Canot find Trigger Data from StEvent" << endm;
213 tofmult = trg->tofMultiplicity();
214 unsigned short detmask=trg->getTrgDetMask();
215 printf(
"TrgDetMask = %4x\n",detmask);
216 if(! ((detmask >> 30) & 0x1)){
217 printf(
"No FCS readout for this event detmask=%x\n",detmask);
220 unsigned short lastdsm4 = trg->lastDSM(4);
221 unsigned short fcs2019 = (lastdsm4 >> 10) & 0x1;
222 printf(
"fcs2019=%1d\n",fcs2019);
226 LOG_INFO <<
"No StEvent found" << endm;
228 mFcsCollection=
event->fcsCollection();
231 LOG_INFO <<
"No StFcsCollection found" << endm;
237 int nh[kFcsNDet]; memset(nh,0,
sizeof(nh));
238 int sum[kFcsNDet][kFcsEcalMaxId]; memset(sum,0,
sizeof(sum));
239 int esum[kFcsNDet][kFcsEcalMaxId]; memset(esum,0,
sizeof(sum));
240 float atot[kFcsNDet]; memset(atot,0,
sizeof(atot));
241 float etot[kFcsNDet]; memset(etot,0,
sizeof(etot));
245 for(
int det=0; det<kFcsNDet; det++){
246 int nhit=mFcsCollection->numberOfHits(det);
248 if(nhit<=0)
continue;
249 StSPtrVecFcsHit& hits = mFcsCollection->hits(det);
250 for (
int i=0; i<nhit; i++){
252 int id = hits[i]->id();
253 int ehp = hits[i]->ehp();
254 int ns = hits[i]->ns();
255 int dep = hits[i]->dep();
256 int ch = hits[i]->channel();
257 float depch=dep+(ch+0.5)/32.0;
258 int ntb = hits[i]->nTimeBin();
260 if(mPedSub>0) ped=mFcsDb->
pedestal(ehp,ns,dep,ch);
263 mTimeId[det]->Fill((
float)
id, hits[i]->fitPeak());
264 if(det<4 && hits[i]->adcSum() > 100){
266 meantb+=hits[i]->fitPeak();
268 mTimeE[det][id][mEvent]=hits[i]->fitPeak();
271 float chi2=hits[i]->fitChi2();
273 mFitIntg[det]->Fill(depch,hits[i]->adcSum());
274 mFitSigm[det]->Fill(depch,hits[i]->fitSigma());
275 mFitTime[det]->Fill(depch,hits[i]->fitPeak());
276 mFitChi2[det]->Fill(depch,chi2);
288 for(
int j=0; j<ntb; j++){
289 unsigned short adc = hits[i]->adc(j);
290 unsigned short tb = hits[i]->timebin(j);
293 mAdcTb2[det]->Fill(
id,tb,adc);
294 mAdcTb[det][id]->Fill(tb,adc);
295 if(tb>=mMinTB && tb<=mMaxTB) {
296 sum[det][id] += (adc - ped);
299 mAdcId[det]->Fill(depch,
float(adc));
300 if(tb>=mMinTBp && tb<=mMaxTBp) mAdcIdp[det]->Fill(depch,
float(adc));
303 int ns2 = hits[i]->ns();
304 int ehp2= hits[i]->ehp();
306 if(det2>=0 && det2<kFcsNDet)
307 mAdcId[det2]->Fill(
float(depch),
float(adc));
311 if(det<kFcsNDet && ch<32){
312 float e = hits[i]->energy();
317 int maxid = mFcsDb->
maxId(det);
320 for(
int id=0;
id<maxid;
id++){
322 mAdcSumId[det]->Fill((
float)
id,
float(sum[det][
id]));
324 atot[det]+=sum[det][id];
328 float x = c * (ns*2-1);
330 mHitMap[ehp]->Fill(x,y,
float(sum[det][
id]));
333 mNHit[det]->Fill(
float(nh[det]));
334 mEsum[0]->Fill(etot[0]+etot[1]);
335 mEsum[1]->Fill(etot[2]+etot[3]);
336 mEsum[2]->Fill(etot[0]+etot[1]+etot[2]+etot[3]);
340 for (
int i=0; i<nhit; i++){
341 int id = hits[i]->id();
342 int ehp = hits[i]->ehp();
343 int ns = hits[i]->ns();
344 int dep = hits[i]->dep();
345 int ch = hits[i]->channel();
346 int ntb = hits[i]->nTimeBin();
347 float ped = mFcsDb->
pedestal(ehp,ns,dep,ch);
350 if(mDump==1 && sum[det][
id]>50){
351 printf(
"\nFCSDump %5d %22s %4d %5.1f %5d ",nevt,name,ntb,ped,sum[det][
id]);
352 for(
int j=0; j<ntb; j++) printf(
"%4d ",hits[i]->adc(j));
355 }
else if(mDump==2 && det==1 &&
id==12){
356 printf(
"\nFCSDump %5d %22s %5.1f %5d ",nevt,name,ped,sum[det][
id]);
358 for(
int j=0; j<ntb; j++){
359 unsigned int adc=hits[i]->adc(j);
360 unsigned int tb =hits[i]->timebin(j);
365 if(max-min>6) printf(
" !!! min=%d max=%d diff=%d",min,max,max-min);
373 if(nmean>0) avg=meantb/float(nmean);
375 mTimeEvt->Fill((
float)mEvent,avg);
378 for(
int det=0; det<kFcsNDet; det++){
379 if(det<=kFcsHcalSouthDetId){
380 int nclu=mFcsCollection->numberOfClusters(det);
382 if(nclu<=0)
continue;
383 StSPtrVecFcsCluster& clusters = mFcsCollection->clusters(det);
384 mNClu[det]->Fill(nclu);
385 for (
int i=0; i<nclu; i++){
387 int ntow=cluster->nTowers();
388 int nnei=cluster->nNeighbor();
389 mNTowClu[det]->Fill(ntow);
390 mNNeiClu[det]->Fill(nnei);
391 StPtrVecFcsHit& hits = cluster->hits();
392 int htid = hits[0]->id();
393 mNTowEClu[det][htid]->Fill(ntow,cluster->energy());
395 mNTowECluIso[det][htid]->Fill(ntow,cluster->energy());
397 mNTowECluIsoH[det][htid]->Fill(ntow,cluster->energy());
404 mDataSize->Fill(log10(nfcsdata));
446 printf(
"StFcsQaMaker::Finish - Closing %s\n",mFilename);
int getColumnNumber(int det, int id) const
get the row number for the channel
float pedestal(int ehp, int ns, int dep, int ch)
Get EPD's EPD map from FCS mapping.
int getRowNumber(int det, int id) const
maximum number of id
int northSouth(int det) const
Ecal=0, Hcal=1, Pres=2.
void getName(int det, int id, char name[])
get the DEP/ch id
int detectorId(int eh, int ns) const
6
int ecalHcalPres(int det) const
Ecal North=0, Ecal South=1, Hcal North=2, Hcal South=3, Pres=4/5.
int getNDep(int ehp, int ns) const
Get Det map.
int maxId(int det) const
number of column
int nRow(int det) const
north or south side
int nColumn(int det) const
number of rows
void getDepfromId(int detectorId, int id, int &ehp, int &ns, int &crt, int &slt, int &dep, int &ch) const
print ET gain