CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PreMixingDigiSimLinkWorker.h
Go to the documentation of this file.
1 #ifndef SimGeneral_PremixingModule_PreMixingDigiSimLinkWorker_h
2 #define SimGeneral_PremixingModule_PreMixingDigiSimLinkWorker_h
3 
10 
12 
14 
15 template <typename DigiSimLinkCollection>
17 public:
19  ~PreMixingDigiSimLinkWorker() override = default;
20 
21  void initializeEvent(edm::Event const& iEvent, edm::EventSetup const& iSetup) override {}
22  void addSignals(edm::Event const& iEvent, edm::EventSetup const& iSetup) override;
23  void addPileups(PileUpEventPrincipal const& pep, edm::EventSetup const& iSetup) override;
24  void put(edm::Event& iEvent,
25  edm::EventSetup const& iSetup,
26  std::vector<PileupSummaryInfo> const& ps,
27  int bunchSpacing) override;
28 
29 private:
32  std::string collectionDM_; // secondary name to be given to new digis
33 
34  std::unique_ptr<DigiSimLinkCollection> merged_;
35 };
36 
37 template <typename DigiSimLinkCollection>
39  edm::ProducesCollector producesCollector,
41  : signalToken_(iC.consumes<DigiSimLinkCollection>(ps.getParameter<edm::InputTag>("labelSig"))),
42  pileupTag_(ps.getParameter<edm::InputTag>("pileInputTag")),
43  collectionDM_(ps.getParameter<std::string>("collectionDM")) {
44  producesCollector.produces<DigiSimLinkCollection>(collectionDM_);
45 }
46 
47 template <typename DigiSimLinkCollection>
49  edm::EventSetup const& iSetup) {
51  iEvent.getByToken(signalToken_, digis);
52 
53  if (digis.isValid()) {
54  merged_ = std::make_unique<DigiSimLinkCollection>(*digis); // for signal we can just copy
55  } else {
56  merged_ = std::make_unique<DigiSimLinkCollection>();
57  }
58 }
59 
60 template <typename DigiSimLinkCollection>
62  edm::EventSetup const& iSetup) {
64  pep.getByLabel(pileupTag_, digis);
65  if (digis.isValid()) {
66  for (const auto& detsetSource : *digis) {
67  auto& detsetTarget = merged_->find_or_insert(detsetSource.detId());
68  std::copy(detsetSource.begin(), detsetSource.end(), std::back_inserter(detsetTarget));
69  }
70  }
71 }
72 
73 template <typename DigiSimLinkCollection>
75  edm::EventSetup const& iSetup,
76  std::vector<PileupSummaryInfo> const& ps,
77  int bunchSpacing) {
78  iEvent.put(std::move(merged_), collectionDM_);
79 }
80 
81 #endif
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
~PreMixingDigiSimLinkWorker() override=default
edm::EDGetTokenT< DigiSimLinkCollection > signalToken_
PreMixingDigiSimLinkWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
int iEvent
Definition: GenABIO.cc:224
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
std::unique_ptr< DigiSimLinkCollection > merged_
def move(src, dest)
Definition: eostools.py:511
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const