CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
12 
13  void setConsumes(edm::ConsumesCollector&) final;
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()) {
52  contentTags_.emplace(rhoString_, rhoTag);
53 }
54 
56  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
57  contentTokens_.emplace(rhoString_, rho);
58 }
59 
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 
100  reco::GsfElectronPtr ele(cand);
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_
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
const edm::EventSetup & c
std::unordered_map< std::string, edm::InputTag > contentTags_
static constexpr char rhoString_[]
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
bool ev
const float getEffectiveArea(float eta) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
result_type operator()(const reco::GsfElectronPtr &) const final
double value(const reco::CandidatePtr &cand) const final
bool isValid() const
Definition: HandleBase.h:70
CandidateType candidateType() const final
edm::Ptr< Candidate > CandidatePtr
persistent reference to an object in a collection of Candidate objects
Definition: CandidateFwd.h:25
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
GsfEleCalPFClusterIsoCut(const edm::ParameterSet &c)
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Analysis-level electron class.
Definition: Electron.h:51
void getEventContent(const edm::EventBase &) final
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:92
#define DEFINE_EDM_PLUGIN(factory, type, name)
void setConsumes(edm::ConsumesCollector &) final