CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/AnalysisDataFormats/TrackInfo/interface/RecoTracktoTP.h

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