5 #include "St_DataSetIter.h"
6 #include "StEventTypes.h"
8 #include "StEEmcFastMaker.h"
11 #include "StEEmcUtil/EEevent/EEeventDst.h"
12 #include "StEEmcUtil/EEevent/EEsectorDst.h"
13 #include "StEEmcUtil/EEevent/EEtwHitDst.h"
14 #include "StEEmcUtil/EEevent/EEsmdHitDst.h"
16 #include "StEEmcUtil/EEmcMC/EEmcMCData.h"
17 #include "StEEmcUtil/EEmcGeom/EEmcGeomDefs.h"
26 if(mEmcCollectionIsLocal) {
27 delete mLocalStEmcCollection;
28 mLocalStEmcCollection=0;
37 SetEmcCollectionLocal(
false);
38 mLocalStEmcCollection=0;
40 mUseFullPreShower =
false;
47 mfixTgain=
new float [kEEmcNumEtas];
48 for (Int_t i=0;i<kEEmcNumEtas;i++) {
49 mfixTgain[i]=getTowerGains()[i];
57 StEEmcFastMaker::~StEEmcFastMaker(){
61 if(mEmcCollectionIsLocal){
62 mLocalStEmcCollection->Clear();
63 delete mLocalStEmcCollection;
71 StEEmcFastMaker::Init(){
72 LOG_INFO<<
"::Init() \n"<< endm;
73 if(mEmcCollectionIsLocal) {
74 LOG_INFO<<
"::Init() use local EmcCollection\n"<< endm;
76 return StMaker::Init();
85 LOG_INFO <<
"::Make() , mEmcCollectionIsLocal="<<mEmcCollectionIsLocal<<endm;
89 if ( (nh = mevIN->readEventFromChain(
this)) >0) {
90 LOG_INFO <<
" RAW geant EEMC hits="<<nh<<endm;
93 LOG_INFO <<
" RAW geant EEMC not seen"<<endm;
100 mevIN->write(&eeveRaw);
103 eeveRaw.sumRawMC(meeve);
107 if(mEmcCollectionIsLocal) {
109 emcColl=mLocalStEmcCollection;
113 emcColl=stevent->emcCollection();
116 stevent->setEmcCollection(emcColl);
117 LOG_WARN<<
"::Make() has added a non existing StEmcCollection()"<<endm;
121 mEE2ST(meeve, emcColl);
132 int mxSector = kEEmcNumSectors;
136 LOG_DEBUG<< Form(
"EE2ST got emcCollection\n")<<endm;
138 for(
int det = kEndcapEmcTowerId; det<= kEndcapSmdVStripId; det++){
140 StDetectorId
id = StDetectorId(det);
142 emcC->setDetector(d);
144 LOG_DEBUG<< Form(
"EE2ST() copy hits from %d EEMC sectors, det=%d\n",eevt->getNSectors(),det)<<endm;
146 for(
int isec=0; isec<mxSector; isec++){
150 LOG_DEBUG<< Form(
"EE2ST() isec=%d sec_add=%p secID=%d det=%d\n",isec,(
void*)EEsec,secID,det)<<endm;
153 case kEndcapEmcTowerId: {
154 bool hasHit[kEEmcNumSubSectors][kEEmcNumEtas];
155 memset(hasHit,0,
sizeof(hasHit));
157 tca = EEsec->getTwHits();
158 for(
int j=0; j<=tca->GetLast(); j++){
161 int sub=t->sub()-
'A'+1;
164 int adc=(int) (t->energy() * mfixTgain[eta-1]);
165 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
169 hasHit[sub-1][eta-1] =
true;
171 LOG_DEBUG<< Form(
"Tw %c %d %f %d \n",t->sub(),t->eta(),t->energy(),adc)<<endm;
176 for (
int sub = 1; sub <= kEEmcNumSubSectors; ++sub)
177 for (
int eta = 1; eta <= kEEmcNumEtas; ++eta)
178 if (!hasHit[sub-1][eta-1]) d->addHit(
new StEmcRawHit(
id,secID,eta,sub,0,0));
182 case kEndcapEmcPreShowerId: {
183 bool hasHit[3*kEEmcNumSubSectors][kEEmcNumEtas];
184 memset(hasHit,0,
sizeof(hasHit));
186 tca = EEsec->getPre1Hits();
187 for(
int j=0; j<=tca->GetLast(); j++){
190 int sub=t->sub()-
'A'+1;
192 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
196 hasHit[sub-1][eta-1] =
true;
197 LOG_DEBUG<< Form(
"Pr1 %c %d adc=%d e=%f\n",t->sub(),t->eta(),adc,t->energy())<<endm;
200 tca = EEsec->getPre2Hits();
201 for(
int j=0; j<=tca->GetLast(); j++){
204 int sub=t->sub()-
'A'+5+1;
206 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
210 hasHit[sub-1][eta-1] =
true;
211 LOG_DEBUG<< Form(
"Pr2 %c %d %d %f\n",t->sub(),t->eta(),adc,t->energy())<<endm;
214 tca = EEsec->getPostHits();
215 for(
int j=0; j<=tca->GetLast(); j++){
218 int sub=t->sub()-
'A'+10+1;
220 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
224 hasHit[sub-1][eta-1] =
true;
225 LOG_DEBUG<< Form (
"Post %c %d %d %f\n",t->sub(),t->eta(),adc,t->energy())<<endm;
228 if (mUseFullPreShower) {
230 for (
int sub = 1; sub <= 15; ++sub)
231 for (
int eta = 1; eta <= kEEmcNumEtas; ++eta)
232 if (!hasHit[sub-1][eta-1]) d->addHit(
new StEmcRawHit(
id,secID,eta,sub,0,0));
236 case kEndcapSmdUStripId: {
237 bool hasHit[kEEmcNumStrips];
238 memset(hasHit,0,
sizeof(hasHit));
240 tca = EEsec->getSmdUHits();
242 for(
int j=0; j<=tca->GetLast(); j++){
247 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
251 hasHit[eta-1] =
true;
252 LOG_DEBUG<< Form(
"SMDU %d %d %f\n",t->strip(),adc,t->energy())<<endm;
257 for (
int eta = 1; eta <= kEEmcNumStrips; ++eta)
258 if (!hasHit[eta-1]) d->addHit(
new StEmcRawHit(
id,secID,eta,1,0,0));
262 case kEndcapSmdVStripId: {
263 bool hasHit[kEEmcNumStrips];
264 memset(hasHit,0,
sizeof(hasHit));
266 tca = EEsec->getSmdVHits();
267 for(
int j=0; j<=tca->GetLast(); j++){
273 if(adc<0) adc=0;
if (adc> getMaxAdc()) adc=getMaxAdc();
276 LOG_DEBUG<< Form(
"SMDV %d %d %f\n",t->strip(),adc,t->energy())<<endm;
278 hasHit[eta-1] =
true;
283 for (
int eta = 1; eta <= kEEmcNumStrips; ++eta)
284 if (!hasHit[eta-1]) d->addHit(
new StEmcRawHit(
id,secID,eta,2,0,0));
299 Float_t StEEmcFastMaker::getSamplingFraction()
307 Float_t *StEEmcFastMaker::getTowerGains()
313 const float feta[kEEmcNumEtas]= {1.95,1.855,1.765,1.675,1.59,1.51,1.435,1.365,1.3,1.235,1.17,1.115};
315 Float_t *mygains=
new Float_t[kEEmcNumEtas];
317 Float_t msamplingFraction = getSamplingFraction();
318 Int_t maxEtot=getMaxET();
319 Int_t maxAdc=getMaxAdc();
320 for (i=0;i<kEEmcNumEtas;i++) {
321 mygains[i]=maxAdc/maxEtot/cosh(feta[i])/msamplingFraction;
StEEmcFastMaker(const char *name="EEmcFastSim")
virtual void Clear(Option_t *option="")
User defined functions.
static Float_t getPreshowerGain()
(adc=g*de ) fixed gain for pre/post shower
static Float_t getSmdGain()
(adc=g*de ) fixed gain for SMD
virtual void Clear(Option_t *opts="")
Clear the maker for next event.