Back to home page

Project CMSSW displayed by LXR

 
 

    


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

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   static constexpr int NBITS = 12,  // number of available bits
0034       MAXADC = 4095,                // 2^12 -1,  adc max range
0035       ADCGAINSWITCH = 4079,         // adc gain switch
0036       NGAINS = 3                    // number of electronic gains
0037       ;
0038 
0039   /// ctor
0040   EcalCoder(bool addNoise,
0041             bool PreMix1,
0042             Noisifier* ebCorrNoise0,
0043             Noisifier* eeCorrNoise0 = nullptr,
0044             Noisifier* ebCorrNoise1 = nullptr,
0045             Noisifier* eeCorrNoise1 = nullptr,
0046             Noisifier* ebCorrNoise2 = nullptr,
0047             Noisifier* eeCorrNoise2 = nullptr);  // make EE version optional for tb compatibility
0048   /// dtor
0049   virtual ~EcalCoder();
0050 
0051   /// can be fetched every event from the EventSetup
0052   void setPedestals(const EcalPedestals* pedestals);
0053 
0054   void setGainRatios(const EcalGainRatios* gainRatios);
0055 
0056   void setFullScaleEnergy(double EBscale, double EEscale);
0057 
0058   void setIntercalibConstants(const EcalIntercalibConstantsMC* ical);
0059 
0060   /// from EcalSamples to EcalDataFrame
0061   virtual void analogToDigital(CLHEP::HepRandomEngine*, const EcalSamples& clf, EcalDataFrame& df) const;
0062 
0063 private:
0064   /// limit on the energy scale due to the electronics range
0065   double fullScaleEnergy(const DetId& did) const;
0066 
0067   /// produce the pulse-shape
0068   void encode(const EcalSamples& ecalSamples, EcalDataFrame& df, CLHEP::HepRandomEngine*) const;
0069 
0070   //      double decode( const EcalMGPASample& sample ,
0071   //             const DetId&          detId    ) const ;
0072 
0073   /// not yet implemented
0074   //      void noisify( const EcalIntercalibConstantsMC* values ,
0075   //            int                              size     ) const ;
0076 
0077   void findPedestal(const DetId& detId, int gainId, double& pedestal, double& width) const;
0078 
0079   void findGains(const DetId& detId, double theGains[]) const;
0080 
0081   void findIntercalibConstant(const DetId& detId, double& icalconst) const;
0082 
0083   const EcalPedestals* m_peds;
0084 
0085   const EcalGainRatios* m_gainRatios;  // the electronics gains
0086 
0087   const EcalIntercalibConstantsMC* m_intercals;  //record specific for simulation of gain variation in MC
0088 
0089   double m_maxEneEB;  // max attainable energy in the ecal barrel
0090   double m_maxEneEE;  // max attainable energy in the ecal endcap
0091 
0092   bool m_addNoise;  // whether add noise to the pedestals and the gains
0093   bool m_PreMix1;   // Follow necessary steps for PreMixing input
0094 
0095   const Noisifier* m_ebCorrNoise[3];
0096   const Noisifier* m_eeCorrNoise[3];
0097 };
0098 
0099 #endif