Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-10-08 23:10:03

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