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 = conf.getParameter<edm::ParameterSet>("modifierConfig");
27  modifier_ = std::make_unique<Modifier>(mod_config, consumesCollector());
28  //declare products
29  produces<Collection>();
30  }
32 
33  void produce(edm::Event& evt, const edm::EventSetup& evs) final {
34  modifier_->setEventContent(evs);
35 
36  auto output = std::make_unique<Collection>();
37 
38  auto input = evt.getHandle(src_);
39  output->reserve(input->size());
40 
41  modifier_->setEvent(evt);
42 
43  for (auto const& itr : *input) {
44  output->push_back(itr);
45  T& obj = output->back();
46  modifier_->modify(obj);
47  }
48 
49  evt.put(std::move(output));
50  }
51 
52  private:
54  std::unique_ptr<Modifier> modifier_;
55  };
56 } // namespace pat
57 
58 #endif
pat::ModifiedObjectProducer::Modifier
pat::ObjectModifier< T > Modifier
Definition: ModifiedObjectProducer.h:20
pat::ModifiedObjectProducer
Definition: ModifiedObjectProducer.h:17
ObjectModifier.h
input
static const std::string input
Definition: EdmProvDump.cc:48
pat::ModifiedObjectProducer::ModifiedObjectProducer
ModifiedObjectProducer(const edm::ParameterSet &conf)
Definition: ModifiedObjectProducer.h:22
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
edm::EDGetTokenT
Definition: EDGetToken.h:33
EDProducer.h
pat::ModifiedObjectProducer::~ModifiedObjectProducer
~ModifiedObjectProducer() override
Definition: ModifiedObjectProducer.h:31
pat::ModifiedObjectProducer::Collection
std::vector< T > Collection
Definition: ModifiedObjectProducer.h:19
pat::ObjectModifier
Definition: ObjectModifier.h:9
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
pat::ModifiedObjectProducer::src_
edm::EDGetTokenT< edm::View< T > > src_
Definition: ModifiedObjectProducer.h:53
edm::stream::EDProducer
Definition: EDProducer.h:38
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
pat::ModifiedObjectProducer::produce
void produce(edm::Event &evt, const edm::EventSetup &evs) final
Definition: ModifiedObjectProducer.h:33
itr
std::vector< std::pair< float, float > >::iterator itr
Definition: HGCDigitizer.cc:29
InputTag.h
eostools.move
def move(src, dest)
Definition: eostools.py:511
T
long double T
Definition: Basic3DVectorLD.h:48
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
pat::ModifiedObjectProducer::modifier_
std::unique_ptr< Modifier > modifier_
Definition: ModifiedObjectProducer.h:54
View.h
ParameterSet.h
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15