Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-10 10:03:12

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/EcalDigi/interface/EBDataFrame.h"
0011 #include "DataFormats/EcalDigi/interface/EEDataFrame.h"
0012 #include "DataFormats/EcalDigi/interface/ESDataFrame.h"
0013 #include "DataFormats/EcalDigi/interface/EcalDigiCollections.h"
0014 #include "SimCalorimetry/EcalSimAlgos/interface/EcalSignalGenerator.h"
0015 #include "SimCalorimetry/EcalSimProducers/interface/EcalDigiProducer.h"
0016 
0017 #include "SimGeneral/PreMixingModule/interface/PreMixingWorker.h"
0018 #include "SimGeneral/PreMixingModule/interface/PreMixingWorkerFactory.h"
0019 
0020 class PreMixingEcalWorker : public PreMixingWorker {
0021 public:
0022   PreMixingEcalWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC);
0023   ~PreMixingEcalWorker() override = default;
0024 
0025   PreMixingEcalWorker(const PreMixingEcalWorker &) = delete;
0026   PreMixingEcalWorker &operator=(const PreMixingEcalWorker &) = delete;
0027 
0028   void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override;
0029 
0030   void initializeEvent(edm::Event const &e, edm::EventSetup const &ES) override;
0031   void addSignals(edm::Event const &e, edm::EventSetup const &ES) override;
0032   void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &es) override;
0033   void put(edm::Event &e, edm::EventSetup const &iSetup, std::vector<PileupSummaryInfo> const &ps, int bs) override;
0034 
0035 private:
0036   edm::InputTag EBPileInputTag_;  // InputTag for Pileup Digis collection
0037   edm::InputTag EEPileInputTag_;  // InputTag for Pileup Digis collection
0038   edm::InputTag ESPileInputTag_;  // InputTag for Pileup Digis collection
0039 
0040   std::string EBDigiCollectionDM_;  // secondary name to be given to collection of digis
0041   std::string EEDigiCollectionDM_;  // secondary name to be given to collection of digis
0042   std::string ESDigiCollectionDM_;  // secondary name to be given to collection of digis
0043 
0044   const double m_EBs25notCont;
0045   const double m_EEs25notCont;
0046   const double m_peToABarrel;
0047   const double m_peToAEndcap;
0048   const bool m_timeDependent;
0049 
0050   EBSignalGenerator theEBSignalGenerator;
0051   EESignalGenerator theEESignalGenerator;
0052   ESSignalGenerator theESSignalGenerator;
0053   EcalDigiProducer myEcalDigitizer_;
0054 };
0055 
0056 // Constructor
0057 PreMixingEcalWorker::PreMixingEcalWorker(const edm::ParameterSet &ps,
0058                                          edm::ProducesCollector producesCollector,
0059                                          edm::ConsumesCollector &&iC)
0060     : EBPileInputTag_(ps.getParameter<edm::InputTag>("EBPileInputTag")),
0061       EEPileInputTag_(ps.getParameter<edm::InputTag>("EEPileInputTag")),
0062       ESPileInputTag_(ps.getParameter<edm::InputTag>("ESPileInputTag")),
0063       m_EBs25notCont(ps.getParameter<double>("EBs25notContainment")),
0064       m_EEs25notCont(ps.getParameter<double>("EEs25notContainment")),
0065       m_peToABarrel(ps.getParameter<double>("photoelectronsToAnalogBarrel")),
0066       m_peToAEndcap(ps.getParameter<double>("photoelectronsToAnalogEndcap")),
0067       m_timeDependent(ps.getParameter<bool>("timeDependent")),
0068       theEBSignalGenerator(
0069           iC, EBPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent),
0070       theEESignalGenerator(
0071           iC, EEPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap, m_timeDependent),
0072       theESSignalGenerator(iC, ESPileInputTag_, m_EBs25notCont, m_EEs25notCont, m_peToABarrel, m_peToAEndcap),
0073       myEcalDigitizer_(ps, iC) {
0074   EBDigiCollectionDM_ = ps.getParameter<std::string>("EBDigiCollectionDM");
0075   EEDigiCollectionDM_ = ps.getParameter<std::string>("EEDigiCollectionDM");
0076   ESDigiCollectionDM_ = ps.getParameter<std::string>("ESDigiCollectionDM");
0077 
0078   producesCollector.produces<EBDigiCollection>(EBDigiCollectionDM_);
0079   producesCollector.produces<EEDigiCollection>(EEDigiCollectionDM_);
0080   producesCollector.produces<ESDigiCollection>(ESDigiCollectionDM_);
0081 
0082   myEcalDigitizer_.setEBNoiseSignalGenerator(&theEBSignalGenerator);
0083   myEcalDigitizer_.setEENoiseSignalGenerator(&theEESignalGenerator);
0084   myEcalDigitizer_.setESNoiseSignalGenerator(&theESSignalGenerator);
0085 }
0086 
0087 void PreMixingEcalWorker::initializeEvent(const edm::Event &e, const edm::EventSetup &ES) {
0088   myEcalDigitizer_.initializeEvent(e, ES);
0089 }
0090 
0091 void PreMixingEcalWorker::addSignals(const edm::Event &e, const edm::EventSetup &ES) {
0092   myEcalDigitizer_.accumulate(e, ES);
0093 }
0094 
0095 void PreMixingEcalWorker::addPileups(const PileUpEventPrincipal &pep, const edm::EventSetup &ES) {
0096   LogDebug("PreMixingEcalWorker") << "\n===============> adding pileups from event  " << pep.principal().id()
0097                                   << " for bunchcrossing " << pep.bunchCrossing();
0098 
0099   theEBSignalGenerator.initializeEvent(&pep.principal(), &ES);
0100   theEESignalGenerator.initializeEvent(&pep.principal(), &ES);
0101   theESSignalGenerator.initializeEvent(&pep.principal(), &ES);
0102 
0103   // add noise signals using incoming digis
0104   theEBSignalGenerator.fill(pep.moduleCallingContext());
0105   theEESignalGenerator.fill(pep.moduleCallingContext());
0106   theESSignalGenerator.fill(pep.moduleCallingContext());
0107 }
0108 
0109 void PreMixingEcalWorker::put(edm::Event &e,
0110                               const edm::EventSetup &ES,
0111                               std::vector<PileupSummaryInfo> const &ps,
0112                               int bs) {
0113   myEcalDigitizer_.finalizeEvent(e, ES);
0114 }
0115 
0116 void PreMixingEcalWorker::beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) {
0117   myEcalDigitizer_.beginLuminosityBlock(lumi, setup);
0118 }
0119 
0120 DEFINE_PREMIXING_WORKER(PreMixingEcalWorker);