Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-05-05 01:48:36

0001 #ifndef SimCalorimetry_EcalSimProducers_EcalDigiProducer_h
0002 #define SimCalorimetry_EcalSimProducers_EcalDigiProducer_h
0003 
0004 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbRecord.h"
0005 #include "CalibCalorimetry/EcalLaserCorrection/interface/EcalLaserDbService.h"
0006 #include "CondFormats/DataRecord/interface/EcalADCToGeVConstantRcd.h"
0007 #include "CondFormats/DataRecord/interface/EcalGainRatiosRcd.h"
0008 #include "CondFormats/DataRecord/interface/EcalIntercalibConstantsMCRcd.h"
0009 #include "CondFormats/DataRecord/interface/ESGainRcd.h"
0010 #include "CondFormats/DataRecord/interface/ESIntercalibConstantsRcd.h"
0011 #include "CondFormats/DataRecord/interface/ESMIPToGeVConstantRcd.h"
0012 #include "CondFormats/DataRecord/interface/ESPedestalsRcd.h"
0013 #include "CondFormats/DataRecord/interface/EcalPedestalsRcd.h"
0014 #include "CondFormats/EcalObjects/interface/EcalADCToGeVConstant.h"
0015 #include "CondFormats/EcalObjects/interface/EcalGainRatios.h"
0016 #include "CondFormats/EcalObjects/interface/EcalIntercalibConstantsMC.h"
0017 #include "CondFormats/EcalObjects/interface/EcalPedestals.h"
0018 #include "CondFormats/ESObjects/interface/ESGain.h"
0019 #include "CondFormats/ESObjects/interface/ESIntercalibConstants.h"
0020 #include "CondFormats/ESObjects/interface/ESMIPToGeVConstant.h"
0021 #include "CondFormats/ESObjects/interface/ESPedestals.h"
0022 #include "DataFormats/Math/interface/Error.h"
0023 #include "CalibFormats/CaloObjects/interface/CaloTSamples.h"
0024 #include "FWCore/Framework/interface/ESWatcher.h"
0025 #include "FWCore/Framework/interface/ProducesCollector.h"
0026 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0027 #include "SimCalorimetry/EcalSimAlgos/interface/APDShape.h"
0028 #include "SimCalorimetry/EcalSimAlgos/interface/EBShape.h"
0029 #include "SimCalorimetry/EcalSimAlgos/interface/EEShape.h"
0030 #include "SimCalorimetry/EcalSimAlgos/interface/EcalElectronicsSim.h"
0031 #include "SimCalorimetry/EcalSimAlgos/interface/ESElectronicsSim.h"
0032 #include "SimCalorimetry/EcalSimAlgos/interface/ESShape.h"
0033 #include "SimCalorimetry/EcalSimAlgos/interface/EcalCorrelatedNoiseMatrix.h"
0034 #include "SimGeneral/NoiseGenerators/interface/CorrelatedNoisifier.h"
0035 
0036 #include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h"
0037 #include "SimCalorimetry/EcalSimAlgos/interface/EcalDigitizerTraits.h"
0038 #include "SimCalorimetry/EcalSimAlgos/interface/EcalTDigitizer.h"
0039 #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixMod.h"
0040 
0041 #include "SimCalorimetry/EcalSimAlgos/interface/EBHitResponse.h"
0042 #include "SimDataFormats/CaloHit/interface/PCaloHit.h"
0043 #include <vector>
0044 
0045 typedef EcalTDigitizer<EBDigitizerTraits> EBDigitizer;
0046 typedef EcalTDigitizer<EEDigitizerTraits> EEDigitizer;
0047 typedef CaloTDigitizer<ESOldDigitizerTraits> ESOldDigitizer;
0048 
0049 class ESDigitizer;
0050 
0051 class APDSimParameters;
0052 class EEHitResponse;
0053 class ESHitResponse;
0054 class CaloHitResponse;
0055 class EcalSimParameterMap;
0056 class EcalCoder;
0057 class ESElectronicsSim;
0058 class ESElectronicsSimFast;
0059 class EcalBaseSignalGenerator;
0060 class CaloGeometry;
0061 class EBDigiCollection;
0062 class EEDigiCollection;
0063 class ESDigiCollection;
0064 class PileUpEventPrincipal;
0065 
0066 namespace edm {
0067   class ConsumesCollector;
0068   class Event;
0069   class EventSetup;
0070   template <typename T>
0071   class Handle;
0072   class ParameterSet;
0073   class StreamID;
0074 }  // namespace edm
0075 
0076 namespace CLHEP {
0077   class HepRandomEngine;
0078 }
0079 
0080 class EcalDigiProducer : public DigiAccumulatorMixMod {
0081 public:
0082   EcalDigiProducer(const edm::ParameterSet &params, edm::ProducesCollector, edm::ConsumesCollector &iC);
0083   EcalDigiProducer(const edm::ParameterSet &params, edm::ConsumesCollector &iC);
0084   ~EcalDigiProducer() override;
0085 
0086   void initializeEvent(edm::Event const &e, edm::EventSetup const &c) override;
0087   void accumulate(edm::Event const &e, edm::EventSetup const &c) override;
0088   void accumulate(PileUpEventPrincipal const &e, edm::EventSetup const &c, edm::StreamID const &) override;
0089   void finalizeEvent(edm::Event &e, edm::EventSetup const &c) override;
0090   void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override;
0091 
0092   void setEBNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator);
0093   void setEENoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator);
0094   void setESNoiseSignalGenerator(EcalBaseSignalGenerator *noiseGenerator);
0095 
0096 private:
0097   virtual void cacheEBDigis(const EBDigiCollection *ebDigiPtr) const {}
0098   virtual void cacheEEDigis(const EEDigiCollection *eeDigiPtr) const {}
0099 
0100   typedef edm::Handle<std::vector<PCaloHit>> HitsHandle;
0101   void accumulateCaloHits(HitsHandle const &ebHandle,
0102                           HitsHandle const &eeHandle,
0103                           HitsHandle const &esHandle,
0104                           int bunchCrossing);
0105 
0106   void checkGeometry(const edm::EventSetup &eventSetup);
0107 
0108   void updateGeometry();
0109 
0110   void checkCalibrations(const edm::Event &event, const edm::EventSetup &eventSetup);
0111 
0112   APDShape m_APDShape;
0113   EBShape m_EBShape;
0114   EEShape m_EEShape;
0115   ESShape m_ESShape;  // no const because gain must be set
0116 
0117   const std::string m_EBdigiCollection;
0118   const std::string m_EEdigiCollection;
0119   const std::string m_ESdigiCollection;
0120   const std::string m_hitsProducerTag;
0121 
0122   const edm::EDGetTokenT<std::vector<PCaloHit>> m_HitsEBToken_;
0123   const edm::EDGetTokenT<std::vector<PCaloHit>> m_HitsEEToken_;
0124   const edm::EDGetTokenT<std::vector<PCaloHit>> m_HitsESToken_;
0125 
0126   const edm::ESGetToken<EcalPedestals, EcalPedestalsRcd> m_pedestalsToken;
0127   const edm::ESGetToken<EcalIntercalibConstantsMC, EcalIntercalibConstantsMCRcd> m_icalToken;
0128   const edm::ESGetToken<EcalLaserDbService, EcalLaserDbRecord> m_laserToken;
0129   const edm::ESGetToken<EcalADCToGeVConstant, EcalADCToGeVConstantRcd> m_agcToken;
0130   const edm::ESGetToken<EcalGainRatios, EcalGainRatiosRcd> m_grToken;
0131   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> m_geometryToken;
0132   edm::ESGetToken<ESGain, ESGainRcd> m_esGainToken;
0133   edm::ESGetToken<ESMIPToGeVConstant, ESMIPToGeVConstantRcd> m_esMIPToGeVToken;
0134   edm::ESGetToken<ESPedestals, ESPedestalsRcd> m_esPedestalsToken;
0135   edm::ESGetToken<ESIntercalibConstants, ESIntercalibConstantsRcd> m_esMIPsToken;
0136   edm::ESWatcher<CaloGeometryRecord> m_geometryWatcher;
0137 
0138   bool m_useLCcorrection;
0139 
0140   const bool m_apdSeparateDigi;
0141 
0142   const double m_EBs25notCont;
0143   const double m_EEs25notCont;
0144 
0145   const unsigned int m_readoutFrameSize;
0146 
0147 protected:
0148   std::unique_ptr<const EcalSimParameterMap> m_ParameterMap;
0149 
0150 private:
0151   const std::string m_apdDigiTag;
0152   std::unique_ptr<const APDSimParameters> m_apdParameters;
0153 
0154   std::unique_ptr<EBHitResponse> m_APDResponse;
0155 
0156 protected:
0157   std::unique_ptr<EBHitResponse> m_EBResponse;
0158   std::unique_ptr<EEHitResponse> m_EEResponse;
0159 
0160 private:
0161   std::unique_ptr<ESHitResponse> m_ESResponse;
0162   std::unique_ptr<CaloHitResponse> m_ESOldResponse;
0163 
0164   const bool m_addESNoise;
0165   const bool m_PreMix1;
0166   const bool m_PreMix2;
0167 
0168   const bool m_doFastES;
0169 
0170   const bool m_doEB, m_doEE, m_doES;
0171 
0172   std::unique_ptr<ESElectronicsSim> m_ESElectronicsSim;
0173   std::unique_ptr<ESOldDigitizer> m_ESOldDigitizer;
0174   std::unique_ptr<ESElectronicsSimFast> m_ESElectronicsSimFast;
0175   std::unique_ptr<ESDigitizer> m_ESDigitizer;
0176 
0177   std::unique_ptr<EBDigitizer> m_APDDigitizer;
0178   std::unique_ptr<EBDigitizer> m_BarrelDigitizer;
0179   std::unique_ptr<EEDigitizer> m_EndcapDigitizer;
0180 
0181   typedef CaloTSamples<float, 10> EcalSamples;
0182 
0183   typedef EcalElectronicsSim<EcalCoder, EcalSamples, EcalDataFrame> EcalElectronicsSim_Ph1;
0184   std::unique_ptr<EcalElectronicsSim_Ph1> m_ElectronicsSim;
0185   std::unique_ptr<EcalCoder> m_Coder;
0186 
0187   std::unique_ptr<EcalElectronicsSim_Ph1> m_APDElectronicsSim;
0188   std::unique_ptr<EcalCoder> m_APDCoder;
0189 
0190   const CaloGeometry *m_Geometry;
0191 
0192   std::array<std::unique_ptr<CorrelatedNoisifier<EcalCorrMatrix>>, 3> m_EBCorrNoise;
0193   std::array<std::unique_ptr<CorrelatedNoisifier<EcalCorrMatrix>>, 3> m_EECorrNoise;
0194 
0195   CLHEP::HepRandomEngine *randomEngine_ = nullptr;
0196 };
0197 
0198 #endif