CMS 3D CMS Logo

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