CMS 3D CMS Logo

BaseIsolator.h
Go to the documentation of this file.
1 #ifndef PhysicsTools_PatAlgos_interface_BaseIsolator_h
2 #define PhysicsTools_PatAlgos_interface_BaseIsolator_h
3 
8 
9 #include <atomic>
10 
11 namespace pat {
12  namespace helper {
13  class BaseIsolator {
14  public:
17  BaseIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector &iC, bool withCut);
18  virtual ~BaseIsolator() {}
19  virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) = 0;
20  virtual void endEvent() = 0;
21 
23  template <typename AnyRef>
24  bool test(const AnyRef &ref) const {
25  bool ok = (getValue(ref.id(), ref.key()) < cut_);
26  try_++;
27  if (!ok)
28  fail_++;
29  return ok;
30  }
32  template <typename AnyRef>
33  float getValue(const AnyRef &ref) const {
34  return getValue(ref.id(), ref.key());
35  }
36 
37  virtual std::string description() const = 0;
38  void print(std::ostream &out) const;
39 
40  protected:
41  virtual float getValue(const edm::ProductID &id, size_t index) const = 0;
44  float cut_;
45  mutable std::atomic<uint64_t> try_, fail_;
46  }; // class BaseIsolator
47  } // namespace helper
48 } // namespace pat
49 
50 inline std::ostream &operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso) {
51  iso.print(stream);
52  return stream;
53 }
54 #endif
float getValue(const AnyRef &ref) const
Returns the associated isolation value given any sort of ref.
Definition: BaseIsolator.h:33
Definition: helper.py:1
std::ostream & operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso)
Definition: BaseIsolator.h:50
std::atomic< uint64_t > try_
Definition: BaseIsolator.h:45
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Definition: HeavyIon.h:7
virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)=0
edm::EDGetTokenT< Isolation > inputToken_
Definition: BaseIsolator.h:43
void print(std::ostream &out) const
Definition: BaseIsolator.cc:14
virtual std::string description() const =0
edm::ValueMap< float > Isolation
Definition: BaseIsolator.h:15
bool test(const AnyRef &ref) const
Tests if the value associated to this item is strictly below the cut.
Definition: BaseIsolator.h:24
virtual void endEvent()=0
std::atomic< uint64_t > fail_
Definition: BaseIsolator.h:45
Definition: event.py:1