test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ModifiedObjectProducer.h
Go to the documentation of this file.
1 #ifndef __PhysicsTools_PatAlgos_ModifiedObjectProducer_h__
2 #define __PhysicsTools_PatAlgos_ModifiedObjectProducer_h__
3 
5 
11 
12 #include <memory>
13 
14 namespace pat {
15 
16  template<class T>
18  public:
19  typedef std::vector<T> Collection;
21 
23  //set our input source
24  src_ = consumes<edm::View<T> >(conf.getParameter<edm::InputTag>("src"));
25  //setup modifier
27  const edm::ParameterSet& mod_config =
28  conf.getParameter<edm::ParameterSet>("modifierConfig");
29  modifier_.reset( new Modifier(mod_config) );
30  modifier_->setConsumes(sumes);
31  //declare products
32  produces<Collection>();
33  }
35 
36  virtual void beginLuminosityBlock(const edm::LuminosityBlock&, const edm::EventSetup& evs) override final {
37  modifier_->setEventContent(evs);
38  }
39 
40  virtual void produce(edm::Event& evt,const edm::EventSetup& evs) override final {
42  std::auto_ptr<Collection> output(new Collection);
43 
44  evt.getByToken(src_,input);
45  output->reserve(input->size());
46 
47  modifier_->setEvent(evt);
48 
49  for( auto itr = input->begin(); itr != input->end(); ++itr ) {
50  output->push_back(*itr);
51  T& obj = output->back();
52  modifier_->modify(obj);
53  }
54 
55  evt.put(output);
56  }
57 
58  private:
60  std::unique_ptr<Modifier> modifier_;
61  };
62 }
63 
64 #endif
T getParameter(std::string const &) const
std::unique_ptr< Modifier > modifier_
ModifiedObjectProducer(const edm::ParameterSet &conf)
virtual void produce(edm::Event &evt, const edm::EventSetup &evs) overridefinal
static std::string const input
Definition: EdmProvDump.cc:44
edm::EDGetTokenT< edm::View< T > > src_
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
virtual void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &evs) overridefinal
pat::ObjectModifier< T > Modifier
long double T