1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
|
//
//
#ifndef DataFormats_PatCandidates_Photon_h
#define DataFormats_PatCandidates_Photon_h
/**
\class pat::Photon Photon.h "DataFormats/PatCandidates/interface/Photon.h"
\brief Analysis-level Photon class
pat::Photon implements the analysis-level photon class within the 'pat'
namespace.
Please post comments and questions to the Physics Tools hypernews:
https://hypernews.cern.ch/HyperNews/CMS/get/physTools.html
\author Steven Lowette, Giovanni Petrucciani, Frederic Ronga
*/
#include "DataFormats/PatCandidates/interface/PATObject.h"
#include "DataFormats/EgammaCandidates/interface/Photon.h"
#include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
#include "DataFormats/PatCandidates/interface/Isolation.h"
#include "DataFormats/PatCandidates/interface/PackedCandidate.h"
#include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
#include "DataFormats/Common/interface/AtomicPtrCache.h"
// Define typedefs for convenience
namespace pat {
class Photon;
typedef std::vector<Photon> PhotonCollection;
typedef edm::Ref<PhotonCollection> PhotonRef;
typedef edm::RefVector<PhotonCollection> PhotonRefVector;
} // namespace pat
namespace reco {
/// pipe operator (introduced to use pat::Photon with PFTopProjectors)
std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
} // namespace reco
// Class definition
namespace pat {
class PATPhotonSlimmer;
class Photon : public PATObject<reco::Photon> {
public:
typedef std::pair<std::string, Bool_t> IdPair;
/// default constructor
Photon();
/// constructor from a reco photon
Photon(const reco::Photon& aPhoton);
/// constructor from a RefToBase to a reco photon (to be superseded by Ptr counterpart)
Photon(const edm::RefToBase<reco::Photon>& aPhotonRef);
/// constructor from a Ptr to a reco photon
Photon(const edm::Ptr<reco::Photon>& aPhotonRef);
/// destructor
~Photon() override;
/// required reimplementation of the Candidate's clone method
Photon* clone() const override { return new Photon(*this); }
// ---- methods for content embedding ----
/// override the superCluster method from CaloJet, to access the internal storage of the supercluster
reco::SuperClusterRef superCluster() const override;
/// direct access to the seed cluster
reco::CaloClusterPtr seed() const;
//method to access the basic clusters
const std::vector<reco::CaloCluster>& basicClusters() const { return basicClusters_; }
//method to access the preshower clusters
const std::vector<reco::CaloCluster>& preshowerClusters() const { return preshowerClusters_; }
//method to access embedded ecal RecHits
const EcalRecHitCollection* recHits() const { return &recHits_; }
/// method to store the photon's supercluster internally
void embedSuperCluster();
/// method to store the electron's seedcluster internally
void embedSeedCluster();
/// method to store the electron's basic clusters
void embedBasicClusters();
/// method to store the electron's preshower clusters
void embedPreshowerClusters();
/// method to store the RecHits internally - can be called from the PATElectronProducer
void embedRecHits(const EcalRecHitCollection* rechits);
// ---- methods for access the generated photon ----
/// return the match to the generated photon
const reco::Candidate* genPhoton() const { return genParticle(); }
/// method to set the generated photon
void setGenPhoton(const reco::GenParticleRef& gp, bool embed = false) { setGenParticleRef(gp, embed); }
// ---- methods for photon ID ----
/// Returns a specific photon ID associated to the pat::Photon given its name.
/// Note: an exception is thrown if the specified ID is not available
Bool_t photonID(const std::string& name) const;
/// Returns true if a specific ID is available in this pat::Photon
bool isPhotonIDAvailable(const std::string& name) const;
/// Returns all the Photon IDs in the form of <name,value> pairs
/// The 'default' ID is the first in the list
const std::vector<IdPair>& photonIDs() const { return photonIDs_; }
/// Store multiple photon ID values, discarding existing ones
/// The first one in the list becomes the 'default' photon id
void setPhotonIDs(const std::vector<IdPair>& ids) { photonIDs_ = ids; }
// ---- methods for photon isolation ----
/// Returns the summed track pt in a cone of deltaR<0.4
/// including the region of the reconstructed photon
float trackIso() const { return trkSumPtSolidConeDR04(); }
/// Returns the summed Et in a cone of deltaR<0.4
/// calculated from recHits
float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
/// Returns summed Et in a cone of deltaR<0.4 calculated
/// from caloTowers
float hcalIso() const { return hcalTowerSumEtConeDR04(); }
/// Returns the calorimeter isolation combined from ecal
/// and hcal
float caloIso() const { return ecalIso() + hcalIso(); }
/// PARTICLE FLOW ISOLATION
/// Returns the isolation calculated with all the PFCandidates
float patParticleIso() const { return userIsolation(pat::PfAllParticleIso); }
/// Returns the isolation calculated with only the charged hadron
/// PFCandidates
float chargedHadronIso() const { return reco::Photon::chargedHadronIso(); }
/// Returns the isolation calculated with only the neutral hadron
/// PFCandidates
float neutralHadronIso() const { return reco::Photon::neutralHadronIso(); }
/// Returns the isolation calculated with only the gamma
/// PFCandidates
float photonIso() const { return reco::Photon::photonIso(); }
/// Returns the isolation calculated with only the pile-up charged hadron
/// PFCandidates
float puChargedHadronIso() const { return userIsolation(pat::PfPUChargedHadronIso); }
/// Returns a user defined isolation value
float userIso(uint8_t index = 0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
/// Returns the isolation variable for a specifc key (or
/// pseudo-key like CaloIso), or -1.0 if not available
float userIsolation(IsolationKeys key) const {
if (key >= 0) {
//if (key >= isolations_.size()) throw cms::Excepton("Missing Data")
//<< "Isolation corresponding to key " << key
//<< " was not stored for this particle.";
if (size_t(key) >= isolations_.size())
return -1.0;
return isolations_[key];
} else
switch (key) {
case pat::CaloIso:
//if (isolations_.size() <= pat::HcalIso) throw cms::Excepton("Missing Data")
//<< "CalIsoo Isolation was not stored for this particle.";
if (isolations_.size() <= pat::HcalIso)
return -1.0;
return isolations_[pat::EcalIso] + isolations_[pat::HcalIso];
default:
return -1.0;
//throw cms::Excepton("Missing Data") << "Isolation corresponding to key "
//<< key << " was not stored for this particle.";
}
}
float puppiChargedHadronIso() const { return puppiChargedHadronIso_; }
float puppiNeutralHadronIso() const { return puppiNeutralHadronIso_; }
float puppiPhotonIso() const { return puppiPhotonIso_; }
/// Sets the isolation variable for a specifc key.
/// Note that you can't set isolation for a pseudo-key like CaloIso
void setIsolation(IsolationKeys key, float value) {
if (key >= 0) {
if (size_t(key) >= isolations_.size())
isolations_.resize(key + 1, -1.0);
isolations_[key] = value;
} else {
throw cms::Exception("Illegal Argument")
<< "The key for which you're setting isolation does not correspond "
<< "to an individual isolation but to the sum of more independent isolations "
<< "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n"
<< "Please set up each component independly.\n";
}
}
/// Sets tracker isolation variable
void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
/// Sets ecal isolation variable
void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
/// Sets hcal isolation variable
void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
/// Sets user isolation variable #index
void setUserIso(float value, uint8_t index = 0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
/// Sets PUPPI isolation
void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_) {
puppiChargedHadronIso_ = chargedhadrons_;
puppiNeutralHadronIso_ = neutralhadrons_;
puppiPhotonIso_ = photons_;
}
// ---- methods for photon isolation deposits ----
/// Returns the IsoDeposit associated with some key, or a null pointer if it is not available
const IsoDeposit* isoDeposit(IsolationKeys key) const {
for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end(); it != ed; ++it) {
if (it->first == key)
return &it->second;
}
return nullptr;
}
/// Return the tracker IsoDeposit
const IsoDeposit* trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
/// Return the ecal IsoDeposit
const IsoDeposit* ecalIsoDeposit() const { return isoDeposit(pat::EcalIso); }
/// Return the hcal IsoDeposit
const IsoDeposit* hcalIsoDeposit() const { return isoDeposit(pat::HcalIso); }
/// Return a specified user-level IsoDeposit
const IsoDeposit* userIsoDeposit(uint8_t index = 0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
/// Sets the IsoDeposit associated with some key; if it is already existent, it is overwritten.
void setIsoDeposit(IsolationKeys key, const IsoDeposit& dep) {
IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
for (; it != ed; ++it) {
if (it->first == key) {
it->second = dep;
return;
}
}
isoDeposits_.push_back(std::make_pair(key, dep));
}
/// Sets tracker IsoDeposit
void trackIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::TrackIso, dep); }
/// Sets ecal IsoDeposit
void ecalIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::EcalIso, dep); }
/// Sets hcal IsoDeposit
void hcalIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::HcalIso, dep); }
/// Sets user-level IsoDeposit
void userIsoDeposit(const IsoDeposit& dep, uint8_t index = 0) {
setIsoDeposit(IsolationKeys(UserBaseIso + index), dep);
}
/// vertex fit method
bool passElectronVeto() const { return passElectronVeto_; }
void setPassElectronVeto(bool flag) { passElectronVeto_ = flag; }
//pixel seed to veto electron (not recommended by EGM POG but it seems very efficient)
bool hasPixelSeed() const { return hasPixelSeed_; }
void setHasPixelSeed(bool flag) { hasPixelSeed_ = flag; }
/// input variables for regression energy corrections
float seedEnergy() const { return seedEnergy_; }
void setSeedEnergy(float e) { seedEnergy_ = e; }
float eMax() const { return eMax_; }
void setEMax(float e) { eMax_ = e; }
float e2nd() const { return e2nd_; }
void setE2nd(float e) { e2nd_ = e; }
float e3x3() const { return e3x3_; }
void setE3x3(float e) { e3x3_ = e; }
float eTop() const { return eTop_; }
void setETop(float e) { eTop_ = e; }
float eBottom() const { return eBottom_; }
void setEBottom(float e) { eBottom_ = e; }
float eLeft() const { return eLeft_; }
void setELeft(float e) { eLeft_ = e; }
float eRight() const { return eRight_; }
void setERight(float e) { eRight_ = e; }
float see() const { return see_; }
void setSee(float s) { see_ = s; }
float spp() const { return spp_; }
void setSpp(float s) { spp_ = s; }
float sep() const { return sep_; }
void setSep(float s) { sep_ = s; }
float maxDR() const { return maxDR_; }
void setMaxDR(float m) { maxDR_ = m; }
float maxDRDPhi() const { return maxDRDPhi_; }
void setMaxDRDPhi(float m) { maxDRDPhi_ = m; }
float maxDRDEta() const { return maxDRDEta_; }
void setMaxDRDEta(float m) { maxDRDEta_ = m; }
float maxDRRawEnergy() const { return maxDRRawEnergy_; }
void setMaxDRRawEnergy(float m) { maxDRRawEnergy_ = m; }
float subClusRawE1() const { return subClusRawE1_; }
void setSubClusRawE1(float s) { subClusRawE1_ = s; }
float subClusRawE2() const { return subClusRawE2_; }
void setSubClusRawE2(float s) { subClusRawE2_ = s; }
float subClusRawE3() const { return subClusRawE3_; }
void setSubClusRawE3(float s) { subClusRawE3_ = s; }
float subClusDPhi1() const { return subClusDPhi1_; }
void setSubClusDPhi1(float s) { subClusDPhi1_ = s; }
float subClusDPhi2() const { return subClusDPhi2_; }
void setSubClusDPhi2(float s) { subClusDPhi2_ = s; }
float subClusDPhi3() const { return subClusDPhi3_; }
void setSubClusDPhi3(float s) { subClusDPhi3_ = s; }
float subClusDEta1() const { return subClusDEta1_; }
void setSubClusDEta1(float s) { subClusDEta1_ = s; }
float subClusDEta2() const { return subClusDEta2_; }
void setSubClusDEta2(float s) { subClusDEta2_ = s; }
float subClusDEta3() const { return subClusDEta3_; }
void setSubClusDEta3(float s) { subClusDEta3_ = s; }
float cryPhi() const { return cryPhi_; }
void setCryPhi(float c) { cryPhi_ = c; }
float cryEta() const { return cryEta_; }
void setCryEta(float c) { cryEta_ = c; }
float iPhi() const { return iPhi_; }
void setIPhi(float i) { iPhi_ = i; }
float iEta() const { return iEta_; }
void setIEta(float i) { iEta_ = i; }
/// pipe operator (introduced to use pat::Photon with PFTopProjectors)
friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
/// References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet reclustering)
edm::RefVector<pat::PackedCandidateCollection> associatedPackedPFCandidates() const;
/// References to PFCandidates linked to this object (e.g. for isolation vetos or masking before jet reclustering)
template <typename T>
void setAssociatedPackedPFCandidates(const edm::RefProd<pat::PackedCandidateCollection>& refprod,
T beginIndexItr,
T endIndexItr) {
packedPFCandidates_ = refprod;
associatedPackedFCandidateIndices_.clear();
associatedPackedFCandidateIndices_.insert(associatedPackedFCandidateIndices_.begin(), beginIndexItr, endIndexItr);
}
/// get the number of non-null PFCandidates
size_t numberOfSourceCandidatePtrs() const override { return associatedPackedFCandidateIndices_.size(); }
/// get the source candidate pointer with index i
reco::CandidatePtr sourceCandidatePtr(size_type i) const override;
friend class PATPhotonSlimmer;
protected:
// ---- for content embedding ----
bool embeddedSuperCluster_;
std::vector<reco::SuperCluster> superCluster_;
/// Place to temporarily store the electron's supercluster after relinking the seed to it
edm::AtomicPtrCache<std::vector<reco::SuperCluster> > superClusterRelinked_;
/// Place to store electron's basic clusters internally
std::vector<reco::CaloCluster> basicClusters_;
/// Place to store electron's preshower clusters internally
std::vector<reco::CaloCluster> preshowerClusters_;
/// True if seed cluster is stored internally
bool embeddedSeedCluster_;
/// Place to store electron's seed cluster internally
std::vector<reco::CaloCluster> seedCluster_;
/// True if RecHits stored internally
bool embeddedRecHits_;
/// Place to store electron's RecHits internally (5x5 around seed+ all RecHits)
EcalRecHitCollection recHits_;
// ---- photon ID's holder ----
std::vector<IdPair> photonIDs_;
// ---- Isolation and IsoDeposit related datamebers ----
typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
IsoDepositPairs isoDeposits_;
std::vector<float> isolations_;
/// ---- conversion veto ----
bool passElectronVeto_;
bool hasPixelSeed_;
/// ---- input variables for regression energy corrections ----
float seedEnergy_;
float eMax_;
float e2nd_;
float e3x3_;
float eTop_;
float eBottom_;
float eLeft_;
float eRight_;
float see_;
float spp_;
float sep_;
float maxDR_;
float maxDRDPhi_;
float maxDRDEta_;
float maxDRRawEnergy_;
float subClusRawE1_;
float subClusRawE2_;
float subClusRawE3_;
float subClusDPhi1_;
float subClusDPhi2_;
float subClusDPhi3_;
float subClusDEta1_;
float subClusDEta2_;
float subClusDEta3_;
float cryEta_;
float cryPhi_;
float iEta_;
float iPhi_;
//PUPPI isolations
float puppiChargedHadronIso_;
float puppiNeutralHadronIso_;
float puppiPhotonIso_;
// ---- link to PackedPFCandidates
edm::RefProd<pat::PackedCandidateCollection> packedPFCandidates_;
std::vector<uint16_t> associatedPackedFCandidateIndices_;
};
} // namespace pat
#endif
|