11 #include "StEventTypes.h"
15 #include "St2eemcFeeRawMaker.h"
17 #include "StEEmcUtil/database/StEEmcDb.h"
18 #include "StEEmcUtil/database/EEmcDbItem.h"
19 #include "EEfeeRaw/EEfeeDataBlock.h"
20 #include "EEfeeRaw/EEfeeRawEvent.h"
21 #include "EEfeeRaw/EEmcEventHeader.h"
22 #include "EEfeeRaw/EEname2Index.h"
37 St2eemcFeeRawMaker::~St2eemcFeeRawMaker(){
50 Int_t St2eemcFeeRawMaker::Init(){
51 meeDb = (
StEEmcDb*)this->GetDataSet(
"StEEmcDb");
62 moutTTree->Branch(
"head",
"EEmcEventHeader",&mrunTT,16000,99);
65 moutTTree->Branch(
"evt",
"EEfeeRawEvent",&meveTT,16000,99);
69 return StMaker::Init();
81 LOG_INFO<<Form(
"\n%s accessing StEvent ID=%d\n",
GetName(),mEvent->id())<<endm;
82 LOG_INFO<<Form(
"StEvent time=%d, ID=%d, runID=%d\n",(
int)mEvent->time(),(int)mEvent->id(),(int)mEvent->runId())<<endm;
84 mrunTT->setTimeStamp(this->GetDBTime().Convert());
85 mrunTT->setProcessingTime(time(0));
87 sprintf(text,
" M-C event file, run=%d , created by %s",mEvent->runId(),
GetName());
88 mrunTT->setComment(text);
91 LOG_INFO<<Form(
"\n%s::InitRun(%d) list DB content \n",
GetName(),runNumber)<<endm;
104 LOG_INFO<<Form(
"\n%s accesing StEvent ID=%d\n",
GetName(),mEvent->id())<<endm;
110 StEmcDetector* twE = emcCollection->detector(kEndcapEmcTowerId);
112 LOG_WARN<<
"No EEMC twE hits, skip event"<<endm;
125 UChar_t token=(int)mEvent->id()%256;
126 for(icr=0;icr<mNFeeCrate;icr++) {
128 mcrateData[icr].clear();
131 for(j=0;j<2;j++) head[j]=((0xa+j)<<8) +crateID;
133 head[3]=(UChar_t)crateID;
135 mcrateData[icr].setHead(head);
141 LOG_INFO<<Form(
"%s:: E_EMC Tower HITS ... %d\n",
GetName(),twE->numberOfModules())<<endm;
142 for ( i = 0; i < (int)twE->numberOfModules(); i++) {
145 if(stmod==0)
continue;
146 StSPtrVecEmcRawHit& emcTowerHits = stmod->hits();
147 LOG_INFO<<Form(
"bbb i=%d %d\n",i,emcTowerHits.size())<<endm;
150 for ( j = 0; j < emcTowerHits.size(); j++) {
151 int adc= emcTowerHits[j]->adc();
152 int sec= emcTowerHits[j]->module()+1;
153 int sub= emcTowerHits[j]->sub()+
'A';
154 int eta= emcTowerHits[j]->eta()+1;
155 float energy=emcTowerHits[j]->energy();
157 const EEmcDbItem *dbItem=meeDb->getT(sec,sub,eta);
160 int chan=dbItem->
chan;
161 int slot=dbItem->crate;
165 LOG_INFO<<Form(
"j=%d, sec=%d, sub=%c, eta=%d rawAdc=%d energy =%g -->crate/chan=%d/%d\n",j,sec,sub,eta,adc,energy,slot,chan)<<endm;
170 if(chan<0 || slot<0) { nDrop++;
continue;}
173 assert(icr<mNFeeCrate);
174 mcrateData[icr].setData(chan,adc);
180 meveTT->setID(mEvent->id());
182 for(icr=0;icr<mNFeeCrate;icr++) {
183 if(mcrateData[icr].getNData(0)<=0)
continue;
185 LOG_INFO<<Form(
"SS crateID=%d, Npositive=%d\n",icr+1,mcrateData[icr].getNData(0))<<endm;
187 meveTT->addFeeDataBlock(mcrateData+icr);
196 LOG_INFO<<Form(
"%s:: stored TTree with %d=%d data blocks, ID=%d \n",
GetName(),n1,meveTT->block->GetEntries(),meveTT->getID())<<endm;
virtual Int_t InitRun(int runumber)
to change time stamp in TTree
virtual const char * GetName() const
special overload