ATLAS Offline Software
Loading...
Searching...
No Matches
ConversionFinderUtils.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5/***************************************************************************
6 ConversionFinderUtils.cxx - Description
7 -------------------
8 begin : 01-01-2008
9 authors : Tatjana Lenz, Thomas Koffas
10 email : tatjana.lenz@cern.ch, Thomas.Koffas@cern.ch
11 changes :
12***************************************************************************/
15//Prep raw data
19#include "TrkTrack/Track.h"
21#include <cmath>
22
23using HepGeom::Point3D;
24
25namespace InDet {
26
27 static const InterfaceID IID_IConversionFinderUtils("InDet::ConversionFinderUtils", 1, 0);
28
30 const std::string& name,
31 const IInterface* parent)
32 : AthAlgTool(type, name, parent)
33 {
34 declareInterface<ConversionFinderUtils>(this);
35 }
36
38
40 {
42 }
43
45 return StatusCode::SUCCESS;
46 }
47
49 return StatusCode::SUCCESS;
50 }
51
55 double
57 const Trk::TrackParameters* per2)
58 {
59
60 const Amg::Vector3D& mom_pos = per1->momentum();
61 const Amg::Vector3D& mom_neg = per2->momentum();
62 double momFraction = mom_pos.mag()/(mom_pos.mag() + mom_neg.mag());
63 return momFraction;
64 }
65
69 double
71 const Trk::Track* trk_neg) const
72 {
73
74 //position of the first measurement on the positive track
75 const Trk::MeasurementBase* first_pos_meas = trk_pos->measurementsOnTrack()->front();
76 Amg::Vector3D trk_hit_pos = first_pos_meas->globalPosition();
77
78 //check if really the first measurement
79 for (const Trk::MeasurementBase* m : *trk_pos->measurementsOnTrack())
80 if(trk_hit_pos.mag() > m->globalPosition().mag()) first_pos_meas = m;
81
82 trk_hit_pos = first_pos_meas->globalPosition();
83
84 //position of the first hit--->track2
85 const Trk::MeasurementBase* first_neg_meas = trk_neg->measurementsOnTrack()->front();
86 Amg::Vector3D trk_hit_neg = first_neg_meas->globalPosition();
87
88 //check if really the first measurement
89 for (const Trk::MeasurementBase* m : *trk_neg->measurementsOnTrack())
90 if(trk_hit_neg.mag() > m->globalPosition().mag()) first_neg_meas = m;
91
92 trk_hit_neg = first_neg_meas->globalPosition();
93 double distance = 1000.;
94
95 //check if measurements are on the same surface
96 if (first_pos_meas->associatedSurface() == first_neg_meas->associatedSurface()) distance =
97 std::sqrt(std::pow(trk_hit_pos[0] - trk_hit_neg[0],2.) + std::pow(trk_hit_pos[1] - trk_hit_neg[1],2.) +
98 std::pow(trk_hit_pos[2] - trk_hit_neg[2],2.));
99
100
101 //if not choose the track with the fist measurement closest to 000 and calculate the distance
102 //of the closest approach of another track to this measurement
103 else {
104
105 //define reference point and track parameter (--> perigees) of the second track
106 Amg::Vector3D ref_point;
107 const Trk::Perigee* perigee;
108
109 if (first_pos_meas->globalPosition().mag() < first_neg_meas->globalPosition().mag()) {
110 ref_point = first_pos_meas->globalPosition();
111 perigee = trk_neg->perigeeParameters();
112 } else {
113 ref_point = first_neg_meas->globalPosition();
114 perigee = trk_pos->perigeeParameters();
115 }
116
117 // when the helix can be approximated as a straight line, when the
118 // distance of closest approach can be calculated as distance^2 = [momentum
119 // x (ref_point-position)]^2/momentum^2
120 const Amg::Vector3D& momentum = perigee->momentum();
121 const Amg::Vector3D& position = perigee->position();
122 double p = momentum.mag();
123 Amg::Vector3D delta = position - ref_point;
124 distance = std::sqrt(std::pow(delta.mag(),2.) - std::pow((delta.adjoint()*momentum)[0]/p,2.));
125 }
126
127 ATH_MSG_DEBUG("Distance between two tracks = "<<distance);
128 return distance;
129 } // end of distBetweenTracks method
130
131 /* add recalculated perigees to the track*/
132 std::unique_ptr<Trk::Track>
134 const Trk::Perigee* mp)
135 {
136
137 // fitQuality from track
138 auto fq = track->fitQuality()->uniqueClone();
139 if(!fq) return nullptr;
140
141 // output datavector of TSOS
142 auto ntsos = std::make_unique<Trk::TrackStates>();
143 const Trk::TrackStates* tsos = track->trackStateOnSurfaces();
144 if(!tsos) {return nullptr;}
147 for(its=tsos->begin();its!=itse;++its) {
148
149 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
150 typePattern.set(Trk::TrackStateOnSurface::Perigee);
151 const Trk::TrackStateOnSurface* per_tsos =
153 ? new Trk::TrackStateOnSurface(nullptr, mp->uniqueClone(), nullptr, typePattern)
154 : (*its)->clone();
155 ntsos->push_back(per_tsos);
156 }
157
158 //Construct the new track
159 Trk::TrackInfo info;
160 return std::make_unique<Trk::Track>(info, std::move(ntsos), std::move(fq));
161 }
162
165 Amg::Vector3D guessVertex)
166 {
167 Amg::Vector3D correctVertex(initVxCandidate->position().x()+guessVertex.x(),
168 initVxCandidate->position().y()+guessVertex.y(),
169 initVxCandidate->position().z()+guessVertex.z());
170
171 Amg::Vector3D globalVertexPosition(correctVertex.x(),correctVertex.y(),correctVertex.z());
172
173 std::vector<Trk::VxTrackAtVertex> tmpVTAV;
174
175 const std::vector<Trk::VxTrackAtVertex> &trkAtVtx = initVxCandidate->vxTrackAtVertex();
176 for (const auto& vtxTrack : trkAtVtx) {
177 const Trk::TrackParameters* vtxPer = vtxTrack.perigeeAtVertex();
178 const AmgVector(5)& iv = vtxPer->parameters();
179 AmgSymMatrix(5) em(*(vtxPer->covariance()));
180 Trk::PerigeeSurface surface (globalVertexPosition);
181
182 Trk::TrackParameters* tmpMeasPer =
183 surface
185 0., 0., iv[2], iv[3], iv[4], std::move(em))
186 .release();
187
188 Trk::VxTrackAtVertex trkV(vtxTrack.trackQuality().chiSquared(),
189 tmpMeasPer);
190 tmpVTAV.push_back(trkV);
191 }//end of loop over VxTracksAtVertex
192
193 if(tmpVTAV.size()!=2) return nullptr;
194
195 //Create the xAOD::Vertex and set the position and VxTrackAtVertex properly
196 xAOD::Vertex *vx = new xAOD::Vertex(*initVxCandidate);
197 vx->setPosition(correctVertex);
198 vx->vxTrackAtVertex().clear();
199 for (const auto& vtxTrack : tmpVTAV) {
200 vx->vxTrackAtVertex().push_back(vtxTrack);
201 }
202
203 return vx;
204 }//end of correct vxCandidate method
205
206} // end InDet
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
#define AmgVector(rows)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
static double momFraction(const Trk::TrackParameters *per1, const Trk::TrackParameters *per2)
helper functions
static xAOD::Vertex * correctVxCandidate(xAOD::Vertex *, Amg::Vector3D)
Correct VxCandidate with respect to a user defined vertex.
double distBetweenTracks(const Trk::Track *trk_pos, const Trk::Track *trk_neg) const
Approximate distance of minimum approach between tracks in pair.
virtual StatusCode initialize() override
virtual StatusCode finalize() override
static const InterfaceID & interfaceID()
ConversionFinderUtils(const std::string &type, const std::string &name, const IInterface *parent)
static std::unique_ptr< Trk::Track > addNewPerigeeToTrack(const Trk::Track *track, const Trk::Perigee *mp)
Add new perigee to track.
Simple helper class for defining track parameters for charged particles.
Definition Charged.h:27
This class is the pure abstract base class for all fittable tracking measurements.
virtual const Surface & associatedSurface() const =0
Interface method to get the associated Surface.
virtual const Amg::Vector3D & globalPosition() const =0
Interface method to get the global Position.
const Amg::Vector3D & momentum() const
Access method for the momentum.
const Amg::Vector3D & position() const
Access method for the position.
std::unique_ptr< ParametersBase< DIM, T > > uniqueClone() const
clone method for polymorphic deep copy returning unique_ptr; it is not overriden, but uses the existi...
Class describing the Line to which the Perigee refers to.
std::unique_ptr< ParametersT< DIM, T, PerigeeSurface > > createUniqueParameters(double l1, double l2, double phi, double theta, double qop, std::optional< AmgSymMatrix(DIM)> cov=std::nullopt) const
Use the Surface as a ParametersBase constructor, from local parameters.
Contains information about the 'fitter' of this track.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
const DataVector< const MeasurementBase > * measurementsOnTrack() const
return a pointer to a vector of MeasurementBase (NOT including any that come from outliers).
const Perigee * perigeeParameters() const
return Perigee.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
void setPosition(const Amg::Vector3D &position)
Sets the 3-position.
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
const Amg::Vector3D & position() const
Returns the 3-pos.
static std::string release
Definition computils.h:50
Eigen::Matrix< double, 3, 1 > Vector3D
Primary Vertex Finder.
static const InterfaceID IID_IConversionFinderUtils("InDet::ConversionFinderUtils", 1, 0)
DataVector< const Trk::TrackStateOnSurface > TrackStates
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
ParametersBase< TrackParametersDim, Charged > TrackParameters
Vertex_v1 Vertex
Define the latest version of the vertex class.