#include <SimCalorimetry/CaloSimAlgos/interface/CaloHitResponse.h>
Public Types | |
enum | { BUNCHSPACE = 25 } |
typedef std::map< DetId, CaloSamples > | AnalogSignalMap |
Public Member Functions | |
void | add (const CaloSamples &signal) |
add a signal, in units of pe | |
void | add (const PCaloHit &hit) |
process a single SimHit | |
void | addHit (const PCaloHit *hit, CaloSamples &frame) const |
adds the amplitude for a single hit to the frame | |
double | analogSignalAmplitude (const PCaloHit &hit, const CaloSimParameters ¶meters) const |
finds the amplitude contribution from this hit, applying photostatistics, if needed. | |
CaloHitResponse (const CaloVSimParameterMap *parameterMap, const CaloVShape *shape) | |
void | clear () |
frees up memory | |
CaloSamples * | findSignal (const DetId &detId) |
users can look for the signal for a given cell | |
CaloSamples | makeAnalogSignal (const PCaloHit &inputHit) const |
creates the signal corresponding to this hit | |
CaloSamples | makeBlankSignal (const DetId &detId) const |
creates an empty signal for this DetId | |
int | nSignals () const |
number of signals in the current cache | |
void | run (MixCollection< PCaloHit > &hits) |
Complete cell digitization. | |
void | setBunchRange (int minBunch, int maxBunch) |
tells it which pileup bunches to do | |
void | setGeometry (const CaloGeometry *geometry) |
geometry needed for time-of-flight | |
void | setHitCorrection (const CaloVHitCorrection *hitCorrection) |
If you want to correct hits, for attenuation or delay, set this. | |
void | setHitFilter (const CaloVHitFilter *filter) |
if you want to reject hits, for example, from a certain subdetector, set this | |
void | setPhaseShift (const double &thePhaseShift) |
setting the phase shift for asynchronous trigger (e.g. test beams) | |
void | setRandomEngine (CLHEP::HepRandomEngine &engine) |
double | timeOfFlight (const DetId &detId) const |
time-of-flight, in ns, to get to this cell returns 0 if no geometry has been set | |
~CaloHitResponse () | |
doesn't delete the pointers passed in | |
Protected Attributes | |
AnalogSignalMap | theAnalogSignalMap |
const CaloGeometry * | theGeometry |
const CaloVHitCorrection * | theHitCorrection |
const CaloVHitFilter * | theHitFilter |
int | theMaxBunch |
int | theMinBunch |
const CaloVSimParameterMap * | theParameterMap |
double | thePhaseShift_ |
CLHEP::RandPoissonQ * | theRandPoisson |
const CaloVShape * | theShape |
Definition at line 29 of file CaloHitResponse.h.
typedef std::map<DetId, CaloSamples> CaloHitResponse::AnalogSignalMap |
Definition at line 32 of file CaloHitResponse.h.
anonymous enum |
CaloHitResponse::CaloHitResponse | ( | const CaloVSimParameterMap * | parameterMap, | |
const CaloVShape * | shape | |||
) |
Definition at line 21 of file CaloHitResponse.cc.
00023 : theAnalogSignalMap(), 00024 theParameterMap(parametersMap), 00025 theShape(shape), 00026 theHitCorrection(0), 00027 theHitFilter(0), 00028 theGeometry(0), 00029 theRandPoisson(0), 00030 theMinBunch(-10), 00031 theMaxBunch(10), 00032 thePhaseShift_(1.) 00033 { 00034 }
CaloHitResponse::~CaloHitResponse | ( | ) |
doesn't delete the pointers passed in
Definition at line 37 of file CaloHitResponse.cc.
References theRandPoisson.
00038 { 00039 delete theRandPoisson; 00040 }
void CaloHitResponse::add | ( | const CaloSamples & | signal | ) |
add a signal, in units of pe
Definition at line 84 of file CaloHitResponse.cc.
References findSignal(), i, CaloSamples::id(), id, CaloSamples::presamples(), CaloSamples::size(), and theAnalogSignalMap.
00085 { 00086 DetId id(signal.id()); 00087 CaloSamples * oldSignal = findSignal(id); 00088 if (oldSignal == 0) { 00089 theAnalogSignalMap[id] = signal; 00090 } else { 00091 // need a "+=" to CaloSamples 00092 int sampleSize = oldSignal->size(); 00093 assert(sampleSize == signal.size()); 00094 assert(signal.presamples() == oldSignal->presamples()); 00095 00096 for(int i = 0; i < sampleSize; ++i) { 00097 (*oldSignal)[i] += signal[i]; 00098 } 00099 } 00100 }
process a single SimHit
Definition at line 69 of file CaloHitResponse.cc.
References CaloVHitFilter::accepts(), edm::isnan(), LogDebug, makeAnalogSignal(), signal, theHitFilter, and PCaloHit::time().
Referenced by CaloTDigitizer< Traits >::addNoiseHits(), ESFastTDigitizer::addNoiseHits(), and CaloTDigitizer< Traits >::addNoiseSignals().
00070 { 00071 // check the hit time makes sense 00072 if ( isnan(hit.time()) ) { return; } 00073 00074 // maybe it's not from this subdetector 00075 if(theHitFilter == 0 || theHitFilter->accepts(hit)) { 00076 LogDebug("CaloHitResponse") << hit; 00077 CaloSamples signal(makeAnalogSignal(hit)); 00078 LogDebug("CaloHitResponse") << signal; 00079 add(signal); 00080 } 00081 }
void CaloHitResponse::addHit | ( | const PCaloHit * | hit, | |
CaloSamples & | frame | |||
) | const |
adds the amplitude for a single hit to the frame
double CaloHitResponse::analogSignalAmplitude | ( | const PCaloHit & | hit, | |
const CaloSimParameters & | parameters | |||
) | const |
finds the amplitude contribution from this hit, applying photostatistics, if needed.
Results are in photoelectrons
Definition at line 135 of file CaloHitResponse.cc.
References CaloSimParameters::doPhotostatistics(), PCaloHit::energy(), Exception, PCaloHit::id(), edm::Service< T >::isAvailable(), CaloSimParameters::simHitToPhotoelectrons(), and theRandPoisson.
Referenced by makeAnalogSignal().
00135 { 00136 00137 if(!theRandPoisson) 00138 { 00139 edm::Service<edm::RandomNumberGenerator> rng; 00140 if ( ! rng.isAvailable()) { 00141 throw cms::Exception("Configuration") 00142 << "CaloHitResponse requires the RandomNumberGeneratorService\n" 00143 "which is not present in the configuration file. You must add the service\n" 00144 "in the configuration file or remove the modules that require it."; 00145 } 00146 theRandPoisson = new CLHEP::RandPoissonQ(rng->getEngine()); 00147 } 00148 00149 // OK, the "energy" in the hit could be a real energy, deposited energy, 00150 // or pe count. This factor converts to photoelectrons 00151 double npe = hit.energy() * parameters.simHitToPhotoelectrons( DetId(hit.id()) ); 00152 // do we need to doPoisson statistics for the photoelectrons? 00153 if(parameters.doPhotostatistics()) { 00154 npe = theRandPoisson->fire(npe); 00155 } 00156 return npe; 00157 }
frees up memory
Definition at line 69 of file CaloHitResponse.h.
References theAnalogSignalMap.
Referenced by EcalMixingModuleValidation::computeSDBunchDigi(), ESFastTDigitizer::run(), CaloTDigitizer< Traits >::run(), and EcalTDigitizer< Traits >::run().
00069 {theAnalogSignalMap.clear();}
CaloSamples * CaloHitResponse::findSignal | ( | const DetId & | detId | ) |
users can look for the signal for a given cell
Definition at line 160 of file CaloHitResponse.cc.
References HLT_VtxMuL3::result, and theAnalogSignalMap.
Referenced by add(), EcalMixingModuleValidation::computeSDBunchDigi(), ESFastTDigitizer::run(), CaloTDigitizer< Traits >::run(), and EcalTDigitizer< Traits >::run().
00160 { 00161 CaloSamples * result = 0; 00162 AnalogSignalMap::iterator signalItr = theAnalogSignalMap.find(detId); 00163 if(signalItr == theAnalogSignalMap.end()) { 00164 result = 0; 00165 } 00166 else { 00167 result = &(signalItr->second); 00168 } 00169 return result; 00170 }
CaloSamples CaloHitResponse::makeAnalogSignal | ( | const PCaloHit & | inputHit | ) | const |
creates the signal corresponding to this hit
Definition at line 103 of file CaloHitResponse.cc.
References analogSignalAmplitude(), BUNCHSPACE, CaloVHitCorrection::correct(), detId, PCaloHit::id(), makeBlankSignal(), python::trackProbabilityAnalysis_cff::parameters, HLT_VtxMuL3::result, signal, CaloVSimParameterMap::simParameters(), CaloSamples::size(), theHitCorrection, theParameterMap, thePhaseShift_, PCaloHit::time(), timeOfFlight(), and tzero.
Referenced by add().
00103 { 00104 00105 // see if we need to correct the hit 00106 PCaloHit hit = inputHit; 00107 00108 if(theHitCorrection != 0) { 00109 theHitCorrection->correct(hit); 00110 } 00111 00112 DetId detId(hit.id()); 00113 const CaloSimParameters & parameters = theParameterMap->simParameters(detId); 00114 00115 double signal = analogSignalAmplitude(hit, parameters); 00116 00117 double jitter = hit.time() - timeOfFlight(detId); 00118 00119 // assume bins count from zero, go for center of bin 00120 const double tzero = parameters.timePhase() -jitter - 00121 BUNCHSPACE*(parameters.binOfMaximum()-thePhaseShift_); 00122 double binTime = tzero; 00123 00124 CaloSamples result(makeBlankSignal(detId)); 00125 00126 for(int bin = 0; bin < result.size(); bin++) { 00127 result[bin] += (*theShape)(binTime)* signal; 00128 binTime += BUNCHSPACE; 00129 } 00130 00131 return result; 00132 }
CaloSamples CaloHitResponse::makeBlankSignal | ( | const DetId & | detId | ) | const |
creates an empty signal for this DetId
Definition at line 173 of file CaloHitResponse.cc.
References CaloSimParameters::binOfMaximum(), python::trackProbabilityAnalysis_cff::parameters, CaloSimParameters::readoutFrameSize(), HLT_VtxMuL3::result, CaloVSimParameterMap::simParameters(), and theParameterMap.
Referenced by makeAnalogSignal(), ESFastTDigitizer::run(), CaloTDigitizer< Traits >::run(), and EcalTDigitizer< Traits >::run().
00173 { 00174 const CaloSimParameters & parameters = theParameterMap->simParameters(detId); 00175 CaloSamples result(detId, parameters.readoutFrameSize()); 00176 result.setPresamples(parameters.binOfMaximum()-1); 00177 return result; 00178 }
int CaloHitResponse::nSignals | ( | ) | const [inline] |
number of signals in the current cache
Definition at line 85 of file CaloHitResponse.h.
References theAnalogSignalMap.
Referenced by ESFastTDigitizer::run(), CaloTDigitizer< Traits >::run(), and EcalTDigitizer< Traits >::run().
00085 {return theAnalogSignalMap.size();}
void CaloHitResponse::run | ( | MixCollection< PCaloHit > & | hits | ) |
Complete cell digitization.
Definition at line 55 of file CaloHitResponse.cc.
References MixCollection< T >::begin(), MixCollection< T >::end(), theMaxBunch, and theMinBunch.
Referenced by EcalMixingModuleValidation::computeSDBunchDigi(), ESFastTDigitizer::run(), CaloTDigitizer< Traits >::run(), and EcalTDigitizer< Traits >::run().
00055 { 00056 00057 for(MixCollection<PCaloHit>::MixItr hitItr = hits.begin(); 00058 hitItr != hits.end(); ++hitItr) 00059 { 00060 // check the bunch crossing range 00061 if ( hitItr.bunch() < theMinBunch || hitItr.bunch() > theMaxBunch ) 00062 { continue; } 00063 00064 add(*hitItr); 00065 } // loop over hits 00066 }
tells it which pileup bunches to do
Definition at line 43 of file CaloHitResponse.cc.
References theMaxBunch, and theMinBunch.
Referenced by EcalMixingModuleValidation::computeSDBunchDigi().
00043 { 00044 theMinBunch = minBunch; 00045 theMaxBunch = maxBunch; 00046 }
void CaloHitResponse::setGeometry | ( | const CaloGeometry * | geometry | ) | [inline] |
geometry needed for time-of-flight
Definition at line 45 of file CaloHitResponse.h.
References theGeometry.
Referenced by CastorDigiProducer::checkGeometry(), HcalDigiProducer::checkGeometry(), EcalMixingModuleValidation::computeSDBunchDigi(), HcalTBDigiProducer::updateGeometry(), EcalTBDigiProducer::updateGeometry(), and EcalDigiProducer::updateGeometry().
00045 { theGeometry = geometry; }
void CaloHitResponse::setHitCorrection | ( | const CaloVHitCorrection * | hitCorrection | ) | [inline] |
If you want to correct hits, for attenuation or delay, set this.
Definition at line 62 of file CaloHitResponse.h.
References theHitCorrection.
Referenced by CastorDigiProducer::CastorDigiProducer(), HcalDigiProducer::HcalDigiProducer(), and HcalTBDigiProducer::HcalTBDigiProducer().
00062 { 00063 theHitCorrection = hitCorrection; 00064 }
void CaloHitResponse::setHitFilter | ( | const CaloVHitFilter * | filter | ) | [inline] |
if you want to reject hits, for example, from a certain subdetector, set this
Definition at line 57 of file CaloHitResponse.h.
References theHitFilter.
Referenced by CastorDigiProducer::CastorDigiProducer(), HcalDigiProducer::HcalDigiProducer(), and HcalTBDigiProducer::HcalTBDigiProducer().
00057 { 00058 theHitFilter = filter; 00059 }
void CaloHitResponse::setPhaseShift | ( | const double & | thePhaseShift | ) | [inline] |
setting the phase shift for asynchronous trigger (e.g. test beams)
Definition at line 96 of file CaloHitResponse.h.
References thePhaseShift_.
Referenced by EcalDigiProducer::EcalDigiProducer(), HcalTBDigiProducer::setPhaseShift(), and EcalTBDigiProducer::setPhaseShift().
00096 { thePhaseShift_ = thePhaseShift; }
void CaloHitResponse::setRandomEngine | ( | CLHEP::HepRandomEngine & | engine | ) |
Definition at line 49 of file CaloHitResponse.cc.
References theRandPoisson.
00050 { 00051 theRandPoisson = new CLHEP::RandPoissonQ(engine); 00052 }
double CaloHitResponse::timeOfFlight | ( | const DetId & | detId | ) | const |
time-of-flight, in ns, to get to this cell returns 0 if no geometry has been set
Definition at line 181 of file CaloHitResponse.cc.
References CaloSubdetectorGeometry::getGeometry(), CaloCellGeometry::getPosition(), CaloGeometry::getSubdetectorGeometry(), PV3DBase< T, PVType, FrameType >::mag(), DetId::rawId(), HLT_VtxMuL3::result, and theGeometry.
Referenced by makeAnalogSignal().
00181 { 00182 // not going to assume there's one of these per subdetector. 00183 // Take the whole CaloGeometry and find the right subdet 00184 double result = 0.; 00185 if(theGeometry == 0) { 00186 edm::LogWarning("CaloHitResponse") << "No Calo Geometry set, so no time of flight correction"; 00187 } 00188 else { 00189 const CaloCellGeometry* cellGeometry = theGeometry->getSubdetectorGeometry(detId)->getGeometry(detId); 00190 if(cellGeometry == 0) { 00191 edm::LogWarning("CaloHitResponse") << "No Calo cell found for ID" 00192 << detId.rawId() << " so no time-of-flight subtraction will be done"; 00193 } 00194 else { 00195 double distance = cellGeometry->getPosition().mag(); 00196 result = distance * cm / c_light; // Units of c_light: mm/ns 00197 } 00198 } 00199 return result; 00200 }
AnalogSignalMap CaloHitResponse::theAnalogSignalMap [protected] |
Definition at line 100 of file CaloHitResponse.h.
Referenced by add(), clear(), findSignal(), and nSignals().
const CaloGeometry* CaloHitResponse::theGeometry [protected] |
const CaloVHitCorrection* CaloHitResponse::theHitCorrection [protected] |
Definition at line 104 of file CaloHitResponse.h.
Referenced by makeAnalogSignal(), and setHitCorrection().
const CaloVHitFilter* CaloHitResponse::theHitFilter [protected] |
int CaloHitResponse::theMaxBunch [protected] |
int CaloHitResponse::theMinBunch [protected] |
const CaloVSimParameterMap* CaloHitResponse::theParameterMap [protected] |
Definition at line 102 of file CaloHitResponse.h.
Referenced by makeAnalogSignal(), and makeBlankSignal().
double CaloHitResponse::thePhaseShift_ [protected] |
Definition at line 114 of file CaloHitResponse.h.
Referenced by makeAnalogSignal(), and setPhaseShift().
CLHEP::RandPoissonQ* CaloHitResponse::theRandPoisson [mutable, protected] |
Definition at line 109 of file CaloHitResponse.h.
Referenced by analogSignalAmplitude(), setRandomEngine(), and ~CaloHitResponse().
const CaloVShape* CaloHitResponse::theShape [protected] |
Definition at line 103 of file CaloHitResponse.h.