Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #ifndef HcalSimProducers_HcalDigitizer_h
0002 #define HcalSimProducers_HcalDigitizer_h
0003 
0004 #include "CalibCalorimetry/HcalAlgos/interface/HcalTimeSlew.h"
0005 #include "CalibFormats/HcalObjects/interface/HcalDbRecord.h"
0006 #include "CondFormats/DataRecord/interface/HBHEDarkeningRecord.h"
0007 #include "CondFormats/DataRecord/interface/HcalTimeSlewRecord.h"
0008 #include "CondFormats/HcalObjects/interface/HBHEDarkening.h"
0009 #include "DataFormats/DetId/interface/DetId.h"
0010 #include "CalibCalorimetry/HcalAlgos/interface/HFRecalibration.h"
0011 #include "FWCore/Framework/interface/ESWatcher.h"
0012 #include "FWCore/Framework/interface/Frameworkfwd.h"
0013 #include "FWCore/Utilities/interface/EDGetToken.h"
0014 #include "Geometry/CaloGeometry/interface/CaloGeometry.h"
0015 #include "Geometry/HcalCommonData/interface/HcalDDDRecConstants.h"
0016 #include "Geometry/HcalCommonData/interface/HcalHitRelabeller.h"
0017 #include "Geometry/Records/interface/CaloGeometryRecord.h"
0018 #include "Geometry/Records/interface/HcalRecNumberingRecord.h"
0019 #include "SimCalorimetry/CaloSimAlgos/interface/CaloTDigitizer.h"
0020 #include "SimCalorimetry/HcalSimAlgos/interface/HcalDigitizerTraits.h"
0021 #include "SimCalorimetry/HcalSimAlgos/interface/HcalHitFilter.h"
0022 #include "SimCalorimetry/HcalSimAlgos/interface/HcalQIE1011Traits.h"
0023 #include "SimCalorimetry/HcalSimAlgos/interface/HcalShapes.h"
0024 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSimParameterMap.h"
0025 #include "SimCalorimetry/HcalSimAlgos/interface/ZDCHitFilter.h"
0026 #include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
0027 
0028 #include <vector>
0029 
0030 class CaloHitResponse;
0031 class HcalSiPMHitResponse;
0032 class HcalAmplifier;
0033 class HPDIonFeedbackSim;
0034 class HcalCoderFactory;
0035 class HcalElectronicsSim;
0036 class HcalTimeSlewSim;
0037 class HcalBaseSignalGenerator;
0038 class HcalShapes;
0039 class PileUpEventPrincipal;
0040 class HcalTopology;
0041 
0042 namespace CLHEP {
0043   class HepRandomEngine;
0044 }
0045 
0046 class HcalDigitizer {
0047 public:
0048   explicit HcalDigitizer(const edm::ParameterSet &ps, edm::ConsumesCollector &iC);
0049   virtual ~HcalDigitizer();
0050 
0051   /**Produces the EDM products,*/
0052   void initializeEvent(edm::Event const &e, edm::EventSetup const &c);
0053   void accumulate(edm::Event const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *);
0054   void accumulate(PileUpEventPrincipal const &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *);
0055   void finalizeEvent(edm::Event &e, edm::EventSetup const &c, CLHEP::HepRandomEngine *);
0056 
0057   void setHBHENoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0058   void setHFNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0059   void setHONoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0060   void setZDCNoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0061   void setQIE10NoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0062   void setQIE11NoiseSignalGenerator(HcalBaseSignalGenerator *noiseGenerator);
0063 
0064 private:
0065   void setup(const edm::EventSetup &es);
0066   void accumulateCaloHits(edm::Handle<std::vector<PCaloHit>> const &hcalHits,
0067                           edm::Handle<std::vector<PCaloHit>> const &zdcHits,
0068                           int bunchCrossing,
0069                           CLHEP::HepRandomEngine *,
0070                           const HcalTopology *h);
0071 
0072   /// some hits in each subdetector, just for testing purposes
0073   void fillFakeHits();
0074   /// make sure the digitizer has the correct list of all cells that
0075   /// exist in the geometry
0076   void checkGeometry(const edm::EventSetup &eventSetup);
0077 
0078   void updateGeometry(const edm::EventSetup &eventSetup);
0079 
0080   void buildHOSiPMCells(const std::vector<DetId> &allCells, const edm::EventSetup &eventSetup);
0081   void buildHFQIECells(const std::vector<DetId> &allCells, const edm::EventSetup &eventSetup);
0082   void buildHBHEQIECells(const std::vector<DetId> &allCells, const edm::EventSetup &eventSetup);
0083 
0084   // function to evaluate aging at the digi level
0085   void darkening(std::vector<PCaloHit> &hcalHits);
0086 
0087   const edm::ESGetToken<HcalDbService, HcalDbRecord> conditionsToken_;
0088   const edm::ESGetToken<HcalTopology, HcalRecNumberingRecord> topoToken_;
0089   edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> m_HBDarkeningToken;
0090   edm::ESGetToken<HBHEDarkening, HBHEDarkeningRecord> m_HEDarkeningToken;
0091   const edm::ESGetToken<HcalTimeSlew, HcalTimeSlewRecord> hcalTimeSlew_delay_token_;
0092   const edm::ESGetToken<CaloGeometry, CaloGeometryRecord> theGeometryToken;
0093   const edm::ESGetToken<HcalDDDRecConstants, HcalRecNumberingRecord> theRecNumberToken;
0094   const edm::ESGetToken<HcalQIETypes, HcalQIETypesRcd> qieTypesToken_;
0095   edm::ESGetToken<HcalMCParams, HcalMCParamsRcd> mcParamsToken_;
0096   edm::ESWatcher<CaloGeometryRecord> theGeometryWatcher_;
0097   edm::ESWatcher<HcalRecNumberingRecord> theRecNumberWatcher_;
0098 
0099   const CaloGeometry *theGeometry;
0100   const HcalDDDRecConstants *theRecNumber;
0101 
0102   /** Reconstruction algorithm*/
0103   typedef CaloTDigitizer<HBHEDigitizerTraits, CaloTDigitizerQIE8Run> HBHEDigitizer;
0104   typedef CaloTDigitizer<HODigitizerTraits, CaloTDigitizerQIE8Run> HODigitizer;
0105   typedef CaloTDigitizer<HFDigitizerTraits, CaloTDigitizerQIE8Run> HFDigitizer;
0106   typedef CaloTDigitizer<ZDCDigitizerTraits, CaloTDigitizerQIE8Run> ZDCDigitizer;
0107   typedef CaloTDigitizer<HcalQIE10DigitizerTraits, CaloTDigitizerQIE1011Run> QIE10Digitizer;
0108   typedef CaloTDigitizer<HcalQIE11DigitizerTraits, CaloTDigitizerQIE1011Run> QIE11Digitizer;
0109 
0110   HcalSimParameterMap theParameterMap;
0111   HcalShapes theShapes;
0112 
0113   std::unique_ptr<CaloHitResponse> theHBHEResponse;
0114   std::unique_ptr<HcalSiPMHitResponse> theHBHESiPMResponse;
0115   std::unique_ptr<CaloHitResponse> theHOResponse;
0116   std::unique_ptr<HcalSiPMHitResponse> theHOSiPMResponse;
0117   std::unique_ptr<CaloHitResponse> theHFResponse;
0118   std::unique_ptr<CaloHitResponse> theHFQIE10Response;
0119   std::unique_ptr<CaloHitResponse> theZDCResponse;
0120 
0121   // we need separate amplifiers (and electronicssims)
0122   // because they might have separate noise generators
0123   std::unique_ptr<HcalAmplifier> theHBHEAmplifier;
0124   std::unique_ptr<HcalAmplifier> theHFAmplifier;
0125   std::unique_ptr<HcalAmplifier> theHOAmplifier;
0126   std::unique_ptr<HcalAmplifier> theZDCAmplifier;
0127   std::unique_ptr<HcalAmplifier> theHFQIE10Amplifier;
0128   std::unique_ptr<HcalAmplifier> theHBHEQIE11Amplifier;
0129 
0130   std::unique_ptr<HPDIonFeedbackSim> theIonFeedback;
0131   std::unique_ptr<HcalCoderFactory> theCoderFactory;
0132 
0133   std::unique_ptr<HcalElectronicsSim> theHBHEElectronicsSim;
0134   std::unique_ptr<HcalElectronicsSim> theHFElectronicsSim;
0135   std::unique_ptr<HcalElectronicsSim> theHOElectronicsSim;
0136   std::unique_ptr<HcalElectronicsSim> theZDCElectronicsSim;
0137   std::unique_ptr<HcalElectronicsSim> theHFQIE10ElectronicsSim;
0138   std::unique_ptr<HcalElectronicsSim> theHBHEQIE11ElectronicsSim;
0139 
0140   HBHEHitFilter theHBHEHitFilter;
0141   HBHEHitFilter theHBHEQIE11HitFilter;
0142   HFHitFilter theHFHitFilter;
0143   HFHitFilter theHFQIE10HitFilter;
0144   HOHitFilter theHOHitFilter;
0145   HOHitFilter theHOSiPMHitFilter;
0146   ZDCHitFilter theZDCHitFilter;
0147 
0148   std::unique_ptr<HcalTimeSlewSim> theTimeSlewSim;
0149 
0150   std::unique_ptr<HBHEDigitizer> theHBHEDigitizer;
0151   std::unique_ptr<HODigitizer> theHODigitizer;
0152   std::unique_ptr<HODigitizer> theHOSiPMDigitizer;
0153   std::unique_ptr<HFDigitizer> theHFDigitizer;
0154   std::unique_ptr<ZDCDigitizer> theZDCDigitizer;
0155   std::unique_ptr<QIE10Digitizer> theHFQIE10Digitizer;
0156   std::unique_ptr<QIE11Digitizer> theHBHEQIE11Digitizer;
0157   std::unique_ptr<HcalHitRelabeller> theRelabeller;
0158 
0159   // need to cache some DetIds for the digitizers,
0160   // if they don't come straight from the geometry
0161   std::vector<DetId> hbheCells;
0162   std::vector<DetId> theHBHEQIE8DetIds, theHBHEQIE11DetIds;
0163   std::vector<DetId> theHOHPDDetIds;
0164   std::vector<DetId> theHOSiPMDetIds;
0165   std::vector<DetId> theHFQIE8DetIds, theHFQIE10DetIds;
0166 
0167   bool isZDC, isHCAL, zdcgeo, hbhegeo, hogeo, hfgeo;
0168   bool testNumbering_;
0169   bool doHFWindow_;
0170   bool killHE_;
0171   bool debugCS_;
0172   bool ignoreTime_;
0173   bool injectTestHits_;
0174 
0175   std::string hitsProducer_;
0176 
0177   int theHOSiPMCode;
0178 
0179   double deliveredLumi;
0180   bool agingFlagHB, agingFlagHE;
0181 
0182   edm::EDGetTokenT<std::vector<PCaloHit>> zdcToken_;
0183   edm::EDGetTokenT<std::vector<PCaloHit>> hcalToken_;
0184   const HBHEDarkening *m_HBDarkening;
0185   const HBHEDarkening *m_HEDarkening;
0186   std::unique_ptr<HFRecalibration> m_HFRecalibration;
0187 
0188   const HcalTimeSlew *hcalTimeSlew_delay_;
0189 
0190   std::vector<double> injectedHitsEnergy_;
0191   std::vector<double> injectedHitsTime_;
0192   std::vector<int> injectedHitsCells_;
0193   std::vector<PCaloHit> injectedHits_;
0194 };
0195 
0196 #endif