8 #include "CLHEP/Random/RandGeneral.h"
9 #include "CLHEP/Random/RandPoissonQ.h"
10 #include "CLHEP/Random/RandFlat.h"
12 #include <gsl/gsl_sf_erf.h>
13 #include <gsl/gsl_sf_result.h>
37 <<
"ESDigitizer requires the RandomNumberGeneratorService\n"
38 "which is not present in the configuration file. You must add the service\n"
39 "in the configuration file or remove the modules that require it.";
81 double zsThresh ( 0. ) ;
87 refFile =
"SimCalorimetry/EcalSimProducers/data/esRefHistosFile_LG.txt";
92 refFile =
"SimCalorimetry/EcalSimProducers/data/esRefHistosFile_HG.txt";
96 int status = gsl_sf_erf_Q_e( zsThresh, &result ) ;
97 if( status != 0 )
std::cerr <<
"ESDigitizer::could not compute gaussian tail probability for the threshold chosen" << std::endl ;
99 const double probabilityLeft ( result.val ) ;
106 if( !histofile.good() )
109 <<
"Reference histos file not opened" ;
116 while( 0 == thisLine )
118 histofile.getline( buffer, 200 ) ;
119 if( !strstr(buffer,
"#") &&
120 !(strspn(buffer,
" ") == strlen(buffer) ) )
123 sscanf( buffer,
"%f" , &histoBin ) ;
128 const uint32_t histoBin1 ( (
int)
m_histoBin ) ;
129 const uint32_t histoBin2 ( histoBin1*histoBin1 ) ;
131 double t_histoSup ( 0 ) ;
133 std::vector<double> t_refHistos ;
134 t_refHistos.reserve( 2500 ) ;
137 while( !( histofile.eof() ) )
139 histofile.getline( buffer, 200 ) ;
140 if( !strstr( buffer,
"#" ) &&
141 !( strspn( buffer,
" " ) == strlen( buffer ) ) )
146 sscanf( buffer,
"%f" , &histoInf ) ;
152 sscanf( buffer,
"%f" , &histoSup ) ;
153 t_histoSup = (double) histoSup ;
158 sscanf( buffer,
"%f", &refBin ) ;
161 t_refHistos.push_back( (
double) refBin ) ;
162 const uint32_t i2 ( thisBin/histoBin2 ) ;
163 const uint32_t off ( i2*histoBin2 ) ;
164 const uint32_t i1 ( ( thisBin - off )/histoBin1 ) ;
165 const uint32_t i0 ( thisBin - off - i1*histoBin1 ) ;
166 m_trip.emplace_back(i0, i1, i2) ;
178 &t_refHistos.front() ,
205 std::vector<DetId> abThreshCh ;
209 for( std::vector<DetId>::const_iterator idItr ( abThreshCh.begin() ) ;
210 idItr != abThreshCh.end(); ++idItr )
216 if( myBin ==
m_trip.size() ) --myBin ;
217 assert( myBin <
m_trip.size() ) ;
224 analogToDigital( analogSignal ,
236 const unsigned int nChan (
m_ranPois->fire() ) ;
237 abThreshCh.reserve( nChan ) ;
239 for(
unsigned int i ( 0 ) ;
i != nChan ; ++
i )
241 std::vector<DetId>::const_iterator idItr ( abThreshCh.end() ) ;
242 uint32_t iChan ( 0 ) ;
247 if( iChan ==
m_detIds->size() ) --iChan ;
248 assert(
m_detIds->size() > iChan ) ;
249 id = (*m_detIds)[ iChan ] ;
250 idItr =
find( abThreshCh.begin() ,
254 while( idItr != abThreshCh.end() ) ;
256 abThreshCh.push_back( std::move(
id) ) ;
void setDetIds(const std::vector< DetId > &detIds)
tell the digitizer which cells exist; cannot change during a run
void createNoisyList(std::vector< DetId > &abThreshCh)
std::vector< Triplet > m_trip
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
CLHEP::RandFlat * m_ranFlat
const EcalSamples * findDetId(const DetId &detId) const
const ElectronicsSim * elecSim() const
CLHEP::RandGeneral * m_ranGeneral
void setGain(const int gain)
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void reserve(size_t isize)
CLHEP::HepRandomEngine * m_engine
const std::vector< DetId > * m_detIds
void push_back(unsigned int i)
virtual void run(DigiCollection &output)
const EcalHitResponse * hitResponse() const
ESDigitizer(EcalHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)
virtual void run(ESDigiCollection &output)
turns hits into digis
CLHEP::RandPoissonQ * m_ranPois