CMS 3D CMS Logo

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, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bunchSpacing) override;
25 
26 private:
29  std::string collectionDM_; // secondary name to be given to new digis
30 
31  std::unique_ptr<DigiSimLinkCollection> merged_;
32 };
33 
34 template <typename DigiSimLinkCollection>
36  signalToken_(iC.consumes<DigiSimLinkCollection>(ps.getParameter<edm::InputTag>("labelSig"))),
37  pileupTag_(ps.getParameter<edm::InputTag>("pileInputTag")),
38  collectionDM_(ps.getParameter<std::string>("collectionDM"))
39 {
40  producer.produces<DigiSimLinkCollection>(collectionDM_);
41 }
42 
43 template <typename DigiSimLinkCollection>
46  iEvent.getByToken(signalToken_, digis);
47 
48  if(digis.isValid()) {
49  merged_ = std::make_unique<DigiSimLinkCollection>(*digis); // for signal we can just copy
50  }
51  else {
52  merged_ = std::make_unique<DigiSimLinkCollection>();
53  }
54 }
55 
56 template <typename DigiSimLinkCollection>
59  pep.getByLabel(pileupTag_, digis);
60  if(digis.isValid()) {
61  for(const auto& detsetSource: *digis) {
62  auto& detsetTarget = merged_->find_or_insert(detsetSource.detId());
63  std::copy(detsetSource.begin(), detsetSource.end(), std::back_inserter(detsetTarget));
64  }
65  }
66 }
67 
68 template <typename DigiSimLinkCollection>
69 void PreMixingDigiSimLinkWorker<DigiSimLinkCollection>::put(edm::Event& iEvent, edm::EventSetup const& iSetup, std::vector<PileupSummaryInfo> const& ps, int bunchSpacing) {
71 }
72 
73 #endif
BranchAliasSetterT< ProductType > produces()
declare what type of product will make and with which optional label
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
def copy(args, dbName)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:579
PreMixingDigiSimLinkWorker(const edm::ParameterSet &ps, edm::ProducerBase &producer, edm::ConsumesCollector &&iC)
~PreMixingDigiSimLinkWorker() override=default
edm::EDGetTokenT< DigiSimLinkCollection > signalToken_
int iEvent
Definition: GenABIO.cc:230
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
bool isValid() const
Definition: HandleBase.h:74
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
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
std::unique_ptr< DigiSimLinkCollection > merged_
def move(src, dest)
Definition: eostools.py:511