00001 #ifndef PhysicsTools_PatAlgos_interface_BaseIsolator_h 00002 #define PhysicsTools_PatAlgos_interface_BaseIsolator_h 00003 00004 #include "DataFormats/Common/interface/ValueMap.h" 00005 #include "FWCore/ParameterSet/interface/ParameterSet.h" 00006 #include "FWCore/Framework/interface/Event.h" 00007 00008 namespace pat { namespace helper { 00009 class BaseIsolator { 00010 public: 00011 typedef edm::ValueMap<float> Isolation; 00012 BaseIsolator() {} 00013 BaseIsolator(const edm::ParameterSet &conf, bool withCut) ; 00014 virtual ~BaseIsolator() {} 00015 virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup) = 0; 00016 virtual void endEvent() = 0; 00017 00019 template<typename AnyRef> bool test(const AnyRef &ref) const { 00020 bool ok = (getValue(ref.id(), ref.key()) < cut_); 00021 try_++; if (!ok) fail_++; 00022 return ok; 00023 } 00025 template<typename AnyRef> float getValue(const AnyRef &ref) const { 00026 return getValue(ref.id(), ref.key()); 00027 } 00028 00029 virtual std::string description() const = 0; 00030 void print(std::ostream &out) const ; 00031 protected: 00032 virtual float getValue(const edm::ProductID &id, size_t index) const = 0; 00033 edm::InputTag input_; 00034 float cut_; 00035 mutable uint64_t try_, fail_; 00036 }; // class BaseIsolator 00037 } } // namespaces 00038 00039 inline std::ostream & operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso) { 00040 iso.print(stream); 00041 return stream; 00042 } 00043 #endif