Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/ConsumesCollector.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/ProducesCollector.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0007 #include "SimGeneral/MixingModule/interface/PileUpEventPrincipal.h"
0008 
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "DataFormats/HcalDigi/interface/HBHEDataFrame.h"
0011 #include "DataFormats/HcalDigi/interface/HFDataFrame.h"
0012 #include "DataFormats/HcalDigi/interface/HODataFrame.h"
0013 #include "DataFormats/HcalDigi/interface/HcalDigiCollections.h"
0014 #include "DataFormats/HcalDigi/interface/QIE10DataFrame.h"
0015 #include "DataFormats/HcalDigi/interface/QIE11DataFrame.h"
0016 #include "SimCalorimetry/HcalSimAlgos/interface/HcalSignalGenerator.h"
0017 #include "SimCalorimetry/HcalSimProducers/interface/HcalDigiProducer.h"
0018 
0019 #include "SimGeneral/PreMixingModule/interface/PreMixingWorker.h"
0020 #include "SimGeneral/PreMixingModule/interface/PreMixingWorkerFactory.h"
0021 
0022 class PreMixingHcalWorker : public PreMixingWorker {
0023 public:
0024   PreMixingHcalWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC);
0025   ~PreMixingHcalWorker() override = default;
0026 
0027   PreMixingHcalWorker(const PreMixingHcalWorker &) = delete;
0028   PreMixingHcalWorker &operator=(const PreMixingHcalWorker &) = delete;
0029 
0030   void beginRun(const edm::Run &run, const edm::EventSetup &ES) override;
0031   void initializeEvent(const edm::Event &e, const edm::EventSetup &ES) override;
0032   void addSignals(const edm::Event &e, const edm::EventSetup &ES) override;
0033   void addPileups(const PileUpEventPrincipal &, const edm::EventSetup &ES) override;
0034   void put(edm::Event &e, const edm::EventSetup &ES, std::vector<PileupSummaryInfo> const &ps, int bs) override;
0035 
0036 private:
0037   edm::InputTag HBHEPileInputTag_;     // InputTag for Pileup Digis collection
0038   edm::InputTag HOPileInputTag_;       // InputTag for Pileup Digis collection
0039   edm::InputTag HFPileInputTag_;       // InputTag for Pileup Digis collection
0040   edm::InputTag ZDCPileInputTag_;      // InputTag for Pileup Digis collection
0041   edm::InputTag QIE10PileInputTag_;    // InputTag for Pileup Digis collection
0042   edm::InputTag QIE11PileInputTag_;    // InputTag for Pileup Digis collection
0043   std::string HBHEDigiCollectionDM_;   // secondary name to be given to collection
0044                                        // of digis
0045   std::string HODigiCollectionDM_;     // secondary name to be given to collection of digis
0046   std::string HFDigiCollectionDM_;     // secondary name to be given to collection of digis
0047   std::string ZDCDigiCollectionDM_;    // secondary name to be given to collection of digis
0048   std::string QIE10DigiCollectionDM_;  // secondary name to be given to
0049                                        // collection of digis
0050   std::string QIE11DigiCollectionDM_;  // secondary name to be given to
0051                                        // collection of digis
0052 
0053   edm::EDGetTokenT<HBHEDigitizerTraits::DigiCollection> tok_hbhe_;
0054   edm::EDGetTokenT<HODigitizerTraits::DigiCollection> tok_ho_;
0055   edm::EDGetTokenT<HFDigitizerTraits::DigiCollection> tok_hf_;
0056   edm::EDGetTokenT<ZDCDigitizerTraits::DigiCollection> tok_zdc_;
0057   edm::EDGetTokenT<HcalQIE10DigitizerTraits::DigiCollection> tok_qie10_;
0058   edm::EDGetTokenT<HcalQIE11DigitizerTraits::DigiCollection> tok_qie11_;
0059 
0060   const edm::ESGetToken<HcalDbService, HcalDbRecord> tokDB_;
0061 
0062   HcalDigiProducer myHcalDigitizer_;
0063   HBHESignalGenerator theHBHESignalGenerator;
0064   HOSignalGenerator theHOSignalGenerator;
0065   HFSignalGenerator theHFSignalGenerator;
0066   ZDCSignalGenerator theZDCSignalGenerator;
0067   QIE10SignalGenerator theQIE10SignalGenerator;
0068   QIE11SignalGenerator theQIE11SignalGenerator;
0069 };
0070 
0071 // Constructor
0072 PreMixingHcalWorker::PreMixingHcalWorker(const edm::ParameterSet &ps,
0073                                          edm::ProducesCollector producesCollector,
0074                                          edm::ConsumesCollector &&iC)
0075     : HBHEPileInputTag_(ps.getParameter<edm::InputTag>("HBHEPileInputTag")),
0076       HOPileInputTag_(ps.getParameter<edm::InputTag>("HOPileInputTag")),
0077       HFPileInputTag_(ps.getParameter<edm::InputTag>("HFPileInputTag")),
0078       ZDCPileInputTag_(ps.getParameter<edm::InputTag>("ZDCPileInputTag")),
0079       QIE10PileInputTag_(ps.getParameter<edm::InputTag>("QIE10PileInputTag")),
0080       QIE11PileInputTag_(ps.getParameter<edm::InputTag>("QIE11PileInputTag")),
0081       tokDB_(iC.esConsumes()),
0082       myHcalDigitizer_(ps, iC) {
0083   tok_hbhe_ = iC.consumes<HBHEDigitizerTraits::DigiCollection>(HBHEPileInputTag_);
0084   tok_ho_ = iC.consumes<HODigitizerTraits::DigiCollection>(HOPileInputTag_);
0085   tok_hf_ = iC.consumes<HFDigitizerTraits::DigiCollection>(HFPileInputTag_);
0086   tok_zdc_ = iC.consumes<ZDCDigitizerTraits::DigiCollection>(ZDCPileInputTag_);
0087   tok_qie10_ = iC.consumes<HcalQIE10DigitizerTraits::DigiCollection>(QIE10PileInputTag_);
0088   tok_qie11_ = iC.consumes<HcalQIE11DigitizerTraits::DigiCollection>(QIE11PileInputTag_);
0089 
0090   theHBHESignalGenerator = HBHESignalGenerator(HBHEPileInputTag_, tok_hbhe_);
0091   theHOSignalGenerator = HOSignalGenerator(HOPileInputTag_, tok_ho_);
0092   theHFSignalGenerator = HFSignalGenerator(HFPileInputTag_, tok_hf_);
0093   theZDCSignalGenerator = ZDCSignalGenerator(ZDCPileInputTag_, tok_zdc_);
0094   theQIE10SignalGenerator = QIE10SignalGenerator(QIE10PileInputTag_, tok_qie10_);
0095   theQIE11SignalGenerator = QIE11SignalGenerator(QIE11PileInputTag_, tok_qie11_);
0096 
0097   // Hcal
0098   // Signal inputs now handled by HcalDigitizer - gets pSimHits directly
0099 
0100   HBHEDigiCollectionDM_ = ps.getParameter<std::string>("HBHEDigiCollectionDM");
0101   HODigiCollectionDM_ = ps.getParameter<std::string>("HODigiCollectionDM");
0102   HFDigiCollectionDM_ = ps.getParameter<std::string>("HFDigiCollectionDM");
0103   ZDCDigiCollectionDM_ = ps.getParameter<std::string>("ZDCDigiCollectionDM");
0104   QIE10DigiCollectionDM_ = ps.getParameter<std::string>("QIE10DigiCollectionDM");
0105   QIE11DigiCollectionDM_ = ps.getParameter<std::string>("QIE11DigiCollectionDM");
0106 
0107   producesCollector.produces<HBHEDigiCollection>();
0108   producesCollector.produces<HODigiCollection>();
0109   producesCollector.produces<HFDigiCollection>();
0110   producesCollector.produces<ZDCDigiCollection>();
0111 
0112   producesCollector.produces<QIE10DigiCollection>("HFQIE10DigiCollection");
0113   producesCollector.produces<QIE11DigiCollection>("HBHEQIE11DigiCollection");
0114 
0115   // initialize HcalDigitizer here...
0116   myHcalDigitizer_.setHBHENoiseSignalGenerator(&theHBHESignalGenerator);
0117   myHcalDigitizer_.setHFNoiseSignalGenerator(&theHFSignalGenerator);
0118   myHcalDigitizer_.setHONoiseSignalGenerator(&theHOSignalGenerator);
0119   myHcalDigitizer_.setZDCNoiseSignalGenerator(&theZDCSignalGenerator);
0120   myHcalDigitizer_.setQIE10NoiseSignalGenerator(&theQIE10SignalGenerator);
0121   myHcalDigitizer_.setQIE11NoiseSignalGenerator(&theQIE11SignalGenerator);
0122 }
0123 
0124 void PreMixingHcalWorker::beginRun(const edm::Run &run, const edm::EventSetup &ES) {
0125   myHcalDigitizer_.beginRun(run, ES);
0126 }
0127 
0128 void PreMixingHcalWorker::initializeEvent(const edm::Event &e, const edm::EventSetup &ES) {
0129   myHcalDigitizer_.initializeEvent(e, ES);
0130 }
0131 
0132 void PreMixingHcalWorker::addSignals(const edm::Event &e, const edm::EventSetup &ES) {
0133   myHcalDigitizer_.accumulate(e, ES);
0134 }
0135 
0136 void PreMixingHcalWorker::addPileups(const PileUpEventPrincipal &pep, const edm::EventSetup &ES) {
0137   const auto &ep = pep.principal();
0138   LogDebug("PreMixingHcalWorker") << "\n===============> adding pileups from event  " << ep.id()
0139                                   << " for bunchcrossing " << pep.bunchCrossing();
0140 
0141   theHBHESignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0142   theHOSignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0143   theHFSignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0144   theZDCSignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0145   theQIE10SignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0146   theQIE11SignalGenerator.initializeEvent(&ep, &ES, tokDB_);
0147 
0148   // put digis from pileup event into digitizer
0149 
0150   const auto *mcc = pep.moduleCallingContext();
0151   theHBHESignalGenerator.fill(mcc);
0152   theHOSignalGenerator.fill(mcc);
0153   theHFSignalGenerator.fill(mcc);
0154   theQIE10SignalGenerator.fill(mcc);
0155   theQIE11SignalGenerator.fill(mcc);
0156 }
0157 
0158 void PreMixingHcalWorker::put(edm::Event &e,
0159                               const edm::EventSetup &ES,
0160                               std::vector<PileupSummaryInfo> const &ps,
0161                               int bs) {
0162   myHcalDigitizer_.finalizeEvent(e, ES);
0163 }
0164 
0165 DEFINE_PREMIXING_WORKER(PreMixingHcalWorker);