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 
13  ObjectModifier(const edm::ParameterSet& conf);
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 
27  for( unsigned i = 0; i < modifiers_.size(); ++i )
28  modifiers_[i]->setConsumes(sumes);
29  }
30 
31  void modify(T& obj) const {
32  for( unsigned i = 0; i < modifiers_.size(); ++i )
33  modifiers_[i]->modifyObject(obj);
34  }
35 
36  private:
37  std::vector<ModifierPointer> modifiers_;
38  };
39 
40  template<class T>
42  const std::vector<edm::ParameterSet>& mods =
43  conf.getParameterSetVector("modifications");
44  for(unsigned i = 0; i < mods.size(); ++i ) {
45  const edm::ParameterSet& iconf = mods[i];
46  const std::string& mname = iconf.getParameter<std::string>("modifierName");
48  ModifyObjectValueFactory::get()->create(mname,iconf);
49  if( nullptr != plugin ) {
50  modifiers_.push_back(ModifierPointer(plugin));
51  } else {
52  throw cms::Exception("BadPluginName")
53  << "The requested modifier: " << mname << " is not available!";
54  }
55  }
56  }
57 }
58 
59 #endif
T getParameter(std::string const &) const
VParameterSet const & getParameterSetVector(std::string const &name) const
auto_ptr< JetDefinition::Plugin > plugin
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
std::vector< ModifierPointer > modifiers_
Definition: HeavyIon.h:7
ObjectModifier(const edm::ParameterSet &conf)
void setEvent(const edm::Event &event)
std::unique_ptr< ModifyObjectValueBase > ModifierPointer
void setConsumes(edm::ConsumesCollector &sumes)
void setEventContent(const edm::EventSetup &setup)
void modify(T &obj) const
long double T
T get(const Candidate &c)
Definition: component.h:55
Definition: event.py:1