File indexing completed on 2024-04-06 12:04:55
0001
0002
0003
0004 #ifndef DataFormats_PatCandidates_Photon_h
0005 #define DataFormats_PatCandidates_Photon_h
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include "DataFormats/PatCandidates/interface/PATObject.h"
0021 #include "DataFormats/EgammaCandidates/interface/Photon.h"
0022 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
0023 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
0024 #include "DataFormats/PatCandidates/interface/Isolation.h"
0025 #include "DataFormats/PatCandidates/interface/PackedCandidate.h"
0026 #include "DataFormats/EcalRecHit/interface/EcalRecHitCollections.h"
0027 #include "DataFormats/Common/interface/AtomicPtrCache.h"
0028
0029
0030 namespace pat {
0031 class Photon;
0032 typedef std::vector<Photon> PhotonCollection;
0033 typedef edm::Ref<PhotonCollection> PhotonRef;
0034 typedef edm::RefVector<PhotonCollection> PhotonRefVector;
0035 }
0036
0037 namespace reco {
0038
0039 std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
0040 }
0041
0042
0043 namespace pat {
0044 class PATPhotonSlimmer;
0045
0046 class Photon : public PATObject<reco::Photon> {
0047 public:
0048 typedef std::pair<std::string, Bool_t> IdPair;
0049
0050
0051 Photon();
0052
0053 Photon(const reco::Photon& aPhoton);
0054
0055 Photon(const edm::RefToBase<reco::Photon>& aPhotonRef);
0056
0057 Photon(const edm::Ptr<reco::Photon>& aPhotonRef);
0058
0059 ~Photon() override;
0060
0061
0062 Photon* clone() const override { return new Photon(*this); }
0063
0064
0065
0066 reco::SuperClusterRef superCluster() const override;
0067
0068 reco::CaloClusterPtr seed() const;
0069
0070
0071 const std::vector<reco::CaloCluster>& basicClusters() const { return basicClusters_; }
0072
0073 const std::vector<reco::CaloCluster>& preshowerClusters() const { return preshowerClusters_; }
0074
0075
0076 const EcalRecHitCollection* recHits() const { return &recHits_; }
0077
0078
0079 void embedSuperCluster();
0080
0081 void embedSeedCluster();
0082
0083 void embedBasicClusters();
0084
0085 void embedPreshowerClusters();
0086
0087 void embedRecHits(const EcalRecHitCollection* rechits);
0088
0089
0090
0091 const reco::Candidate* genPhoton() const { return genParticle(); }
0092
0093 void setGenPhoton(const reco::GenParticleRef& gp, bool embed = false) { setGenParticleRef(gp, embed); }
0094
0095
0096
0097
0098 Bool_t photonID(const std::string& name) const;
0099
0100 bool isPhotonIDAvailable(const std::string& name) const;
0101
0102
0103 const std::vector<IdPair>& photonIDs() const { return photonIDs_; }
0104
0105
0106 void setPhotonIDs(const std::vector<IdPair>& ids) { photonIDs_ = ids; }
0107
0108
0109
0110
0111 float trackIso() const { return trkSumPtSolidConeDR04(); }
0112
0113
0114 float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
0115
0116
0117 float hcalIso() const { return hcalTowerSumEtConeDR04(); }
0118
0119
0120 float caloIso() const { return ecalIso() + hcalIso(); }
0121
0122
0123
0124 float patParticleIso() const { return userIsolation(pat::PfAllParticleIso); }
0125
0126
0127 float chargedHadronIso() const { return reco::Photon::chargedHadronIso(); }
0128
0129
0130 float neutralHadronIso() const { return reco::Photon::neutralHadronIso(); }
0131
0132
0133 float photonIso() const { return reco::Photon::photonIso(); }
0134
0135
0136 float puChargedHadronIso() const { return userIsolation(pat::PfPUChargedHadronIso); }
0137
0138
0139 float userIso(uint8_t index = 0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
0140
0141
0142 float userIsolation(IsolationKeys key) const {
0143 if (key >= 0) {
0144
0145
0146
0147 if (size_t(key) >= isolations_.size())
0148 return -1.0;
0149 return isolations_[key];
0150 } else
0151 switch (key) {
0152 case pat::CaloIso:
0153
0154
0155 if (isolations_.size() <= pat::HcalIso)
0156 return -1.0;
0157 return isolations_[pat::EcalIso] + isolations_[pat::HcalIso];
0158 default:
0159 return -1.0;
0160
0161
0162 }
0163 }
0164
0165 float puppiChargedHadronIso() const { return puppiChargedHadronIso_; }
0166 float puppiNeutralHadronIso() const { return puppiNeutralHadronIso_; }
0167 float puppiPhotonIso() const { return puppiPhotonIso_; }
0168
0169
0170
0171 void setIsolation(IsolationKeys key, float value) {
0172 if (key >= 0) {
0173 if (size_t(key) >= isolations_.size())
0174 isolations_.resize(key + 1, -1.0);
0175 isolations_[key] = value;
0176 } else {
0177 throw cms::Exception("Illegal Argument")
0178 << "The key for which you're setting isolation does not correspond "
0179 << "to an individual isolation but to the sum of more independent isolations "
0180 << "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n"
0181 << "Please set up each component independly.\n";
0182 }
0183 }
0184
0185 void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
0186
0187 void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
0188
0189 void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
0190
0191 void setUserIso(float value, uint8_t index = 0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
0192
0193 void setIsolationPUPPI(float chargedhadrons_, float neutralhadrons_, float photons_) {
0194 puppiChargedHadronIso_ = chargedhadrons_;
0195 puppiNeutralHadronIso_ = neutralhadrons_;
0196 puppiPhotonIso_ = photons_;
0197 }
0198
0199
0200
0201 const IsoDeposit* isoDeposit(IsolationKeys key) const {
0202 for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end(); it != ed; ++it) {
0203 if (it->first == key)
0204 return &it->second;
0205 }
0206 return nullptr;
0207 }
0208
0209 const IsoDeposit* trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
0210
0211 const IsoDeposit* ecalIsoDeposit() const { return isoDeposit(pat::EcalIso); }
0212
0213 const IsoDeposit* hcalIsoDeposit() const { return isoDeposit(pat::HcalIso); }
0214
0215 const IsoDeposit* userIsoDeposit(uint8_t index = 0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
0216
0217 void setIsoDeposit(IsolationKeys key, const IsoDeposit& dep) {
0218 IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
0219 for (; it != ed; ++it) {
0220 if (it->first == key) {
0221 it->second = dep;
0222 return;
0223 }
0224 }
0225 isoDeposits_.push_back(std::make_pair(key, dep));
0226 }
0227
0228 void trackIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::TrackIso, dep); }
0229
0230 void ecalIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::EcalIso, dep); }
0231
0232 void hcalIsoDeposit(const IsoDeposit& dep) { setIsoDeposit(pat::HcalIso, dep); }
0233
0234 void userIsoDeposit(const IsoDeposit& dep, uint8_t index = 0) {
0235 setIsoDeposit(IsolationKeys(UserBaseIso + index), dep);
0236 }
0237
0238 bool passElectronVeto() const { return passElectronVeto_; }
0239 void setPassElectronVeto(bool flag) { passElectronVeto_ = flag; }
0240
0241 bool hasPixelSeed() const { return hasPixelSeed_; }
0242 void setHasPixelSeed(bool flag) { hasPixelSeed_ = flag; }
0243
0244
0245 float seedEnergy() const { return seedEnergy_; }
0246 void setSeedEnergy(float e) { seedEnergy_ = e; }
0247
0248 float eMax() const { return eMax_; }
0249 void setEMax(float e) { eMax_ = e; }
0250 float e2nd() const { return e2nd_; }
0251 void setE2nd(float e) { e2nd_ = e; }
0252 float e3x3() const { return e3x3_; }
0253 void setE3x3(float e) { e3x3_ = e; }
0254 float eTop() const { return eTop_; }
0255 void setETop(float e) { eTop_ = e; }
0256 float eBottom() const { return eBottom_; }
0257 void setEBottom(float e) { eBottom_ = e; }
0258 float eLeft() const { return eLeft_; }
0259 void setELeft(float e) { eLeft_ = e; }
0260 float eRight() const { return eRight_; }
0261 void setERight(float e) { eRight_ = e; }
0262
0263 float see() const { return see_; }
0264 void setSee(float s) { see_ = s; }
0265 float spp() const { return spp_; }
0266 void setSpp(float s) { spp_ = s; }
0267 float sep() const { return sep_; }
0268 void setSep(float s) { sep_ = s; }
0269
0270 float maxDR() const { return maxDR_; }
0271 void setMaxDR(float m) { maxDR_ = m; }
0272 float maxDRDPhi() const { return maxDRDPhi_; }
0273 void setMaxDRDPhi(float m) { maxDRDPhi_ = m; }
0274 float maxDRDEta() const { return maxDRDEta_; }
0275 void setMaxDRDEta(float m) { maxDRDEta_ = m; }
0276 float maxDRRawEnergy() const { return maxDRRawEnergy_; }
0277 void setMaxDRRawEnergy(float m) { maxDRRawEnergy_ = m; }
0278
0279 float subClusRawE1() const { return subClusRawE1_; }
0280 void setSubClusRawE1(float s) { subClusRawE1_ = s; }
0281 float subClusRawE2() const { return subClusRawE2_; }
0282 void setSubClusRawE2(float s) { subClusRawE2_ = s; }
0283 float subClusRawE3() const { return subClusRawE3_; }
0284 void setSubClusRawE3(float s) { subClusRawE3_ = s; }
0285
0286 float subClusDPhi1() const { return subClusDPhi1_; }
0287 void setSubClusDPhi1(float s) { subClusDPhi1_ = s; }
0288 float subClusDPhi2() const { return subClusDPhi2_; }
0289 void setSubClusDPhi2(float s) { subClusDPhi2_ = s; }
0290 float subClusDPhi3() const { return subClusDPhi3_; }
0291 void setSubClusDPhi3(float s) { subClusDPhi3_ = s; }
0292
0293 float subClusDEta1() const { return subClusDEta1_; }
0294 void setSubClusDEta1(float s) { subClusDEta1_ = s; }
0295 float subClusDEta2() const { return subClusDEta2_; }
0296 void setSubClusDEta2(float s) { subClusDEta2_ = s; }
0297 float subClusDEta3() const { return subClusDEta3_; }
0298 void setSubClusDEta3(float s) { subClusDEta3_ = s; }
0299
0300 float cryPhi() const { return cryPhi_; }
0301 void setCryPhi(float c) { cryPhi_ = c; }
0302 float cryEta() const { return cryEta_; }
0303 void setCryEta(float c) { cryEta_ = c; }
0304
0305 float iPhi() const { return iPhi_; }
0306 void setIPhi(float i) { iPhi_ = i; }
0307 float iEta() const { return iEta_; }
0308 void setIEta(float i) { iEta_ = i; }
0309
0310
0311 friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
0312
0313
0314 edm::RefVector<pat::PackedCandidateCollection> associatedPackedPFCandidates() const;
0315
0316 template <typename T>
0317 void setAssociatedPackedPFCandidates(const edm::RefProd<pat::PackedCandidateCollection>& refprod,
0318 T beginIndexItr,
0319 T endIndexItr) {
0320 packedPFCandidates_ = refprod;
0321 associatedPackedFCandidateIndices_.clear();
0322 associatedPackedFCandidateIndices_.insert(associatedPackedFCandidateIndices_.begin(), beginIndexItr, endIndexItr);
0323 }
0324
0325
0326 size_t numberOfSourceCandidatePtrs() const override { return associatedPackedFCandidateIndices_.size(); }
0327
0328 reco::CandidatePtr sourceCandidatePtr(size_type i) const override;
0329
0330 friend class PATPhotonSlimmer;
0331
0332 protected:
0333
0334 bool embeddedSuperCluster_;
0335 std::vector<reco::SuperCluster> superCluster_;
0336
0337 edm::AtomicPtrCache<std::vector<reco::SuperCluster> > superClusterRelinked_;
0338
0339 std::vector<reco::CaloCluster> basicClusters_;
0340
0341 std::vector<reco::CaloCluster> preshowerClusters_;
0342
0343 bool embeddedSeedCluster_;
0344
0345 std::vector<reco::CaloCluster> seedCluster_;
0346
0347 bool embeddedRecHits_;
0348
0349 EcalRecHitCollection recHits_;
0350
0351 std::vector<IdPair> photonIDs_;
0352
0353 typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
0354 IsoDepositPairs isoDeposits_;
0355 std::vector<float> isolations_;
0356
0357
0358 bool passElectronVeto_;
0359 bool hasPixelSeed_;
0360
0361
0362 float seedEnergy_;
0363 float eMax_;
0364 float e2nd_;
0365 float e3x3_;
0366 float eTop_;
0367 float eBottom_;
0368 float eLeft_;
0369 float eRight_;
0370
0371 float see_;
0372 float spp_;
0373 float sep_;
0374
0375 float maxDR_;
0376 float maxDRDPhi_;
0377 float maxDRDEta_;
0378 float maxDRRawEnergy_;
0379
0380 float subClusRawE1_;
0381 float subClusRawE2_;
0382 float subClusRawE3_;
0383
0384 float subClusDPhi1_;
0385 float subClusDPhi2_;
0386 float subClusDPhi3_;
0387
0388 float subClusDEta1_;
0389 float subClusDEta2_;
0390 float subClusDEta3_;
0391
0392 float cryEta_;
0393 float cryPhi_;
0394 float iEta_;
0395 float iPhi_;
0396
0397
0398 float puppiChargedHadronIso_;
0399 float puppiNeutralHadronIso_;
0400 float puppiPhotonIso_;
0401
0402
0403 edm::RefProd<pat::PackedCandidateCollection> packedPFCandidates_;
0404 std::vector<uint16_t> associatedPackedFCandidateIndices_;
0405 };
0406
0407 }
0408
0409 #endif