CMS 3D CMS Logo

Photon.h
Go to the documentation of this file.
1 //
2 //
3 
4 #ifndef DataFormats_PatCandidates_Photon_h
5 #define DataFormats_PatCandidates_Photon_h
6 
28 
29 // Define typedefs for convenience
30 namespace pat {
31  class Photon;
32  typedef std::vector<Photon> PhotonCollection;
35 } // namespace pat
36 
37 namespace reco {
39  std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
40 } // namespace reco
41 
42 // Class definition
43 namespace pat {
44  class PATPhotonSlimmer;
45 
46  class Photon : public PATObject<reco::Photon> {
47  public:
48  typedef std::pair<std::string, Bool_t> IdPair;
49 
51  Photon();
53  Photon(const reco::Photon& aPhoton);
55  Photon(const edm::RefToBase<reco::Photon>& aPhotonRef);
57  Photon(const edm::Ptr<reco::Photon>& aPhotonRef);
59  ~Photon() override;
60 
62  Photon* clone() const override { return new Photon(*this); }
63 
64  // ---- methods for content embedding ----
66  reco::SuperClusterRef superCluster() const override;
68  reco::CaloClusterPtr seed() const;
69 
70  //method to access the basic clusters
71  const std::vector<reco::CaloCluster>& basicClusters() const { return basicClusters_; }
72  //method to access the preshower clusters
73  const std::vector<reco::CaloCluster>& preshowerClusters() const { return preshowerClusters_; }
74 
75  //method to access embedded ecal RecHits
76  const EcalRecHitCollection* recHits() const { return &recHits_; }
77 
79  void embedSuperCluster();
81  void embedSeedCluster();
83  void embedBasicClusters();
88 
89  // ---- methods for access the generated photon ----
91  const reco::Candidate* genPhoton() const { return genParticle(); }
93  void setGenPhoton(const reco::GenParticleRef& gp, bool embed = false) { setGenParticleRef(gp, embed); }
94 
95  // ---- methods for photon ID ----
98  Bool_t photonID(const std::string& name) const;
100  bool isPhotonIDAvailable(const std::string& name) const;
103  const std::vector<IdPair>& photonIDs() const { return photonIDs_; }
106  void setPhotonIDs(const std::vector<IdPair>& ids) { photonIDs_ = ids; }
107 
108  // ---- methods for photon isolation ----
111  float trackIso() const { return trkSumPtSolidConeDR04(); }
114  float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
117  float hcalIso() const { return hcalTowerSumEtConeDR04(); }
120  float caloIso() const { return ecalIso() + hcalIso(); }
121 
133  float photonIso() const { return reco::Photon::photonIso(); }
137 
139  float userIso(uint8_t index = 0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
143  if (key >= 0) {
144  //if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
145  //<< "Isolation corresponding to key " << key
146  //<< " was not stored for this particle.";
147  if (size_t(key) >= isolations_.size())
148  return -1.0;
149  return isolations_[key];
150  } else
151  switch (key) {
152  case pat::CaloIso:
153  //if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
154  //<< "CalIsoo Isolation was not stored for this particle.";
155  if (isolations_.size() <= pat::HcalIso)
156  return -1.0;
158  default:
159  return -1.0;
160  //throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
161  //<< key << " was not stored for this particle.";
162  }
163  }
164 
167  float puppiPhotonIso() const { return puppiPhotonIso_; }
168 
172  if (key >= 0) {
173  if (size_t(key) >= isolations_.size())
174  isolations_.resize(key + 1, -1.0);
175  isolations_[key] = value;
176  } else {
177  throw cms::Exception("Illegal Argument")
178  << "The key for which you're setting isolation does not correspond "
179  << "to an individual isolation but to the sum of more independent isolations "
180  << "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n"
181  << "Please set up each component independly.\n";
182  }
183  }
193  void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_) {
194  puppiChargedHadronIso_ = chargedhadrons_;
195  puppiNeutralHadronIso_ = neutralhadrons_;
196  puppiPhotonIso_ = photons_;
197  }
198 
199  // ---- methods for photon isolation deposits ----
202  for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end(); it != ed; ++it) {
203  if (it->first == key)
204  return &it->second;
205  }
206  return nullptr;
207  }
211  const IsoDeposit* ecalIsoDeposit() const { return isoDeposit(pat::EcalIso); }
213  const IsoDeposit* hcalIsoDeposit() const { return isoDeposit(pat::HcalIso); }
215  const IsoDeposit* userIsoDeposit(uint8_t index = 0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
218  IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
219  for (; it != ed; ++it) {
220  if (it->first == key) {
221  it->second = dep;
222  return;
223  }
224  }
225  isoDeposits_.push_back(std::make_pair(key, dep));
226  }
234  void userIsoDeposit(const IsoDeposit& dep, uint8_t index = 0) {
236  }
238  bool passElectronVeto() const { return passElectronVeto_; }
240  //pixel seed to veto electron (not recommended by EGM POG but it seems very efficient)
241  bool hasPixelSeed() const { return hasPixelSeed_; }
243 
245  float seedEnergy() const { return seedEnergy_; }
246  void setSeedEnergy(float e) { seedEnergy_ = e; }
247 
248  float eMax() const { return eMax_; }
249  void setEMax(float e) { eMax_ = e; }
250  float e2nd() const { return e2nd_; }
251  void setE2nd(float e) { e2nd_ = e; }
252  float e3x3() const { return e3x3_; }
253  void setE3x3(float e) { e3x3_ = e; }
254  float eTop() const { return eTop_; }
255  void setETop(float e) { eTop_ = e; }
256  float eBottom() const { return eBottom_; }
257  void setEBottom(float e) { eBottom_ = e; }
258  float eLeft() const { return eLeft_; }
259  void setELeft(float e) { eLeft_ = e; }
260  float eRight() const { return eRight_; }
261  void setERight(float e) { eRight_ = e; }
262 
263  float see() const { return see_; }
264  void setSee(float s) { see_ = s; }
265  float spp() const { return spp_; }
266  void setSpp(float s) { spp_ = s; }
267  float sep() const { return sep_; }
268  void setSep(float s) { sep_ = s; }
269 
270  float maxDR() const { return maxDR_; }
271  void setMaxDR(float m) { maxDR_ = m; }
272  float maxDRDPhi() const { return maxDRDPhi_; }
273  void setMaxDRDPhi(float m) { maxDRDPhi_ = m; }
274  float maxDRDEta() const { return maxDRDEta_; }
275  void setMaxDRDEta(float m) { maxDRDEta_ = m; }
276  float maxDRRawEnergy() const { return maxDRRawEnergy_; }
278 
279  float subClusRawE1() const { return subClusRawE1_; }
280  void setSubClusRawE1(float s) { subClusRawE1_ = s; }
281  float subClusRawE2() const { return subClusRawE2_; }
282  void setSubClusRawE2(float s) { subClusRawE2_ = s; }
283  float subClusRawE3() const { return subClusRawE3_; }
284  void setSubClusRawE3(float s) { subClusRawE3_ = s; }
285 
286  float subClusDPhi1() const { return subClusDPhi1_; }
287  void setSubClusDPhi1(float s) { subClusDPhi1_ = s; }
288  float subClusDPhi2() const { return subClusDPhi2_; }
289  void setSubClusDPhi2(float s) { subClusDPhi2_ = s; }
290  float subClusDPhi3() const { return subClusDPhi3_; }
291  void setSubClusDPhi3(float s) { subClusDPhi3_ = s; }
292 
293  float subClusDEta1() const { return subClusDEta1_; }
294  void setSubClusDEta1(float s) { subClusDEta1_ = s; }
295  float subClusDEta2() const { return subClusDEta2_; }
296  void setSubClusDEta2(float s) { subClusDEta2_ = s; }
297  float subClusDEta3() const { return subClusDEta3_; }
298  void setSubClusDEta3(float s) { subClusDEta3_ = s; }
299 
300  float cryPhi() const { return cryPhi_; }
301  void setCryPhi(float c) { cryPhi_ = c; }
302  float cryEta() const { return cryEta_; }
303  void setCryEta(float c) { cryEta_ = c; }
304 
305  float iPhi() const { return iPhi_; }
306  void setIPhi(float i) { iPhi_ = i; }
307  float iEta() const { return iEta_; }
308  void setIEta(float i) { iEta_ = i; }
309 
311  friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
312 
316  template <typename T>
318  T beginIndexItr,
319  T endIndexItr) {
320  packedPFCandidates_ = refprod;
322  associatedPackedFCandidateIndices_.insert(associatedPackedFCandidateIndices_.begin(), beginIndexItr, endIndexItr);
323  }
324 
326  size_t numberOfSourceCandidatePtrs() const override { return associatedPackedFCandidateIndices_.size(); }
329 
330  friend class PATPhotonSlimmer;
331 
332  protected:
333  // ---- for content embedding ----
335  std::vector<reco::SuperCluster> superCluster_;
339  std::vector<reco::CaloCluster> basicClusters_;
341  std::vector<reco::CaloCluster> preshowerClusters_;
345  std::vector<reco::CaloCluster> seedCluster_;
350  // ---- photon ID's holder ----
351  std::vector<IdPair> photonIDs_;
352  // ---- Isolation and IsoDeposit related datamebers ----
353  typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
355  std::vector<float> isolations_;
356 
360 
362  float seedEnergy_;
363  float eMax_;
364  float e2nd_;
365  float e3x3_;
366  float eTop_;
367  float eBottom_;
368  float eLeft_;
369  float eRight_;
370 
371  float see_;
372  float spp_;
373  float sep_;
374 
375  float maxDR_;
376  float maxDRDPhi_;
377  float maxDRDEta_;
379 
383 
387 
391 
392  float cryEta_;
393  float cryPhi_;
394  float iEta_;
395  float iPhi_;
396 
397  //PUPPI isolations
401 
402  // ---- link to PackedPFCandidates
404  std::vector<uint16_t> associatedPackedFCandidateIndices_;
405  };
406 
407 } // namespace pat
408 
409 #endif
float eTop() const
Definition: Photon.h:254
float subClusRawE1() const
Definition: Photon.h:279
float subClusDEta3_
Definition: Photon.h:390
float subClusDPhi1_
Definition: Photon.h:384
void setSpp(float s)
Definition: Photon.h:266
float neutralHadronIso() const
Definition: Photon.h:130
Analysis-level Photon class.
Definition: Photon.h:46
edm::RefVector< PhotonCollection > PhotonRefVector
Definition: Photon.h:34
float patParticleIso() const
Definition: Photon.h:124
void setIEta(float i)
Definition: Photon.h:308
float eLeft() const
Definition: Photon.h:258
float cryEta_
Definition: Photon.h:392
float userIso(uint8_t index=0) const
Returns a user defined isolation value.
Definition: Photon.h:139
float eLeft_
Definition: Photon.h:368
const IsoDeposit * hcalIsoDeposit() const
Return the hcal IsoDeposit.
Definition: Photon.h:213
Definition: Photon.py:1
float seedEnergy() const
input variables for regression energy corrections
Definition: Photon.h:245
void setEcalIso(float caloIso)
Sets ecal isolation variable.
Definition: Photon.h:187
float maxDR() const
Definition: Photon.h:270
const IsoDeposit * trackIsoDeposit() const
Return the tracker IsoDeposit.
Definition: Photon.h:209
void setSubClusDPhi3(float s)
Definition: Photon.h:291
void setTrackIso(float trackIso)
Sets tracker isolation variable.
Definition: Photon.h:185
size_t size_type
Definition: Candidate.h:29
void setE2nd(float e)
Definition: Photon.h:251
const reco::GenParticle * genParticle(size_t idx=0) const
Definition: PATObject.h:285
float photonIso() const
Definition: Photon.h:133
float cryEta() const
Definition: Photon.h:302
void setSee(float s)
Definition: Photon.h:264
bool passElectronVeto_
-— conversion veto -—
Definition: Photon.h:358
const reco::Candidate * genPhoton() const
return the match to the generated photon
Definition: Photon.h:91
void trackIsoDeposit(const IsoDeposit &dep)
Sets tracker IsoDeposit.
Definition: Photon.h:228
edm::Ref< PhotonCollection > PhotonRef
Definition: Photon.h:33
float ecalRecHitSumEtConeDR04() const
Definition: Photon.h:457
void setMaxDRRawEnergy(float m)
Definition: Photon.h:277
float iPhi() const
Definition: Photon.h:305
void embedSeedCluster()
method to store the electron&#39;s seedcluster internally
float caloIso() const
Definition: Photon.h:120
float subClusRawE2() const
Definition: Photon.h:281
float sep_
Definition: Photon.h:373
void setAssociatedPackedPFCandidates(const edm::RefProd< pat::PackedCandidateCollection > &refprod, T beginIndexItr, T endIndexItr)
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
Definition: Photon.h:317
void ecalIsoDeposit(const IsoDeposit &dep)
Sets ecal IsoDeposit.
Definition: Photon.h:230
void setSubClusDPhi2(float s)
Definition: Photon.h:289
float spp_
Definition: Photon.h:372
float eRight_
Definition: Photon.h:369
const IsoDeposit * isoDeposit(IsolationKeys key) const
Returns the IsoDeposit associated with some key, or a null pointer if it is not available.
Definition: Photon.h:201
void embedRecHits(const EcalRecHitCollection *rechits)
method to store the RecHits internally - can be called from the PATElectronProducer ...
bool hasPixelSeed_
Definition: Photon.h:359
void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_)
Sets PUPPI isolation.
Definition: Photon.h:193
float see_
Definition: Photon.h:371
float subClusDPhi3_
Definition: Photon.h:386
std::vector< reco::SuperCluster > superCluster_
Definition: Photon.h:335
IsolationKeys
Enum defining isolation keys.
Definition: Isolation.h:9
std::vector< reco::CaloCluster > preshowerClusters_
Place to store electron&#39;s preshower clusters internally.
Definition: Photon.h:341
void setUserIso(float value, uint8_t index=0)
Sets user isolation variable index.
Definition: Photon.h:191
float subClusDEta3() const
Definition: Photon.h:297
float subClusDEta1() const
Definition: Photon.h:293
void setIPhi(float i)
Definition: Photon.h:306
const IsoDeposit * userIsoDeposit(uint8_t index=0) const
Return a specified user-level IsoDeposit.
Definition: Photon.h:215
reco::CandidatePtr sourceCandidatePtr(size_type i) const override
get the source candidate pointer with index i
float puppiChargedHadronIso() const
Definition: Photon.h:165
void setGenParticleRef(const reco::GenParticleRef &ref, bool embed=false)
Set the generator level particle reference.
Definition: PATObject.h:743
float subClusRawE2_
Definition: Photon.h:381
float chargedHadronIso() const
Definition: Photon.h:127
float trackIso() const
Definition: Photon.h:111
std::vector< reco::CaloCluster > seedCluster_
Place to store electron&#39;s seed cluster internally.
Definition: Photon.h:345
float sep() const
Definition: Photon.h:267
float spp() const
Definition: Photon.h:265
float photonIso() const
Definition: Photon.h:550
#define embed
Definition: AMPTWrapper.h:188
void setHcalIso(float caloIso)
Sets hcal isolation variable.
Definition: Photon.h:189
Definition: HeavyIon.h:7
float trkSumPtSolidConeDR04() const
Definition: Photon.h:495
void setIsolation(IsolationKeys key, float value)
Definition: Photon.h:171
bool passElectronVeto() const
vertex fit method
Definition: Photon.h:238
float subClusRawE1_
Definition: Photon.h:380
void setELeft(float e)
Definition: Photon.h:259
float subClusRawE3_
Definition: Photon.h:382
void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep)
Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
Definition: Photon.h:217
void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0)
Sets user-level IsoDeposit.
Definition: Photon.h:234
void setEMax(float e)
Definition: Photon.h:249
slimmer of PAT Taus
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:66
float puppiChargedHadronIso_
Definition: Photon.h:398
float hcalTowerSumEtConeDR04(int depth=0) const
Definition: Photon.h:475
void setERight(float e)
Definition: Photon.h:261
float subClusDEta2() const
Definition: Photon.h:295
float maxDRDPhi() const
Definition: Photon.h:272
void setMaxDRDEta(float m)
Definition: Photon.h:275
bool isPhotonIDAvailable(const std::string &name) const
Returns true if a specific ID is available in this pat::Photon.
float eMax_
Definition: Photon.h:363
const std::vector< reco::CaloCluster > & basicClusters() const
Definition: Photon.h:71
float puppiNeutralHadronIso_
Definition: Photon.h:399
void setPhotonIDs(const std::vector< IdPair > &ids)
Definition: Photon.h:106
float chargedHadronIso() const
Accessors for Particle Flow Isolation variables.
Definition: Photon.h:545
float puppiNeutralHadronIso() const
Definition: Photon.h:166
float userIsolation(IsolationKeys key) const
Definition: Photon.h:142
void embedBasicClusters()
method to store the electron&#39;s basic clusters
edm::RefProd< pat::PackedCandidateCollection > packedPFCandidates_
Definition: Photon.h:403
float iEta() const
Definition: Photon.h:307
void setPassElectronVeto(bool flag)
Definition: Photon.h:239
void setETop(float e)
Definition: Photon.h:255
Bool_t photonID(const std::string &name) const
const std::vector< reco::CaloCluster > & preshowerClusters() const
Definition: Photon.h:73
Definition: value.py:1
void setSeedEnergy(float e)
Definition: Photon.h:246
float subClusRawE3() const
Definition: Photon.h:283
void setSubClusDPhi1(float s)
Definition: Photon.h:287
void hcalIsoDeposit(const IsoDeposit &dep)
Sets hcal IsoDeposit.
Definition: Photon.h:232
void setSubClusDEta1(float s)
Definition: Photon.h:294
float subClusDPhi2() const
Definition: Photon.h:288
float subClusDPhi3() const
Definition: Photon.h:290
std::vector< IdPair > photonIDs_
Definition: Photon.h:351
float puppiPhotonIso_
Definition: Photon.h:400
float subClusDPhi1() const
Definition: Photon.h:286
float eRight() const
Definition: Photon.h:260
float maxDRDEta() const
Definition: Photon.h:274
~Photon() override
destructor
void embedPreshowerClusters()
method to store the electron&#39;s preshower clusters
size_t numberOfSourceCandidatePtrs() const override
get the number of non-null PFCandidates
Definition: Photon.h:326
bool embeddedSuperCluster_
Definition: Photon.h:334
void setCryEta(float c)
Definition: Photon.h:303
float ecalIso() const
Definition: Photon.h:114
edm::AtomicPtrCache< std::vector< reco::SuperCluster > > superClusterRelinked_
Place to temporarily store the electron&#39;s supercluster after relinking the seed to it...
Definition: Photon.h:337
float e2nd_
Definition: Photon.h:364
void embedSuperCluster()
method to store the photon&#39;s supercluster internally
float iEta_
Definition: Photon.h:394
EcalRecHitCollection recHits_
Place to store electron&#39;s RecHits internally (5x5 around seed+ all RecHits)
Definition: Photon.h:349
bool embeddedRecHits_
True if RecHits stored internally.
Definition: Photon.h:347
unsigned int index
index type
Definition: Candidate.h:50
void setCryPhi(float c)
Definition: Photon.h:301
float e3x3_
Definition: Photon.h:365
void setHasPixelSeed(bool flag)
Definition: Photon.h:242
float hcalIso() const
Definition: Photon.h:117
float cryPhi_
Definition: Photon.h:393
float subClusDEta2_
Definition: Photon.h:389
const EcalRecHitCollection * recHits() const
Definition: Photon.h:76
void setSubClusDEta2(float s)
Definition: Photon.h:296
float puChargedHadronIso() const
Definition: Photon.h:136
void setMaxDR(float m)
Definition: Photon.h:271
float subClusDEta1_
Definition: Photon.h:388
float eMax() const
Definition: Photon.h:248
IsoDepositPairs isoDeposits_
Definition: Photon.h:354
float eBottom_
Definition: Photon.h:367
void setSubClusRawE2(float s)
Definition: Photon.h:282
float e2nd() const
Definition: Photon.h:250
reco::SuperClusterRef superCluster() const override
override the superCluster method from CaloJet, to access the internal storage of the supercluster ...
void setEBottom(float e)
Definition: Photon.h:257
float seedEnergy_
-— input variables for regression energy corrections -—
Definition: Photon.h:362
void setMaxDRDPhi(float m)
Definition: Photon.h:273
fixed size matrix
Photon * clone() const override
required reimplementation of the Candidate&#39;s clone method
Definition: Photon.h:62
void setSubClusDEta3(float s)
Definition: Photon.h:298
float subClusDPhi2_
Definition: Photon.h:385
const IsoDeposit * ecalIsoDeposit() const
Return the ecal IsoDeposit.
Definition: Photon.h:211
bool embeddedSeedCluster_
True if seed cluster is stored internally.
Definition: Photon.h:343
void setSubClusRawE1(float s)
Definition: Photon.h:280
float eBottom() const
Definition: Photon.h:256
bool hasPixelSeed() const
Definition: Photon.h:241
Templated PAT object container.
Definition: PATObject.h:43
float puppiPhotonIso() const
Definition: Photon.h:167
float iPhi_
Definition: Photon.h:395
void setSubClusRawE3(float s)
Definition: Photon.h:284
std::vector< uint16_t > associatedPackedFCandidateIndices_
Definition: Photon.h:404
float maxDRDEta_
Definition: Photon.h:377
float cryPhi() const
Definition: Photon.h:300
float maxDRRawEnergy() const
Definition: Photon.h:276
long double T
float maxDRRawEnergy_
Definition: Photon.h:378
float eTop_
Definition: Photon.h:366
float maxDRDPhi_
Definition: Photon.h:376
float see() const
Definition: Photon.h:263
float maxDR_
Definition: Photon.h:375
std::vector< std::pair< IsolationKeys, pat::IsoDeposit > > IsoDepositPairs
Definition: Photon.h:353
float neutralHadronIso() const
Definition: Photon.h:549
const std::vector< IdPair > & photonIDs() const
Definition: Photon.h:103
void setGenPhoton(const reco::GenParticleRef &gp, bool embed=false)
method to set the generated photon
Definition: Photon.h:93
reco::CaloClusterPtr seed() const
direct access to the seed cluster
std::vector< Photon > PhotonCollection
Definition: Photon.h:31
std::pair< std::string, Bool_t > IdPair
Definition: Photon.h:48
Photon()
default constructor
void setE3x3(float e)
Definition: Photon.h:253
std::vector< reco::CaloCluster > basicClusters_
Place to store electron&#39;s basic clusters internally.
Definition: Photon.h:339
std::vector< float > isolations_
Definition: Photon.h:355
edm::RefVector< pat::PackedCandidateCollection > associatedPackedPFCandidates() const
References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet recl...
float e3x3() const
Definition: Photon.h:252
void setSep(float s)
Definition: Photon.h:268