CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/SimCalorimetry/CastorSim/src/CastorElectronicsSim.cc

Go to the documentation of this file.
00001 #include "SimCalorimetry/CastorSim/src/CastorElectronicsSim.h"
00002 #include "SimCalorimetry/CastorSim/src/CastorAmplifier.h"
00003 #include "SimCalorimetry/CastorSim/src/CastorCoderFactory.h"
00004 #include "DataFormats/HcalDigi/interface/CastorDataFrame.h"
00005 #include "CLHEP/Random/RandFlat.h"
00006 
00007 
00008 
00009 CastorElectronicsSim::CastorElectronicsSim(CastorAmplifier * amplifier, const CastorCoderFactory * coderFactory)
00010   : theAmplifier(amplifier),
00011     theCoderFactory(coderFactory),
00012     theRandFlat(0),
00013     theStartingCapId(0)
00014 {
00015 }
00016 
00017 
00018 CastorElectronicsSim::~CastorElectronicsSim()
00019 {
00020   delete theRandFlat;
00021 }
00022 
00023 
00024 void CastorElectronicsSim::setRandomEngine(CLHEP::HepRandomEngine & engine)
00025 {
00026   theRandFlat = new CLHEP::RandFlat(engine);
00027 }
00028 
00029 
00030 template<class Digi> 
00031 void CastorElectronicsSim::convert(CaloSamples & frame, Digi & result) {
00032   result.setSize(frame.size());
00033   theAmplifier->amplify(frame);
00034   theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
00035 }
00036 
00037 void CastorElectronicsSim::analogToDigital(CaloSamples & lf, CastorDataFrame & result) {
00038   convert<CastorDataFrame>(lf, result);
00039 }
00040 
00041 void CastorElectronicsSim::newEvent() {
00042   // pick a new starting Capacitor ID
00043   theStartingCapId = theRandFlat->fireInt(4);
00044   theAmplifier->setStartingCapId(theStartingCapId);
00045 }
00046