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 { namespace helper {
12 class BaseIsolator {
13  public:
16  BaseIsolator(const edm::ParameterSet &conf, edm::ConsumesCollector & iC, bool withCut) ;
17  virtual ~BaseIsolator() {}
18  virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) = 0;
19  virtual void endEvent() = 0;
20 
22  template<typename AnyRef> bool test(const AnyRef &ref) const {
23  bool ok = (getValue(ref.id(), ref.key()) < cut_);
24  try_++; if (!ok) fail_++;
25  return ok;
26  }
28  template<typename AnyRef> float getValue(const AnyRef &ref) const {
29  return getValue(ref.id(), ref.key());
30  }
31 
32  virtual std::string description() const = 0;
33  void print(std::ostream &out) const ;
34  protected:
35  virtual float getValue(const edm::ProductID &id, size_t index) const = 0;
38  float cut_;
39  mutable std::atomic<uint64_t> try_, fail_;
40 }; // class BaseIsolator
41 } } // namespaces
42 
43 inline std::ostream & operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso) {
44  iso.print(stream);
45  return stream;
46 }
47 #endif
void print(std::ostream &out) const
Definition: BaseIsolator.cc:16
Definition: helper.py:1
std::atomic< uint64_t > try_
Definition: BaseIsolator.h:39
Definition: HeavyIon.h:7
virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)=0
edm::EDGetTokenT< Isolation > inputToken_
Definition: BaseIsolator.h:37
std::ostream & operator<<(std::ostream &out, const strbitset::index_type &r)
Definition: strbitset.cc:27
virtual std::string description() const =0
edm::ValueMap< float > Isolation
Definition: BaseIsolator.h:14
bool test(const AnyRef &ref) const
Tests if the value associated to this item is strictly below the cut.
Definition: BaseIsolator.h:22
virtual void endEvent()=0
float getValue(const AnyRef &ref) const
Returns the associated isolation value given any sort of ref.
Definition: BaseIsolator.h:28
std::atomic< uint64_t > fail_
Definition: BaseIsolator.h:39
Definition: event.py:1