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 
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
mps_fire.i
i
Definition: mps_fire.py:428
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
cuts
const TkSoA *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
Definition: CAHitNtupletGeneratorKernelsImpl.h:338
pat::helper::MultiIsolator::make
static BaseIsolator * make(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut)
Definition: MultiIsolator.cc:60
edm::View::refAt
RefToBase< value_type > refAt(size_type i) const
pat::helper::MultiIsolator::fill
void fill(const edm::View< T > &coll, int idx, IsolationValuePairs &isolations) const
Definition: MultiIsolator.h:84
pat::helper::MultiIsolator::test
uint32_t test(const edm::View< T > &coll, int idx) const
Definition: MultiIsolator.h:64
pat::helper::MultiIsolator::IsolationValuePairs
std::vector< std::pair< pat::IsolationKeys, float > > IsolationValuePairs
Definition: MultiIsolator.h:17
pat::helper::MultiIsolator::enabled
bool enabled() const
True if it has a non null configuration.
Definition: MultiIsolator.h:55
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
pat::helper::MultiIsolator::endEvent
void endEvent()
Definition: MultiIsolator.cc:85
Isolation.h
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::View
Definition: CaloClusterFwd.h:14
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
helper
Definition: helper.py:1
pat::helper::MultiIsolator::addIsolator
void addIsolator(BaseIsolator *iso, uint32_t mask, pat::IsolationKeys key)
Definition: MultiIsolator.cc:54
pat::helper::MultiIsolator::printSummary
std::string printSummary() const
Definition: MultiIsolator.cc:100
edm::EventSetup
Definition: EventSetup.h:58
pat
Definition: HeavyIon.h:7
pat::helper::BaseIsolator
Definition: BaseIsolator.h:13
pat::helper::MultiIsolator
Definition: MultiIsolator.h:15
pat::helper::MultiIsolator::print
void print(std::ostream &out) const
Definition: MultiIsolator.cc:91
pat::IsolationKeys
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
pat::helper::MultiIsolator::beginEvent
void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)
Definition: MultiIsolator.cc:79
BaseIsolator.h
edm::RefToBase
Definition: AssociativeIterator.h:54
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
View.h
ParameterSet.h
event
Definition: event.py:1
pat::helper::MultiIsolator::keys_
std::vector< pat::IsolationKeys > keys_
Definition: MultiIsolator.h:60
edm::Event
Definition: Event.h:73
crabWrapper.key
key
Definition: crabWrapper.py:19
pat::helper::MultiIsolator::~MultiIsolator
~MultiIsolator()
Definition: MultiIsolator.h:20
pat::helper::MultiIsolator::masks_
std::vector< uint32_t > masks_
Definition: MultiIsolator.h:59
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
pat::helper::MultiIsolator::MultiIsolator
MultiIsolator()
Definition: MultiIsolator.h:18
pat::helper::MultiIsolator::isolators_
std::vector< std::unique_ptr< BaseIsolator > > isolators_
Definition: MultiIsolator.h:58