7 #include "CLHEP/Random/RandFlat.h"
8 #include "CLHEP/Random/RandGaussQ.h"
9 #include "CLHEP/Random/RandGeneral.h"
14 addNoise_(addNoise), peds_(0), mips_(0)
24 std::vector<ESSample> essamples;
26 if ( wasEmpty) essamples =
fastEncode(cs, histoDistribution, hInf, hSup, hBin);
29 for(
int i=0;
i<df.
size();
i++) {
36 for(
int i = 0;
i < df.
size();
i++) {
47 <<
"ESElectroncSimFast requires the RandomNumberGeneratorService\n"
48 "which is not present in the configuration file. You must add the service\n"
49 "in the configuration file or remove the modules that require it.";
53 results.reserve(timeframe.
size());
57 int baseline_ = (int) it_ped->getMean();
58 double sigma_ = (double) it_ped->getRms();
59 double MIPADC_ = (double) (*it_mip);
63 for (
int i=0;
i<timeframe.
size();
i++) {
69 CLHEP::RandGaussQ gaussQDistribution(rng->
getEngine(), 0, sigma_);
70 noi = gaussQDistribution.fire();
73 signal = timeframe[
i]*ADCGeV + noi + baseline_;
96 results.reserve(timeframe.
size());
99 double hBin2 = hBin*hBin;
100 double hBin3 = hBin*hBin*hBin;
101 double width = (hSup - hInf)/hBin;
103 double thisRnd = histoDistribution->fire();
104 int thisRndCell = (int)((hBin3)*(thisRnd)/width);
105 bin[2] = (int)(thisRndCell/hBin2);
106 bin[1] = (int)((thisRndCell - hBin2*bin[2])/hBin);
107 bin[0] = (int)(thisRndCell - hBin*(bin[1] + hBin*bin[2]));
110 int baseline_ = (int) it_ped->getMean();
114 for(
int ii=0; ii<3; ii++){
116 noi[ii] = hInf + bin[ii]*
width;
117 if (noi[ii]>0) noi[ii] += 0.5;
118 else if (noi[ii]<0) noi[ii] -= 0.5;
120 adc[ii] = int(noi[ii]) - 1000 + baseline_;
125 results.push_back(
ESSample(adc[ii]));
int adc(sample_type sample)
get the ADC sample (12 bits)
const ESPedestals * peds_
double decode(const ESSample &sample, const DetId &detId) const
const ESIntercalibConstants * mips_
const ESDetId & id() const
const self & getMap() const
void digitalToAnalog(const ESDataFrame &df, CaloSamples &cs) const
virtual void analogToDigital(const CaloSamples &cs, ESDataFrame &df, bool wasEmpty, CLHEP::RandGeneral *histoDistribution, double hInf, double hSup, double hBin) const
const_iterator find(uint32_t rawId) const
std::vector< ESSample > fastEncode(const CaloSamples &timeframe, CLHEP::RandGeneral *histoDistribution, double hInf, double hSup, double hBin) const
virtual CLHEP::HepRandomEngine & getEngine() const =0
Use this to get the random number engine, this is the only function most users should call...
void setSample(int i, const ESSample &sam)
int size() const
get the size
std::vector< Item >::const_iterator const_iterator
ESElectronicsSimFast(bool addNoise)
DetId id() const
get the (generic) id
std::vector< ESSample > standEncode(const CaloSamples &timeframe) const