8 #include "StFcsTrgQaMaker.h"
10 #include "StMessMgr.h"
12 #include "StEvent/StEventTypes.h"
13 #include "StEvent/StTriggerData.h"
14 #include "StEvent/StFcsCollection.h"
15 #include "StEvent/StFcsHit.h"
16 #include "StEvent/StFcsCluster.h"
17 #include "StFcsDbMaker/StFcsDb.h"
18 #include "StSpinPool/StFcsTriggerSimMaker/StFcsTriggerSimMaker.h"
20 #include "RTS/src/TRG_FCS/fcs_trg_base.h"
30 StFcsTrgQaMaker::StFcsTrgQaMaker(
const Char_t* name) :
StMaker(name) {};
32 StFcsTrgQaMaker::~StFcsTrgQaMaker(){};
34 Int_t StFcsTrgQaMaker::Init(){
35 mFcsDb =
static_cast< StFcsDb*
>(GetDataSet(
"fcsDb"));
37 LOG_FATAL <<
"Error finding StFcsDb"<< endm;
42 LOG_FATAL <<
"Error finding StFcsTrgSimMaker"<< endm;
47 LOG_FATAL <<
"Error finding fcs_trg_base from StFcsTrgSimMaker"<< endm;
53 sprintf(mFilename,
"%d/%d.trgQa.root",yday,mRun);
54 }
else if(mFilename==0){
55 char* fname =
"fcs.trgqa.root";
58 printf(
"StFcsTrgQaMaker::Init - Opening %s\n",mFilename);
59 mFile=
new TFile(mFilename,
"RECREATE");
61 const char* NS[2]={
"N",
"S"};
62 const char* JP[5]={
"A",
"B",
"C",
"D",
"E"};
64 mTow[0] =
new TH2F(
"ETow",
"Ecal; +-col; -row",22*2+1,-22.5,22.5,34,-34.5,-0.5);
65 mTow[1] =
new TH2F(
"HTow",
"Hcal; +-col; -row",13*2+1,-13.5,13.5,20,-20.5,-0.5);
67 mETot[0] =
new TH1F(
"ETotN",
"ETotN", 256,0,512);
68 mETot[1] =
new TH1F(
"ETotS",
"ETotS", 256,0,512);
69 mHTot[0] =
new TH1F(
"HTotN",
"HTotN", 256,0,256);
70 mHTot[1] =
new TH1F(
"HTotS",
"HTotS", 256,0,256);
72 mEHT[0] =
new TH1F(
"EHTN" ,
"MAX EHT", 256,0,256);
73 mEHT[1] =
new TH1F(
"EHTS" ,
"MAX EHT", 256,0,256);
74 mEHTMap =
new TH2F(
"EHTMap",
"MAX E2x2Map",21,-10.5,10.5,16,-16.5,-0.5);
75 mHHT[0] =
new TH1F(
"HHTN" ,
"MAX HHT", 256,0,256);
76 mHHT[1] =
new TH1F(
"HHTS" ,
"MAX HHT", 256,0,256);
77 mHHTMap =
new TH2F(
"HHTMap",
"MAX H2x2Map",13,-6.5,6.5,10,-10.5,-0.5);
79 for(
int ns=0; ns<2; ns++){
80 for(
int j=0; j<5; j++){
81 mJP[ns][j] =
new TH1F(Form(
"JP%1s_%1s",JP[j],NS[ns]),
82 Form(
"JP%1s_%1s",JP[j],NS[ns]),256,0,512);
85 mJPMap[0] =
new TH1F(
"JP2",Form(
"JP2 THR A=%d,BC=%d,DE=%d",trg->JPATHR2,trg->JPBCTHR2,trg->JPDETHR2),11,-5.5,5.5);
86 mJPMap[1] =
new TH1F(
"JP1",Form(
"JP1 THR A=%d,BC=%d,DE=%d",trg->JPATHR1,trg->JPBCTHR1,trg->JPDETHR1),11,-5.5,5.5);
87 mJPMap[2] =
new TH1F(
"JP0",Form(
"JP0 THR A=%d,BC=%d,DE=%d",trg->JPATHR0,trg->JPBCTHR0,trg->JPDETHR0),11,-5.5,5.5);
89 mE4x4 =
new TH1F(
"E4x4",
"MAX E4x4", 256,0,256);
90 mEM4x4 =
new TH1F(
"EM4x4",
"MAX EM4x4", 256,0,256);
91 mELE4x4 =
new TH1F(
"ELE4x4",
"MAX ELE4x4", 256,0,256);
92 mERatio =
new TH1F(
"EMRatio",
"MAX EM Ratio=E/(E+Hmax)", 64,0,1.05);
93 mELERatio =
new TH1F(
"ELERatio",
"MAX ELE Ratio=E/(E+Hmax)", 64,0,1.05);
95 mH4x4 =
new TH1F(
"H4x4",
"MAX H4x4", 256,0,256);
96 mEH4x4 =
new TH1F(
"EH4x4",
"MAX E+H4x4", 256,0,256);
97 mHAD4x4 =
new TH1F(
"HAD4x4",
"MAX Had4x4", 256,0,256);
98 mHRatio =
new TH1F(
"HRatio",
"MAX E+H Ratio=E/(E+H)", 64,0,1.05);
99 mHADRatio =
new TH1F(
"HADRatio",
"MAX Had Ratio=E/(E+H)", 64,0,1.05);
101 mE4x4Map[0] =
new TH2F(
"EM4x4MapEM2", Form(
"EM EM2=%d",trg->EMTHR2), 19,-9.5,9.5,15,-15.5,-0.5);
102 mE4x4Map[1] =
new TH2F(
"EM4x4MapEM1", Form(
"EM EM1=%d",trg->EMTHR1), 19,-9.5,9.5,15,-15.5,-0.5);
103 mE4x4Map[2] =
new TH2F(
"EM4x4MapEM0", Form(
"EM EM0=%d",trg->EMTHR0), 19,-9.5,9.5,15,-15.5,-0.5);
104 mE4x4Map[3] =
new TH2F(
"EM4x4MapELE2", Form(
"EM ELE2=%d",trg->ELETHR2),19,-9.5,9.5,15,-15.5,-0.5);
106 mELE4x4Map[0] =
new TH2F(
"ELE4x4MapELE2",Form(
"ELE ELE2=%d",trg->ELETHR2), 19,-9.5,9.5,15,-15.5,-0.5);
107 mELE4x4Map[1] =
new TH2F(
"ELE4x4MapELE1",Form(
"ELE ELE1=%d",trg->ELETHR1), 19,-9.5,9.5,15,-15.5,-0.5);
109 mEH4x4Map[0] =
new TH2F(
"EHMapHAD2", Form(
"E+H HAD2=%d",trg->HADTHR2), 19,-9.5,9.5,15,-15.5,-0.5);
110 mEH4x4Map[1] =
new TH2F(
"EHMapHAD1", Form(
"E+H HAD1=%d",trg->HADTHR1), 19,-9.5,9.5,15,-15.5,-0.5);
111 mEH4x4Map[2] =
new TH2F(
"EHMapHAD0", Form(
"E+H HAD0=%d",trg->HADTHR0), 19,-9.5,9.5,15,-15.5,-0.5);
113 mDsmOut =
new TH1F(
"DsmOut",
"DsmOut",33,0,33);
114 mDepOut =
new TH1F(
"DepOut",
"DepOut",33,0,33);
115 mTcuBit =
new TH1F(
"TcuBit",
"TcuBit",33,0,33);
116 mTcuDep =
new TH1F(
"TcuDep",
"TcuDepMismatch",33,0,33);
117 mSimDep =
new TH1F(
"SimDep",
"SimDepMismatch",33,0,33);
119 const float maxadc=500;
120 mAdc[0]=
new TH2F(
"EN_Id_Adc",
"EcalNorth; Id; ADC",mFcsDb->
maxId(0),0.0,mFcsDb->
maxId(0),500,0.0,maxadc);
121 mAdc[1]=
new TH2F(
"ES_Id_Adc",
"EcalSouth; Id; ADC",mFcsDb->
maxId(1),0.0,mFcsDb->
maxId(1),500,0.0,maxadc);
122 mAdc[2]=
new TH2F(
"HN_Id_Adc",
"HcalNorth; Id; ADC",mFcsDb->
maxId(2),0.0,mFcsDb->
maxId(2),500,0.0,maxadc);
123 mAdc[3]=
new TH2F(
"HS_Id_Adc",
"HcalSouth; Id; ADC",mFcsDb->
maxId(3),0.0,mFcsDb->
maxId(3),500,0.0,maxadc);
124 mAdc[4]=
new TH2F(
"PN_Id_Adc",
"PresNorth; Id; ADC",mFcsDb->
maxId(4),0.0,mFcsDb->
maxId(4),500,0.0,maxadc);
125 mAdc[5]=
new TH2F(
"PS_Id_Adc",
"PresSouth; Id; ADC",mFcsDb->
maxId(5),0.0,mFcsDb->
maxId(5),500,0.0,maxadc);
133 LOG_FATAL <<
"Error finding fcs_trg_base from StFcsTrgSimMaker"<< endm;
139 event =
static_cast<StEvent*
>(GetInputDS(
"StEvent"));
143 LOG_INFO <<
"No StEvent found" << endm;
145 fcs=
event->fcsCollection();
148 LOG_INFO <<
"No StFcsCollection found" << endm;
151 if(fcs->isDataExist()==0) {
152 LOG_INFO <<
"No FCS data in this event" << endm;
164 LOG_ERROR <<
"could not get StTriggerData from DataSet."<<endm;
168 LOG_ERROR <<
"could not get StTriggerData DataSet."<<endm;
172 unsigned int tcubit = trgd->lastDSM(2) + (trgd->lastDSM(5)<<16);
175 for(
int i=0; i<32; i++) if((tcubit >> i) & 0x1) mTcuBit->Fill(i);
178 unsigned int dsmout=trg->dsmout;
179 for(
int i=0; i<32; i++) if((dsmout >> i) & 0x1) mDsmOut->Fill(i);
185 int nhit=fcs->numberOfHits(det);
186 StSPtrVecFcsHit& hits = fcs->hits(det);
188 for (
int i=0; i<nhit; i++){
189 int ehp = hits[i]->ehp();
190 int ns = hits[i]->ns();
191 int dep = hits[i]->dep();
192 int ch = hits[i]->channel();
194 if(dep==0 && (ch==4 || ch==5) ){
195 int ntb = hits[i]->nTimeBin();
196 for(
int j=0; j<ntb; j++){
197 int adc = hits[i]->adc(j);
198 unsigned short tb = hits[i]->timebin(j);
200 if(tb!=mS3off)
continue;
201 if(ch==4) depout += adc;
202 if(ch==5) depout += (adc << 8);
205 if(dep==1 && ch==36){
206 int ntb = hits[i]->nTimeBin();
207 for(
int j=0; j<ntb; j++){
208 int adc = hits[i]->adc(j);
209 unsigned short tb = hits[i]->timebin(j);
211 if(tb!=mS2off)
continue;
212 if(ns==0) depout += (adc&0xff) << 16;
213 if(ns==1) depout += (adc&0xff) << 24;
217 for(
int i=0; i<32; i++) if((depout >> i) & 0x1) mDepOut->Fill(i);
219 const char* BIT[32]={
"HAD0",
"HAD1",
"HAD2",
221 "JP2",
"JPA1",
"JPBC1",
"JPDE1",
"JPA0",
"JPBC0",
"JPDE0",
222 "DiJP",
"DiJPAsy",
"DiELEA",
223 "ELE0-N",
"ELE1-N",
"ELE2-N",
"EM3-N",
"EHT-N",
"HHT-N",
"ETOT-N",
"HTOT-N",
224 "ELE0-S",
"ELE1-S",
"ELE2-S",
"EM3-S",
"EHT-S",
"HHT-S",
"ETOT-S",
"HTOT-S"};
226 LOG_INFO << Form(
"FCSBits SIM = %08x ",dsmout);
227 for(
int i=0; i<32; i++){
if((dsmout>>i)&1) {LOG_INFO << BIT[i] <<
" ";} } LOG_INFO<<endm;
228 LOG_INFO << Form(
"FCSBits DEP = %08x ",depout);
229 for(
int i=0; i<32; i++){
if((depout>>i)&1) {LOG_INFO << BIT[i] <<
" ";} } LOG_INFO<<endm;
230 LOG_INFO << Form(
"FCSBits TCU = %08x ",tcubit);
231 for(
int i=0; i<32; i++){
if((tcubit>>i)&1) {LOG_INFO << BIT[i] <<
" ";} } LOG_INFO<<endm;
235 LOG_INFO << Form(
"FCSBitsMM DEP-TCU Mismatch ");
236 for(
int i=0; i<32; i++) if(((depout>> i)&1) != ((tcubit>>i)&1)) {mTcuDep->Fill(i); LOG_INFO << BIT[i] <<
" ";}
238 LOG_INFO << Form(
"FCSBitsMM SIM-DEP Mismatch ");
239 for(
int i=0; i<32; i++) if(((dsmout >>i)&1) != ((depout>>i)&1)) {mSimDep->Fill(i); LOG_INFO << BIT[i] <<
" ";}
243 for(
int det=0; det<4; det++){
244 int nhit=fcs->numberOfHits(det);
245 StSPtrVecFcsHit& hits = fcs->hits(det);
246 for (
int i=0; i<nhit; i++){
247 int id = hits[i]->id();
248 int ehp = hits[i]->ehp();
249 int ns = hits[i]->ns();
252 float cc = c * (ns*2-1);
254 mTow[ehp]->Fill(cc,rr,hits[i]->energy());
260 int maxns2,maxc2,maxr2;
261 int maxns3,maxc3,maxr3;
262 int maxns4,maxc4,maxr4;
263 int maxns5,maxc5,maxr5;
265 for(
int ns=0; ns<kFcsNorthSouth; ns++){
267 for(
int c=0; c<kFcsEcal4x4NCol+1; c++){
268 for(
int r=0; r<kFcsEcal4x4NRow+1; r++){
269 if(trg->e2x2[ns][r][c]>max){
270 max=trg->e2x2[ns][r][c]; maxr=r; maxc=c;
276 mEHTMap->Fill((maxc+1)*(ns*2-1),-maxr-1);
281 for(
int ns=0; ns<kFcsNorthSouth; ns++){
283 for(
int c=0; c<kFcsHcal4x4NCol+1; c++){
284 for(
int r=0; r<kFcsHcal4x4NRow+1; r++){
285 if(trg->h2x2[ns][r][c]>max){
286 max=trg->h2x2[ns][r][c]; maxr=r; maxc=c;
292 mHHTMap->Fill((maxc+1)*(ns*2-1),-maxr-1);
297 mETot[0]->Fill(trg->etot[0]);
298 mETot[1]->Fill(trg->etot[1]);
301 mHTot[0]->Fill(trg->htot[0]);
302 mHTot[1]->Fill(trg->htot[1]);
305 for(
int ns=0; ns<kFcsNorthSouth; ns++){
306 for(
int j=0; j<5; j++){
307 if(trg->jet[ns][j]>max){
308 mJP[ns][j]->Fill(trg->jet[ns][j]);
309 if((trg->d_out.s2[ns].s2_to_s3[0].d[1]>>j)&0x1) mJPMap[0]->Fill((j+1)*(ns*2-1));
310 if((trg->d_out.s2[ns].s2_to_s3[1].d[1]>>j)&0x1) mJPMap[1]->Fill((j+1)*(ns*2-1));
311 if((trg->d_out.s2[ns].s2_to_s3[0].d[2]>>j)&0x1) mJPMap[2]->Fill((j+1)*(ns*2-1));
317 for(
int ns=0; ns<kFcsNorthSouth; ns++){
319 int emmax=0, elemax=0, summax=0, hadmax=0;
320 for(
int c=0; c<kFcsEcal4x4NCol; c++){
321 for(
int r=0; r<kFcsEcal4x4NRow; r++){
322 int esum=trg->esum[ns][r][c];
323 int sum=trg->sum[ns][r][c];
325 max=esum; maxns=ns; maxr=r; maxc=c;
327 if(esum>emmax && trg->ratiomax[ns][r][c] > 1.0/(1.0+(
float)trg->EM_HERATIO_THR/128)){
328 emmax=esum; maxns2=ns; maxr2=r; maxc2=c;
330 if(esum>elemax && trg->ratiomax[ns][r][c] > 1.0/(1.0+(
float)trg->EM_HERATIO_THR/128) && trg->epdcoin[ns][r][c]){
331 elemax=esum; maxns3=ns; maxr3=r; maxc3=c;
334 summax=sum; maxns4=ns; maxr4=r; maxc4=c;
336 if(sum>hadmax && trg->ratio[ns][r][c] < 1.0/(1.0+(
float)trg->HAD_HERATIO_THR/128)){
337 hadmax=sum; maxns5=ns; maxr5=r; maxc5=c;
339 int cc=(c+1)*(ns*2-1);
341 if(esum > trg->EMTHR2) mE4x4Map[0]->Fill(cc,rr);
342 if(esum > trg->EMTHR1) mE4x4Map[1]->Fill(cc,rr);
343 if(esum > trg->EMTHR0) mE4x4Map[2]->Fill(cc,rr);
344 if(esum > trg->ELETHR2) mE4x4Map[3]->Fill(cc,rr);
345 if(trg->epdcoin[ns][r][c]){
346 if(esum > trg->ELETHR2) mELE4x4Map[0]->Fill(cc,rr);
347 if(esum > trg->ELETHR1) mELE4x4Map[1]->Fill(cc,rr);
349 if(sum > trg->HADTHR2) mEH4x4Map[0]->Fill(cc,rr);
350 if(sum > trg->HADTHR1) mEH4x4Map[1]->Fill(cc,rr);
351 if(sum > trg->HADTHR0) mEH4x4Map[2]->Fill(cc,rr);
354 if(max>0) mE4x4->Fill(max);
355 if(emmax>0) mEM4x4->Fill(emmax);
356 if(elemax>0) mELE4x4->Fill(elemax);
357 if(summax>0) mEH4x4->Fill(summax);
358 if(hadmax>0) mHAD4x4->Fill(summax);
359 if(max>0) mERatio->Fill(trg->ratiomax[maxns][maxr][maxc]);
360 if(elemax>0) mELERatio->Fill(trg->ratiomax[maxns3][maxr3][maxc3]);
361 if(summax>0) mHRatio->Fill(trg->ratio[maxns4][maxr4][maxc4]);
362 if(hadmax>0) mHADRatio->Fill(trg->ratio[maxns5][maxr5][maxc5]);
365 for(
int det=0; det<kFcsNDet; det++){
366 StSPtrVecFcsHit& hits = fcs->hits(det);
367 int nh=fcs->numberOfHits(det);
368 for(
int i=0; i<nh; i++) mAdc[det]->Fill(hits[i]->
id(),(
float)hits[i]->adcSum());
377 printf(
"StFcsTrgQaMaker::Finish - Closing %s\n",mFilename);
int getColumnNumber(int det, int id) const
get the row number for the channel
int getRowNumber(int det, int id) const
maximum number of id
int maxId(int det) const
number of column
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)