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