CMS 3D CMS Logo

L1TEGMultiMerger.cc
Go to the documentation of this file.
6 
14 #include <vector>
15 #include <iostream>
16 
18 public:
19  explicit L1TEGMultiMerger(const edm::ParameterSet&);
20  ~L1TEGMultiMerger() override;
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23 private:
24  void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
25 
26  template <class T>
28  public:
30  : instanceLabel_(conf.getParameter<std::string>("instance")) {
31  for (const auto& producer_tag : conf.getParameter<std::vector<edm::InputTag>>("pfProducers")) {
32  tokens_.push_back(
33  prod->consumes<T>(edm::InputTag(producer_tag.label(), producer_tag.instance(), producer_tag.process())));
34  }
35  // FIXME: move this outside
36  prod->produces<T>(instanceLabel_);
37  }
38 
39  void produce(edm::Event& iEvent) const {
41  auto out = std::make_unique<T>();
42  for (const auto& token : tokens_) {
43  iEvent.getByToken(token, handle);
45  }
47  }
48 
49  private:
50  template <class TT>
51  void populate(std::unique_ptr<TT>& out, const edm::Handle<TT>& in) const {
52  out->insert(out->end(), in->begin(), in->end());
53  }
54 
56  for (int bx = in->getFirstBX(); bx <= in->getLastBX(); bx++) {
57  for (auto egee_itr = in->begin(bx); egee_itr != in->end(bx); egee_itr++) {
58  out->push_back(bx, *egee_itr);
59  }
60  }
61  }
62 
63  std::vector<edm::EDGetTokenT<T>> tokens_;
65  };
66 
67  std::vector<InstanceMerger<l1t::TkElectronCollection>> tkEleMerger;
68  std::vector<InstanceMerger<l1t::TkEmCollection>> tkEmMerger;
69  std::vector<InstanceMerger<BXVector<l1t::EGamma>>> tkEGMerger;
70 };
71 
73  for (const auto& config : conf.getParameter<std::vector<edm::ParameterSet>>("tkEgs")) {
75  }
76  for (const auto& config : conf.getParameter<std::vector<edm::ParameterSet>>("tkElectrons")) {
78  }
79  for (const auto& config : conf.getParameter<std::vector<edm::ParameterSet>>("tkEms")) {
81  }
82 }
83 
85 
87  for (const auto& egMerger : tkEGMerger)
88  egMerger.produce(iEvent);
89  for (const auto& eleMerger : tkEleMerger)
90  eleMerger.produce(iEvent);
91  for (const auto& emMerger : tkEmMerger)
92  emMerger.produce(iEvent);
93 }
94 
97  psetDesc.add<std::string>("instance");
98  psetDesc.add<std::vector<edm::InputTag>>("pfProducers");
100  desc.addVPSet("tkElectrons", psetDesc);
101  desc.addVPSet("tkEms", psetDesc);
102  desc.addVPSet("tkEgs", psetDesc);
103  descriptions.addWithDefaultLabel(desc);
104 }
105 
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
std::vector< InstanceMerger< BXVector< l1t::EGamma > > > tkEGMerger
void populate(std::unique_ptr< BXVector< l1t::EGamma >> &out, const edm::Handle< BXVector< l1t::EGamma >> &in) const
InstanceMerger(L1TEGMultiMerger *prod, const edm::ParameterSet &conf)
std::vector< InstanceMerger< l1t::TkEmCollection > > tkEmMerger
void produce(edm::Event &iEvent) const
Definition: config.py:1
std::unique_ptr< T, impl::DeviceDeleter > unique_ptr
int iEvent
Definition: GenABIO.cc:224
std::vector< InstanceMerger< l1t::TkElectronCollection > > tkEleMerger
L1TEGMultiMerger(const edm::ParameterSet &)
void produce(edm::StreamID, edm::Event &, const edm::EventSetup &) const override
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
void populate(std::unique_ptr< TT > &out, const edm::Handle< TT > &in) const
std::vector< edm::EDGetTokenT< T > > tokens_
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
long double T
~L1TEGMultiMerger() override
def move(src, dest)
Definition: eostools.py:511