Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-06-18 02:20:06

0001 #ifndef TrackReco_Track_h
0002 #define TrackReco_Track_h
0003 /** \class reco::Track Track.h DataFormats/TrackReco/interface/Track.h
0004  *
0005  * This class describes the reconstructed tracks that are stored in the AOD and
0006  * RECO. It also contains a reference to more detailed information about each
0007  * track, that is stoed in the TrackExtra object, available only in RECO.
0008  *
0009  * Note that most of the functions provided in this Track class rely on the existance of
0010  * the TrackExtra object, so will not work on AOD.
0011  *
0012  * The most useful functions are those provided in the TrackBase class from which this
0013  * inherits, all of which work on AOD.
0014  *
0015  * \author Luca Lista, INFN
0016  *
0017  *
0018  */
0019 #include "DataFormats/TrackReco/interface/TrackBase.h"
0020 #include "DataFormats/TrackReco/interface/TrackExtra.h"
0021 #include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
0022 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
0023 #include "FWCore/Utilities/interface/thread_safety_macros.h"
0024 
0025 namespace reco {
0026 
0027   class Track : public TrackBase {
0028   public:
0029     /// default constructor
0030     Track() {}
0031 
0032     /// virtual destructor
0033     ~Track() override;
0034 
0035     /// constructor from fit parameters and error matrix
0036     Track(double chi2,
0037           double ndof,
0038           const Point& referencePoint,
0039           const Vector& momentum,
0040           int charge,
0041           const CovarianceMatrix&,
0042           TrackAlgorithm = undefAlgorithm,
0043           TrackQuality quality = undefQuality,
0044           float t0 = 0,
0045           float beta = 0,
0046           float covt0t0 = -1.,
0047           float covbetabeta = -1.);
0048 
0049     /// return true if the outermost hit is valid
0050     bool outerOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->outerOk(); }
0051 
0052     /// return true if the innermost hit is valid
0053     bool innerOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->innerOk(); }
0054 
0055     /// position of the innermost hit
0056     const math::XYZPoint& innerPosition() const { return extra_->innerPosition(); }
0057 
0058     /// momentum vector at the innermost hit position
0059     const math::XYZVector& innerMomentum() const { return extra_->innerMomentum(); }
0060 
0061     /// position of the outermost hit
0062     const math::XYZPoint& outerPosition() const { return extra_->outerPosition(); }
0063 
0064     /// momentum vector at the outermost hit position
0065     const math::XYZVector& outerMomentum() const { return extra_->outerMomentum(); }
0066 
0067     /// outermost trajectory state curvilinear errors
0068     CovarianceMatrix outerStateCovariance() const { return extra_->outerStateCovariance(); }
0069 
0070     /// innermost trajectory state curvilinear errors
0071     CovarianceMatrix innerStateCovariance() const { return extra_->innerStateCovariance(); }
0072 
0073     /// fill outermost trajectory state curvilinear errors
0074     CovarianceMatrix& fillOuter CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillOuter(v); }
0075 
0076     CovarianceMatrix& fillInner CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillInner(v); }
0077 
0078     /// DetId of the detector on which surface the outermost state is located
0079     unsigned int outerDetId() const { return extra_->outerDetId(); }
0080 
0081     /// DetId of the detector on which surface the innermost state is located
0082     unsigned int innerDetId() const { return extra_->innerDetId(); }
0083 
0084     /// Access to reconstructed hits on the track.
0085     auto recHits() const { return extra_->recHits(); }
0086 
0087     /// Iterator to first hit on the track.
0088     trackingRecHit_iterator recHitsBegin() const { return extra_->recHitsBegin(); }
0089 
0090     /// Iterator to last hit on the track.
0091     trackingRecHit_iterator recHitsEnd() const { return extra_->recHitsEnd(); }
0092 
0093     /// Get i-th hit on the track.
0094     TrackingRecHitRef recHit(size_t i) const { return extra_->recHit(i); }
0095 
0096     /// Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits).
0097     size_t recHitsSize() const { return extra_->recHitsSize(); }
0098 
0099     /// x coordinate of momentum vector at the outermost hit position
0100     double outerPx() const { return extra_->outerPx(); }
0101 
0102     /// y coordinate of momentum vector at the outermost hit position
0103     double outerPy() const { return extra_->outerPy(); }
0104 
0105     /// z coordinate of momentum vector at the outermost hit position
0106     double outerPz() const { return extra_->outerPz(); }
0107 
0108     /// x coordinate of the outermost hit position
0109     double outerX() const { return extra_->outerX(); }
0110 
0111     /// y coordinate of the outermost hit position
0112     double outerY() const { return extra_->outerY(); }
0113 
0114     /// z coordinate of the outermost hit position
0115     double outerZ() const { return extra_->outerZ(); }
0116 
0117     /// magnitude of momentum vector at the outermost hit position
0118     double outerP() const { return extra_->outerP(); }
0119 
0120     /// transverse momentum at the outermost hit position
0121     double outerPt() const { return extra_->outerPt(); }
0122 
0123     /// azimuthal angle of the  momentum vector at the outermost hit position
0124     double outerPhi() const { return extra_->outerPhi(); }
0125 
0126     /// pseudorapidity of the  momentum vector at the outermost hit position
0127     double outerEta() const { return extra_->outerEta(); }
0128 
0129     /// polar angle of the  momentum vector at the outermost hit position
0130     double outerTheta() const { return extra_->outerTheta(); }
0131 
0132     /// polar radius of the outermost hit position
0133     double outerRadius() const { return extra_->outerRadius(); }
0134 
0135     /// set reference to "extra" object
0136     void setExtra(const TrackExtraRef& ref) { extra_ = ref; }
0137 
0138     /// reference to "extra" object
0139     const TrackExtraRef& extra() const { return extra_; }
0140 
0141     /// Number of valid hits on track.
0142     unsigned short found() const { return numberOfValidHits(); }
0143 
0144     /// Number of lost (=invalid) hits on track.
0145     unsigned short lost() const { return numberOfLostHits(); }
0146 
0147     /// direction of how the hits were sorted in the original seed
0148     const PropagationDirection& seedDirection() const { return extra_->seedDirection(); }
0149 
0150     /**  return the edm::reference to the trajectory seed in the original
0151      *   seeds collection. If the collection has been dropped from the
0152      *   Event, the reference may be invalid. Its validity should be tested,
0153      *   before the reference is actually used.
0154      */
0155     const edm::RefToBase<TrajectorySeed>& seedRef() const { return extra_->seedRef(); }
0156 
0157     /// get the residuals
0158     const TrackResiduals& residuals() const { return extra_->residuals(); }
0159 
0160     // Check validity of track extra and rechits
0161     bool recHitsOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->recHitsOk(); }
0162 
0163   private:
0164     /// Reference to additional information stored only on RECO.
0165     TrackExtraRef extra_;
0166   };
0167 
0168 }  // namespace reco
0169 
0170 #endif