Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:21

0001 #include "DataFormats/HcalDigi/interface/CastorDataFrame.h"
0002 #include "SimCalorimetry/CastorSim/interface/CastorAmplifier.h"
0003 #include "SimCalorimetry/CastorSim/interface/CastorCoderFactory.h"
0004 #include "SimCalorimetry/CastorSim/interface/CastorElectronicsSim.h"
0005 
0006 #include "CLHEP/Random/RandFlat.h"
0007 
0008 CastorElectronicsSim::CastorElectronicsSim(CastorAmplifier *amplifier, const CastorCoderFactory *coderFactory)
0009     : theAmplifier(amplifier), theCoderFactory(coderFactory), theStartingCapId(0) {}
0010 
0011 CastorElectronicsSim::~CastorElectronicsSim() {}
0012 
0013 template <class Digi>
0014 void CastorElectronicsSim::convert(CaloSamples &frame, Digi &result, CLHEP::HepRandomEngine *engine) {
0015   result.setSize(frame.size());
0016   theAmplifier->amplify(frame, engine);
0017   theCoderFactory->coder(frame.id())->fC2adc(frame, result, theStartingCapId);
0018 }
0019 
0020 void CastorElectronicsSim::analogToDigital(CLHEP::HepRandomEngine *engine, CaloSamples &lf, CastorDataFrame &result) {
0021   convert<CastorDataFrame>(lf, result, engine);
0022 }
0023 
0024 void CastorElectronicsSim::newEvent(CLHEP::HepRandomEngine *engine) {
0025   // pick a new starting Capacitor ID
0026   theStartingCapId = CLHEP::RandFlat::shootInt(engine, 4);
0027   theAmplifier->setStartingCapId(theStartingCapId);
0028 }