CMS 3D CMS Logo

Photon.h

Go to the documentation of this file.
00001 //
00002 // $Id: Photon.h,v 1.16 2008/10/08 11:44:31 fronga Exp $
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 #include "DataFormats/EgammaCandidates/interface/PhotonID.h"
00028 
00029 // Define typedefs for convenience
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 
00038 // Class definition
00039 namespace pat {
00040 
00041 
00042   typedef reco::Photon PhotonType;
00043 
00044 
00045   class Photon : public PATObject<PhotonType> {
00046 
00047     public:
00048 
00050       Photon();
00052       Photon(const PhotonType & aPhoton);
00054       Photon(const edm::RefToBase<PhotonType> & aPhotonRef);
00056       Photon(const edm::Ptr<PhotonType> & aPhotonRef);
00058       virtual ~Photon();
00059 
00061       virtual Photon * clone() const { return new Photon(*this); }
00062 
00063       // ---- methods for content embedding ----
00065       reco::SuperClusterRef superCluster() const;
00067       void embedSuperCluster();
00068 
00069       // ---- methods for access the generated photon ----
00071       const reco::Particle * genPhoton() const { return genParticle(); }
00073       void setGenPhoton(const reco::GenParticleRef & gp, bool embed=false) { setGenParticleRef(gp, embed); }
00074 
00075       // ---- methods for photon ID ----
00077       const reco::PhotonID * photonID() const { return photonID_.empty() ? 0 : & photonID_[0]; }
00079       void setPhotonID(const reco::PhotonID & photonID) { photonID_.clear(); photonID_.push_back(photonID); }
00081       bool isLooseEM() const { return photonIDOrThrow().isLooseEM(); }
00083       bool isLoosePhoton() const { return photonIDOrThrow().isLoosePhoton(); }
00085       bool isTightPhoton() const { return photonIDOrThrow().isTightPhoton(); }
00088       float isolationEcalRecHit() const { return photonIDOrThrow().isolationEcalRecHit(); }
00091       float isolationHcalRecHit() const { return photonIDOrThrow().isolationHcalRecHit(); }
00094       float isolationSolidTrkCone() const { return photonIDOrThrow().isolationSolidTrkCone(); }
00097       float isolationHollowTrkCone() const { return photonIDOrThrow().isolationHollowTrkCone(); }
00100       int nTrkSolidCone() const { return photonIDOrThrow().nTrkSolidCone(); }
00103       int nTrkHollowCone() const { return photonIDOrThrow().nTrkHollowCone(); }
00106       float r9() const { return photonIDOrThrow().r9(); }
00109       bool isEBPho() const { return photonIDOrThrow().isEBPho(); }
00112       bool isEEPho() const { return photonIDOrThrow().isEEPho(); }
00115       bool isEBGap() const { return photonIDOrThrow().isEBGap(); }
00118       bool isEEGap() const { return photonIDOrThrow().isEEGap(); }
00121       bool isEBEEGap() const { return photonIDOrThrow().isEBEEGap(); }
00124       bool isAlsoElectron() const { return photonIDOrThrow().isAlsoElectron(); }
00125 
00126       // ---- methods for photon isolation ----
00128       float isolation(IsolationKeys key) const { 
00129           if (key >= 0) {
00130               //if (key >= isolations_.size()) throw cms::Excepton("Missing Data") << "Isolation corresponding to key " << key << " was not stored for this particle.";
00131               if (size_t(key) >= isolations_.size()) return -1.0;
00132               return isolations_[key];
00133           } else switch (key) {
00134               case CaloIso:  
00135                   //if (isolations_.size() <= HCalIso) throw cms::Excepton("Missing Data") << "CalIsoo Isolation was not stored for this particle.";
00136                   if (isolations_.size() <= HCalIso) return -1.0; 
00137                   return isolations_[ECalIso] + isolations_[HCalIso];
00138               default:
00139                   return -1.0;
00140                   //throw cms::Excepton("Missing Data") << "Isolation corresponding to key " << key << " was not stored for this particle.";
00141           }
00142       }
00144       float trackIso() const { return isolation(TrackerIso); }
00146       float caloIso()  const { return isolation(CaloIso); }
00148       float ecalIso()  const { return isolation(ECalIso); }
00150       float hcalIso()  const { return isolation(HCalIso); }
00152       float userIso(uint8_t index=0)  const { return isolation(IsolationKeys(UserBaseIso + index)); }
00155       void setIsolation(IsolationKeys key, float value) {
00156           if (key >= 0) {
00157               if (size_t(key) >= isolations_.size()) isolations_.resize(key+1, -1.0);
00158               isolations_[key] = value;
00159           } else {
00160               throw cms::Exception("Illegal Argument") << 
00161                   "The key for which you're setting isolation does not correspond " <<
00162                   "to an individual isolation but to the sum of more independent isolations " <<
00163                   "(e.g. Calo = ECal + HCal), so you can't SET the value, just GET it.\n" <<
00164                   "Please set up each component independly.\n";
00165           }
00166       }
00168       void setTrackIso(float trackIso) { setIsolation(TrackerIso, trackIso); }
00170       void setECalIso(float caloIso)   { setIsolation(ECalIso, caloIso);  } 
00172       void setHCalIso(float caloIso)   { setIsolation(HCalIso, caloIso);  }
00174       void setUserIso(float value, uint8_t index=0)  { setIsolation(IsolationKeys(UserBaseIso + index), value); }
00175 
00176       // ---- methods for photon isolation deposits ----
00178       const IsoDeposit * isoDeposit(IsolationKeys key) const {
00179           for (IsoDepositPairs::const_iterator it = isoDeposits_.begin(), ed = isoDeposits_.end(); 
00180                   it != ed; ++it) 
00181           {
00182               if (it->first == key) return & it->second;
00183           }
00184           return 0;
00185       } 
00187       const IsoDeposit * trackerIsoDeposit() const { return isoDeposit(TrackerIso); }
00189       const IsoDeposit * ecalIsoDeposit()    const { return isoDeposit(ECalIso); }
00191       const IsoDeposit * hcalIsoDeposit()    const { return isoDeposit(HCalIso); }
00193       const IsoDeposit * userIsoDeposit(uint8_t index=0) const { return isoDeposit(IsolationKeys(UserBaseIso + index)); }
00195       void setIsoDeposit(IsolationKeys key, const IsoDeposit &dep) {
00196           IsoDepositPairs::iterator it = isoDeposits_.begin(), ed = isoDeposits_.end();
00197           for (; it != ed; ++it) {
00198               if (it->first == key) { it->second = dep; return; }
00199           }
00200           isoDeposits_.push_back(std::make_pair(key,dep));
00201       } 
00203       void trackerIsoDeposit(const IsoDeposit &dep) { setIsoDeposit(TrackerIso, dep); }
00205       void ecalIsoDeposit(const IsoDeposit &dep)    { setIsoDeposit(ECalIso, dep); }
00207       void hcalIsoDeposit(const IsoDeposit &dep)    { setIsoDeposit(HCalIso, dep); }
00209       void userIsoDeposit(const IsoDeposit &dep, uint8_t index=0) { setIsoDeposit(IsolationKeys(UserBaseIso + index), dep); }
00210 
00211     protected:
00212 
00214       const reco::PhotonID & photonIDOrThrow() const {
00215         if (photonID_.empty()) throw cms::Exception("Missing Data") << "This pat::Photon doesn't include a reco::PhotonID.\n";
00216         return photonID_[0];
00217       }
00218 
00219     protected:
00220 
00221       // ---- for content embedding ----
00222       bool embeddedSuperCluster_;
00223       std::vector<reco::SuperCluster> superCluster_;
00224       // ---- holder for a reco::PhotonID object ----
00225       std::vector<reco::PhotonID> photonID_;
00226       // ---- Isolation and IsoDeposit related datamebers ----
00227       typedef std::vector<std::pair<IsolationKeys, pat::IsoDeposit> > IsoDepositPairs;
00228       IsoDepositPairs    isoDeposits_;
00229       std::vector<float> isolations_;
00230 
00231   };
00232 
00233 
00234 }
00235 
00236 #endif

Generated on Tue Jun 9 17:30:43 2009 for CMSSW by  doxygen 1.5.4