CMS 3D CMS Logo

PhoAnyPFIsoWithEAAndExpoScalingEBCut.cc
Go to the documentation of this file.
4 
5 
7 public:
9 
10  result_type operator()(const reco::PhotonPtr&) const override final;
11 
12  void setConsumes(edm::ConsumesCollector&) override final;
13  void getEventContent(const edm::EventBase&) override final;
14 
15  double value(const reco::CandidatePtr& cand) const override final;
16 
17  CandidateType candidateType() const override final {
18  return PHOTON;
19  }
20 
21 private:
22  // Cut values
23  float _C1_EB;
24  float _C2_EB;
25  float _C3_EB;
26  float _C1_EE;
27  float _C2_EE;
28  // Configuration
31  // Effective area constants
33  // The isolations computed upstream
35  // The rho
37 
38  constexpr static char anyPFIsoWithEA_[] = "anyPFIsoWithEA";
39  constexpr static char rhoString_ [] = "rho";
40 };
41 
44 
47  "PhoAnyPFIsoWithEAAndExpoScalingEBCut");
48 
51  _C1_EB(c.getParameter<double>("C1_EB")),
52  _C2_EB(c.getParameter<double>("C2_EB")),
53  _C3_EB(c.getParameter<double>("C3_EB")),
54  _C1_EE(c.getParameter<double>("C1_EE")),
55  _C2_EE(c.getParameter<double>("C2_EE")),
56  _barrelCutOff(c.getParameter<double>("barrelCutOff")),
57  _useRelativeIso(c.getParameter<bool>("useRelativeIso")),
58  _effectiveAreas( (c.getParameter<edm::FileInPath>("effAreasConfigFile")).fullPath())
59 {
60 
61  edm::InputTag maptag = c.getParameter<edm::InputTag>("anyPFIsoMap");
62  contentTags_.emplace(anyPFIsoWithEA_,maptag);
63 
65  contentTags_.emplace(rhoString_,rhoTag);
66 
67 }
68 
70  auto anyPFIsoWithEA =
72  contentTokens_.emplace(anyPFIsoWithEA_,anyPFIsoWithEA);
73 
74  auto rho = cc.consumes<double>(contentTags_[rhoString_]);
75  contentTokens_.emplace(rhoString_, rho);
76 }
77 
81 }
82 
83 CutApplicatorBase::result_type
86 
87  // in case we are by-value
88  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
90  float anyisoval = -1.0;
91  if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
92  anyisoval = (*_anyPFIsoMap)[cand];
93  } else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
94  cand.id() == edm::ProductID() ) {
95  // in case we have spoofed a ptr
96  //note this must be a 1:1 valuemap (only one product input)
97  anyisoval = _anyPFIsoMap->begin()[cand.key()];
98  } else if ( _anyPFIsoMap.isValid() ){ // throw an exception
99  anyisoval = (*_anyPFIsoMap)[cand];
100  }
101 
102  // Figure out the cut value
103  // The value is generally pt-dependent: C1 + pt * C2
104  const float pt = cand->pt();
105 
106  // In this version of the isolation cut we apply
107  // exponential pt scaling to the barrel isolation cut,
108  // and linear pt scaling to the endcap isolation cut.
109  double absEta = std::abs(cand->superCluster()->eta());
110  const float isolationCutValue =
111  ( absEta < _barrelCutOff ?
112  _C1_EB + exp( pt*_C2_EB + _C3_EB)
113  : _C1_EE + pt * _C2_EE);
114 
115  // Retrieve the variable value for this particle
116  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
117 
118  // Apply pile-up correction
119  double eA = _effectiveAreas.getEffectiveArea( absEta );
120  double rho = *_rhoHandle;
121  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
122 
123  // Divide by pT if the relative isolation is requested
124  if( _useRelativeIso )
125  anyPFIsoWithEA /= pt;
126 
127  // Apply the cut and return the result
128  return anyPFIsoWithEA < isolationCutValue;
129 }
130 
133  reco::PhotonPtr pho(cand);
134 
135  // in case we are by-value
136  const std::string& inst_name = contentTags_.find(anyPFIsoWithEA_)->second.instance();
138  float anyisoval = -1.0;
139  if( _anyPFIsoMap.isValid() && _anyPFIsoMap->contains( cand.id() ) ) {
140  anyisoval = (*_anyPFIsoMap)[cand];
141  } else if ( _anyPFIsoMap.isValid() && _anyPFIsoMap->idSize() == 1 &&
142  cand.id() == edm::ProductID() ) {
143  // in case we have spoofed a ptr
144  //note this must be a 1:1 valuemap (only one product input)
145  anyisoval = _anyPFIsoMap->begin()[cand.key()];
146  } else if ( _anyPFIsoMap.isValid() ){ // throw an exception
147  anyisoval = (*_anyPFIsoMap)[cand];
148  }
149 
150  // Figure out the cut value
151  // The value is generally pt-dependent: C1 + pt * C2
152  const float pt = pho->pt();
153 
154  // In this version of the isolation cut we apply
155  // exponential pt scaling to the barrel isolation cut,
156  // and linear pt scaling to the endcap isolation cut.
157  double absEta = std::abs(pho->superCluster()->eta());
158 
159  // Retrieve the variable value for this particle
160  float anyPFIso = _anyPFIsoMap.isValid() ? anyisoval : pat->userFloat(inst_name);
161 
162  // Apply pile-up correction
163  double eA = _effectiveAreas.getEffectiveArea( absEta );
164  double rho = *_rhoHandle;
165  float anyPFIsoWithEA = std::max(0.0, anyPFIso - rho * eA);
166 
167  // Divide by pT if the relative isolation is requested
168  if( _useRelativeIso )
169  anyPFIsoWithEA /= pt;
170 
171  // Apply the cut and return the result
172  return anyPFIsoWithEA;
173 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
T getParameter(std::string const &) const
virtual double pt() const final
transverse momentum
void setConsumes(edm::ConsumesCollector &) override final
reco::SuperClusterRef superCluster() const
Ref to SuperCluster.
key_type key() const
Definition: Ptr.h:185
std::unordered_map< std::string, edm::EDGetToken > contentTokens_
double value(const reco::CandidatePtr &cand) const override final
bool ev
const float getEffectiveArea(float eta) const
#define constexpr
std::unordered_map< std::string, edm::InputTag > contentTags_
float userFloat(const std::string &key) const
Definition: PATObject.h:791
Definition: HeavyIon.h:7
bool contains(ProductID id) const
Definition: ValueMap.h:155
edm::Handle< edm::ValueMap< float > > _anyPFIsoMap
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool isValid() const
Definition: HandleBase.h:74
size_t idSize() const
Definition: ValueMap.h:159
const_iterator begin() const
Definition: ValueMap.h:208
CandidateType candidateType() const override final
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:180
bool getByLabel(InputTag const &, Handle< T > &) const
Definition: EventBase.h:94
HLT enums.
#define DEFINE_EDM_PLUGIN(factory, type, name)
void getEventContent(const edm::EventBase &) override final
result_type operator()(const reco::PhotonPtr &) const override final