Track

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
#ifndef TrackReco_Track_h
#define TrackReco_Track_h
/** \class reco::Track Track.h DataFormats/TrackReco/interface/Track.h
 *
 * This class describes the reconstructed tracks that are stored in the AOD and
 * RECO. It also contains a reference to more detailed information about each
 * track, that is stoed in the TrackExtra object, available only in RECO.
 *
 * Note that most of the functions provided in this Track class rely on the existance of
 * the TrackExtra object, so will not work on AOD.
 *
 * The most useful functions are those provided in the TrackBase class from which this
 * inherits, all of which work on AOD.
 *
 * \author Luca Lista, INFN
 *
 *
 */
#include "DataFormats/TrackReco/interface/TrackBase.h"
#include "DataFormats/TrackReco/interface/TrackExtra.h"
#include "DataFormats/TrackReco/interface/TrackExtraFwd.h"
#include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
#include "FWCore/Utilities/interface/thread_safety_macros.h"

namespace reco {

  class Track : public TrackBase {
  public:
    /// default constructor
    Track() {}

    /// virtual destructor
    ~Track() override;

    /// constructor from fit parameters and error matrix
    Track(double chi2,
          double ndof,
          const Point& referencePoint,
          const Vector& momentum,
          int charge,
          const CovarianceMatrix&,
          TrackAlgorithm = undefAlgorithm,
          TrackQuality quality = undefQuality,
          float t0 = 0,
          float beta = 0,
          float covt0t0 = -1.,
          float covbetabeta = -1.);

    /// return true if the outermost hit is valid
    bool outerOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->outerOk(); }

    /// return true if the innermost hit is valid
    bool innerOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->innerOk(); }

    /// position of the innermost hit
    const math::XYZPoint& innerPosition() const { return extra_->innerPosition(); }

    /// momentum vector at the innermost hit position
    const math::XYZVector& innerMomentum() const { return extra_->innerMomentum(); }

    /// position of the outermost hit
    const math::XYZPoint& outerPosition() const { return extra_->outerPosition(); }

    /// momentum vector at the outermost hit position
    const math::XYZVector& outerMomentum() const { return extra_->outerMomentum(); }

    /// outermost trajectory state curvilinear errors
    CovarianceMatrix outerStateCovariance() const { return extra_->outerStateCovariance(); }

    /// innermost trajectory state curvilinear errors
    CovarianceMatrix innerStateCovariance() const { return extra_->innerStateCovariance(); }

    /// fill outermost trajectory state curvilinear errors
    CovarianceMatrix& fillOuter CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillOuter(v); }

    CovarianceMatrix& fillInner CMS_THREAD_SAFE(CovarianceMatrix& v) const { return extra_->fillInner(v); }

    /// DetId of the detector on which surface the outermost state is located
    unsigned int outerDetId() const { return extra_->outerDetId(); }

    /// DetId of the detector on which surface the innermost state is located
    unsigned int innerDetId() const { return extra_->innerDetId(); }

    /// Access to reconstructed hits on the track.
    auto recHits() const { return extra_->recHits(); }

    /// Iterator to first hit on the track.
    trackingRecHit_iterator recHitsBegin() const { return extra_->recHitsBegin(); }

    /// Iterator to last hit on the track.
    trackingRecHit_iterator recHitsEnd() const { return extra_->recHitsEnd(); }

    /// Get i-th hit on the track.
    TrackingRecHitRef recHit(size_t i) const { return extra_->recHit(i); }

    /// Get number of RecHits. (Warning, this includes invalid hits, which are not physical hits).
    size_t recHitsSize() const { return extra_->recHitsSize(); }

    /// x coordinate of momentum vector at the outermost hit position
    double outerPx() const { return extra_->outerPx(); }

    /// y coordinate of momentum vector at the outermost hit position
    double outerPy() const { return extra_->outerPy(); }

    /// z coordinate of momentum vector at the outermost hit position
    double outerPz() const { return extra_->outerPz(); }

    /// x coordinate of the outermost hit position
    double outerX() const { return extra_->outerX(); }

    /// y coordinate of the outermost hit position
    double outerY() const { return extra_->outerY(); }

    /// z coordinate of the outermost hit position
    double outerZ() const { return extra_->outerZ(); }

    /// magnitude of momentum vector at the outermost hit position
    double outerP() const { return extra_->outerP(); }

    /// transverse momentum at the outermost hit position
    double outerPt() const { return extra_->outerPt(); }

    /// azimuthal angle of the  momentum vector at the outermost hit position
    double outerPhi() const { return extra_->outerPhi(); }

    /// pseudorapidity of the  momentum vector at the outermost hit position
    double outerEta() const { return extra_->outerEta(); }

    /// polar angle of the  momentum vector at the outermost hit position
    double outerTheta() const { return extra_->outerTheta(); }

    /// polar radius of the outermost hit position
    double outerRadius() const { return extra_->outerRadius(); }

    /// set reference to "extra" object
    void setExtra(const TrackExtraRef& ref) { extra_ = ref; }

    /// reference to "extra" object
    const TrackExtraRef& extra() const { return extra_; }

    /// Number of valid hits on track.
    unsigned short found() const { return numberOfValidHits(); }

    /// Number of lost (=invalid) hits on track.
    unsigned short lost() const { return numberOfLostHits(); }

    /// direction of how the hits were sorted in the original seed
    const PropagationDirection& seedDirection() const { return extra_->seedDirection(); }

    /**  return the edm::reference to the trajectory seed in the original
     *   seeds collection. If the collection has been dropped from the
     *   Event, the reference may be invalid. Its validity should be tested,
     *   before the reference is actually used.
     */
    const edm::RefToBase<TrajectorySeed>& seedRef() const { return extra_->seedRef(); }

    /// get the residuals
    const TrackResiduals& residuals() const { return extra_->residuals(); }

    // Check validity of track extra and rechits
    bool recHitsOk() const { return extra_.isNonnull() && extra_.isAvailable() && extra_->recHitsOk(); }

  private:
    /// Reference to additional information stored only on RECO.
    TrackExtraRef extra_;
  };

}  // namespace reco

#endif