StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFcsEpdQaMaker.cxx
1 /*
2  *
3  * \class StFcsEpdQaMaker
4  *
5  */
6 
7 #include "StFcsEpdQaMaker.h"
8 
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/StEpdCollection.h"
14 #include "StRoot/StEvent/StFcsHit.h"
15 #include "StRoot/StEvent/StEpdHit.h"
16 #include "StRoot/StFcsDbMaker/StFcsDb.h"
17 #include "StRoot/StSpinPool/StFcsRawDaqReader/StFcsRawDaqReader.h"
18 
19 #include "TH1F.h"
20 #include "TH2F.h"
21 #include "TString.h"
22 #include "TFile.h"
23 #include "TCanvas.h"
24 
25 #include <string.h>
26 #include <time.h>
27 
28 StFcsEpdQaMaker::StFcsEpdQaMaker(const Char_t* name) : StMaker(name) {
29  sprintf(mFilename,"0.epdqa.root");
30 }
31 
32 StFcsEpdQaMaker::~StFcsEpdQaMaker(){};
33 
34 Int_t StFcsEpdQaMaker::Init(){
35  mFcsDb = static_cast<StFcsDb*>(GetDataSet("fcsDb"));
36  if(!mFcsDb){
37  LOG_FATAL << "Error finding StFcsDb"<< endm;
38  return kStFatal;
39  }
40 
41  if(mFilename[0]=='0' && mRun>0){
42  int yday=mRun/1000;
43  sprintf(mFilename,"%d/%d.epdqa.root",yday,mRun);
44  printf("StFcsEpdQaMaker::Init - Opening %s\n",mFilename);
45  }
46  mFile=new TFile(mFilename,"RECREATE");
47 
48  char t[100], n[100];
49  char *cNS[2]={"N","S"};
50  for(int det=kFcsPresNorthDetId; det<=kFcsPresSouthDetId; det++){
51  for(int id=0; id<kFcsPresMaxId; id++){
52  char name[100];
53  int ns= mFcsDb->northSouth(det);
54  mFcsDb->getName(det,id,name);
55  sprintf(t,"EPDADC_%1s%03d",cNS[ns],id);
56  sprintf(n,"%s; QTADC; DEP Fit Integral",name);
57  mQtDepA[ns][id] = new TH2F(t,n,64,0,1024,64,0,1024*4);
58  sprintf(t,"EPDTAC_%1s%03d",cNS[ns],id);
59  sprintf(n,"%s; QTTAC; DEP Fit Peak Timebin",name);
60  mQtDepT[ns][id] = new TH2F(t,n,50,0,3000,50,45,56);
61  sprintf(t,"EPDRatio_%1s%03d",cNS[ns],id);
62  sprintf(n,"%s; DEP Peak Timebin; QTADC/DEPIntg",name);
63  mQtDepR[ns][id] = new TH2F(t,n,50,44,57,50,0.0,0.8);
64  }
65  }
66  mQtDepA[0][kFcsPresMaxId] = new TH2F("EPDADCc","EPDADC QTc; QTc ADC; DEP Fit Integral",64,0,1024,64,0,1024*4);
67  mQtDepT[0][kFcsPresMaxId] = new TH2F("EPDTACc","EPDTAC QTc; QTc TAC; DEP Fit Peak Timebin",50,0,3000,50,45,56);
68  mQtDepR[0][kFcsPresMaxId] = new TH2F("EPDRatioc","EPDRatio QTc; DEP Peak Timebin; QTcADC/DEPIntg",50,44,57,50,0.0,0.8);
69  mQtDepA[1][kFcsPresMaxId] = new TH2F("EPDADCbmqtad","EPDADC QTb; QTb ADC; DEP Fit Integral",64,0,1024,64,0,1024*4);
70  mQtDepT[1][kFcsPresMaxId] = new TH2F("EPDTACb","EPDTAC QTb; QTb TAC; DEP Fit Peak Timebin",50,0,3000,50,45,56);
71  mQtDepR[1][kFcsPresMaxId] = new TH2F("EPDRatiob","EPDRatio QTb; DEP Peak Timebin; QTbADC/DEPIntg",50,44,57,50,0.0,0.8);
72  return kStOK;
73 };
74 
76  mFcsCollection=0;
77  StTriggerData* trg=0;
78 
79  //Getting StFcsRawDaqReader and TriggerData
80  StFcsRawDaqReader* fcsraw=(StFcsRawDaqReader*)GetMaker("daqReader");
81  StEvent* event= (StEvent*)GetInputDS("StEvent");
82  if(fcsraw){
83  //Getting trigger data (if daq file)
84  trg = fcsraw->trgdata();
85  if(!trg){
86  LOG_INFO << "Canot find Trigger Data from StFcsRawDaqReader" << endm;
87  }
88  }else if(event){
89  trg=event->triggerData();
90  if(!trg){
91  LOG_INFO << "Canot find Trigger Data from StEvent" << endm;
92  }
93  }
94 
95  //tof multiplicity from trigger data
96  int tofmult = 0;
97  //check if FCS was readout for this event
98  if(trg){
99  tofmult = trg->tofMultiplicity();
100  //unsigned short detmask=trg->getTrgDetMask();
101  //printf("TrgDetMask = %4x\n",detmask);
102  //if(! ((detmask >> 30) & 0x1)){ //FCS_ID=30 but detmask is 16bit:O
103  //printf("No FCS readout for this event detmask=%x\n",detmask);
104  //return kStOK;
105  //}
106  //unsigned short lastdsm4 = trg->lastDSM(4);
107  //unsigned short fcs2019 = (lastdsm4 >> 10) & 0x1;
108  //printf("fcs2019=%1d\n",fcs2019);
109  unsigned short lastdsm2 = trg->lastDSM(2);
110  unsigned short lastdsm5 = trg->lastDSM(5);
111  printf("lastdsm2=%04x lastdsm5=%04x tofmult=%d\n",lastdsm2,lastdsm5,tofmult);
112  }
113 
114  if(!event) {
115  LOG_INFO << "No StEvent found" << endm;
116  }else{
117  mFcsCollection=event->fcsCollection();
118  mEpdCollection=event->epdCollection();
119  }
120  if(!mFcsCollection){
121  LOG_INFO << "No StFcsCollection found" << endm;
122  return kStErr;
123  }
124  if(!mEpdCollection){
125  LOG_INFO << "No StEpdCollection found" << endm;
126  return kStErr;
127  }
128 
129  for(int det=kFcsPresNorthDetId; det<kFcsNDet; det++){
130  int nhit=mFcsCollection->numberOfHits(det);
131  printf("StFcsEpdQaMaker found %d hits for det=%d\n",nhit,det);
132  if(nhit<=0) continue;
133  StSPtrVecFcsHit& hits = mFcsCollection->hits(det);
134  for (int i=0; i<nhit; i++){
135  int id = hits[i]->id();
136  //int ehp = hits[i]->ehp();
137  int ns = hits[i]->ns();
138  int dep = hits[i]->dep();
139  int ch = hits[i]->channel();
140  //int ntb = hits[i]->nTimeBin();
141  int pp,tt;
142  mFcsDb->getEPDfromId(det,id,pp,tt);
143  int QTcQRb = tt<=9?0:1;
144 
145  //from fits
146  float fititeg=0;
147  float fitpeak=0;
148  fititeg = hits[i]->adcSum();
149  fitpeak = hits[i]->fitPeak();
150  // printf("Dep=%02d Ch=%02d PP=%02d TT=%02d DEP=%6d PEAK=%f",
151  // dep,ch,pp,tt,fititeg,fitpeak);
152 
153  //get EPD data from epd collection
154  int nepd = mEpdCollection->epdHits().size();
155  int adc=0, tac=0;
156  for(int j=0; j<nepd; j++){
157  StEpdHit* epd = mEpdCollection->epdHits()[j];
158  int ew = epd->side();
159  int epp = epd->position();
160  int ett = epd->tile();
161  if(ew==1 && epp==pp && ett==tt){
162  adc = epd->adc();
163  tac = epd->tac();
164  break;
165  }
166  }
167  if(Debug()) printf(" Dep=%02d Ch=%02d PP=%02d TT=%02d QT=%4d DEP=%6.1f TAC=%4d PEAK=%4.2f\n",
168  dep,ch,pp,tt,adc,fititeg,tac,fitpeak);
169 
170  mQtDepA[ns][id]->Fill(adc,fititeg);
171  mQtDepA[QTcQRb][kFcsPresMaxId]->Fill(adc,fititeg);
172  if(fititeg>100) {
173  mQtDepT[ns][id]->Fill(tac,fitpeak);
174  mQtDepT[QTcQRb][kFcsPresMaxId]->Fill(tac,fitpeak);
175  mQtDepR[ns][id]->Fill(fitpeak,float(adc)/fititeg);
176  mQtDepR[QTcQRb][kFcsPresMaxId]->Fill(fitpeak,float(adc)/fititeg);
177  }
178  }
179  }
180 
181  return kStOK;
182 };
183 
185  mFile->Write();
186  mFile->Close();
187  printf("StFcsEpdQaMaker::Finish - Closing %s\n",mFilename);
188  return kStOK;
189 };
190 
191 ClassImp(StFcsEpdQaMaker)
192 
193 /*
194  * $Id: StFcsEpdQaMaker.cxx,v 1.1 2021/05/30 21:33:05 akio Exp $
195  * $Log: StFcsEpdQaMaker.cxx,v $
196  * Revision 1.1 2021/05/30 21:33:05 akio
197  * QA for EPD West from DEP and QT comparison
198  *
199  */
virtual Int_t Make()
int northSouth(int det) const
Ecal=0, Hcal=1, Pres=2.
Definition: StFcsDb.cxx:430
void getName(int det, int id, char name[])
get the DEP/ch id
Definition: StFcsDb.cxx:505
short side() const
+1 if tile is on West side; -1 if on East side
Definition: StEpdHit.h:145
int position() const
position of supersector on a wheel [1,12]
Definition: StEpdHit.h:147
int adc() const
ADC value [0,4095].
Definition: StEpdHit.h:149
void getEPDfromId(int det, int id, int &pp, int &tt)
Get FCS&#39;s EPD map foom EPD mapping.
Definition: StFcsDb.cxx:1484
Stores information for tiles in STAR Event Plane Detector.
Definition: StEpdHit.h:43
virtual Int_t Finish()
Definition: Stypes.h:40
int tile() const
tile on the supersector [1,31]
Definition: StEpdHit.h:148
Definition: Stypes.h:44
int tac() const
TAC value [0,4095].
Definition: StEpdHit.h:150