CMS 3D CMS Logo

GsfEleCalPFClusterIsoCut.cc
Go to the documentation of this file.
4 
6 public:
7  enum IsoType { UNDEF = -1, ISO_ECAL = 0, ISO_HCAL = 1 };
8 
10 
11  result_type operator()(const reco::GsfElectronPtr&) const final;
12 
14  void getEventContent(const edm::EventBase&) final;
15 
16  double value(const reco::CandidatePtr& cand) const final;
17 
19 
20 private:
21  // Cut values
23  // Configuration
24  const int isoType_;
25  const float ptCutOff_;
26  const float barrelCutOff_;
28  // Effective area constants
30  // The rho
32 
33  constexpr static char rhoString_[] = "rho";
34 };
35 
37 
39 
42  isoCutEBLowPt_(c.getParameter<double>("isoCutEBLowPt")),
43  isoCutEBHighPt_(c.getParameter<double>("isoCutEBHighPt")),
44  isoCutEELowPt_(c.getParameter<double>("isoCutEELowPt")),
45  isoCutEEHighPt_(c.getParameter<double>("isoCutEEHighPt")),
46  isoType_(c.getParameter<int>("isoType")),
47  ptCutOff_(c.getParameter<double>("ptCutOff")),
48  barrelCutOff_(c.getParameter<double>("barrelCutOff")),
49  isRelativeIso_(c.getParameter<bool>("isRelativeIso")),
50  effectiveAreas_((c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath()) {
51  edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
52  contentTags_.emplace(rhoString_, rhoTag);
53 }
54 
56  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
57  contentTokens_.emplace(rhoString_, rho);
58 }
59 
61  ev.getByLabel(contentTags_[rhoString_], rhoHandle_);
62 }
63 
65  // Establish the cut value
66  double absEta = std::abs(cand->superCluster()->eta());
67 
68  const pat::Electron* elPat = dynamic_cast<const pat::Electron*>(cand.get());
69  if (!elPat) {
70  throw cms::Exception("ERROR: this VID selection is meant to be run on miniAOD/PAT only")
71  << std::endl
72  << "Change input format to PAT/miniAOD or contact Egamma experts" << std::endl
73  << std::endl;
74  }
75 
76  const float isoCut = (cand->pt() < ptCutOff_ ? (absEta < barrelCutOff_ ? isoCutEBLowPt_ : isoCutEELowPt_)
78 
79  const float eA = effectiveAreas_.getEffectiveArea(absEta);
80  const float rho = rhoHandle_.isValid() ? (float)(*rhoHandle_) : 0; // std::max likes float arguments
81 
82  float isoValue = -999;
83  if (isoType_ == ISO_ECAL) {
84  isoValue = elPat->ecalPFClusterIso();
85  } else if (isoType_ == ISO_HCAL) {
86  isoValue = elPat->hcalPFClusterIso();
87  } else {
88  throw cms::Exception("ERROR: unknown type requested for PF cluster isolation.")
89  << std::endl
90  << "Check VID configuration." << std::endl;
91  }
92  float isoValueCorr = std::max(0.0f, isoValue - rho * eA);
93 
94  // Apply the cut and return the result
95  // Scale by pT if the relative isolation is requested but avoid division by 0
96  return isoValueCorr < isoCut * (isRelativeIso_ ? cand->pt() : 1.);
97 }
98 
101  // Establish the cut value
102  double absEta = std::abs(ele->superCluster()->eta());
103 
104  const pat::Electron* elPat = dynamic_cast<const pat::Electron*>(ele.get());
105  if (!elPat) {
106  throw cms::Exception("ERROR: this VID selection is meant to be run on miniAOD/PAT only")
107  << std::endl
108  << "Change input format to PAT/miniAOD or contact Egamma experts" << std::endl
109  << std::endl;
110  }
111 
112  const float eA = effectiveAreas_.getEffectiveArea(absEta);
113  const float rho = rhoHandle_.isValid() ? (float)(*rhoHandle_) : 0; // std::max likes float arguments
114 
115  float isoValue = -999;
116  if (isoType_ == ISO_ECAL) {
117  isoValue = elPat->ecalPFClusterIso();
118  } else if (isoType_ == ISO_HCAL) {
119  isoValue = elPat->hcalPFClusterIso();
120  } else {
121  throw cms::Exception("ERROR: unknown type requested for PF cluster isolation.")
122  << std::endl
123  << "Check VID configuration." << std::endl;
124  }
125  float isoValueCorr = std::max(0.0f, isoValue - rho * eA);
126 
127  // Divide by pT if the relative isolation is requested
128  if (isRelativeIso_)
129  isoValueCorr /= ele->pt();
130 
131  // Apply the cut and return the result
132  return isoValueCorr;
133 }
edm::Handle< double > rhoHandle_
std::unordered_map< std::string, edm::InputTag > contentTags_
static constexpr char rhoString_[]
double pt() const final
transverse momentum
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
result_type operator()(const reco::GsfElectronPtr &) const final
double value(const reco::CandidatePtr &cand) const final
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:141
const float getEffectiveArea(float eta) const
CandidateType candidateType() const final
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
GsfEleCalPFClusterIsoCut(const edm::ParameterSet &c)
Analysis-level electron class.
Definition: Electron.h:51
void getEventContent(const edm::EventBase &) final
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setConsumes(edm::ConsumesCollector &) final
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:155