00001 // 00002 // $Id: Photon.cc,v 1.18 2011/06/08 20:40:19 rwolf Exp $ 00003 // 00004 00005 #include "DataFormats/PatCandidates/interface/Photon.h" 00006 00007 00008 using pat::Photon; 00009 00010 00012 Photon::Photon() : 00013 PATObject<reco::Photon>(reco::Photon()), 00014 embeddedSuperCluster_(false) 00015 { 00016 } 00017 00019 Photon::Photon(const reco::Photon & aPhoton) : 00020 PATObject<reco::Photon>(aPhoton), 00021 embeddedSuperCluster_(false) 00022 { 00023 } 00024 00026 Photon::Photon(const edm::RefToBase<reco::Photon> & aPhotonRef) : 00027 PATObject<reco::Photon>(aPhotonRef), 00028 embeddedSuperCluster_(false) 00029 { 00030 } 00031 00033 Photon::Photon(const edm::Ptr<reco::Photon> & aPhotonRef) : 00034 PATObject<reco::Photon>(aPhotonRef), 00035 embeddedSuperCluster_(false) 00036 { 00037 } 00038 00040 Photon::~Photon() { 00041 } 00042 00043 std::ostream& 00044 reco::operator<<(std::ostream& out, const pat::Photon& obj) 00045 { 00046 if(!out) return out; 00047 00048 out << "\tpat::Photon: "; 00049 out << std::setiosflags(std::ios::right); 00050 out << std::setiosflags(std::ios::fixed); 00051 out << std::setprecision(3); 00052 out << " E/pT/eta/phi " 00053 << obj.energy()<<"/" 00054 << obj.pt()<<"/" 00055 << obj.eta()<<"/" 00056 << obj.phi(); 00057 return out; 00058 } 00059 00062 reco::SuperClusterRef Photon::superCluster() const { 00063 if (embeddedSuperCluster_) { 00064 return reco::SuperClusterRef(&superCluster_, 0); 00065 } else { 00066 return reco::Photon::superCluster(); 00067 } 00068 } 00069 00071 void Photon::embedSuperCluster() { 00072 superCluster_.clear(); 00073 if (reco::Photon::superCluster().isNonnull()) { 00074 superCluster_.push_back(*reco::Photon::superCluster()); 00075 embeddedSuperCluster_ = true; 00076 } 00077 } 00078 00079 // method to retrieve a photon ID (or throw) 00080 Bool_t Photon::photonID(const std::string & name) const { 00081 for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) { 00082 if (it->first == name) return it->second; 00083 } 00084 cms::Exception ex("Key not found"); 00085 ex << "pat::Photon: the ID " << name << " can't be found in this pat::Photon.\n"; 00086 ex << "The available IDs are: "; 00087 for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) { 00088 ex << "'" << it->first << "' "; 00089 } 00090 ex << ".\n"; 00091 throw ex; 00092 } 00093 // check if an ID is there 00094 bool Photon::isPhotonIDAvailable(const std::string & name) const { 00095 for (std::vector<IdPair>::const_iterator it = photonIDs_.begin(), ed = photonIDs_.end(); it != ed; ++it) { 00096 if (it->first == name) return true; 00097 } 00098 return false; 00099 }