1 #ifndef CaloSimAlgos_CaloTDigitizer_h 2 #define CaloSimAlgos_CaloTDigitizer_h 17 class HepRandomEngine;
20 template<
class Traits>
27 void operator()(DigiCollection &
output, CLHEP::HepRandomEngine* engine,
CaloSamples * analogSignal, std::vector<DetId>::const_iterator idItr, ElectronicsSim* theElectronicsSim){
29 theElectronicsSim->analogToDigital(engine, *analogSignal , digi);
48 : theHitResponse(hitResponse),
49 theNoiseSignalGenerator(0),
50 theElectronicsSim(electronicsSim),
62 const std::vector<DetId>&
detIds()
const {assert( 0 != theDetIds ) ;
return *theDetIds;}
63 void setDetIds(
const std::vector<DetId> & detIds) {theDetIds = &detIds;}
78 void add(
const std::vector<PCaloHit> &
hits,
int bunchCrossing, CLHEP::HepRandomEngine* engine) {
79 if(theHitResponse->withinBunchRange(bunchCrossing)) {
80 for(std::vector<PCaloHit>::const_iterator it = hits.begin(), itEnd = hits.end(); it != itEnd; ++it) {
81 theHitResponse->add(*it, engine);
87 theHitResponse->initializeHits();
97 void run(DigiCollection &
output, CLHEP::HepRandomEngine* engine) {
98 theHitResponse->finalizeHits(engine);
101 assert(theDetIds->size() != 0);
103 if(theNoiseSignalGenerator != 0) addNoiseSignals(engine);
105 theElectronicsSim->newEvent(engine);
108 int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals();
109 output.reserve(nDigisExpected);
112 csColl_.reserve(nDigisExpected);
113 theHitResponse->setStorePrecise(
true);
117 for(std::vector<DetId>::const_iterator idItr = theDetIds->begin();
118 idItr != theDetIds->end(); ++idItr)
120 CaloSamples * analogSignal = theHitResponse->findSignal(*idItr);
121 if(analogSignal && debugCS_) csColl_.push_back(*analogSignal);
122 bool needToDeleteSignal =
false;
124 if(analogSignal == 0 && addNoise_) {
127 analogSignal =
new CaloSamples(theHitResponse->makeBlankSignal(*idItr));
128 needToDeleteSignal =
true;
130 if(analogSignal != 0) {
131 runAnalogToDigital(output,engine,analogSignal,idItr,theElectronicsSim);
132 if(needToDeleteSignal)
delete analogSignal;
137 theHitResponse->clear();
142 std::vector<CaloSamples> noiseSignals;
144 theNoiseSignalGenerator->fillEvent(engine);
145 theNoiseSignalGenerator->getNoiseSignals(noiseSignals);
146 for(std::vector<CaloSamples>::const_iterator signalItr = noiseSignals.begin(),
147 signalEnd = noiseSignals.end(); signalItr != signalEnd; ++signalItr)
149 theHitResponse->add(*signalItr);
CaloSamplesCollection csColl_
std::vector< CaloSamples > CaloSamplesCollection
void add(const std::vector< PCaloHit > &hits, int bunchCrossing, CLHEP::HepRandomEngine *engine)
Traits::ElectronicsSim ElectronicsSim
const std::vector< DetId > & detIds() const
tell the digitizer which cells exist
void operator()(DigiCollection &output, CLHEP::HepRandomEngine *engine, CaloSamples *analogSignal, std::vector< DetId >::const_iterator idItr, ElectronicsSim *theElectronicsSim)
std::tuple< unsigned int, int, int, DigiType, int, int, int, float > Digi
Traits::ElectronicsSim ElectronicsSim
CaloVNoiseSignalGenerator * theNoiseSignalGenerator
Creates electronics signals from hits.
CaloTDigitizer(CaloHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)
void addNoiseSignals(CLHEP::HepRandomEngine *engine)
void setNoiseSignalGenerator(CaloVNoiseSignalGenerator *generator)
CaloHitResponse * theHitResponse
runHelper< Traits > runAnalogToDigital
~CaloTDigitizer()
doesn't delete the pointers passed in
void run(MixCollection< PCaloHit > &, DigiCollection &)
turns hits into digis
ElectronicsSim * theElectronicsSim
Traits::DigiCollection DigiCollection
void setDebugCaloSamples(bool debug)
Traits::DigiCollection DigiCollection
const CaloSamplesCollection & getCaloSamples() const
void run(DigiCollection &output, CLHEP::HepRandomEngine *engine)
Collects the digis.
void setDetIds(const std::vector< DetId > &detIds)
const std::vector< DetId > * theDetIds