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 "DataFormats/HcalDigi/interface/HcalUpgradeDataFrame.h"
00009 #include "CLHEP/Random/RandFlat.h"
00010
00011
00012
00013 HcalElectronicsSim::HcalElectronicsSim(HcalAmplifier * amplifier, const HcalCoderFactory * coderFactory)
00014 : theAmplifier(amplifier),
00015 theCoderFactory(coderFactory),
00016 theRandFlat(0),
00017 theStartingCapId(0),
00018 theStartingCapIdIsRandom(true)
00019 {
00020 }
00021
00022
00023 HcalElectronicsSim::~HcalElectronicsSim() {
00024 if (theRandFlat) delete theRandFlat;
00025 }
00026
00027
00028 void HcalElectronicsSim::setRandomEngine(CLHEP::HepRandomEngine & engine) {
00029 theRandFlat = new CLHEP::RandFlat(engine);
00030 theAmplifier->setRandomEngine(engine);
00031 theTDC.setRandomEngine(engine);
00032 }
00033
00034
00035 void HcalElectronicsSim::setDbService(const HcalDbService * service) {
00036
00037 theTDC.setDbService(service);
00038 }
00039
00040 template<class Digi>
00041 void HcalElectronicsSim::convert(CaloSamples & frame, Digi & result) {
00042 result.setSize(frame.size());
00043 theAmplifier->amplify(frame);
00044 theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
00045 }
00046
00047
00048 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HBHEDataFrame & result) {
00049 convert<HBHEDataFrame>(lf, result);
00050 }
00051
00052
00053 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HODataFrame & result) {
00054 convert<HODataFrame>(lf, result);
00055 }
00056
00057
00058 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, HFDataFrame & result) {
00059 convert<HFDataFrame>(lf, result);
00060 }
00061
00062 void HcalElectronicsSim::analogToDigital(CaloSamples & lf, ZDCDataFrame & result) {
00063 convert<ZDCDataFrame>(lf, result);
00064 }
00065
00066
00067 void HcalElectronicsSim::analogToDigital(CaloSamples & lf,
00068 HcalUpgradeDataFrame & result) {
00069 convert<HcalUpgradeDataFrame>(lf, result);
00070 theTDC.timing(lf, result);
00071 }
00072
00073 void HcalElectronicsSim::newEvent() {
00074
00075 if(theStartingCapIdIsRandom)
00076 {
00077 theStartingCapId = theRandFlat->fireInt(4);
00078 theAmplifier->setStartingCapId(theStartingCapId);
00079 }
00080 }
00081
00082
00083 void HcalElectronicsSim::setStartingCapId(int startingCapId)
00084 {
00085 theStartingCapId = startingCapId;
00086 theAmplifier->setStartingCapId(theStartingCapId);
00087
00088 theStartingCapIdIsRandom = false;
00089 }
00090