File indexing completed on 2024-04-06 12:27:04
0001 #ifndef MuonIsolation_MuIsoBaseIsolator_H
0002 #define MuonIsolation_MuIsoBaseIsolator_H
0003
0004 #include <vector>
0005 #include "FWCore/Framework/interface/Event.h"
0006
0007 #include "DataFormats/RecoCandidate/interface/IsoDeposit.h"
0008 #include "DataFormats/TrackReco/interface/Track.h"
0009 #include "DataFormats/Candidate/interface/Candidate.h"
0010
0011 namespace muonisolation {
0012 class MuIsoBaseIsolator {
0013 public:
0014 typedef reco::IsoDeposit::Veto Veto;
0015 typedef reco::IsoDeposit::Vetos Vetos;
0016
0017 struct DepositAndVetos {
0018 DepositAndVetos() : dep(nullptr), vetos(nullptr) {}
0019 DepositAndVetos(const reco::IsoDeposit* depA, const Vetos* vetosA = nullptr) : dep(depA), vetos(vetosA) {}
0020 const reco::IsoDeposit* dep;
0021 const Vetos* vetos;
0022 };
0023 typedef std::vector<DepositAndVetos> DepositContainer;
0024
0025 enum ResultType { ISOL_INT_TYPE = 0, ISOL_FLOAT_TYPE, ISOL_BOOL_TYPE, ISOL_INVALID_TYPE };
0026
0027 class Result {
0028 public:
0029 Result() : valInt(-999), valFloat(-999), valBool(false), typeF_(ISOL_INVALID_TYPE) {}
0030 Result(ResultType typ) : valInt(-999), valFloat(-999.), valBool(false), typeF_(typ) {}
0031
0032 template <typename T>
0033 T val() const;
0034
0035 int valInt;
0036 float valFloat;
0037 bool valBool;
0038 ResultType typeF() const { return typeF_; }
0039
0040 protected:
0041 ResultType typeF_;
0042 };
0043
0044 virtual ~MuIsoBaseIsolator() {}
0045
0046
0047 virtual Result result(const DepositContainer& deposits, const edm::Event* = nullptr) const = 0;
0048
0049 virtual Result result(const DepositContainer& deposits,
0050 const reco::Candidate& muon,
0051 const edm::Event* = nullptr) const {
0052 return result(deposits);
0053 }
0054
0055 virtual Result result(const DepositContainer& deposits,
0056 const reco::Track& muon,
0057 const edm::Event* = nullptr) const {
0058 return result(deposits);
0059 }
0060
0061 virtual ResultType resultType() const = 0;
0062 };
0063
0064 template <>
0065 inline int MuIsoBaseIsolator::Result::val<int>() const {
0066 return valInt;
0067 }
0068 template <>
0069 inline float MuIsoBaseIsolator::Result::val<float>() const {
0070 return valFloat;
0071 }
0072 template <>
0073 inline bool MuIsoBaseIsolator::Result::val<bool>() const {
0074 return valBool;
0075 }
0076
0077 }
0078 #endif