CMS 3D CMS Logo

ModifiedObjectProducer.cc
Go to the documentation of this file.
13 
14 #include <memory>
15 
16 namespace pat {
17 
18  template <class T>
20  public:
21  typedef std::vector<T> Collection;
23 
25  //set our input source
26  src_ = consumes<edm::View<T> >(conf.getParameter<edm::InputTag>("src"));
27  //setup modifier
28  const edm::ParameterSet& mod_config = conf.getParameter<edm::ParameterSet>("modifierConfig");
29  modifier_ = std::make_unique<Modifier>(mod_config, consumesCollector());
30  //declare products
31  produces<Collection>();
32  }
34 
35  void produce(edm::Event& evt, const edm::EventSetup& evs) final {
36  modifier_->setEventContent(evs);
37 
38  auto output = std::make_unique<Collection>();
39 
40  auto input = evt.getHandle(src_);
41  output->reserve(input->size());
42 
43  modifier_->setEvent(evt);
44 
45  for (auto const& itr : *input) {
46  output->push_back(itr);
47  T& obj = output->back();
48  modifier_->modify(obj);
49  }
50 
51  evt.put(std::move(output));
52  }
53 
54  private:
56  std::unique_ptr<Modifier> modifier_;
57  };
58 } // namespace pat
59 
66 
std::unique_ptr< Modifier > modifier_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pat::ModifiedObjectProducer< pat::Tau > ModifiedTauProducer
pat::ModifiedObjectProducer< reco::GsfElectron > ModifiedGsfElectronProducer
pat::ModifiedObjectProducer< pat::Electron > ModifiedElectronProducer
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
ModifiedObjectProducer(const edm::ParameterSet &conf)
pat::ModifiedObjectProducer< pat::Jet > ModifiedJetProducer
static std::string const input
Definition: EdmProvDump.cc:47
Definition: HeavyIon.h:7
edm::EDGetTokenT< edm::View< T > > src_
void produce(edm::Event &evt, const edm::EventSetup &evs) final
pat::ModifiedObjectProducer< pat::Photon > ModifiedPhotonProducer
pat::ObjectModifier< T > Modifier
long double T
def move(src, dest)
Definition: eostools.py:511
pat::ModifiedObjectProducer< pat::Muon > ModifiedMuonProducer