Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/TauReco/interface/PFRecoTauChargedHadron.h"
0002 
0003 #include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
0004 
0005 namespace reco {
0006 
0007   PFRecoTauChargedHadron::PFRecoTauChargedHadron() : CompositePtrCandidate(), algo_(kUndefined) {}
0008 
0009   PFRecoTauChargedHadron::PFRecoTauChargedHadron(PFRecoTauChargedHadronAlgorithm algo, Charge q)
0010       : CompositePtrCandidate(), algo_(algo) {
0011     if (q > 0.)
0012       this->setPdgId(+211);
0013     else if (q < 0.)
0014       this->setPdgId(-211);
0015   }
0016 
0017   PFRecoTauChargedHadron::PFRecoTauChargedHadron(Charge q,
0018                                                  const LorentzVector& p4,
0019                                                  const Point& vtx,
0020                                                  int status,
0021                                                  bool integerCharge,
0022                                                  PFRecoTauChargedHadronAlgorithm algo)
0023       : CompositePtrCandidate(q, p4, vtx, 211, status, integerCharge), algo_(algo) {
0024     if (q > 0.)
0025       this->setPdgId(+211);
0026     else if (q < 0.)
0027       this->setPdgId(-211);
0028   }
0029 
0030   PFRecoTauChargedHadron::PFRecoTauChargedHadron(const Candidate& c, PFRecoTauChargedHadronAlgorithm algo)
0031       : CompositePtrCandidate(c), algo_(algo) {
0032     if (c.charge() > 0.)
0033       this->setPdgId(+211);
0034     else if (c.charge() < 0.)
0035       this->setPdgId(-211);
0036   }
0037 
0038   PFRecoTauChargedHadron::~PFRecoTauChargedHadron() {}
0039 
0040   const CandidatePtr& PFRecoTauChargedHadron::getChargedPFCandidate() const { return chargedPFCandidate_; }
0041 
0042   const PFRecoTauChargedHadron::TrackPtr& PFRecoTauChargedHadron::getTrack() const { return track_; }
0043 
0044   const CandidatePtr& PFRecoTauChargedHadron::getLostTrackCandidate() const { return lostTrackCandidate_; }
0045 
0046   const std::vector<CandidatePtr>& PFRecoTauChargedHadron::getNeutralPFCandidates() const {
0047     return neutralPFCandidates_;
0048   }
0049 
0050   const math::XYZPointF& PFRecoTauChargedHadron::positionAtECALEntrance() const { return positionAtECALEntrance_; }
0051 
0052   PFRecoTauChargedHadron::PFRecoTauChargedHadronAlgorithm PFRecoTauChargedHadron::algo() const { return algo_; }
0053 
0054   bool PFRecoTauChargedHadron::algoIs(PFRecoTauChargedHadron::PFRecoTauChargedHadronAlgorithm algo) const {
0055     return (algo_ == algo);
0056   }
0057 
0058   void PFRecoTauChargedHadron::print(std::ostream& stream) const {
0059     stream << " Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi()
0060            << " (mass = " << this->mass() << ")" << std::endl;
0061     stream << " charge = " << this->charge() << " (pdgId = " << this->pdgId() << ")" << std::endl;
0062     stream << "charged PFCandidate";
0063     if (chargedPFCandidate_.isNonnull()) {
0064       stream << " (" << chargedPFCandidate_.id() << ":" << chargedPFCandidate_.key() << "):"
0065              << " Pt = " << chargedPFCandidate_->pt() << ", eta = " << chargedPFCandidate_->eta()
0066              << ", phi = " << chargedPFCandidate_->phi() << " (pdgId = " << chargedPFCandidate_->pdgId() << ")"
0067              << std::endl;
0068     } else {
0069       stream << ": N/A" << std::endl;
0070     }
0071     stream << "reco::Track: ";
0072     if (track_.isNonnull()) {
0073       stream << "Pt = " << track_->pt() << " +/- " << track_->ptError() << ", eta = " << track_->eta()
0074              << ", phi = " << track_->phi() << std::endl;
0075     } else if (lostTrackCandidate_.isNonnull()) {
0076       stream << "(lostTrackCandidate: " << lostTrackCandidate_.id() << ":" << lostTrackCandidate_.key() << "):"
0077              << " Pt = " << lostTrackCandidate_->pt() << ", eta = " << lostTrackCandidate_->eta()
0078              << ", phi = " << lostTrackCandidate_->phi() << std::endl;
0079     } else {
0080       stream << "N/A" << std::endl;
0081     }
0082     stream << "neutral PFCandidates:";
0083     if (!neutralPFCandidates_.empty()) {
0084       stream << std::endl;
0085       int idx = 0;
0086       for (std::vector<CandidatePtr>::const_iterator neutralPFCandidate = neutralPFCandidates_.begin();
0087            neutralPFCandidate != neutralPFCandidates_.end();
0088            ++neutralPFCandidate) {
0089         stream << " #" << idx << " (" << neutralPFCandidate->id() << ":" << neutralPFCandidate->key() << "):"
0090                << " Pt = " << (*neutralPFCandidate)->pt() << ", eta = " << (*neutralPFCandidate)->eta()
0091                << ", phi = " << (*neutralPFCandidate)->phi() << " (pdgId = " << (*neutralPFCandidate)->pdgId() << ")"
0092                << std::endl;
0093         ++idx;
0094       }
0095     } else {
0096       stream << " ";
0097       stream << "N/A" << std::endl;
0098     }
0099     stream << "position@ECAL entrance: x = " << this->positionAtECALEntrance().x()
0100            << ", y = " << this->positionAtECALEntrance().y() << ", z = " << this->positionAtECALEntrance().z()
0101            << " (eta = " << this->positionAtECALEntrance().eta() << ", phi = " << this->positionAtECALEntrance().phi()
0102            << ")" << std::endl;
0103     std::string algo_string = "undefined";
0104     if (algo_ == kChargedPFCandidate)
0105       algo_string = "chargedPFCandidate";
0106     else if (algo_ == kTrack)
0107       algo_string = "Track";
0108     else if (algo_ == kPFNeutralHadron)
0109       algo_string = "PFNeutralHadron";
0110     stream << "algo = " << algo_string << std::endl;
0111   }
0112 
0113   std::ostream& operator<<(std::ostream& stream, const reco::PFRecoTauChargedHadron& c) {
0114     c.print(stream);
0115     return stream;
0116   }
0117 }  // namespace reco