#include <ESElectronicsSim.h>
Public Types | |
enum | { MAXADC = 4095 } |
enum | { MINADC = 0 } |
Public Member Functions | |
virtual void | analogToDigital (const CaloSamples &cs, ESDataFrame &df) const |
virtual void | digitalToAnalog (const ESDataFrame &df, CaloSamples &cs) const |
ESElectronicsSim (bool addNoise) | |
void | newEvent () |
anything that needs to be done once per event | |
void | setGain (const int gain) |
void | setMIPs (const ESIntercalibConstants *mips) |
void | setMIPToGeV (const double MIPToGeV) |
void | setPedestals (const ESPedestals *peds) |
Private Member Functions | |
double | decode (const ESSample &sample, const DetId &detId) const |
std::vector< ESSample > | encode (const CaloSamples &timeframe) const |
Private Attributes | |
bool | addNoise_ |
int | gain_ |
const ESIntercalibConstants * | mips_ |
double | MIPToGeV_ |
const ESPedestals * | peds_ |
Definition at line 12 of file ESElectronicsSim.h.
anonymous enum |
anonymous enum |
ESElectronicsSim::ESElectronicsSim | ( | bool | addNoise | ) |
Definition at line 11 of file ESElectronicsSim.cc.
void ESElectronicsSim::analogToDigital | ( | const CaloSamples & | cs, |
ESDataFrame & | df | ||
) | const [virtual] |
Definition at line 20 of file ESElectronicsSim.cc.
References encode(), i, ESDataFrame::setSample(), ESDataFrame::setSize(), ESDataFrame::size(), and CaloSamples::size().
void ESElectronicsSim::digitalToAnalog | ( | const ESDataFrame & | df, |
CaloSamples & | cs | ||
) | const [virtual] |
Definition at line 32 of file ESElectronicsSim.cc.
References decode(), i, ESDataFrame::id(), and ESDataFrame::size().
std::vector< ESSample > ESElectronicsSim::encode | ( | const CaloSamples & | timeframe | ) | const [private] |
Definition at line 42 of file ESElectronicsSim.cc.
References ecalMGPA::adc(), addNoise_, Exception, ESCondObjectContainer< T >::find(), ESCondObjectContainer< T >::getMap(), i, CaloSamples::id(), edm::Service< T >::isAvailable(), MAXADC, MINADC, mips_, MIPToGeV_, peds_, python::entryComment::results, and CaloSamples::size().
Referenced by analogToDigital().
{ edm::Service<edm::RandomNumberGenerator> rng; if ( ! rng.isAvailable()) { throw cms::Exception("Configuration") << "ESElectroncSim requires the RandomNumberGeneratorService\n" "which is not present in the configuration file. You must add the service\n" "in the configuration file or remove the modules that require it."; } std::vector<ESSample> results; results.reserve(timeframe.size()); ESPedestals::const_iterator it_ped = peds_->find(timeframe.id()); ESIntercalibConstantMap::const_iterator it_mip = mips_->getMap().find(timeframe.id()); int baseline_ = (int) it_ped->getMean(); double sigma_ = (double) it_ped->getRms(); double MIPADC_ = (double) (*it_mip); int adc = 0; double ADCGeV = MIPADC_/MIPToGeV_; for (int i=0; i<timeframe.size(); i++) { double noi = 0; double signal = 0; if (addNoise_) { CLHEP::RandGaussQ gaussQDistribution(rng->getEngine(), 0., sigma_); noi = gaussQDistribution.fire(); } signal = timeframe[i]*ADCGeV + noi + baseline_; if (signal>0) signal += 0.5; else if (signal<0) signal -= 0.5; adc = int(signal); if (adc>MAXADC) adc = MAXADC; if (adc<MINADC) adc = MINADC; results.push_back(ESSample(adc)); } return results; }
void ESElectronicsSim::newEvent | ( | ) | [inline] |
void ESElectronicsSim::setGain | ( | const int | gain | ) | [inline] |
Definition at line 21 of file ESElectronicsSim.h.
References gain_.
Referenced by EcalDigiProducer::checkCalibrations().
{ gain_ = gain; }
void ESElectronicsSim::setMIPs | ( | const ESIntercalibConstants * | mips | ) | [inline] |
Definition at line 23 of file ESElectronicsSim.h.
References mips_.
Referenced by EcalDigiProducer::checkCalibrations().
{ mips_ = mips; }
void ESElectronicsSim::setMIPToGeV | ( | const double | MIPToGeV | ) | [inline] |
Definition at line 24 of file ESElectronicsSim.h.
References MIPToGeV_.
Referenced by EcalDigiProducer::checkCalibrations().
{ MIPToGeV_ = MIPToGeV; }
void ESElectronicsSim::setPedestals | ( | const ESPedestals * | peds | ) | [inline] |
Definition at line 22 of file ESElectronicsSim.h.
References peds_.
Referenced by EcalDigiProducer::checkCalibrations().
{ peds_ = peds; }
bool ESElectronicsSim::addNoise_ [private] |
Definition at line 34 of file ESElectronicsSim.h.
Referenced by encode().
int ESElectronicsSim::gain_ [private] |
Definition at line 35 of file ESElectronicsSim.h.
Referenced by setGain().
const ESIntercalibConstants* ESElectronicsSim::mips_ [private] |
Definition at line 37 of file ESElectronicsSim.h.
double ESElectronicsSim::MIPToGeV_ [private] |
Definition at line 38 of file ESElectronicsSim.h.
Referenced by encode(), and setMIPToGeV().
const ESPedestals* ESElectronicsSim::peds_ [private] |
Definition at line 36 of file ESElectronicsSim.h.
Referenced by encode(), and setPedestals().