00001 #ifndef TRACKINFO_TPTORECOTRACK_H 00002 #define TRACKINFO_TPTORECOTRACK_H 00003 00004 #include "DataFormats/TrackReco/interface/TrackFwd.h" 00005 #include "DataFormats/TrackReco/interface/Track.h" 00006 #include "DataFormats/VertexReco/interface/Vertex.h" 00007 #include "DataFormats/VertexReco/interface/VertexFwd.h" 00008 #include "DataFormats/BeamSpot/interface/BeamSpot.h" 00009 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h" 00010 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticleFwd.h" 00011 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertex.h" 00012 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h" 00013 #include "DataFormats/Math/interface/Vector3D.h" 00014 #include "DataFormats/Math/interface/Point3D.h" 00015 #include "DataFormats/GeometryVector/interface/GlobalPoint.h" 00016 #include "DataFormats/GeometryVector/interface/GlobalVector.h" 00017 #include "TMath.h" 00018 //#include <vector> 00019 00020 00021 class TPtoRecoTrack 00022 { 00023 public: 00024 00025 TPtoRecoTrack(); 00026 ~TPtoRecoTrack(); 00027 00028 void SetTrackingParticle(TrackingParticleRef tp) {trackingParticle_ = tp;} 00029 00030 void SetRecoTrack_AlgoA(reco::TrackBaseRef track) {recoTrack_AlgoA_ = track;} 00031 void SetRecoTrack_AlgoB(reco::TrackBaseRef track) {recoTrack_AlgoB_ = track;} 00032 00033 void SetRecoVertex_AlgoA(reco::VertexRef vertex) {recoVertex_AlgoA_ = vertex;} 00034 void SetRecoVertex_AlgoB(reco::VertexRef vertex) {recoVertex_AlgoB_ = vertex;} 00035 00036 void SetBeamSpot(math::XYZPoint bs) {beamSpot_ = bs;} 00037 00038 // Interogation Functions 00039 reco::Track RTA() {return recoTrack_AlgoA_.isNonnull() ? *recoTrack_AlgoA_ : reco::Track();} 00040 reco::Track RTB() {return recoTrack_AlgoB_.isNonnull() ? *recoTrack_AlgoB_ : reco::Track();} 00041 TrackingParticle TP() {return trackingParticle_.isNonnull() ? *trackingParticle_ : TrackingParticle();} 00042 reco::Vertex RVA() {return recoVertex_AlgoA_.isNonnull() ? *recoVertex_AlgoA_ : reco::Vertex();} 00043 reco::Vertex RVB() {return recoVertex_AlgoB_.isNonnull() ? *recoVertex_AlgoB_ : reco::Vertex();} 00044 math::XYZPoint BeamSpot() {return beamSpot_;} 00045 00046 bool matched() {return matchedA() && matchedB();} 00047 bool matchedA() {return trackingParticle_.isNonnull() && recoTrack_AlgoA_.isNonnull();} 00048 bool matchedB() {return trackingParticle_.isNonnull() && recoTrack_AlgoB_.isNonnull();} 00049 bool matchedAnotB() {return matchedA() && !matchedB();} 00050 bool matchedBnotA() {return matchedB() && !matchedA();} 00051 bool hasRVA() {return recoVertex_AlgoA_.isNonnull() && fabs(recoVertex_AlgoA_->position().Mag2())>0.0;} // position is ROOT::MATH::Cartesian3D<double> 00052 bool hasRVB() {return recoVertex_AlgoB_.isNonnull() && fabs(recoVertex_AlgoB_->position().Mag2())>0.0;} // position is ROOT::MATH::Cartesian3D<double> 00053 bool hasRV() {return hasRVA() && hasRVB();} 00054 bool hasPCA() {return s_pca().mag()<9999.0;} 00055 bool allmatchedA() {return matchedA() && hasRVA();} 00056 bool allmatchedB() {return matchedB() && hasRVA();} 00057 bool allmatched() {return matched() && hasRV();} 00058 00059 // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed BeamSpot (as opposed to (0,0,0) ). 00060 double rA_dxy() {return RTA().dxy( BeamSpot() );} 00061 double rB_dxy() {return RTB().dxy( BeamSpot() );} 00062 double rA_dsz() {return RTA().dsz( BeamSpot() );} 00063 double rB_dsz() {return RTB().dsz( BeamSpot() );} 00064 double rA_d0() {return -1.0 * rA_dxy();} 00065 double rB_d0() {return -1.0 * rB_dxy();} 00066 double rA_dz() {return RTA().dz( BeamSpot() );} 00067 double rB_dz() {return RTB().dz( BeamSpot() );} 00068 00069 // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed vertex (as opposed to (0,0,0) ). 00070 double rA_d02() {return -1.0 * RTA().dxy( RVA().position() );} 00071 double rA_dz2() {return RTA().dz( RVA().position() );} 00072 double rB_d02() {return -1.0 * RTB().dxy( RVB().position() );} 00073 double rB_dz2() {return RTB().dz( RVB().position());} 00074 00075 // These members for sim d0 and dz are not included in the TrackingParticle class and must be included seperately. 00076 void SetTrackingParticleMomentumPCA(const GlobalVector &p) {simMomPCA_ = p;} 00077 void SetTrackingParticlePCA(const GlobalPoint &v) {simPCA_ = v;} 00078 00079 GlobalVector s_p() {return simMomPCA_;} 00080 GlobalPoint s_pca() {return simPCA_;} 00081 GlobalPoint s_v() {return GlobalPoint(s_pca().x()-BeamSpot().x(), s_pca().y()-BeamSpot().y(), s_pca().z()-BeamSpot().z() );} 00082 00083 double s_qoverp() {return TP().charge() / s_p().mag();} 00084 double s_theta() {return s_p().theta();} 00085 double s_lambda() {return M_PI/2-s_p().theta();} 00086 double s_phi() {return s_p().phi();} 00087 double s_eta() {return -0.5*log( tan (0.5*s_p().theta()) );} 00088 00089 double s_dxy() {return ( - s_v().x() * s_p().y() + s_v().y() * s_p().x() ) / s_p().perp();} 00090 double s_dsz() {return s_v().z()*s_p().perp()/ s_p().mag() - ((s_v().x()*s_p().x() + s_v().y()*s_p().y()) / s_p().perp()) * s_p().z()/s_p().mag();} 00091 double s_d0() {return -1.0*s_dxy();} 00092 double s_dz() {return s_v().z() - ( s_v().x() * s_p().x() + s_v().y() * s_p().y() )/s_p().perp() * s_p().z()/s_p().perp();} 00093 00094 // Short cut methods to get TP truth info 00095 TrackingParticle TPMother(unsigned short i); 00096 TrackingParticle TPMother() {return numTPMothers()==1 ? TPMother(0) : TrackingParticle();} 00097 int numTPSourceTracks() {return TP().parentVertex()->nSourceTracks();} 00098 int numTPMothers(); 00099 bool hasTPMother() {return numTPMothers()>0;} 00100 00101 protected: 00102 00103 reco::TrackBaseRef recoTrack_AlgoA_; 00104 reco::VertexRef recoVertex_AlgoA_; 00105 00106 reco::TrackBaseRef recoTrack_AlgoB_; 00107 reco::VertexRef recoVertex_AlgoB_; 00108 00109 TrackingParticleRef trackingParticle_; 00110 00111 GlobalVector simMomPCA_; // Momentum at point of closest approach to the beamspot of the trackingParticle. 00112 GlobalPoint simPCA_; // Point of closest approach to the BeamSpot of the TrackingParticle. 00113 math::XYZPoint beamSpot_; // I use type XYZPoint to faciliate the use of the recoTrack memeber dxy(XYZPoint). 00114 00115 }; 00116 00117 00118 #endif // TRACKINFO_TPTORECOTRACK_H 00119