CMS 3D CMS Logo

PreMixingCrossingFrameWorker.cc
Go to the documentation of this file.
7 
10 
13 
14 namespace edm {
15  template <typename T>
17  public:
19  ~PreMixingCrossingFrameWorker() 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<PCrossingFrame<T> > merged_;
35  };
36 
37  template <typename T>
39  edm::ProducesCollector producesCollector,
41  : signalToken_(iC.consumes<CrossingFrame<T> >(ps.getParameter<edm::InputTag>("labelSig"))),
42  pileupTag_(ps.getParameter<edm::InputTag>("pileInputTag")),
43  collectionDM_(ps.getParameter<std::string>("collectionDM")) {
44  producesCollector.produces<PCrossingFrame<T> >(
45  collectionDM_); // TODO: this is needed only to store the pointed-to objects, do we really need it?
46  producesCollector.produces<CrossingFrame<T> >(collectionDM_);
47  }
48 
49  template <typename T>
52  iEvent.getByToken(signalToken_, hcf);
53 
54  const auto& cf = *hcf;
55  if (!cf.getPileups().empty()) {
56  throw cms::Exception("LogicError") << "Got CrossingFrame from signal with pileup content?";
57  }
58 
59  merged_ = std::make_unique<PCrossingFrame<T> >(cf); // for signal we just copy
60  }
61 
62  template <typename T>
65  pep.getByLabel(pileupTag_, hcf);
66 
67  const auto& cf = *hcf;
68  if (!cf.getSignals().empty()) {
69  throw cms::Exception("LogicError") << "Got PCrossingFrame from pileup with signal content?";
70  }
71 
72  merged_->setAllExceptSignalFrom(cf);
73  }
74 
75  template <typename T>
77  edm::EventSetup const& iSetup,
78  std::vector<PileupSummaryInfo> const& ps,
79  int bunchSpacing) {
80  auto orphanHandle = iEvent.put(std::move(merged_), collectionDM_);
81  const auto& pcf = *orphanHandle;
82 
83  const auto bx = pcf.getBunchRange();
84  auto cf = std::make_unique<CrossingFrame<T> >(
85  bx.first, bx.second, pcf.getBunchSpace(), pcf.getSubDet(), pcf.getMaxNbSources());
86  cf->addSignals(&(pcf.getSignals()), pcf.getEventID());
87  cf->setPileups(pcf.getPileups());
88  iEvent.put(std::move(cf), collectionDM_);
89  }
90 } // namespace edm
91 
94 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
void addSignals(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
ProductRegistryHelper::BranchAliasSetterT< ProductType > produces()
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
~PreMixingCrossingFrameWorker() override=default
std::unique_ptr< PCrossingFrame< T > > merged_
int iEvent
Definition: GenABIO.cc:224
void put(edm::Event &iEvent, edm::EventSetup const &iSetup, std::vector< PileupSummaryInfo > const &ps, int bunchSpacing) override
edm::EDGetTokenT< CrossingFrame< T > > signalToken_
void initializeEvent(edm::Event const &iEvent, edm::EventSetup const &iSetup) override
void addPileups(PileUpEventPrincipal const &pep, edm::EventSetup const &iSetup) override
HLT enums.
bool getByLabel(edm::InputTag const &tag, edm::Handle< T > &result) const
PreMixingCrossingFrameWorker(const edm::ParameterSet &ps, edm::ProducesCollector, edm::ConsumesCollector &&iC)
long double T
#define DEFINE_PREMIXING_WORKER(TYPE)
def move(src, dest)
Definition: eostools.py:511