CMS 3D CMS Logo

MultiIsolator.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_PatAlgos_interface_MultiIsolator_h
2 #define PhysicsTools_PatAlgos_interface_MultiIsolator_h
3 
7 
9 #include "boost/ptr_container/ptr_vector.hpp"
10 
12 
13 namespace pat { namespace helper {
15  public:
16  typedef std::vector<std::pair<pat::IsolationKeys,float> > IsolationValuePairs;
18  MultiIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector && iC, bool cuts=true) ;
20 
21  // adds an isolator (and takes onwership of the pointer)
22  void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key) ;
23 
24  // parses an isolator and adds it to the list
25  void addIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector & iC, bool withCut, uint32_t mask, pat::IsolationKeys key) ;
26 
27  // Parses out an isolator, and returns a pointer to it.
28  // For an empty PSet, it returns a null pointer.
29  // You own the returned pointer!
30  static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector & iC, bool withCut) ;
31 
32  void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup);
33  void endEvent() ;
34 
35  template<typename T>
36  uint32_t test(const edm::View<T> &coll, int idx) const;
37 
38  template<typename T>
39  void fill(const edm::View<T> &coll, int idx, IsolationValuePairs& isolations) const ;
40 
42  template<typename RefType>
43  void fill(const RefType &ref, IsolationValuePairs& isolations) const ;
44 
45  void print(std::ostream &out) const ;
46 
47  std::string printSummary() const ;
48 
50  bool enabled() const { return !isolators_.empty(); }
51  private:
52  boost::ptr_vector<BaseIsolator> isolators_;
53  std::vector<uint32_t> masks_;
54  std::vector<pat::IsolationKeys> keys_;
55 };
56 
57  template<typename T>
58  uint32_t
60  uint32_t retval = 0;
61  edm::RefToBase<T> rb = coll.refAt(idx); // edm::Ptr<T> in a shiny new future to come one remote day ;-)
62  for (size_t i = 0, n = isolators_.size(); i < n; ++i) {
63  if (!isolators_[i].test(rb)) retval |= masks_[i];
64  }
65  return retval;
66  }
67 
68  template<typename RefType>
69  void
70  MultiIsolator::fill(const RefType &rb, IsolationValuePairs & isolations) const
71  {
72  isolations.resize(isolators_.size());
73  for (size_t i = 0, n = isolators_.size(); i < n; ++i) {
74  isolations[i].first = keys_[i];
75  isolations[i].second = isolators_[i].getValue(rb);
76  }
77  }
78 
79 
80  template<typename T>
81  void
82  MultiIsolator::fill(const edm::View<T> &coll, int idx, IsolationValuePairs & isolations) const
83  {
84  edm::RefToBase<T> rb = coll.refAt(idx);
85  fill(rb, isolations);
86  }
87 
88 }} // namespace
89 
90 #endif
91 
std::vector< uint32_t > masks_
Definition: MultiIsolator.h:53
Definition: helper.py:1
boost::ptr_vector< BaseIsolator > isolators_
Definition: MultiIsolator.h:52
void print(std::ostream &out) const
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
Definition: HeavyIon.h:7
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:50
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
std::string printSummary() const
static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut)
uint32_t test(const edm::View< T > &coll, int idx) const
Definition: MultiIsolator.h:59
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:54
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:16
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)
Definition: event.py:1
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:82