7 #include <StEventTypes.h>
10 #include "StEEmcSimulatorMaker/StEEmcFastMaker.h"
11 #include "StEEmcSimulatorMaker/StEEmcSlowMaker.h"
12 #include "StEEmcMixerMaker.h"
13 #include "StEEmcUtil/database/EEmcDbItem.h"
14 #include "StEEmcUtil/database/StEEmcDb.h"
15 #include "StEEmcUtil/database/cstructs/eemcConstDB.hh"
16 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
18 #include "StDAQMaker/StDAQReader.h"
19 #include "StEmcRawMaker/StEemcRaw.h"
21 #include "StEmcRawMaker/StEEmcPrint.h"
35 StEEmcMixerMaker::~StEEmcMixerMaker() {
48 StEEmcMixerMaker::Init(){
49 mEEDb=(
StEEmcDb*)GetDataSet(
"StEEmcDb");
52 LOG_FATAL<<
"::Init()\n\n Fatal Error - Eemc_DbMaker is not in the chain,\n panicOff="<<panicOff<<endm;
55 assert(!strcmp(mEEDb->ClassName(),
"StEEmcDb"));
56 return StMaker::Init();
67 LOG_INFO <<
"::Make() start...."<<endm;
69 if(mEvent==0) panicOff=
true;
72 LOG_WARN<<
"::Make(), raw2pixels() no emc collection, skip"<<endm;
77 LOG_FATAL<<
"::Make()\n\n Fatal Error was encounter earlier, Endcap embedding disabled panicOff="<<panicOff<<endm;
95 eemcPrint.setMode(15);
97 LOG_DEBUG<<
"::Make() -------------- print data: Ecoll-A ---- real backg eve ---------"<<endm;
98 if(Debug()) eemcPrint.print(ecolA);
108 LOG_WARN<<
"::Make() No fast EEmcSimulator found, nothing to embed"<<endm;
return kStWarn; }
109 ecolB = sim->GetLocalEmcCollection();
112 LOG_WARN<<
"::Make() No second EmcCollection to embed"<<endm;
return kStWarn; }
115 LOG_DEBUG <<
"::Make() -------------- print data: Ecoll-B ----- M-C physics probe eve -----------"<<endm;
116 if(Debug()) eemcPrint.print(ecolB);
119 LOG_DEBUG<<
GetName() <<
"::Make() -------------- print data: Ecoll-A+B ----- before mrging -----"<<endm;
120 if(Debug()) eemcPrint.printChange(ecolA,ecolB,Form(
"before merging"));
122 if(!mergeADCs(ecolA,ecolB))
return kStErr;
124 mMixerEmcCollection = ecolA;
126 LOG_DEBUG <<
"::Make() -------------- print Ecoll-A after mixing ----------------"<<endm;
127 if(Debug()) eemcPrint.print(ecolA);
129 LOG_DEBUG <<
"::Make() -------------- print data: Ecoll-A+B ----- after mrging -----"<<endm;
130 if(Debug()) eemcPrint.printChange(ecolA,ecolB,Form(
"after merging"));
143 LOG_DEBUG <<
"::Make() merging ADCs ..."<<endm;
154 for(
int det = kEndcapEmcTowerId; det<= kEndcapSmdVStripId; det++){
156 StDetectorId
id = StDetectorId(det);
160 LOG_WARN<<
"detectorA not loaded"<<endm;
162 LOG_WARN<<
"detectorB not loaded"<<endm;
164 if(!detectorA || !detectorB)
continue;
165 for(
int secID=1; secID<=kEEmcNumSectors; secID++){
169 StSPtrVecEmcRawHit& rawHitA=sectorA->hits();
170 StSPtrVecEmcRawHit& rawHitB=sectorB->hits();
173 vector<StEmcRawHit*> myHitB;
174 for(UInt_t k2=0;k2<rawHitB.size();k2++)
175 myHitB.push_back(rawHitB[k2]);
176 vector<StEmcRawHit*>::iterator hitB;
183 for(UInt_t k1=0;k1<rawHitA.size();k1++) {
186 uint Bmod=rawHitA[k1]->module();
188 if((
int)Bmod==!secID) {
189 LOG_FATAL <<
"::Make()\n\n Fatal Error "<<Bmod<<
"= Bmod==!secID ="<<secID<<
" StEvent internal consistency failed - corrupted event file, abort"<<endm;
196 uint Beta=rawHitA[k1]->eta();
197 int Bsub=rawHitA[k1]->sub();
200 rawHitA[k1]->setEnergy(-654.3210);
202 for( hitB=myHitB.begin() ; hitB< myHitB.end(); hitB++) {
203 if( (*hitB)->module()!=Bmod)
continue;
204 if( (*hitB)->eta() !=Beta)
continue;
205 if( (*hitB)->sub() !=Bsub)
continue;
207 int adc=(*hitB)->adc();
217 hitB=(vector<StEmcRawHit*>::iterator)NULL;
227 int adcSum=rawHitA[k1]->adc() +adcAdd;
229 rawHitA[k1]->setAdc(adcSum);
244 LOG_WARN<<Form(
"%s::Make() merging: %d hits in collB for sect=%d are dropped\n since those channels are not avaliable in collA, \n a create is probably masked out\n",
GetName(), myHitB.size(),secID)<<endm;
const EEmcDbItem * StBarrelIndex2Item(int StDetId, int Bmod, int Beta, int Bsub) const
virtual const char * GetName() const
special overload