00001 #include "AtlfastEvent/Track.h" 00002 #include "AtlfastEvent/IAOOvisitor.h" 00003 00004 #include "GaudiKernel/MsgStream.h" 00005 #include <iomanip> 00006 #include <iostream> 00007 00008 namespace Atlfast { 00009 using std::setw; 00010 using std::setprecision; 00011 using std::setiosflags; 00012 using std::ios; 00013 00014 // ................................................ 00015 // Message stream operator for simple debug output 00016 00017 MsgStream& operator << ( MsgStream& s, const Track& t ) { 00018 if (t.truth()) { 00019 s << "Track created from particle " << t.pdg_id() << endreq 00020 << " with (px,py,pz) " 00021 <<t.truth()->momentum().px() <<" " 00022 <<t.truth()->momentum().py() <<" " 00023 <<t.truth()->momentum().pz() <<" " 00024 <<endreq<<endreq; 00025 } 00026 TrackTrajectory traj = t.trajectory(); 00027 TrackParameters param = traj.parameters(); 00028 TrackTrajectory truthTraj = t.truthTrajectory(); 00029 TrackParameters truthParam = truthTraj.parameters(); 00030 00031 s << " unsmeared Track smeared Track"<<endreq; 00032 00033 s<<setiosflags(ios::fixed); 00034 s<<setprecision(7); 00035 s<<setw(20); 00036 00037 s <<setw(20)<< truthParam.pT() 00038 <<setw(20)<< param.pT() 00039 << " pT"<<endreq; 00040 s <<setw(20)<< truthParam.eta() 00041 <<setw(20)<< param.eta() 00042 << " eta"<<endreq; 00043 s << "------------------ -------------------" << endreq; 00044 00045 s <<setw(20)<< truthParam.impactParameter() 00046 <<setw(20)<< param.impactParameter() 00047 << " d0"<<endreq; 00048 s <<setw(20)<< truthParam.zPerigee() 00049 <<setw(20)<< param.zPerigee() 00050 << " z0" << endreq; 00051 s <<setw(20)<< truthParam.phi().val() 00052 <<setw(20)<< param.phi().val() 00053 << " phi" <<endreq; 00054 s <<setw(20)<< truthParam.cotTheta() 00055 <<setw(20)<<param.cotTheta() 00056 << " cot Theta" << endreq; 00057 s <<setw(20)<< truthParam.invPtCharge() 00058 <<setw(20)<< param.invPtCharge() 00059 << " 1/(q.PT)" <<endreq; 00060 s << "------------------- -------------------" << endreq; 00061 s <<setw(20)<< truthTraj.radius() 00062 <<setw(20)<< traj.radius() 00063 << " radius" <<endreq; 00064 s <<setw(20)<< truthTraj.curvature() 00065 <<setw(20)<< traj.curvature() 00066 << " curvature" <<endreq<<endreq; 00067 00068 s << "Matrix used"<<endreq ; 00069 s << setiosflags(ios::scientific); 00070 s << setiosflags(ios::left); 00071 s << setprecision(5); 00072 for (int a = 1; a<6; a++){ 00073 for (int b=1; b<6; b++){ 00074 s << setw(12) << t.smearMatrix() (a,b); 00075 } 00076 s <<endreq; 00077 } 00078 00079 return s ; 00080 } 00082 void Track::accept(IAOOvisitor* iaPtr) const{ 00083 iaPtr->process(this); 00084 } 00085 00087 TrackTrajectory Track::trajectory() const { 00088 return m_trajectory; 00089 } 00091 int Track::pdg_id() const {return m_pdg_id;} 00093 const HepMC::GenParticle* Track::truth() const { return m_truth ; } 00095 const HepSymMatrix Track::smearMatrix() const {return m_smearMatrix;} 00097 void Track::setMatrix(const HepSymMatrix& matrix) {m_smearMatrix = matrix;} 00099 const TrackTrajectory Track::truthTrajectory() const {return m_truthTrajectory;} 00101 HepLorentzVector Track::momentum() const { 00102 return m_truth->momentum(); 00103 } 00105 double Track::eta() const{ 00106 return momentum().pseudoRapidity(); 00107 } 00109 double Track::phi() const{ 00110 return momentum().phi(); 00111 } 00113 double Track::pT() const{ 00114 return momentum().perp(); 00115 } 00117 double Track::eT() const{ 00118 return momentum().perp(); 00119 } 00121 double Track::mT() const{ 00122 return momentum().mt(); 00123 } 00125 IKinematic* Track::clone() const{ 00126 IKinematic* ik = new Track(*this); 00127 return ik; 00128 } 00130 void Track::print(const std::string& coor, std::string t) const{ 00131 AODNavigationImp::print(coor, t); 00132 std::cout<<s<<"\n" 00133 <<std::string(73,' ') 00134 <<"Track"<<std::endl; 00135 } 00136 00138 MsgStream& operator << ( MsgStream& s, const Track* t ) { 00139 return s << *t ; 00140 } 00141 00142 } // end namespace 00143 00144 00145 00146 00147 00148 00149 00150 00151 00152 00153 00154 00155 00156 00157 00158