00001 #include "DataFormats/TauReco/interface/RecoTauPiZero.h" 00002 #include "DataFormats/Math/interface/deltaPhi.h" 00003 00004 namespace reco { 00005 00006 size_t RecoTauPiZero::numberOfGammas() const 00007 { 00008 size_t nGammas = 0; 00009 size_t nDaughters = numberOfDaughters(); 00010 for(size_t i = 0; i < nDaughters; ++i) { 00011 if(daughter(i)->pdgId() == 22) ++nGammas; 00012 } 00013 return nGammas; 00014 } 00015 00016 size_t RecoTauPiZero::numberOfElectrons() const 00017 { 00018 size_t nElectrons = 0; 00019 size_t nDaughters = numberOfDaughters(); 00020 for(size_t i = 0; i < nDaughters; ++i) { 00021 if(std::abs(daughter(i)->pdgId()) == 11) ++nElectrons; 00022 } 00023 return nElectrons; 00024 } 00025 00026 double RecoTauPiZero::maxDeltaPhi() const 00027 { 00028 double maxDPhi = 0; 00029 size_t nDaughters = numberOfDaughters(); 00030 for(size_t i = 0; i < nDaughters; ++i) { 00031 double dPhi = std::fabs(deltaPhi(*this, *daughter(i))); 00032 if(dPhi > maxDPhi) 00033 maxDPhi = dPhi; 00034 } 00035 return maxDPhi; 00036 } 00037 00038 double RecoTauPiZero::maxDeltaEta() const 00039 { 00040 double maxDEta = 0; 00041 size_t nDaughters = numberOfDaughters(); 00042 for(size_t i = 0; i < nDaughters; ++i) { 00043 double dEta = std::fabs(eta() - daughter(i)->eta()); 00044 if(dEta > maxDEta) 00045 maxDEta = dEta; 00046 } 00047 return maxDEta; 00048 } 00049 00050 RecoTauPiZero::PiZeroAlgorithm RecoTauPiZero::algo() const { 00051 return algoName_; 00052 } 00053 00054 bool RecoTauPiZero::algoIs(RecoTauPiZero::PiZeroAlgorithm algo) const { 00055 return (algoName_ == algo); 00056 } 00057 00058 namespace { 00059 std::ostream& operator<<(std::ostream& out, const reco::Candidate::LorentzVector& p4) 00060 { 00061 out << "(mass/pt/eta/phi) (" << std::setiosflags(std::ios::fixed) << std::setprecision(2) 00062 << p4.mass() << "/" << std::setprecision(1) << p4.pt() << "/" << std::setprecision(2) << p4.eta() 00063 << "/" << std::setprecision(2) << p4.phi() << ")"; 00064 return out; 00065 } 00066 } 00067 00068 void RecoTauPiZero::print(std::ostream& out) const { 00069 if (!out) return; 00070 00071 out << "RecoTauPiZero: " << this->p4() << 00072 " nDaughters: " << this->numberOfDaughters() << 00073 " (gamma/e) (" << this->numberOfGammas() << "/" << this->numberOfElectrons() << ")" << 00074 " maxDeltaPhi: " << std::setprecision(3) << maxDeltaPhi() << 00075 " maxDeltaEta: " << std::setprecision(3) << maxDeltaEta() << 00076 " algo: " << algo() << 00077 std::endl; 00078 00079 for(size_t i = 0; i < this->numberOfDaughters(); ++i) 00080 { 00081 out << "--- daughter " << i << ": " << daughterPtr(i)->p4() << 00082 " key: " << daughterPtr(i).key() << std::endl; 00083 } 00084 } 00085 00086 std::ostream& operator<<(std::ostream& out, const reco::RecoTauPiZero& piZero) 00087 { 00088 if(!out) return out; 00089 piZero.print(out); 00090 return out; 00091 } 00092 }