00001 #ifndef TRACKINFO_RECOTRACKTOTP_H 00002 #define TRACKINFO_RECOTRACKTOTP_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 RecoTracktoTP 00022 { 00023 public: 00024 00025 RecoTracktoTP(); 00026 ~RecoTracktoTP(); 00027 00028 void SetTrackingParticle(TrackingParticleRef tp) {trackingParticle_ = tp;} 00029 void SetRecoTrack(reco::TrackBaseRef track) {recoTrack = track;} 00030 void SetRecoVertex(reco::VertexRef vertex) {recoVertex = vertex;} 00031 void SetBeamSpot(math::XYZPoint bs) {beamSpot_ = bs;} 00032 00033 // Interogation Functions 00034 reco::Track RT() {return recoTrack.isNonnull() ? *recoTrack : reco::Track();} 00035 TrackingParticle TP() {return trackingParticle_.isNonnull() ? *trackingParticle_ : TrackingParticle();} 00036 reco::Vertex RV() {return recoVertex.isNonnull() ? *recoVertex : reco::Vertex();} 00037 math::XYZPoint BeamSpot() {return beamSpot_;} 00038 00039 bool matched() {return trackingParticle_.isNonnull() && recoTrack.isNonnull();} 00040 bool hasRV() {return recoVertex.isNonnull() && fabs(recoVertex->position().Mag2())>0.0;} // position is ROOT::MATH::Cartesian3D<double> 00041 bool hasPCA() {return s_pca().mag()<9999.0;} 00042 bool allmatched() {return matched() && hasRV();} 00043 00044 // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed BeamSpot (as opposed to (0,0,0) ). 00045 double r_dxy() {return RT().dxy( BeamSpot() );} 00046 double r_dsz() {return RT().dsz( BeamSpot() );} 00047 double r_d0() {return -1.0 * r_dxy();} 00048 double r_dz() {return RT().dz( BeamSpot() );} 00049 00050 // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed vertex (as opposed to (0,0,0) ). 00051 double r_d02() {return -1.0 * RT().dxy( RV().position() );} 00052 double r_dz2() {return RT().dz( RV().position() );} 00053 00054 // These members for sim d0 and dz are not included in the TrackingParticle class and must be included seperately. 00055 void SetTrackingParticleMomentumPCA(const GlobalVector &p) {simMomPCA_ = p;} 00056 void SetTrackingParticlePCA(const GlobalPoint &v) {simPCA_ = v;} 00057 00058 GlobalVector s_p() {return simMomPCA_;} 00059 GlobalPoint s_pca() {return simPCA_;} 00060 GlobalPoint s_v() {return GlobalPoint(s_pca().x()-BeamSpot().x(), s_pca().y()-BeamSpot().y(), s_pca().z()-BeamSpot().z() );} 00061 00062 double s_qoverp() {return TP().charge() / s_p().mag();} 00063 double s_theta() {return s_p().theta();} 00064 double s_lambda() {return M_PI/2-s_p().theta();} 00065 double s_phi() {return s_p().phi();} 00066 double s_eta() {return -0.5*log( tan (0.5*s_p().theta()) );} 00067 00068 double s_dxy() {return ( - s_v().x() * s_p().y() + s_v().y() * s_p().x() ) / s_p().perp();} 00069 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();} 00070 double s_d0() {return -1.0*s_dxy();} 00071 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();} 00072 00073 // Short cut methods to get TP truth info 00074 TrackingParticle TPMother(unsigned short i); 00075 TrackingParticle TPMother() {return numTPMothers()==1 ? TPMother(0) : TrackingParticle();} 00076 int numTPSourceTracks() {return TP().parentVertex()->nSourceTracks();} 00077 int numTPMothers(); 00078 bool hasTPMother() {return numTPMothers()>0;} 00079 00080 protected: 00081 00082 reco::TrackBaseRef recoTrack; 00083 reco::VertexRef recoVertex; 00084 00085 TrackingParticleRef trackingParticle_; 00086 00087 GlobalVector simMomPCA_; // Momentum at point of closest approach to the beamspot of the trackingParticle. 00088 GlobalPoint simPCA_; // Point of closest approach to the BeamSpot of the TrackingParticle. 00089 math::XYZPoint beamSpot_; // I use type XYZPoint to faciliate the use of the recoTrack memeber dxy(XYZPoint). 00090 00091 }; 00092 00093 00094 #endif // TRACKINFO_RECOTRACKTOTP_H 00095