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 }
GsfEleCalPFClusterIsoCut::IsoType
IsoType
Definition: GsfEleCalPFClusterIsoCut.cc:7
electrons_cff.bool
bool
Definition: electrons_cff.py:372
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
GsfEleCalPFClusterIsoCut::value
double value(const reco::CandidatePtr &cand) const final
Definition: GsfEleCalPFClusterIsoCut.cc:99
contentValuesFiles.fullPath
fullPath
Definition: contentValuesFiles.py:64
edm
HLT enums.
Definition: AlignableModifier.h:19
GsfEleCalPFClusterIsoCut::isoCutEBLowPt_
const float isoCutEBLowPt_
Definition: GsfEleCalPFClusterIsoCut.cc:22
HLT_2018_cff.rhoTag
rhoTag
Definition: HLT_2018_cff.py:13606
GsfEleCalPFClusterIsoCut::isoCutEEHighPt_
const float isoCutEEHighPt_
Definition: GsfEleCalPFClusterIsoCut.cc:22
GsfEleCalPFClusterIsoCut::isoType_
const int isoType_
Definition: GsfEleCalPFClusterIsoCut.cc:24
edm::Ptr::get
T const * get() const
Returns C++ pointer to the item.
Definition: Ptr.h:139
reco::LeafCandidate::pt
double pt() const final
transverse momentum
Definition: LeafCandidate.h:146
watchdog.const
const
Definition: watchdog.py:83
edm::Handle< double >
GsfEleCalPFClusterIsoCut::isoCutEBHighPt_
const float isoCutEBHighPt_
Definition: GsfEleCalPFClusterIsoCut.cc:22
GsfEleCalPFClusterIsoCut::getEventContent
void getEventContent(const edm::EventBase &) final
Definition: GsfEleCalPFClusterIsoCut.cc:60
CutApplicatorWithEventContentBase::contentTags_
std::unordered_map< std::string, edm::InputTag > contentTags_
Definition: CutApplicatorWithEventContentBase.h:35
candidate_functions::CandidateCut::result_type
bool result_type
Definition: CandidateCut.h:11
EffectiveAreas
Definition: EffectiveAreas.h:8
GsfEleCalPFClusterIsoCut::barrelCutOff_
const float barrelCutOff_
Definition: GsfEleCalPFClusterIsoCut.cc:26
CutApplicatorWithEventContentBase.h
zSelection_cfi.isoCut
isoCut
Definition: zSelection_cfi.py:5
GsfEleCalPFClusterIsoCut::isRelativeIso_
bool isRelativeIso_
Definition: GsfEleCalPFClusterIsoCut.cc:27
GsfElectron.h
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
DDAxes::rho
GsfEleCalPFClusterIsoCut::candidateType
CandidateType candidateType() const final
Definition: GsfEleCalPFClusterIsoCut.cc:18
GsfEleCalPFClusterIsoCut::rhoHandle_
edm::Handle< double > rhoHandle_
Definition: GsfEleCalPFClusterIsoCut.cc:31
edm::ParameterSet
Definition: ParameterSet.h:36
CutApplicatorBase::CandidateType
CandidateType
Definition: CutApplicatorBase.h:47
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
edmplugin::PluginFactory
Definition: PluginFactory.h:34
cand
Definition: decayParser.h:34
GsfEleCalPFClusterIsoCut
Definition: GsfEleCalPFClusterIsoCut.cc:5
createfilelist.int
int
Definition: createfilelist.py:10
GsfEleCalPFClusterIsoCut::UNDEF
Definition: GsfEleCalPFClusterIsoCut.cc:7
GsfEleCalPFClusterIsoCut::effectiveAreas_
EffectiveAreas effectiveAreas_
Definition: GsfEleCalPFClusterIsoCut.cc:29
GsfEleCalPFClusterIsoCut::GsfEleCalPFClusterIsoCut
GsfEleCalPFClusterIsoCut(const edm::ParameterSet &c)
Definition: GsfEleCalPFClusterIsoCut.cc:40
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
cc
edm::Ptr< reco::GsfElectron >
GsfEleCalPFClusterIsoCut::isoCutEELowPt_
const float isoCutEELowPt_
Definition: GsfEleCalPFClusterIsoCut.cc:22
GsfEleCalPFClusterIsoCut::ptCutOff_
const float ptCutOff_
Definition: GsfEleCalPFClusterIsoCut.cc:25
ev
bool ev
Definition: Hydjet2Hadronizer.cc:95
CutApplicatorWithEventContentBase::contentTokens_
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
Definition: CutApplicatorWithEventContentBase.h:40
edm::EventBase
Definition: EventBase.h:46
Exception
Definition: hltDiff.cc:246
EffectiveAreas::getEffectiveArea
const float getEffectiveArea(float eta) const
Definition: EffectiveAreas.cc:44
GsfEleCalPFClusterIsoCut::setConsumes
void setConsumes(edm::ConsumesCollector &) final
Definition: GsfEleCalPFClusterIsoCut.cc:55
reco::GsfElectron::superCluster
SuperClusterRef superCluster() const override
reference to a SuperCluster
Definition: GsfElectron.h:163
pat::Electron
Analysis-level electron class.
Definition: Electron.h:51
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EffectiveAreas.h
GsfEleCalPFClusterIsoCut::ISO_HCAL
Definition: GsfEleCalPFClusterIsoCut.cc:7
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
GsfEleCalPFClusterIsoCut::ISO_ECAL
Definition: GsfEleCalPFClusterIsoCut.cc:7
CutApplicatorBase::ELECTRON
Definition: CutApplicatorBase.h:47
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:39
CutApplicatorWithEventContentBase
Definition: CutApplicatorWithEventContentBase.h:19
GsfEleCalPFClusterIsoCut::operator()
result_type operator()(const reco::GsfElectronPtr &) const final
Definition: GsfEleCalPFClusterIsoCut.cc:64
GsfEleCalPFClusterIsoCut::rhoString_
constexpr static char rhoString_[]
Definition: GsfEleCalPFClusterIsoCut.cc:33