CMS 3D CMS Logo

Classes | Functions
GhostTrackVertexFinder.cc File Reference
#include <algorithm>
#include <iterator>
#include <memory>
#include <map>
#include <set>
#include <vector>
#include <Math/SVector.h>
#include <Math/SMatrix.h>
#include <Math/MatrixFunctions.h>
#include "DataFormats/GeometryVector/interface/GlobalPoint.h"
#include "DataFormats/GeometryVector/interface/GlobalVector.h"
#include "DataFormats/GeometryCommonDetAlgo/interface/GlobalError.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "TrackingTools/TrajectoryParametrization/interface/GlobalTrajectoryParameters.h"
#include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
#include "TrackingTools/TrajectoryState/interface/FreeTrajectoryState.h"
#include "TrackingTools/GeomPropagators/interface/AnalyticalImpactPointExtrapolator.h"
#include "TrackingTools/TransientTrack/interface/TransientTrack.h"
#include "TrackingTools/TransientTrack/interface/TransientTrackFromFTSFactory.h"
#include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
#include "RecoVertex/VertexPrimitives/interface/VertexFitter.h"
#include "RecoVertex/VertexPrimitives/interface/VertexState.h"
#include "RecoVertex/VertexPrimitives/interface/CachingVertex.h"
#include "RecoVertex/VertexPrimitives/interface/LinearizedTrackState.h"
#include "RecoVertex/VertexPrimitives/interface/ConvertError.h"
#include "RecoVertex/VertexPrimitives/interface/ConvertToFromReco.h"
#include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
#include "RecoVertex/VertexTools/interface/VertexTrackFactory.h"
#include "RecoVertex/VertexTools/interface/VertexDistance3D.h"
#include "RecoVertex/VertexTools/interface/GeometricAnnealing.h"
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexFitter.h"
#include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h"
#include "RecoVertex/GhostTrackFitter/interface/GhostTrack.h"
#include "RecoVertex/GhostTrackFitter/interface/GhostTrackState.h"
#include "RecoVertex/GhostTrackFitter/interface/GhostTrackFitter.h"
#include "RecoVertex/GhostTrackFitter/interface/GhostTrackPrediction.h"
#include "RecoVertex/GhostTrackFitter/interface/SequentialGhostTrackFitter.h"
#include "RecoVertex/GhostTrackFitter/interface/KalmanGhostTrackUpdater.h"
#include "RecoVertex/GhostTrackFitter/interface/GhostTrackVertexFinder.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"

Go to the source code of this file.

Classes

struct  reco::GhostTrackVertexFinder::FinderInfo
 

Functions

static bool covarianceUpdate (Matrix3S &cov, const Vector3 &residual, const Matrix3S &error, double &chi2, double theta, double phi)
 
static GhostTrackPrediction dummyPrediction (const Vertex &primaryVertex, const Track &ghostTrack)
 
static double fitChi2 (const CachingVertex< 5 > &vtx)
 
static void mergeTrackHelper (const std::vector< RefCountedVertexTrack > &tracks, std::vector< RefCountedVertexTrack > &newTracks, const VertexState &state, const VtxTrackIs &ghostTrackFinder, RefCountedVertexTrack &ghostTrack, const VertexTrackFactory< 5 > &factory)
 
static RefCountedVertexTrack relinearizeTrack (const RefCountedVertexTrack &track, const VertexState &state, const VertexTrackFactory< 5 > factory)
 
static std::vector< RefCountedVertexTrack > relinearizeTracks (const std::vector< RefCountedVertexTrack > &tracks, const VertexState &state)
 
static VertexState stateMean (const VertexState &v1, const VertexState &v2)
 
static double trackVertexCompat (const CachingVertex< 5 > &vtx, const RefCountedVertexTrack &vertexTrack)
 
static TransientTrack transientGhostTrack (const GhostTrackPrediction &pred, const MagneticField *field)
 
static CachingVertex< 5 > vertexAtState (const TransientTrack &ghostTrack, const GhostTrackPrediction &pred, const GhostTrackState &state)
 
static double vtxErrorLong (const GlobalError &error, const GlobalVector &dir)
 
static GlobalPoint vtxMean (const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2)
 

Function Documentation

◆ covarianceUpdate()

static bool covarianceUpdate ( Matrix3S &  cov,
const Vector3 &  residual,
const Matrix3S &  error,
double &  chi2,
double  theta,
double  phi 
)
static

Definition at line 145 of file GhostTrackVertexFinder.cc.

References hltPixelTracks_cff::chi2, funct::cos(), relativeConstraints::error, funct::sin(), and theta().

Referenced by vertexAtState().

146  {
147  using namespace ROOT::Math;
148 
149  Matrix23 jacobian;
150  jacobian(0, 0) = std::cos(phi) * std::cos(theta);
151  jacobian(0, 1) = std::sin(phi) * std::cos(theta);
152  jacobian(0, 2) = -std::sin(theta);
153  jacobian(1, 0) = -std::sin(phi);
154  jacobian(1, 1) = std::cos(phi);
155 
156  Matrix2S measErr = Similarity(jacobian, error);
157  Matrix2S combErr = Similarity(jacobian, cov) + measErr;
158  if (!measErr.Invert() || !combErr.Invert())
159  return false;
160 
161  cov -= SimilarityT(jacobian * cov, combErr);
162  chi2 += Similarity(jacobian * residual, measErr);
163 
164  return true;
165 }
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Geom::Theta< T > theta() const

◆ dummyPrediction()

static GhostTrackPrediction dummyPrediction ( const Vertex primaryVertex,
const Track ghostTrack 
)
static

Definition at line 542 of file GhostTrackVertexFinder.cc.

References RecoVertex::convertError(), RecoVertex::convertPos(), BeamMonitor_cff::primaryVertex, reco::TrackBase::px(), reco::TrackBase::py(), and reco::TrackBase::pz().

Referenced by reco::GhostTrackVertexFinder::vertices().

542  {
545  GlobalVector(ghostTrack.px(), ghostTrack.py(), ghostTrack.pz()),
546  0.05);
547 }
reco::Vertex::Point convertPos(const GlobalPoint &p)
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:640
reco::Vertex::Error convertError(const GlobalError &ge)
Definition: ConvertError.h:8
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:643
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:646
primaryVertex
hltOfflineBeamSpot for HLTMON
Global3DVector GlobalVector
Definition: GlobalVector.h:10

◆ fitChi2()

static double fitChi2 ( const CachingVertex< 5 > &  vtx)
static

Definition at line 645 of file GhostTrackVertexFinder.cc.

References extraflags_cff::vtx.

Referenced by PFGsfHelper::PFGsfHelper(), and reco::GhostTrackVertexFinder::recursiveMerge().

645 { return vtx.totalChiSquared() / vtx.degreesOfFreedom(); }

◆ mergeTrackHelper()

static void mergeTrackHelper ( const std::vector< RefCountedVertexTrack > &  tracks,
std::vector< RefCountedVertexTrack > &  newTracks,
const VertexState state,
const VtxTrackIs &  ghostTrackFinder,
RefCountedVertexTrack &  ghostTrack,
const VertexTrackFactory< 5 > &  factory 
)
static

Definition at line 668 of file GhostTrackVertexFinder.cc.

References submitPVValidationJobs::gt, relinearizeTrack(), HLT_2022v12_cff::track, and tracks.

Referenced by reco::GhostTrackVertexFinder::mergeVertices().

673  {
674  for (std::vector<RefCountedVertexTrack>::const_iterator iter = tracks.begin(); iter != tracks.end(); ++iter) {
675  bool gt = ghostTrackFinder(*iter);
676  if (gt && ghostTrack)
677  continue;
678 
679  RefCountedVertexTrack track = relinearizeTrack(*iter, state, factory);
680 
681  if (gt)
682  ghostTrack = *iter;
683  else
684  newTracks.push_back(*iter);
685  }
686 }
static RefCountedVertexTrack relinearizeTrack(const RefCountedVertexTrack &track, const VertexState &state, const VertexTrackFactory< 5 > factory)
auto const & tracks
cannot be loose

◆ relinearizeTrack()

static RefCountedVertexTrack relinearizeTrack ( const RefCountedVertexTrack &  track,
const VertexState state,
const VertexTrackFactory< 5 >  factory 
)
static

Definition at line 218 of file GhostTrackVertexFinder.cc.

References HLT_2022v12_cff::track, and VertexTrackFactory< N >::vertexTrack().

Referenced by mergeTrackHelper(), reco::GhostTrackVertexFinder::reassignTracks(), and relinearizeTracks().

220  {
221  RefCountedLinearizedTrackState linTrack = track->linearizedTrack();
222  linTrack = linTrack->stateWithNewLinearizationPoint(state.position());
223  return factory.vertexTrack(linTrack, state);
224 }
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const

◆ relinearizeTracks()

static std::vector<RefCountedVertexTrack> relinearizeTracks ( const std::vector< RefCountedVertexTrack > &  tracks,
const VertexState state 
)
static

Definition at line 226 of file GhostTrackVertexFinder.cc.

References relinearizeTrack(), and tracks.

Referenced by reco::GhostTrackVertexFinder::reassignTracks().

227  {
228  VertexTrackFactory<5> vertexTrackFactory;
229 
230  std::vector<RefCountedVertexTrack> finalTracks;
231  finalTracks.reserve(tracks.size());
232 
233  for (std::vector<RefCountedVertexTrack>::const_iterator iter = tracks.begin(); iter != tracks.end(); ++iter)
234  finalTracks.push_back(relinearizeTrack(*iter, state, vertexTrackFactory));
235 
236  return finalTracks;
237 }
static RefCountedVertexTrack relinearizeTrack(const RefCountedVertexTrack &track, const VertexState &state, const VertexTrackFactory< 5 > factory)
auto const & tracks
cannot be loose

◆ stateMean()

static VertexState stateMean ( const VertexState v1,
const VertexState v2 
)
static

Definition at line 141 of file GhostTrackVertexFinder.cc.

References VertexState::error(), VertexState::position(), and vtxMean().

Referenced by reco::GhostTrackVertexFinder::mergeVertices().

141  {
142  return VertexState(vtxMean(v1.position(), v1.error(), v2.position(), v2.error()), v1.error() + v2.error());
143 }
GlobalError error() const
Definition: VertexState.h:64
static GlobalPoint vtxMean(const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2)
GlobalPoint position() const
Definition: VertexState.h:62

◆ trackVertexCompat()

static double trackVertexCompat ( const CachingVertex< 5 > &  vtx,
const RefCountedVertexTrack &  vertexTrack 
)
static

Definition at line 247 of file GhostTrackVertexFinder.cc.

References conv, DeadROC_duringRun::dir, relativeConstraints::error, point, HLT_2022v12_cff::track, and extraflags_cff::vtx.

Referenced by reco::GhostTrackVertexFinder::reassignTracks().

247  {
248  using namespace ROOT::Math;
249 
250  TransientTrack track = vertexTrack->linearizedTrack()->track();
251  GlobalPoint point = vtx.position();
253  TrajectoryStateOnSurface tsos = extrap.extrapolate(track.impactPointState(), point);
254 
255  if (!tsos.isValid())
256  return 1.0e6;
257 
258  GlobalPoint point1 = vtx.position();
259  GlobalPoint point2 = tsos.globalPosition();
260  Vector3 dir = conv(point2 - point1);
261  Matrix3S error = vtx.error().matrix() + tsos.cartesianError().matrix().Sub<Matrix3S>(0, 0);
262  if (!error.Invert())
263  return 1.0e6;
264 
265  return ROOT::Math::Similarity(error, dir);
266 }
EPOS::IO_EPOS conv
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ transientGhostTrack()

static TransientTrack transientGhostTrack ( const GhostTrackPrediction pred,
const MagneticField field 
)
static

Definition at line 117 of file GhostTrackVertexFinder.cc.

References TransientTrackFromFTSFactory::build(), and reco::GhostTrackPrediction::fts().

Referenced by reco::GhostTrackVertexFinder::refitGhostTrack(), and reco::GhostTrackVertexFinder::vertices().

117  {
118  return TransientTrackFromFTSFactory().build(pred.fts(field));
119 }
FreeTrajectoryState fts(const MagneticField *fieldProvider) const
reco::TransientTrack build(const FreeTrajectoryState &fts) const

◆ vertexAtState()

static CachingVertex<5> vertexAtState ( const TransientTrack ghostTrack,
const GhostTrackPrediction pred,
const GhostTrackState state 
)
static

Definition at line 167 of file GhostTrackVertexFinder.cc.

References hltPixelTracks_cff::chi2, conv, covarianceUpdate(), relativeConstraints::error, sistrip::SpyUtilities::isValid(), LinearizedTrackStateFactory::linearizedTrackState(), GlobalErrorBase< T, ErrorWeightType >::matrix(), point, reco::GhostTrackPrediction::position(), reco::GhostTrackPrediction::positionError(), VertexTrackFactory< N >::vertexTrack(), and vtxMean().

Referenced by reco::GhostTrackVertexFinder::initialVertices(), reco::GhostTrackVertexFinder::reassignTracks(), and reco::GhostTrackVertexFinder::refitGhostTrack().

169  {
170  LinearizedTrackStateFactory linTrackFactory;
171  VertexTrackFactory<5> vertexTrackFactory;
172 
173  if (!state.isValid())
174  return CachingVertex<5>();
175 
176  GlobalPoint pca1 = pred.position(state.lambda());
177  GlobalError err1 = pred.positionError(state.lambda());
178 
179  GlobalPoint pca2 = state.globalPosition();
180  GlobalError err2 = state.cartesianError();
181 
182  GlobalPoint point = vtxMean(pca1, err1, pca2, err2);
183 
184  const TransientTrack &recTrack = state.track();
185 
186  RefCountedLinearizedTrackState linState[2] = {linTrackFactory.linearizedTrackState(point, ghostTrack),
187  linTrackFactory.linearizedTrackState(point, recTrack)};
188  if (!linState[0]->isValid() || !linState[1]->isValid())
189  return CachingVertex<5>();
190 
191  Matrix3S cov = SMatrixIdentity();
192  cov *= 10000;
193  double chi2 = 0.;
194  if (!covarianceUpdate(cov,
195  conv(pca1 - point),
196  err1.matrix(),
197  chi2,
198  linState[0]->predictedStateParameters()[1],
199  linState[0]->predictedStateParameters()[2]) ||
200  !covarianceUpdate(cov,
201  conv(pca2 - point),
202  err2.matrix(),
203  chi2,
204  linState[1]->predictedStateParameters()[1],
205  linState[1]->predictedStateParameters()[2]))
206  return CachingVertex<5>();
207 
208  GlobalError error(cov);
209  VertexState vtxState(point, error);
210 
211  std::vector<RefCountedVertexTrack> linTracks(2);
212  linTracks[0] = vertexTrackFactory.vertexTrack(linState[0], vtxState);
213  linTracks[1] = vertexTrackFactory.vertexTrack(linState[1], vtxState);
214 
215  return CachingVertex<5>(point, error, linTracks, chi2);
216 }
RefCountedLinearizedTrackState linearizedTrackState(const GlobalPoint &linP, const reco::TransientTrack &track) const override
const bool isValid(const Frame &aFrame, const FrameQuality &aQuality, const uint16_t aExpectedPos)
static bool covarianceUpdate(Matrix3S &cov, const Vector3 &residual, const Matrix3S &error, double &chi2, double theta, double phi)
GlobalPoint position(double lambda=0.) const
RefCountedVertexTrack vertexTrack(const RefCountedLinearizedTrackState lt, const VertexState vs, float weight=1.0) const
GlobalError positionError(double lambda=0.) const
static GlobalPoint vtxMean(const GlobalPoint &p1, const GlobalError &e1, const GlobalPoint &p2, const GlobalError &e2)
const AlgebraicSymMatrix33 matrix() const
EPOS::IO_EPOS conv
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ vtxErrorLong()

static double vtxErrorLong ( const GlobalError error,
const GlobalVector dir 
)
static

Definition at line 121 of file GhostTrackVertexFinder.cc.

References conv, DeadROC_duringRun::dir, and relativeConstraints::error.

Referenced by vtxMean().

121  {
122  return ROOT::Math::Similarity(conv(dir), error.matrix());
123 }
EPOS::IO_EPOS conv

◆ vtxMean()

static GlobalPoint vtxMean ( const GlobalPoint p1,
const GlobalError e1,
const GlobalPoint p2,
const GlobalError e2 
)
static

Definition at line 125 of file GhostTrackVertexFinder.cc.

References change_name::diff, StorageManager_cfg::e1, LaserDQM_cfg::p1, SiStripOfflineCRack_cfg::p2, UNLIKELY, and vtxErrorLong().

Referenced by GlobalTrackingRegion::checkRZ(), RectangularEtaPhiTrackingRegion::checkRZOld(), stateMean(), and vertexAtState().

125  {
126  GlobalVector diff = p2 - p1;
127 
128  if UNLIKELY (p1 == p2) {
129  edm::LogWarning("GhostTrackVertexFinder") << "Averaging with self at " << p1;
130  return p1;
131  }
132 
133  double err1 = vtxErrorLong(e1, diff);
134  double err2 = vtxErrorLong(e2, diff);
135 
136  double weight = err1 / (err1 + err2);
137 
138  return p1 + weight * diff;
139 }
Definition: weight.py:1
static double vtxErrorLong(const GlobalError &error, const GlobalVector &dir)
#define UNLIKELY(x)
Definition: Likely.h:21
Log< level::Warning, false > LogWarning