Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:54:47

0001 #include "DataFormats/TauReco/interface/RecoTauPiZero.h"
0002 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0003 #include "DataFormats/Math/interface/deltaPhi.h"
0004 
0005 namespace reco {
0006 
0007   size_t RecoTauPiZero::numberOfGammas() const {
0008     size_t nGammas = 0;
0009     size_t nDaughters = numberOfDaughters();
0010     for (size_t i = 0; i < nDaughters; ++i) {
0011       if (daughter(i)->pdgId() == 22)
0012         ++nGammas;
0013     }
0014     return nGammas;
0015   }
0016 
0017   size_t RecoTauPiZero::numberOfElectrons() const {
0018     size_t nElectrons = 0;
0019     size_t nDaughters = numberOfDaughters();
0020     for (size_t i = 0; i < nDaughters; ++i) {
0021       if (std::abs(daughter(i)->pdgId()) == 11)
0022         ++nElectrons;
0023     }
0024     return nElectrons;
0025   }
0026 
0027   double RecoTauPiZero::maxDeltaPhi() const {
0028     double maxDPhi = 0;
0029     size_t nDaughters = numberOfDaughters();
0030     for (size_t i = 0; i < nDaughters; ++i) {
0031       double dPhi = std::fabs(deltaPhi(*this, *daughter(i)));
0032       if (dPhi > maxDPhi)
0033         maxDPhi = dPhi;
0034     }
0035     return maxDPhi;
0036   }
0037 
0038   double RecoTauPiZero::maxDeltaEta() const {
0039     double maxDEta = 0;
0040     size_t nDaughters = numberOfDaughters();
0041     for (size_t i = 0; i < nDaughters; ++i) {
0042       double dEta = std::fabs(eta() - daughter(i)->eta());
0043       if (dEta > maxDEta)
0044         maxDEta = dEta;
0045     }
0046     return maxDEta;
0047   }
0048 
0049   RecoTauPiZero::PiZeroAlgorithm RecoTauPiZero::algo() const { return algoName_; }
0050 
0051   bool RecoTauPiZero::algoIs(RecoTauPiZero::PiZeroAlgorithm algo) const { return (algoName_ == algo); }
0052 
0053   namespace {
0054     std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType) {
0055       if (pfCandidateType == reco::PFCandidate::X)
0056         return "undefined";
0057       else if (pfCandidateType == reco::PFCandidate::h)
0058         return "PFChargedHadron";
0059       else if (pfCandidateType == reco::PFCandidate::e)
0060         return "PFElectron";
0061       else if (pfCandidateType == reco::PFCandidate::mu)
0062         return "PFMuon";
0063       else if (pfCandidateType == reco::PFCandidate::gamma)
0064         return "PFGamma";
0065       else if (pfCandidateType == reco::PFCandidate::h0)
0066         return "PFNeutralHadron";
0067       else if (pfCandidateType == reco::PFCandidate::h_HF)
0068         return "HF_had";
0069       else if (pfCandidateType == reco::PFCandidate::egamma_HF)
0070         return "HF_em";
0071       else
0072         assert(0);
0073     }
0074   }  // namespace
0075 
0076   void RecoTauPiZero::print(std::ostream& stream) const {
0077     std::cout << "Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi() << std::endl;
0078     size_t numDaughters = this->numberOfDaughters();
0079     for (size_t iDaughter = 0; iDaughter < numDaughters; ++iDaughter) {
0080       const reco::PFCandidate* daughter = dynamic_cast<const reco::PFCandidate*>(this->daughterPtr(iDaughter).get());
0081       std::cout << " daughter #" << iDaughter << " (" << getPFCandidateType(daughter->particleId()) << "):"
0082                 << " Pt = " << daughter->pt() << ", eta = " << daughter->eta() << ", phi = " << daughter->phi()
0083                 << std::endl;
0084     }
0085   }
0086 
0087   std::ostream& operator<<(std::ostream& out, const reco::RecoTauPiZero& piZero) {
0088     if (!out)
0089       return out;
0090     piZero.print(out);
0091     return out;
0092   }
0093 }  // namespace reco