CMS 3D CMS Logo

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