Go to the documentation of this file.00001 #include "SimCalorimetry/HcalSimAlgos/interface/HcalElectronicsSim.h"
00002 #include "SimCalorimetry/HcalSimAlgos/interface/HcalAmplifier.h"
00003 #include "SimCalorimetry/HcalSimAlgos/interface/HcalCoderFactory.h"
00004 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
00005 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
00006 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
00007 #include "DataFormats/HcalDigi/interface/ZDCDataFrame.h"
00008 #include "CLHEP/Random/RandFlat.h"
00009
00010
00011
00012 HcalElectronicsSim::HcalElectronicsSim(HcalAmplifier * amplifier, const HcalCoderFactory * coderFactory)
00013 : theAmplifier(amplifier),
00014 theCoderFactory(coderFactory),
00015 theRandFlat(0),
00016 theStartingCapId(0),
00017 theStartingCapIdIsRandom(true)
00018 {
00019 }
00020
00021
00022 HcalElectronicsSim::~HcalElectronicsSim()
00023 {
00024 delete theRandFlat;
00025 }
00026
00027
00028 void HcalElectronicsSim::setRandomEngine(CLHEP::HepRandomEngine & engine)
00029 {
00030 theRandFlat = new CLHEP::RandFlat(engine);
00031 theAmplifier->setRandomEngine(engine);
00032 }
00033
00034
00035 template<class Digi>
00036 void HcalElectronicsSim::convert(CaloSamples & frame, Digi & result) {
00037 result.setSize(frame.size());
00038 theAmplifier->amplify(frame);
00039 theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
00040 }
00041
00042
00043 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HBHEDataFrame & result) {
00044 convert<HBHEDataFrame>(lf, result);
00045 }
00046
00047
00048 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HODataFrame & result) {
00049 convert<HODataFrame>(lf, result);
00050 }
00051
00052
00053 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HFDataFrame & result) {
00054 convert<HFDataFrame>(lf, result);
00055 }
00056
00057 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, ZDCDataFrame & result) {
00058 convert<ZDCDataFrame>(lf, result);
00059 }
00060
00061
00062 void HcalElectronicsSim::newEvent() {
00063
00064 if(theStartingCapIdIsRandom)
00065 {
00066 theStartingCapId = theRandFlat->fireInt(4);
00067 theAmplifier->setStartingCapId(theStartingCapId);
00068 }
00069 }
00070
00071
00072 void HcalElectronicsSim::setStartingCapId(int startingCapId)
00073 {
00074 theStartingCapId = startingCapId;
00075 theAmplifier->setStartingCapId(theStartingCapId);
00076
00077 theStartingCapIdIsRandom = false;
00078 }
00079