3 #include "StEmcSimpleSimulator.h"
9 #include "StEvent/StEmcRawHit.h"
10 #include "StMcEvent/StMcCalorimeterHit.hh"
11 #include "StEmcUtil/geometry/StEmcGeom.h"
12 #include "StEmcUtil/database/StBemcTables.h"
22 case kBarrelEmcTowerId:
30 case kBarrelEmcPreShowerId:
37 case kBarrelSmdEtaStripId:
44 case kBarrelSmdPhiStripId:
52 LOG_ERROR << det <<
" is not an OK value for detector (see StEnumerations.h). BEMC simulations will be JUNK!" << endm;
55 mGeom = StEmcGeom::instance(det - 8);
57 mEmbeddingMode =
false;
69 if(mcHit->module() <= 0 || mcHit->eta() <= 0 || mcHit->sub() <= 0) {
70 LOG_ERROR <<
"These quantities must all be positive: module=" << mcHit->module()
71 <<
" eta=" << mcHit->eta() <<
" sub=" << mcHit->sub() << endm;
77 float pseudoRapidity; mGeom->getEta(mcHit->module(), mcHit->eta(), pseudoRapidity);
78 int softId; mGeom->getId(mcHit->module(), mcHit->eta(), mcHit->sub(), softId);
82 rawHit->setEnergy(mcHit->dE() * samplingFraction(pseudoRapidity));
84 LOG_DEBUG << Form(
"det=%2d softId=%5d dE=%e sF=%.1f ADC=%4d ped=%6.2f rms=%4.2f energy=%.4f",
85 mDetectorId, softId, mcHit->dE(), samplingFraction(pseudoRapidity), rawHit->adc(),
86 0.0, 0.0, rawHit->energy()) << endm;
92 float calib = mTables->calib(mDetectorId-8, softId);
94 double ADC = mcHit->dE() * samplingFraction(pseudoRapidity) / calib;
97 float pedMean(0.0), pedRMS(0.0);
99 pedMean = mTables->pedestal(mDetectorId-8, softId);
100 pedRMS = mTables->pedestalRMS(mDetectorId-8, softId);
101 ADC += mRandom.Gaus(pedMean, pedRMS);
105 ADC = pedMean + (ADC-pedMean) * mRandom.Gaus(mCalibScale, mCalibSpread);
109 double maxADC = mRandom.Gaus(mMaxADC, mMaxADCSpread);
110 if(ADC < 0) ADC = 0.0;
111 if(ADC > maxADC) ADC = maxADC;
113 rawHit->setAdc(static_cast<unsigned int>(ADC));
115 float energy = (rawHit->adc() - pedMean) * calib;
116 rawHit->setEnergy(energy);
118 LOG_DEBUG << Form(
"det=%2d softId=%5d dE=%e sF=%.1f ADC=%4d ped=%6.2f rms=%4.2f energy=%.4f",
119 mDetectorId, softId, mcHit->dE(), samplingFraction(pseudoRapidity), rawHit->adc(),
120 pedMean, pedRMS, rawHit->energy()) << endm;
126 LOG_ERROR <<
"StEmcSimpleSimulator is not configured for " << mMode <<
" so raw hit is NULL" << endm;
133 double StEmcSimpleSimulator::samplingFraction(
double eta) {
134 Double_t x = TMath::Abs(eta);
135 return mSF[0]+mSF[1]*x+mSF[2]*x*x;
virtual StEmcRawHit * makeRawHit(const StMcCalorimeterHit *mcHit)
workhorse function