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,
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
Handle.h
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
PreMixingDigiSimLinkWorker::signalToken_
edm::EDGetTokenT< DigiSimLinkCollection > signalToken_
Definition: PreMixingDigiSimLinkWorker.h:30
edm::EDGetTokenT< DigiSimLinkCollection >
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:85964
PreMixingDigiSimLinkWorker
Definition: PreMixingDigiSimLinkWorker.h:16
PreMixingDigiSimLinkWorker::put
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
Definition: PreMixingDigiSimLinkWorker.h:74
PreMixingDigiSimLinkWorker::initializeEvent
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: PreMixingDigiSimLinkWorker.h:21
PreMixingDigiSimLinkWorker::addPileups
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
Definition: PreMixingDigiSimLinkWorker.h:61
PileUpEventPrincipal
Definition: PileUpEventPrincipal.h:19
edm::Handle
Definition: AssociativeIterator.h:50
PreMixingDigiSimLinkWorker::pileupTag_
edm::InputTag pileupTag_
Definition: PreMixingDigiSimLinkWorker.h:31
ProducesCollector.h
HLTEgPhaseIITestSequence_cff.bunchSpacing
bunchSpacing
Definition: HLTEgPhaseIITestSequence_cff.py:1574
PreMixingWorker.h
EventPrincipal.h
PileUpEventPrincipal.h
PreMixingDigiSimLinkWorker::~PreMixingDigiSimLinkWorker
~PreMixingDigiSimLinkWorker() override=default
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PreMixingDigiSimLinkWorker::merged_
std::unique_ptr< DigiSimLinkCollection > merged_
Definition: PreMixingDigiSimLinkWorker.h:34
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::ProducesCollector::produces
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
Definition: ProducesCollector.h:52
edm::EventSetup
Definition: EventSetup.h:57
PreMixingDigiSimLinkWorker::collectionDM_
std::string collectionDM_
Definition: PreMixingDigiSimLinkWorker.h:32
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
edm::ProducesCollector
Definition: ProducesCollector.h:43
PreMixingWorker
Definition: PreMixingWorker.h:14
ConsumesCollector.h
ParameterSet.h
PileUpEventPrincipal::getByLabel
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
Definition: PileUpEventPrincipal.h:33
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
PreMixingDigiSimLinkWorker::addSignals
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
Definition: PreMixingDigiSimLinkWorker.h:48
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
PreMixingDigiSimLinkWorker::PreMixingDigiSimLinkWorker
PreMixingDigiSimLinkWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
Definition: PreMixingDigiSimLinkWorker.h:38