1 #ifndef CaloSimAlgos_CaloTDigitizer_h 2 #define CaloSimAlgos_CaloTDigitizer_h 18 class HepRandomEngine;
21 template <
class Traits>
29 CLHEP::HepRandomEngine *engine,
31 std::vector<DetId>::const_iterator idItr,
32 ElectronicsSim *theElectronicsSim) {
34 theElectronicsSim->analogToDigital(engine, *analogSignal, digi);
52 : theHitResponse(hitResponse),
53 theNoiseSignalGenerator(
nullptr),
54 theElectronicsSim(electronicsSim),
63 const std::vector<DetId> &
detIds()
const {
64 assert(0 != theDetIds);
67 void setDetIds(
const std::vector<DetId> &detIds) { theDetIds = &detIds; }
75 void add(
const std::vector<PCaloHit> &
hits,
int bunchCrossing, CLHEP::HepRandomEngine *engine) {
76 if (theHitResponse->withinBunchRange(bunchCrossing)) {
77 for (std::vector<PCaloHit>::const_iterator it = hits.begin(), itEnd = hits.end(); it != itEnd; ++it) {
78 theHitResponse->add(*it, engine);
90 void run(DigiCollection &
output, CLHEP::HepRandomEngine *engine) {
91 assert(!theDetIds->empty());
93 if (theNoiseSignalGenerator !=
nullptr)
94 addNoiseSignals(engine);
96 theHitResponse->finalizeHits(engine);
99 theElectronicsSim->newEvent(engine);
102 int nDigisExpected = addNoise_ ? theDetIds->size() : theHitResponse->nSignals();
103 output.reserve(nDigisExpected);
106 csColl_.reserve(nDigisExpected);
107 theHitResponse->setStorePrecise(
true);
111 for (std::vector<DetId>::const_iterator idItr = theDetIds->begin(); idItr != theDetIds->end(); ++idItr) {
112 CaloSamples *analogSignal = theHitResponse->findSignal(*idItr);
113 if (analogSignal && debugCS_)
114 csColl_.push_back(*analogSignal);
115 bool needToDeleteSignal =
false;
117 if (analogSignal ==
nullptr && addNoise_) {
120 analogSignal =
new CaloSamples(theHitResponse->makeBlankSignal(*idItr));
121 needToDeleteSignal =
true;
123 if (analogSignal !=
nullptr) {
124 runAnalogToDigital(output, engine, analogSignal, idItr, theElectronicsSim);
125 if (needToDeleteSignal)
131 theHitResponse->clear();
135 std::vector<CaloSamples> noiseSignals;
137 theNoiseSignalGenerator->fillEvent(engine);
138 theNoiseSignalGenerator->getNoiseSignals(noiseSignals);
139 for (std::vector<CaloSamples>::const_iterator signalItr = noiseSignals.begin(), signalEnd = noiseSignals.end();
140 signalItr != signalEnd;
142 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