CMS 3D CMS Logo

PhoAnyPFIsoWithEACut.cc
Go to the documentation of this file.
4 
6 public:
8 
9  result_type operator()(const reco::PhotonPtr&) const final;
10 
12  void getEventContent(const edm::EventBase&) final;
13 
14  double value(const reco::CandidatePtr& cand) const final;
15 
17 
18 private:
19  // Cut values
20  float _C1_EB;
21  float _C2_EB;
22  float _C1_EE;
23  float _C2_EE;
24  // Configuration
27  // Effective area constants
29  // The isolations computed upstream
31  // The rho
33 
34  constexpr static char anyPFIsoWithEA_[] = "anyPFIsoWithEA";
35  constexpr static char rhoString_[] = "rho";
36 };
37 
39 constexpr char PhoAnyPFIsoWithEACut::rhoString_[];
40 
42 
45  _C1_EB(c.getParameter<double>("C1_EB")),
46  _C2_EB(c.getParameter<double>("C2_EB")),
47  _C1_EE(c.getParameter<double>("C1_EE")),
48  _C2_EE(c.getParameter<double>("C2_EE")),
49  _barrelCutOff(c.getParameter<double>("barrelCutOff")),
50  _useRelativeIso(c.getParameter<bool>("useRelativeIso")),
51  _effectiveAreas((c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath()) {
52  edm::InputTag maptag = c.getParameter<edm::InputTag>("anyPFIsoMap");
53  contentTags_.emplace(anyPFIsoWithEA_, maptag);
54 
55  edm::InputTag rhoTag = c.getParameter<edm::InputTag>("rho");
56  contentTags_.emplace(rhoString_, rhoTag);
57 }
58 
60  auto anyPFIsoWithEA = cc.consumes<edm::ValueMap<float> >(contentTags_[anyPFIsoWithEA_]);
61  contentTokens_.emplace(anyPFIsoWithEA_, anyPFIsoWithEA);
62 
63  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
64  contentTokens_.emplace(rhoString_, rho);
65 }
66 
69  ev.getByLabel(contentTags_[rhoString_], _rhoHandle);
70 }
71 
73  // in case we are by-value
74  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
76  float anyisoval = -1.0;
77  if (_anyPFIsoMap.isValid() && _anyPFIsoMap->contains(cand.id())) {
78  anyisoval = (*_anyPFIsoMap)[cand];
79  } else if (_anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 && cand.id() == edm::ProductID()) {
80  // in case we have spoofed a ptr
81  //note this must be a 1:1 valuemap (only one product input)
82  anyisoval = _anyPFIsoMap->begin()[cand.key()];
83  } else if (_anyPFIsoMap.isValid()) { // throw an exception
84  anyisoval = (*_anyPFIsoMap)[cand];
85  }
86 
87  // Figure out the cut value
88  // The value is generally pt-dependent: C1 + pt * C2
89  const double absEta = std::abs(cand->superCluster()->eta());
90  const float anyPFIsoWithEACutValue =
91  (absEta < _barrelCutOff ? _C1_EB + cand->pt() * _C2_EB : _C1_EE + cand->pt() * _C2_EE);
92 
93  // Retrieve the variable value for this particle
94  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
95 
96  // Apply pile-up correction
97  const double eA = _effectiveAreas.getEffectiveArea(absEta);
98  const double rho = _rhoHandle.isValid() ? *_rhoHandle : 0;
99  const float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
100 
101  // Apply the cut and return the result
102  // Scale by pT if the relative isolation is requested but avoid division by 0
103  return anyPFIsoWithEA < anyPFIsoWithEACutValue * (_useRelativeIso ? cand->pt() : 1.);
104 }
105 
107  reco::PhotonPtr pho(cand);
108 
109  // in case we are by-value
110  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
112  float anyisoval = -1.0;
113  if (_anyPFIsoMap.isValid() && _anyPFIsoMap->contains(cand.id())) {
114  anyisoval = (*_anyPFIsoMap)[cand];
115  } else if (_anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 && cand.id() == edm::ProductID()) {
116  // in case we have spoofed a ptr
117  //note this must be a 1:1 valuemap (only one product input)
118  anyisoval = _anyPFIsoMap->begin()[cand.key()];
119  } else if (_anyPFIsoMap.isValid()) { // throw an exception
120  anyisoval = (*_anyPFIsoMap)[cand];
121  }
122 
123  // Figure out the cut value
124  // The value is generally pt-dependent: C1 + pt * C2
125  double absEta = std::abs(pho->superCluster()->eta());
126 
127  // Retrieve the variable value for this particle
128  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
129 
130  // Apply pile-up correction
131  double eA = _effectiveAreas.getEffectiveArea(absEta);
132  double rho = *_rhoHandle;
133  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
134 
135  // Divide by pT if the relative isolation is requested
136  if (_useRelativeIso)
137  anyPFIsoWithEA /= pho->pt();
138 
139  // Apply the cut and return the result
140  return anyPFIsoWithEA;
141 }
CandidateType candidateType() const final
void setConsumes(edm::ConsumesCollector &) final
std::unordered_map< std::string, edm::InputTag > contentTags_
size_t idSize() const
Definition: ValueMap.h:157
static constexpr char anyPFIsoWithEA_[]
static constexpr char rhoString_[]
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
double value(const reco::CandidatePtr &cand) const final
Definition: HeavyIon.h:7
void getEventContent(const edm::EventBase &) final
edm::Handle< double > _rhoHandle
result_type operator()(const reco::PhotonPtr &) const final
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const float getEffectiveArea(float eta) const
const_iterator begin() const
Definition: ValueMap.h:229
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
bool isValid() const
Definition: HandleBase.h:70
HLT enums.
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
#define DEFINE_EDM_PLUGIN(factory, type, name)
EffectiveAreas _effectiveAreas
bool contains(ProductID id) const
Definition: ValueMap.h:155
PhoAnyPFIsoWithEACut(const edm::ParameterSet &c)