CMS 3D CMS Logo

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
26  const edm::ParameterSet& mod_config =
27  conf.getParameter<edm::ParameterSet>("modifierConfig");
28  modifier_ = std::make_unique<Modifier>(mod_config, consumesCollector());
29  //declare products
30  produces<Collection>();
31  }
33 
35  modifier_->setEventContent(evs);
36  }
37 
38  void produce(edm::Event& evt,const edm::EventSetup& evs) final {
40  auto output = std::make_unique<Collection>();
41 
42  evt.getByToken(src_,input);
43  output->reserve(input->size());
44 
45  modifier_->setEvent(evt);
46 
47  for( auto itr = input->begin(); itr != input->end(); ++itr ) {
48  output->push_back(*itr);
49  T& obj = output->back();
50  modifier_->modify(obj);
51  }
52 
53  evt.put(std::move(output));
54  }
55 
56  private:
58  std::unique_ptr<Modifier> modifier_;
59  };
60 }
61 
62 #endif
T getParameter(std::string const &) const
std::unique_ptr< Modifier > modifier_
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &evs) final
ModifiedObjectProducer(const edm::ParameterSet &conf)
static std::string const input
Definition: EdmProvDump.cc:48
Definition: HeavyIon.h:7
edm::EDGetTokenT< edm::View< T > > src_
void produce(edm::Event &evt, const edm::EventSetup &evs) final
pat::ObjectModifier< T > Modifier
long double T
def move(src, dest)
Definition: eostools.py:511