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 ) ;
178 &t_refHistos.front() ,
206 std::vector<DetId> abThreshCh ;
210 for( std::vector<DetId>::const_iterator idItr ( abThreshCh.begin() ) ;
211 idItr != abThreshCh.end(); ++idItr )
217 if( myBin ==
m_trip.size() ) --myBin ;
218 assert( myBin <
m_trip.size() ) ;
225 analogToDigital( analogSignal ,
237 const unsigned int nChan (
m_ranPois->fire() ) ;
238 abThreshCh.reserve( nChan ) ;
240 for(
unsigned int i ( 0 ) ;
i != nChan ; ++
i )
242 std::vector<DetId>::const_iterator idItr ( abThreshCh.end() ) ;
243 uint32_t iChan ( 0 ) ;
248 if( iChan ==
m_detIds->size() ) --iChan ;
249 assert(
m_detIds->size() > iChan ) ;
250 id = (*m_detIds)[ iChan ] ;
251 idItr =
find( abThreshCh.begin() ,
255 while( idItr != abThreshCh.end() ) ;
257 abThreshCh.push_back(
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)
virtual void run(MixCollection< PCaloHit > &input, DigiCollection &output)
turns hits into digis
CLHEP::RandFlat * m_ranFlat
const EcalSamples * findDetId(const DetId &detId) const
const ElectronicsSim * elecSim() const
CLHEP::RandGeneral * m_ranGeneral
virtual void run(MixCollection< PCaloHit > &input, DigiCollection &output)
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)
const EcalHitResponse * hitResponse() const
ESDigitizer(EcalHitResponse *hitResponse, ElectronicsSim *electronicsSim, bool addNoise)
CLHEP::RandPoissonQ * m_ranPois