Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 11:23:40

0001 
0002 #ifndef EcalSimAlgos_EcalCoder_h
0003 #define EcalSimAlgos_EcalCoder_h 1
0004 
0005 #include "CalibFormats/CaloObjects/interface/CaloTSamples.h"
0006 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0007 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
0008 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0009 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix.h"
0010 
0011 template <typename M>
0012 class CorrelatedNoisifier;
0013 class EcalMGPASample;
0014 class EcalDataFrame;
0015 class DetId;
0016 
0017 #include <vector>
0018 
0019 namespace CLHEP {
0020   class HepRandomEngine;
0021 }
0022 
0023 /* \class EEDigitizerTraits
0024  * \brief Converts CaloDataFrame in CaloTimeSample and vice versa.
0025  *
0026  */
0027 class EcalCoder {
0028 public:
0029   typedef CaloTSamples<float, 10> EcalSamples;
0030 
0031   typedef CorrelatedNoisifier<EcalCorrMatrix> Noisifier;
0032 
0033   enum {
0034     NBITS = 12,            // number of available bits
0035     MAXADC = 4095,         // 2^12 -1,  adc max range
0036     ADCGAINSWITCH = 4079,  // adc gain switch
0037     NGAINS = 3             // number of electronic gains
0038   };
0039 
0040   /// ctor
0041   EcalCoder(bool addNoise,
0042             bool PreMix1,
0043             Noisifier* ebCorrNoise0,
0044             Noisifier* eeCorrNoise0 = nullptr,
0045             Noisifier* ebCorrNoise1 = nullptr,
0046             Noisifier* eeCorrNoise1 = nullptr,
0047             Noisifier* ebCorrNoise2 = nullptr,
0048             Noisifier* eeCorrNoise2 = nullptr);  // make EE version optional for tb compatibility
0049   /// dtor
0050   virtual ~EcalCoder();
0051 
0052   /// can be fetched every event from the EventSetup
0053   void setPedestals(const EcalPedestals* pedestals);
0054 
0055   void setGainRatios(const EcalGainRatios* gainRatios);
0056 
0057   void setFullScaleEnergy(double EBscale, double EEscale);
0058 
0059   void setIntercalibConstants(const EcalIntercalibConstantsMC* ical);
0060 
0061   /// from EcalSamples to EcalDataFrame
0062   virtual void analogToDigital(CLHEP::HepRandomEngine*, const EcalSamples& clf, EcalDataFrame& df) const;
0063 
0064 private:
0065   /// limit on the energy scale due to the electronics range
0066   double fullScaleEnergy(const DetId& did) const;
0067 
0068   /// produce the pulse-shape
0069   void encode(const EcalSamples& ecalSamples, EcalDataFrame& df, CLHEP::HepRandomEngine*) const;
0070 
0071   //      double decode( const EcalMGPASample& sample ,
0072   //             const DetId&          detId    ) const ;
0073 
0074   /// not yet implemented
0075   //      void noisify( const EcalIntercalibConstantsMC* values ,
0076   //            int                              size     ) const ;
0077 
0078   void findPedestal(const DetId& detId, int gainId, double& pedestal, double& width) const;
0079 
0080   void findGains(const DetId& detId, double theGains[]) const;
0081 
0082   void findIntercalibConstant(const DetId& detId, double& icalconst) const;
0083 
0084   const EcalPedestals* m_peds;
0085 
0086   const EcalGainRatios* m_gainRatios;  // the electronics gains
0087 
0088   const EcalIntercalibConstantsMC* m_intercals;  //record specific for simulation of gain variation in MC
0089 
0090   double m_maxEneEB;  // max attainable energy in the ecal barrel
0091   double m_maxEneEE;  // max attainable energy in the ecal endcap
0092 
0093   bool m_addNoise;  // whether add noise to the pedestals and the gains
0094   bool m_PreMix1;   // Follow necessary steps for PreMixing input
0095 
0096   const Noisifier* m_ebCorrNoise[3];
0097   const Noisifier* m_eeCorrNoise[3];
0098 };
0099 
0100 #endif