Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:05:22

0001 #include "Rtypes.h"
0002 #include "DataFormats/TrackReco/interface/TrackBase.h"
0003 #include "DataFormats/TrackReco/interface/fillCovariance.h"
0004 #include <algorithm>
0005 
0006 using namespace reco;
0007 
0008 // To be kept in synch with the enumerator definitions in TrackBase.h file
0009 std::string const TrackBase::algoNames[] = {"undefAlgorithm",
0010                                             "ctf",
0011                                             "duplicateMerge",
0012                                             "cosmics",
0013                                             "initialStep",
0014                                             "lowPtTripletStep",
0015                                             "pixelPairStep",
0016                                             "detachedTripletStep",
0017                                             "mixedTripletStep",
0018                                             "pixelLessStep",
0019                                             "tobTecStep",
0020                                             "jetCoreRegionalStep",
0021                                             "conversionStep",
0022                                             "muonSeededStepInOut",
0023                                             "muonSeededStepOutIn",
0024                                             "outInEcalSeededConv",
0025                                             "inOutEcalSeededConv",
0026                                             "nuclInter",
0027                                             "standAloneMuon",
0028                                             "globalMuon",
0029                                             "cosmicStandAloneMuon",
0030                                             "cosmicGlobalMuon",
0031                                             "highPtTripletStep",
0032                                             "lowPtQuadStep",
0033                                             "detachedQuadStep",
0034                                             "displacedGeneralStep",
0035                                             "displacedRegionalStep",
0036                                             "bTagGhostTracks",
0037                                             "beamhalo",
0038                                             "gsf",
0039                                             "hltPixel",
0040                                             "hltIter0",
0041                                             "hltIter1",
0042                                             "hltIter2",
0043                                             "hltIter3",
0044                                             "hltIter4",
0045                                             "hltIterX",
0046                                             "hiRegitMuInitialStep",
0047                                             "hiRegitMuLowPtTripletStep",
0048                                             "hiRegitMuPixelPairStep",
0049                                             "hiRegitMuDetachedTripletStep",
0050                                             "hiRegitMuMixedTripletStep",
0051                                             "hiRegitMuPixelLessStep",
0052                                             "hiRegitMuTobTecStep",
0053                                             "hiRegitMuMuonSeededStepInOut",
0054                                             "hiRegitMuMuonSeededStepOutIn"};
0055 
0056 std::string const TrackBase::qualityNames[] = {
0057     "loose", "tight", "highPurity", "confirmed", "goodIterative", "looseSetWithPV", "highPuritySetWithPV", "discarded"};
0058 
0059 TrackBase::TrackBase()
0060     : covt0t0_(-1.f),
0061       covbetabeta_(-1.f),
0062       chi2_(0),
0063       vertex_(0, 0, 0),
0064       t0_(0),
0065       momentum_(0, 0, 0),
0066       beta_(0),
0067       ndof_(0),
0068       charge_(0),
0069       algorithm_(undefAlgorithm),
0070       originalAlgorithm_(undefAlgorithm),
0071       quality_(0),
0072       nLoops_(0),
0073       stopReason_(0) {
0074   algoMask_.set(algorithm_);
0075   index idx = 0;
0076   for (index i = 0; i < dimension; ++i) {
0077     for (index j = 0; j <= i; ++j) {
0078       covariance_[idx++] = 0;
0079     }
0080   }
0081 }
0082 
0083 TrackBase::TrackBase(double chi2,
0084                      double ndof,
0085                      const Point &vertex,
0086                      const Vector &momentum,
0087                      int charge,
0088                      const CovarianceMatrix &cov,
0089                      TrackAlgorithm algorithm,
0090                      TrackQuality quality,
0091                      signed char nloops,
0092                      uint8_t stopReason,
0093                      float t0,
0094                      float beta,
0095                      float covt0t0,
0096                      float covbetabeta)
0097     : covt0t0_(covt0t0),
0098       covbetabeta_(covbetabeta),
0099       chi2_(chi2),
0100       vertex_(vertex),
0101       t0_(t0),
0102       momentum_(momentum),
0103       beta_(beta),
0104       ndof_(ndof),
0105       charge_(charge),
0106       algorithm_(algorithm),
0107       originalAlgorithm_(algorithm),
0108       quality_(0),
0109       nLoops_(nloops),
0110       stopReason_(stopReason) {
0111   algoMask_.set(algorithm_);
0112 
0113   index idx = 0;
0114   for (index i = 0; i < dimension; ++i) {
0115     for (index j = 0; j <= i; ++j) {
0116       covariance_[idx++] = cov(i, j);
0117     }
0118   }
0119   setQuality(quality);
0120 }
0121 
0122 TrackBase::~TrackBase() { ; }
0123 
0124 TrackBase::CovarianceMatrix &TrackBase::fill(CovarianceMatrix &v) const { return fillCovariance(v, covariance_); }
0125 
0126 TrackBase::TrackQuality TrackBase::qualityByName(const std::string &name) {
0127   TrackQuality size = qualitySize;
0128   int index = std::find(qualityNames, qualityNames + size, name) - qualityNames;
0129   if (index == size) {
0130     return undefQuality;  // better this or throw() ?
0131   }
0132 
0133   // cast
0134   return TrackQuality(index);
0135 }
0136 
0137 TrackBase::TrackAlgorithm TrackBase::algoByName(const std::string &name) {
0138   TrackAlgorithm size = algoSize;
0139   int index = std::find(algoNames, algoNames + size, name) - algoNames;
0140   if (index == size) {
0141     return undefAlgorithm;  // better this or throw() ?
0142   }
0143 
0144   // cast
0145   return TrackAlgorithm(index);
0146 }
0147 
0148 double TrackBase::dxyError(Point const &vtx, math::Error<3>::type const &vertexCov) const {
0149   // Gradient of TrackBase::dxy(const Point &myBeamSpot) with respect to track parameters. Using unrolled expressions to avoid calling for higher dimension matrices
0150   // ( 0, 0, x_vert * cos(phi) + y_vert * sin(phi), 1, 0 )
0151   // Gradient with respect to point parameters
0152   // ( sin(phi), -cos(phi))
0153   // Propagate covariance assuming cross-terms of the covariance between track and vertex parameters are 0
0154   return std::sqrt((vtx.x() * px() + vtx.y() * py()) * (vtx.x() * px() + vtx.y() * py()) / (pt() * pt()) *
0155                        covariance(i_phi, i_phi) +
0156                    2 * (vtx.x() * px() + vtx.y() * py()) / pt() * covariance(i_phi, i_dxy) + covariance(i_dxy, i_dxy) +
0157                    py() * py() / (pt() * pt()) * vertexCov(0, 0) - 2 * py() * px() / (pt() * pt()) * vertexCov(0, 1) +
0158                    px() * px() / (pt() * pt()) * vertexCov(1, 1));
0159 }