CMS 3D CMS Logo

PFRecoTauChargedHadron.cc
Go to the documentation of this file.
2 
4 
5 namespace reco {
6 
9  algo_(kUndefined)
10 {}
11 
14  algo_(algo)
15 {
16  if ( q > 0. ) this->setPdgId(+211);
17  else if ( q < 0. ) this->setPdgId(-211);
18 }
19 
21  const Point& vtx,
22  int status, bool integerCharge,
24  : CompositePtrCandidate(q, p4, vtx, 211, status, integerCharge),
25  algo_(algo)
26 {
27  if ( q > 0. ) this->setPdgId(+211);
28  else if ( q < 0. ) this->setPdgId(-211);
29 }
30 
33  algo_(algo)
34 {
35  if ( c.charge() > 0. ) this->setPdgId(+211);
36  else if ( c.charge() < 0. ) this->setPdgId(-211);
37 }
38 
40 {}
41 
43 {
44  return chargedPFCandidate_;
45 }
46 
48 {
49  return track_;
50 }
51 
52 const std::vector<PFCandidatePtr>& PFRecoTauChargedHadron::getNeutralPFCandidates() const
53 {
54  return neutralPFCandidates_;
55 }
56 
58 {
60 }
61 
63 {
64  return algo_;
65 }
66 
68 {
69  return (algo_ == algo);
70 }
71 
72 namespace
73 {
74  std::string getPFCandidateType(reco::PFCandidate::ParticleType pfCandidateType)
75  {
76  if ( pfCandidateType == reco::PFCandidate::X ) return "undefined";
77  else if ( pfCandidateType == reco::PFCandidate::h ) return "PFChargedHadron";
78  else if ( pfCandidateType == reco::PFCandidate::e ) return "PFElectron";
79  else if ( pfCandidateType == reco::PFCandidate::mu ) return "PFMuon";
80  else if ( pfCandidateType == reco::PFCandidate::gamma ) return "PFGamma";
81  else if ( pfCandidateType == reco::PFCandidate::h0 ) return "PFNeutralHadron";
82  else if ( pfCandidateType == reco::PFCandidate::h_HF ) return "HF_had";
83  else if ( pfCandidateType == reco::PFCandidate::egamma_HF ) return "HF_em";
84  else assert(0);
85  }
86 }
87 
88 void PFRecoTauChargedHadron::print(std::ostream& stream) const
89 {
90  stream << " Pt = " << this->pt() << ", eta = " << this->eta() << ", phi = " << this->phi() << " (mass = " << this->mass() << ")" << std::endl;
91  stream << " charge = " << this->charge() << " (pdgId = " << this->pdgId() << ")" << std::endl;
92  stream << "charged PFCandidate";
94  stream << " (" << chargedPFCandidate_.id() << ":" << chargedPFCandidate_.key() << "):"
95  << " Pt = " << chargedPFCandidate_->pt() << ", eta = " << chargedPFCandidate_->eta() << ", phi = " << chargedPFCandidate_->phi()
96  << " (type = " << getPFCandidateType(chargedPFCandidate_->particleId()) << ")" << std::endl;
97  } else {
98  stream << ": N/A" << std::endl;
99  }
100  stream << "reco::Track: ";
101  if ( track_.isNonnull() ) {
102  stream << "Pt = " << track_->pt() << " +/- " << track_->ptError() << ", eta = " << track_->eta() << ", phi = " << track_->phi() << std::endl;
103  } else {
104  stream << "N/A" << std::endl;
105  }
106  stream << "neutral PFCandidates:";
107  if ( neutralPFCandidates_.size() >= 1 ) {
108  stream << std::endl;
109  int idx = 0;
110  for ( std::vector<PFCandidatePtr>::const_iterator neutralPFCandidate = neutralPFCandidates_.begin();
111  neutralPFCandidate != neutralPFCandidates_.end(); ++neutralPFCandidate ) {
112  stream << " #" << idx << " (" << neutralPFCandidate->id() << ":" << neutralPFCandidate->key() << "):"
113  << " Pt = " << (*neutralPFCandidate)->pt() << ", eta = " << (*neutralPFCandidate)->eta() << ", phi = " << (*neutralPFCandidate)->phi()
114  << " (type = " << getPFCandidateType((*neutralPFCandidate)->particleId()) << ")" << std::endl;
115  ++idx;
116  }
117  } else {
118  stream << " ";
119  stream << "N/A" << std::endl;
120  }
121  stream << "position@ECAL entrance: x = " << this->positionAtECALEntrance().x() << ", y = " << this->positionAtECALEntrance().y() << ", z = " << this->positionAtECALEntrance().z()
122  << " (eta = " << this->positionAtECALEntrance().eta() << ", phi = " << this->positionAtECALEntrance().phi() << ")" << std::endl;
123  std::string algo_string = "undefined";
124  if ( algo_ == kChargedPFCandidate ) algo_string = "chargedPFCandidate";
125  else if ( algo_ == kTrack ) algo_string = "Track";
126  else if ( algo_ == kPFNeutralHadron ) algo_string = "PFNeutralHadron";
127  stream << "algo = " << algo_string << std::endl;
128 }
129 
130 std::ostream& operator<<(std::ostream& stream, const reco::PFRecoTauChargedHadron& c)
131 {
132  c.print(stream);
133  return stream;
134 }
135 }
virtual double pt() const final
transverse momentum
int Charge
electric charge type
Definition: Candidate.h:35
PFRecoTauChargedHadronAlgorithm algo() const
Algorithm that built this charged hadron.
ParticleType
particle types
Definition: PFCandidate.h:44
virtual double mass() const final
mass
key_type key() const
Definition: Ptr.h:186
virtual double eta() const final
momentum pseudorapidity
virtual void setPdgId(int pdgId) final
virtual int status() const final
status word
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< float > > XYZPointF
point in space with cartesian internal representation
Definition: Point3D.h:10
virtual double phi() const final
momentum azimuthal angle
virtual int charge() const final
electric charge
Definition: LeafCandidate.h:91
void print(std::ostream &stream=std::cout) const
std::ostream & operator<<(std::ostream &, BeamSpot beam)
Definition: BeamSpot.cc:71
virtual int pdgId() const final
PDG identifier.
const TrackPtr & getTrack() const
reference to reco::Track
bool isNonnull() const
Checks for non-null.
Definition: Ptr.h:169
PFRecoTauChargedHadronAlgorithm algo_
const std::vector< PFCandidatePtr > & getNeutralPFCandidates() const
references to additional neutral PFCandidates
std::vector< PFCandidatePtr > neutralPFCandidates_
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:181
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
virtual int charge() const =0
electric charge
fixed size matrix
bool algoIs(PFRecoTauChargedHadronAlgorithm algo) const
Check whether a given algo produced this charged hadron.
math::XYZPoint Point
point in the space
Definition: Candidate.h:41
virtual const LorentzVector & p4() const final
four-momentum Lorentz vector
Definition: LeafCandidate.h:99
const math::XYZPointF & positionAtECALEntrance() const
position at ECAL entrance
const PFCandidatePtr & getChargedPFCandidate() const
reference to "charged" PFCandidate (either charged PFCandidate or PFNeutralHadron) ...