CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ObjectModifier.h
Go to the documentation of this file.
1 #ifndef __PhysicsTools_PatAlgos_ObjectModifier_h__
2 #define __PhysicsTools_PatAlgos_ObjectModifier_h__
3 
5 #include <memory>
6 
7 namespace pat {
8  template <class T>
9  class ObjectModifier {
10  public:
11  typedef std::unique_ptr<ModifyObjectValueBase> ModifierPointer;
12 
15 
16  void setEvent(const edm::Event& event) {
17  for (unsigned i = 0; i < modifiers_.size(); ++i)
18  modifiers_[i]->setEvent(event);
19  }
20 
22  for (unsigned i = 0; i < modifiers_.size(); ++i)
23  modifiers_[i]->setEventContent(setup);
24  }
25 
26  void modify(T& obj) const {
27  for (unsigned i = 0; i < modifiers_.size(); ++i)
28  modifiers_[i]->modifyObject(obj);
29  }
30 
31  private:
32  std::vector<ModifierPointer> modifiers_;
33  };
34 
35  template <class T>
37  const std::vector<edm::ParameterSet>& mods = conf.getParameterSetVector("modifications");
38  for (unsigned i = 0; i < mods.size(); ++i) {
39  const edm::ParameterSet& iconf = mods[i];
40  const std::string& mname = iconf.getParameter<std::string>("modifierName");
41  modifiers_.emplace_back(ModifyObjectValueFactory::get()->create(mname, iconf, cc));
42  }
43  }
44 } // namespace pat
45 
46 #endif
VParameterSet const & getParameterSetVector(std::string const &name) const
ObjectModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &&cc)
std::vector< ModifierPointer > modifiers_
void setEvent(const edm::Event &event)
std::unique_ptr< ModifyObjectValueBase > ModifierPointer
tuple mods
Definition: mps_splice.py:43
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
void setEventContent(const edm::EventSetup &setup)
void modify(T &obj) const
#define get
long double T