Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef DataFormats_PatCandidates_Photon_h
00006 #define DataFormats_PatCandidates_Photon_h
00007
00022 #include "DataFormats/PatCandidates/interface/PATObject.h"
00023 #include "DataFormats/EgammaCandidates/interface/Photon.h"
00024 #include "DataFormats/EgammaReco/interface/SuperClusterFwd.h"
00025 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00026 #include "DataFormats/PatCandidates/interface/Isolation.h"
00027
00028
00029
00030 namespace pat {
00031 class Photon;
00032 typedef std::vector<Photon> PhotonCollection;
00033 typedef edm::Ref<PhotonCollection> PhotonRef;
00034 typedef edm::RefVector<PhotonCollection> PhotonRefVector;
00035 }
00036
00037 namespace reco {
00039 std::ostream& operator<<(std::ostream& out, const pat::Photon& obj);
00040 }
00041
00042
00043 namespace pat {
00044
00045
00046 class Photon : public PATObject<reco::Photon> {
00047
00048 public:
00049
00050 typedef std::pair<std::string,Bool_t> IdPair;
00051
00053 Photon();
00055 Photon(const reco::Photon & aPhoton);
00057 Photon(const edm::RefToBase<reco::Photon> & aPhotonRef);
00059 Photon(const edm::Ptr<reco::Photon> & aPhotonRef);
00061 virtual ~Photon();
00062
00064 virtual Photon * clone() const { return new Photon(*this); }
00065
00066
00068 reco::SuperClusterRef superCluster() const;
00070 void embedSuperCluster();
00071
00072
00074 const reco::Candidate * genPhoton() const { return genParticle(); }
00076 void setGenPhoton(const reco::GenParticleRef & gp, bool embed=false) { setGenParticleRef(gp, embed); }
00077
00078
00081 Bool_t photonID(const std::string & name) const;
00083 bool isPhotonIDAvailable(const std::string & name) const;
00086 const std::vector<IdPair> & photonIDs() const { return photonIDs_; }
00089 void setPhotonIDs(const std::vector<IdPair> & ids) { photonIDs_ = ids; }
00090
00091
00092
00095 float trackIso() const { return trkSumPtSolidConeDR04(); }
00098 float ecalIso() const { return ecalRecHitSumEtConeDR04(); }
00101 float hcalIso() const { return hcalTowerSumEtConeDR04(); }
00104 float caloIso() const { return ecalIso()+hcalIso(); }
00106 float userIso(uint8_t index=0) const { return userIsolation(IsolationKeys(UserBaseIso + index)); }
00109 float userIsolation(IsolationKeys key) const {
00110 if (key >= 0) {
00111
00112
00113
00114 if (size_t(key) >= isolations_.size()) return -1.0;
00115 return isolations_[key];
00116 } else switch (key) {
00117 case pat::CaloIso:
00118
00119
00120 if (isolations_.size() <= pat::HcalIso) return -1.0;
00121 return isolations_[pat::EcalIso] + isolations_[pat::HcalIso];
00122 default:
00123 return -1.0;
00124
00125
00126 }
00127 }
00130 void setIsolation(IsolationKeys key, float value) {
00131 if (key >= 0) {
00132 if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
00133 isolations_[key] = value;
00134 } else {
00135 throw cms::Exception("Illegal Argument") <<
00136 "The key for which you're setting isolation does not correspond " <<
00137 "to an individual isolation but to the sum of more independent isolations " <<
00138 "(e.g. Calo = Ecal + Hcal), so you can't SET the value, just GET it.\n" <<
00139 "Please set up each component independly.\n";
00140 }
00141 }
00143 void setTrackIso(float trackIso) { setIsolation(TrackIso, trackIso); }
00145 void setEcalIso(float caloIso) { setIsolation(EcalIso, caloIso); }
00147 void setHcalIso(float caloIso) { setIsolation(HcalIso, caloIso); }
00149 void setUserIso(float value, uint8_t index=0) { setIsolation(IsolationKeys(UserBaseIso + index), value); }
00150
00151
00153 const IsoDeposit * isoDeposit(IsolationKeys key) const {
00154 for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00155 it != ed; ++it)
00156 {
00157 if (it->first == key) return & it->second;
00158 }
00159 return 0;
00160 }
00162 const IsoDeposit * trackIsoDeposit() const { return isoDeposit(pat::TrackIso); }
00164 const IsoDeposit * ecalIsoDeposit() const { return isoDeposit(pat::EcalIso ); }
00166 const IsoDeposit * hcalIsoDeposit() const { return isoDeposit(pat::HcalIso ); }
00168 const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
00170 void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep) {
00171 IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00172 for (; it != ed; ++it) {
00173 if (it->first == key) { it->second = dep; return; }
00174 }
00175 isoDeposits_.push_back(std::make_pair(key,dep));
00176 }
00178 void trackIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::TrackIso, dep); }
00180 void ecalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::EcalIso, dep); }
00182 void hcalIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(pat::HcalIso, dep); }
00184 void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
00185
00187 friend std::ostream& reco::operator<<(std::ostream& out, const pat::Photon& obj);
00188
00189 protected:
00190
00191
00192 bool embeddedSuperCluster_;
00193 std::vector<reco::SuperCluster> superCluster_;
00194
00195 std::vector<IdPair> photonIDs_;
00196
00197 typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
00198 IsoDepositPairs isoDeposits_;
00199 std::vector<float> isolations_;
00200
00201 };
00202
00203
00204 }
00205
00206 #endif