Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:28:31

0001 #ifndef EcalSimAlgos_EcalElectronicsSim_h
0002 #define EcalSimAlgos_EcalElectronicsSim_h
0003 
0004 #include "SimCalorimetry/CaloSimAlgos/interface/CaloVNoiseSignalGenerator.h"
0005 #include "CLHEP/Random/RandGaussQ.h"
0006 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSimParameterMap.h"
0007 
0008 class EcalSimParameterMap;
0009 
0010 namespace CLHEP {
0011   class HepRandomEngine;
0012 }
0013 
0014 /* \class EcalElectronicsSim
0015  * \brief Converts CaloDataFrame in CaloTimeSample and vice versa.
0016  * 
0017  */
0018 
0019 template <typename CoderType, typename SamplesType, typename DataFrameType>
0020 class EcalElectronicsSim {
0021 public:
0022   EcalElectronicsSim(const EcalSimParameterMap* parameterMap,
0023                      CoderType* coder,
0024                      bool applyConstantTerm,
0025                      double rmsConstantTerm)
0026       : m_simMap(parameterMap), m_theCoder(coder), m_thisCT(rmsConstantTerm), m_applyConstantTerm(applyConstantTerm) {}
0027 
0028   /// from EcalSamples to EcalDataFrame
0029 
0030   void analogToDigital(CLHEP::HepRandomEngine* engine, SamplesType& clf, DataFrameType& df) const {
0031     // input signal is in pe.  Converted in GeV
0032     amplify(clf, engine);
0033     m_theCoder->analogToDigital(engine, clf, df);
0034   }
0035 
0036   void newEvent() {}
0037 
0038   void setNoiseSignalGenerator(const CaloVNoiseSignalGenerator* noiseSignalGenerator) {
0039     theNoiseSignalGenerator = noiseSignalGenerator;
0040   }
0041 
0042 private:
0043   /// input signal is in pe.  Converted in GeV
0044   void amplify(SamplesType& clf, CLHEP::HepRandomEngine* engine) const {
0045     const double fac(m_simMap->simParameters(clf.id()).photoelectronsToAnalog());
0046     if (m_applyConstantTerm) {
0047       clf *= fac * CLHEP::RandGaussQ::shoot(engine, 1.0, m_thisCT);
0048     } else {
0049       clf *= fac;
0050     }
0051   }
0052 
0053   /// map of parameters
0054 
0055   const EcalSimParameterMap* m_simMap;
0056 
0057   const CaloVNoiseSignalGenerator* theNoiseSignalGenerator;
0058 
0059   CoderType* m_theCoder;
0060 
0061   const double m_thisCT;
0062   const bool m_applyConstantTerm;
0063 };
0064 
0065 #endif