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 {
00018 }
00019
00020
00021 HcalElectronicsSim::~HcalElectronicsSim()
00022 {
00023 delete theRandFlat;
00024 }
00025
00026
00027 void HcalElectronicsSim::setRandomEngine(CLHEP::HepRandomEngine & engine)
00028 {
00029 theRandFlat = new CLHEP::RandFlat(engine);
00030 }
00031
00032
00033 template<class Digi>
00034 void HcalElectronicsSim::convert(CaloSamples & frame, Digi & result) {
00035 result.setSize(frame.size());
00036 theAmplifier->amplify(frame);
00037 theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
00038 }
00039
00040
00041 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HBHEDataFrame & result) {
00042 convert<HBHEDataFrame>(lf, result);
00043 }
00044
00045
00046 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HODataFrame & result) {
00047 convert<HODataFrame>(lf, result);
00048 }
00049
00050
00051 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HFDataFrame & result) {
00052 convert<HFDataFrame>(lf, result);
00053 }
00054
00055 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, ZDCDataFrame & result) {
00056 convert<ZDCDataFrame>(lf, result);
00057 }
00058
00059
00060 void HcalElectronicsSim::newEvent() {
00061
00062 theStartingCapId = theRandFlat->fireInt(4);
00063 theAmplifier->setStartingCapId(theStartingCapId);
00064 }
00065