CMS 3D CMS Logo

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