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
pat::helper::BaseIsolator::inputToken_
edm::EDGetTokenT< Isolation > inputToken_
Definition: BaseIsolator.h:43
edm::EDGetTokenT
Definition: EDGetToken.h:33
cms::cuda::stream
cudaStream_t stream
Definition: HistoContainer.h:57
pat::helper::BaseIsolator::~BaseIsolator
virtual ~BaseIsolator()
Definition: BaseIsolator.h:18
convertSQLiteXML.ok
bool ok
Definition: convertSQLiteXML.py:98
pat::helper::BaseIsolator::getValue
float getValue(const AnyRef &ref) const
Returns the associated isolation value given any sort of ref.
Definition: BaseIsolator.h:33
pat::helper::BaseIsolator::fail_
std::atomic< uint64_t > fail_
Definition: BaseIsolator.h:45
pat::helper::BaseIsolator::beginEvent
virtual void beginEvent(const edm::Event &event, const edm::EventSetup &eventSetup)=0
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
pat::helper::BaseIsolator::input_
edm::InputTag input_
Definition: BaseIsolator.h:42
helper
Definition: helper.py:1
operator<<
std::ostream & operator<<(std::ostream &stream, const pat::helper::BaseIsolator &iso)
Definition: BaseIsolator.h:50
pat::helper::BaseIsolator::print
void print(std::ostream &out) const
Definition: BaseIsolator.cc:14
edm::EventSetup
Definition: EventSetup.h:57
pat
Definition: HeavyIon.h:7
pat::helper::BaseIsolator
Definition: BaseIsolator.h:13
ValueMap.h
pat::helper::BaseIsolator::BaseIsolator
BaseIsolator()
Definition: BaseIsolator.h:16
pat::helper::BaseIsolator::cut_
float cut_
Definition: BaseIsolator.h:44
pat::helper::BaseIsolator::test
bool test(const AnyRef &ref) const
Tests if the value associated to this item is strictly below the cut.
Definition: BaseIsolator.h:24
edm::ValueMap< float >
pat::helper::BaseIsolator::try_
std::atomic< uint64_t > try_
Definition: BaseIsolator.h:45
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
ConsumesCollector.h
ParameterSet.h
event
Definition: event.py:1
pat::helper::BaseIsolator::endEvent
virtual void endEvent()=0
edm::Event
Definition: Event.h:73
pat::helper::BaseIsolator::Isolation
edm::ValueMap< float > Isolation
Definition: BaseIsolator.h:15
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
edm::ProductID
Definition: ProductID.h:27
pat::helper::BaseIsolator::description
virtual std::string description() const =0