CMS 3D CMS Logo

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
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
def create(alignables, pedeDump, additionalData, outputFile, config)
ObjectModifier(const edm::ParameterSet &conf, edm::ConsumesCollector &&cc)
std::vector< ModifierPointer > modifiers_
Definition: HeavyIon.h:7
void setEvent(const edm::Event &event)
std::unique_ptr< ModifyObjectValueBase > ModifierPointer
void setEventContent(const edm::EventSetup &setup)
void modify(T &obj) const
long double T
Definition: event.py:1