Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-04-12 23:30:39

0001 #include "FWCore/Framework/interface/MakerMacros.h"
0002 #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixModFactory.h"
0003 #include "SimFastTiming/FastTimingCommon/plugins/MTDDigiProducer.h"
0004 #include "FWCore/Framework/interface/Event.h"
0005 #include "FWCore/ServiceRegistry/interface/Service.h"
0006 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0007 #include "FWCore/Utilities/interface/StreamID.h"
0008 
0009 //
0010 MTDDigiProducer::MTDDigiProducer(edm::ParameterSet const& pset,
0011                                  edm::ProducesCollector producesCollector,
0012                                  edm::ConsumesCollector& iC)
0013     : DigiAccumulatorMixMod() {
0014   std::vector<std::string> psetNames;
0015 
0016   pset.getParameterSetNames(psetNames);
0017 
0018   for (const auto& psname : psetNames) {
0019     const auto& ps = pset.getParameterSet(psname);
0020     const std::string& digitizerName = ps.getParameter<std::string>("digitizerName");
0021     theDigitizers_.emplace_back(MTDDigitizerFactory::get()->create(digitizerName, ps, producesCollector, iC));
0022   }
0023 }
0024 
0025 //
0026 MTDDigiProducer::~MTDDigiProducer() {}
0027 
0028 //
0029 void MTDDigiProducer::initializeEvent(edm::Event const& event, edm::EventSetup const& es) {
0030   edm::Service<edm::RandomNumberGenerator> rng;
0031   randomEngine_ = &rng->getEngine(event.streamID());
0032   for (auto& digitizer : theDigitizers_) {
0033     digitizer->initializeEvent(event, es);
0034   }
0035 }
0036 
0037 //
0038 void MTDDigiProducer::finalizeEvent(edm::Event& event, edm::EventSetup const& es) {
0039   for (auto& digitizer : theDigitizers_) {
0040     digitizer->finalizeEvent(event, es, randomEngine_);
0041   }
0042   randomEngine_ = nullptr;  // to prevent access outside event
0043 }
0044 
0045 //
0046 void MTDDigiProducer::accumulate(edm::Event const& event, edm::EventSetup const& es) {
0047   for (auto& digitizer : theDigitizers_) {
0048     digitizer->accumulate(event, es, randomEngine_);
0049   }
0050 }
0051 
0052 void MTDDigiProducer::accumulate(PileUpEventPrincipal const& event,
0053                                  edm::EventSetup const& es,
0054                                  edm::StreamID const& streamID) {
0055   for (auto& digitizer : theDigitizers_) {
0056     digitizer->accumulate(event, es, randomEngine_);
0057   }
0058 }