CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_5_3_13_patch3/src/AnalysisDataFormats/TrackInfo/interface/TPtoRecoTrack.h

Go to the documentation of this file.
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 SetShared_AlgoA(const float &mA) {sharedA_= mA;}
00034     void SetShared_AlgoB(const float &mB) {sharedB_= mB;}
00035   
00036     void SetRecoVertex_AlgoA(reco::VertexRef vertex)  {recoVertex_AlgoA_ = vertex;}
00037     void SetRecoVertex_AlgoB(reco::VertexRef vertex)  {recoVertex_AlgoB_ = vertex;}
00038 
00039     void SetBeamSpot(math::XYZPoint bs)           {beamSpot_ = bs;}
00040   
00041     // Interogation Functions
00042     reco::Track       RTA()         const {return recoTrack_AlgoA_.isNonnull()  ? *recoTrack_AlgoA_  : reco::Track();}
00043     reco::Track       RTB()         const {return recoTrack_AlgoB_.isNonnull()  ? *recoTrack_AlgoB_  : reco::Track();}
00044     TrackingParticle  TP()          const {return trackingParticle_.isNonnull() ? *trackingParticle_ : TrackingParticle();}
00045     reco::Vertex      RVA()         const {return recoVertex_AlgoA_.isNonnull() ? *recoVertex_AlgoA_ : reco::Vertex();} 
00046     reco::Vertex      RVB()         const {return recoVertex_AlgoB_.isNonnull() ? *recoVertex_AlgoB_ : reco::Vertex();}
00047     math::XYZPoint    BeamSpot()    const {return beamSpot_;}
00048   
00049     bool          matched()         const {return matchedA() && matchedB();}
00050     bool          matchedA()        const {return trackingParticle_.isNonnull() && recoTrack_AlgoA_.isNonnull();} 
00051     bool          matchedB()        const {return trackingParticle_.isNonnull() && recoTrack_AlgoB_.isNonnull();}
00052     bool          matchedAnotB()    const {return matchedA() && !matchedB();}
00053     bool          matchedBnotA()    const {return matchedB() && !matchedA();}
00054     bool          hasRVA()          const {return recoVertex_AlgoA_.isNonnull() && fabs(recoVertex_AlgoA_->position().Mag2())>0.0;}   // position is ROOT::MATH::Cartesian3D<double> 
00055     bool          hasRVB()          const {return recoVertex_AlgoB_.isNonnull() && fabs(recoVertex_AlgoB_->position().Mag2())>0.0;}   // position is ROOT::MATH::Cartesian3D<double>
00056     bool          hasRV()           const {return hasRVA() && hasRVB();}
00057     bool          hasPCA()          const {return s_pca().mag()<9999.0;}
00058     bool          allmatchedA()     const {return matchedA() && hasRVA();} 
00059     bool          allmatchedB()     const {return matchedB() && hasRVA();} 
00060     bool          allmatched()      const {return matched() && hasRV();} 
00061     float         GetSharedA()      const {return sharedA_;}
00062     float         GetSharedB()      const {return sharedB_;}
00063   
00064     // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed BeamSpot (as opposed to (0,0,0) ).
00065     double        rA_dxy()          const {return RTA().dxy( BeamSpot() );}
00066     double        rB_dxy()          const {return RTB().dxy( BeamSpot() );}
00067     double        rA_dsz()          const {return RTA().dsz( BeamSpot() );}
00068     double        rB_dsz()          const {return RTB().dsz( BeamSpot() );}
00069     double        rA_d0()           const {return -1.0 * rA_dxy();}
00070     double        rB_d0()           const {return -1.0 * rB_dxy();}
00071     double        rA_dz()           const {return RTA().dz( BeamSpot() );}
00072     double        rB_dz()           const {return RTB().dz( BeamSpot() );}
00073     
00074     // These members for reco d0 and dz are the TIP and LIP w.r.t the reconstructed vertex (as opposed to (0,0,0) ).
00075     double        rA_d02()          const {return -1.0 * RTA().dxy( RVA().position() );}
00076     double        rA_dz2()          const {return RTA().dz( RVA().position() );}
00077     double        rB_d02()          const {return -1.0 * RTB().dxy( RVB().position() );}
00078     double        rB_dz2()          const {return RTB().dz( RVB().position());}
00079     
00080     // These members for sim d0 and dz are not included in the TrackingParticle class and must be included seperately.
00081     void SetTrackingParticleMomentumPCA(const GlobalVector &p)    {simMomPCA_ = p;} 
00082     void SetTrackingParticlePCA(const GlobalPoint &v)             {simPCA_ = v;} 
00083   
00084     GlobalVector    s_p()           const {return simMomPCA_;}
00085     GlobalPoint     s_pca()         const {return simPCA_;}
00086     GlobalPoint     s_v()           const {return GlobalPoint(s_pca().x()-BeamSpot().x(), s_pca().y()-BeamSpot().y(), s_pca().z()-BeamSpot().z() );}
00087   
00088     double          s_qoverp()      const {return TP().charge() / s_p().mag();}
00089     double          s_theta()       const {return s_p().theta();}
00090     double          s_lambda()      const {return M_PI/2-s_p().theta();}
00091     double          s_phi()         const {return s_p().phi();}
00092     double          s_eta()         const {return -1.0*log( tan (0.5*s_p().theta()) );}
00093   
00094     double          s_dxy()         const {return ( - s_v().x() * s_p().y() + s_v().y() * s_p().x() ) / s_p().perp();}
00095     double          s_dsz()         const {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();}
00096     double          s_d0()          const {return -1.0*s_dxy();}
00097     double          s_dz()          const {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();}  
00098   
00099     // Short cut methods to get TP truth info
00100     TrackingParticle      TPMother(unsigned short i) const;
00101     TrackingParticle      TPMother()            const {return numTPMothers()==1 ? TPMother(0) : TrackingParticle();}
00102     int                   numTPSourceTracks()   const {return TP().parentVertex()->nSourceTracks();}
00103     int                   numTPMothers() const;
00104     bool                  hasTPMother()         const {return numTPMothers()>0;}
00105 
00106     protected:
00107   
00108     reco::TrackBaseRef recoTrack_AlgoA_;
00109     reco::VertexRef recoVertex_AlgoA_;
00110   
00111     reco::TrackBaseRef recoTrack_AlgoB_;
00112     reco::VertexRef recoVertex_AlgoB_;
00113   
00114     TrackingParticleRef trackingParticle_;
00115   
00116     GlobalVector      simMomPCA_;       // Momentum at point of closest approach to the beamspot of the trackingParticle.
00117     GlobalPoint       simPCA_;          // Point of closest approach to the BeamSpot of the TrackingParticle.
00118     math::XYZPoint    beamSpot_;        // I use type XYZPoint to faciliate the use of the recoTrack memeber dxy(XYZPoint).
00119     float             sharedA_;          // Number of shared hits with track A
00120     float             sharedB_;          // Number of shared hits with track B
00121 
00122 };
00123 
00124 
00125 #endif // TRACKINFO_TPTORECOTRACK_H
00126