6 #include "CLHEP/Random/RandGeneral.h" 7 #include "CLHEP/Random/RandPoissonQ.h" 8 #include "CLHEP/Random/RandFlat.h" 10 #include <gsl/gsl_sf_erf.h> 11 #include <gsl/gsl_sf_result.h> 40 assert(1 == gain || 2 == gain);
50 refFile =
"SimCalorimetry/EcalSimProducers/data/esRefHistosFile_LG.txt";
53 refFile =
"SimCalorimetry/EcalSimProducers/data/esRefHistosFile_HG.txt";
57 int status = gsl_sf_erf_Q_e(zsThresh, &result);
59 std::cerr <<
"ESDigitizer::could not compute gaussian tail probability for the threshold chosen" << std::endl;
61 const double probabilityLeft(result.val);
65 if (!histofile.good()) {
71 while (0 == thisLine) {
72 histofile.getline(buffer, 200);
73 if (!strstr(buffer,
"#") && !(strspn(buffer,
" ") == strlen(buffer))) {
75 sscanf(buffer,
"%f", &histoBin);
81 const uint32_t histoBin2(histoBin1 * histoBin1);
85 std::vector<double> t_refHistos;
86 t_refHistos.reserve(2500);
89 while (!(histofile.eof())) {
90 histofile.getline(buffer, 200);
91 if (!strstr(buffer,
"#") && !(strspn(buffer,
" ") == strlen(buffer))) {
94 sscanf(buffer,
"%f", &histoInf);
99 sscanf(buffer,
"%f", &histoSup);
100 t_histoSup = (double)histoSup;
104 sscanf(buffer,
"%f", &refBin);
106 t_refHistos.push_back((
double)refBin);
107 const uint32_t i2(thisBin / histoBin2);
108 const uint32_t off(i2 * histoBin2);
109 const uint32_t i1((thisBin - off) / histoBin1);
110 const uint32_t i0(thisBin - off - i1 * histoBin1);
111 m_trip.emplace_back(i0, i1, i2);
122 m_ranGeneral =
new CLHEP::RandGeneral(
nullptr, &t_refHistos.front(), t_refHistos.size(), 0);
139 std::vector<DetId> abThreshCh;
144 for (std::vector<DetId>::const_iterator idItr(abThreshCh.begin()); idItr != abThreshCh.end(); ++idItr) {
149 if (myBin ==
m_trip.size())
151 assert(myBin <
m_trip.size());
165 CLHEP::RandPoissonQ randPoissonQ(*engine,
m_meanNoisy);
166 const unsigned int nChan(randPoissonQ.fire());
167 abThreshCh.reserve(nChan);
169 for (
unsigned int i(0);
i != nChan; ++
i) {
170 std::vector<DetId>::const_iterator idItr(abThreshCh.end());
174 iChan = (uint32_t)CLHEP::RandFlat::shoot(engine,
m_detIds->size());
178 id = (*m_detIds)[iChan];
179 idItr =
find(abThreshCh.begin(), abThreshCh.end(),
id);
180 }
while (idItr != abThreshCh.end());
void setDetIds(const std::vector< DetId > &detIds)
tell the digitizer which cells exist; cannot change during a run
std::vector< Triplet > m_trip
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const EcalSamples * findDetId(const DetId &detId) const
const ElectronicsSim * elecSim() const
CLHEP::RandGeneral * m_ranGeneral
void createNoisyList(std::vector< DetId > &abThreshCh, CLHEP::HepRandomEngine *)
void setGain(const int gain)
void reserve(size_t isize)
const std::vector< DetId > * m_detIds
void push_back(unsigned int i)
virtual void run(DigiCollection &output, CLHEP::HepRandomEngine *)
void run(ESDigiCollection &output, CLHEP::HepRandomEngine *) override
turns hits into digis
const EcalHitResponse * hitResponse() const
ESDigitizer(EcalHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)