CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/SimCalorimetry/EcalSimAlgos/interface/EcalCoder.h

Go to the documentation of this file.
00001 
00002 #ifndef EcalSimAlgos_EcalCoder_h
00003 #define EcalSimAlgos_EcalCoder_h 1
00004 
00005 #include "CalibFormats/CaloObjects/interface/CaloTSamples.h"
00006 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
00007 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
00008 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
00009 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix.h"
00010 
00011 template<typename M> class CorrelatedNoisifier ;
00012 class EcalMGPASample;
00013 class EcalDataFrame;
00014 class DetId;
00015 
00016 #include<vector>
00017 
00018 /* \class EEDigitizerTraits
00019  * \brief Converts CaloDataFrame in CaloTimeSample and vice versa.
00020  *
00021  */
00022 class EcalCoder
00023 {
00024    public:
00025 
00026       typedef CaloTSamples<float,10> EcalSamples ;
00027       
00028       typedef CorrelatedNoisifier<EcalCorrMatrix> Noisifier ;
00029 
00030       enum { NBITS         =   12 , // number of available bits
00031              MAXADC        = 4095 , // 2^12 -1,  adc max range
00032              ADCGAINSWITCH = 4079 , // adc gain switch
00033              NGAINS        =    3   // number of electronic gains
00034       };
00035 
00037       EcalCoder( bool        addNoise        , 
00038                  Noisifier* ebCorrNoise0     ,
00039                  Noisifier* eeCorrNoise0 = 0 ,
00040                  Noisifier* ebCorrNoise1 = 0 ,
00041                  Noisifier* eeCorrNoise1 = 0 ,
00042                  Noisifier* ebCorrNoise2 = 0 ,
00043                  Noisifier* eeCorrNoise2 = 0   ) ; // make EE version optional for tb compatibility
00045       virtual ~EcalCoder() ;
00046 
00048       void setPedestals( const EcalPedestals* pedestals ) ;
00049 
00050       void setGainRatios( const EcalGainRatios* gainRatios ) ;
00051 
00052       void setFullScaleEnergy( double EBscale ,
00053                                double EEscale   ) ;
00054 
00055       void setIntercalibConstants( const EcalIntercalibConstantsMC* ical ) ; 
00056  
00057 
00059       virtual void analogToDigital( const EcalSamples& clf , 
00060                                     EcalDataFrame&     df    ) const;
00061  
00062    private:
00063 
00065       double fullScaleEnergy( const DetId & did ) const ;
00066 
00068       void encode( const EcalSamples& ecalSamples , 
00069                    EcalDataFrame&     df            ) const ;
00070 
00071 //      double decode( const EcalMGPASample& sample , 
00072 //                   const DetId&          detId    ) const ;
00073 
00075       //      void noisify( const EcalIntercalibConstantsMC* values ,
00076       //                    int                              size     ) const ;
00077 
00078       void findPedestal( const DetId& detId    , 
00079                          int          gainId   , 
00080                          double&      pedestal ,
00081                          double&      width      ) const ;
00082     
00083       void findGains( const DetId& detId, 
00084                       double       theGains[] ) const ;
00085 
00086       void findIntercalibConstant( const DetId& detId ,
00087                                    double&      icalconst ) const ;
00088    
00089       const EcalPedestals* m_peds ;
00090       
00091       const EcalGainRatios* m_gainRatios ; // the electronics gains
00092 
00093       const EcalIntercalibConstantsMC* m_intercals ; //record specific for simulation of gain variation in MC
00094 
00095       double m_maxEneEB ; // max attainable energy in the ecal barrel
00096       double m_maxEneEE ; // max attainable energy in the ecal endcap
00097       
00098       bool m_addNoise ;   // whether add noise to the pedestals and the gains
00099 
00100       const Noisifier* m_ebCorrNoise[3] ;
00101       const Noisifier* m_eeCorrNoise[3] ;
00102 };
00103 
00104 #endif