Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "FWCore/Framework/interface/MakerMacros.h"
0002 #include "SimGeneral/MixingModule/interface/DigiAccumulatorMixModFactory.h"
0003 #include "SimCalorimetry/HGCalSimProducers/plugins/HGCDigiProducer.h"
0004 #include "FWCore/Framework/interface/stream/EDProducer.h"
0005 #include "FWCore/Framework/interface/Event.h"
0006 #include "FWCore/ServiceRegistry/interface/Service.h"
0007 #include "FWCore/Utilities/interface/RandomNumberGenerator.h"
0008 #include "FWCore/Utilities/interface/StreamID.h"
0009 
0010 //
0011 HGCDigiProducer::HGCDigiProducer(edm::ParameterSet const& pset,
0012                                  edm::ProducesCollector producesCollector,
0013                                  edm::ConsumesCollector& iC)
0014     : HGCDigiProducer(pset, iC) {
0015   premixStage1_ = pset.getParameter<bool>("premixStage1");
0016   if (premixStage1_) {
0017     producesCollector.produces<PHGCSimAccumulator>(theDigitizer_.digiCollection());
0018   } else {
0019     producesCollector.produces<HGCalDigiCollection>(theDigitizer_.digiCollection());
0020   }
0021 }
0022 
0023 HGCDigiProducer::HGCDigiProducer(edm::ParameterSet const& pset, edm::ConsumesCollector& iC)
0024     : DigiAccumulatorMixMod(), theDigitizer_(pset, iC) {}
0025 
0026 //
0027 void HGCDigiProducer::initializeEvent(edm::Event const& event, edm::EventSetup const& es) {
0028   edm::Service<edm::RandomNumberGenerator> rng;
0029   randomEngine_ = &rng->getEngine(event.streamID());
0030   theDigitizer_.initializeEvent(event, es);
0031 }
0032 
0033 //
0034 void HGCDigiProducer::finalizeEvent(edm::Event& event, edm::EventSetup const& es) {
0035   theDigitizer_.finalizeEvent(event, es, randomEngine_);
0036   randomEngine_ = nullptr;  // to precent access outside event
0037 }
0038 
0039 //
0040 void HGCDigiProducer::accumulate(edm::Event const& event, edm::EventSetup const& es) {
0041   if (premixStage1_) {
0042     theDigitizer_.accumulate_forPreMix(event, es, randomEngine_);
0043   }
0044 
0045   else {
0046     theDigitizer_.accumulate(event, es, randomEngine_);
0047   }
0048 }
0049 
0050 void HGCDigiProducer::accumulate(PileUpEventPrincipal const& event,
0051                                  edm::EventSetup const& es,
0052                                  edm::StreamID const& streamID) {
0053   if (premixStage1_) {
0054     theDigitizer_.accumulate_forPreMix(event, es, randomEngine_);
0055   } else {
0056     theDigitizer_.accumulate(event, es, randomEngine_);
0057   }
0058 }
0059 
0060 DEFINE_DIGI_ACCUMULATOR(HGCDigiProducer);