CMS 3D CMS Logo

PreMixingMuonWorker.h
Go to the documentation of this file.
1 #ifndef SimGeneral_PreMixingModule_PreMixingMuonWorker_h
2 #define SimGeneral_PreMixingModule_PreMixingMuonWorker_h
3 
10 
13 
14 template <typename DigiCollection>
16 public:
18  edm::ProducesCollector producesCollector,
20  : PreMixingMuonWorker(ps, producesCollector, iC) {}
22  ~PreMixingMuonWorker() override = default;
23 
24  void initializeEvent(edm::Event const& iEvent, edm::EventSetup const& iSetup) override {}
25  void addSignals(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
26  void addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& iSetup) override;
28  edm::EventSetup const& iSetup,
29  std::vector<PileupSummaryInfo> const& ps,
30  int bunchSpacing) override {
31  put(iEvent);
32  }
33 
34  void put(edm::Event& iEvent);
35 
36 private:
39  std::string collectionDM_; // secondary name to be given to new digis
40 
41  std::unique_ptr<DigiCollection> accumulated_;
42 };
43 
44 template <typename DigiCollection>
46  edm::ProducesCollector producesCollector,
48  : signalToken_(iC.consumes<DigiCollection>(ps.getParameter<edm::InputTag>("digiTagSig"))),
49  pileupTag_(ps.getParameter<edm::InputTag>("pileInputTag")),
50  collectionDM_(ps.getParameter<std::string>("collectionDM")) {
51  producesCollector.produces<DigiCollection>(collectionDM_);
52 }
53 
54 template <typename DigiCollection>
57  iEvent.getByToken(signalToken_, digis);
58 
59  accumulated_ = std::make_unique<DigiCollection>(*digis); // for signal we can just copy
60 }
61 
62 template <typename DigiCollection>
65  pep.getByLabel(pileupTag_, digis);
66  for (const auto& elem : *digis) {
67  accumulated_->put(elem.second, elem.first);
68  }
69 }
70 
71 template <typename DigiCollection>
73  iEvent.put(std::move(accumulated_), collectionDM_);
74 }
75 
76 #endif
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
std::unique_ptr< DigiCollection > accumulated_
int iEvent
Definition: GenABIO.cc:224
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
edm::EDGetTokenT< DigiCollection > signalToken_
HLT enums.
PreMixingMuonWorker(const edm::ParameterSet &ps, edm::ProducesCollector producesCollector, edm::ConsumesCollector &&iC)
def move(src, dest)
Definition: eostools.py:511
~PreMixingMuonWorker() override=default
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const