ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::AdaptiveMultiVertexFitter Class Reference

#include <AdaptiveMultiVertexFitter.h>

Inheritance diagram for Trk::AdaptiveMultiVertexFitter:
Collaboration diagram for Trk::AdaptiveMultiVertexFitter:

Public Member Functions

StatusCode initialize ()
StatusCode finalize ()
 AdaptiveMultiVertexFitter (const std::string &t, const std::string &n, const IInterface *p)
 default constructor due to Athena interface
virtual ~AdaptiveMultiVertexFitter ()
 destructor
void fit (std::vector< xAOD::Vertex * > &allVertices) const
 fit all the provided MVFVxCandidate, which have to be already properly initialized.
void addVtxToFit (xAOD::Vertex *pVtx) const
 Adds a new MVFVxCandidate to a previous multi-vertex fit and fits everything together.
void addVtxTofit (xAOD::Vertex *pVtx) const
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const

Static Public Member Functions

static const InterfaceID & interfaceID ()

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

std::vector< double > collectWeights (TrackToVtxLink &tracklink) const
 Internal function to collect the weights of the tracks partecipating to all the possible vertices (needed to renormalize the probability of the track to belong to the vertex under consideration, to be provided to the AnnealingMaker class).
void prepareCompatibility (xAOD::Vertex *newvertex) const
 Internal function to prepare the compatibility information of all the tracks of the new vertex (an IP3dAtaPlane is added, which makes later the estimation of the compatibilities of the tracks to the vertex for the downweighting faster).
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static bool findAmongVertices (const xAOD::Vertex *vertex, const std::vector< xAOD::Vertex * > &previousVertices)
 Internal method to find a VxCandidate among a vector of VxCandidates.

Private Attributes

long int m_maxIterations
 Max number of iterations.
double m_maxDistToLinPoint
 Maximum distance of linearization point of track to actual fitted vertex before needing to relinearize (in mm)
double m_initialError
 Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleading: take the error, square it and initialize the variable with its inverse)
bool m_doSmoothing
 True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided to the fitter will be ignored.
double m_minweight
 Minimum weight a track as to have in order to be considered in the fit of one of the vertices.
double m_maxRelativeShift
 Maximum shift allowed for last iteration... (in terms of Delta|VecR|/sigma|VecR|)
ToolHandle< Trk::IVertexLinearizedTrackFactorym_LinearizedTrackFactory
ToolHandle< Trk::IVertexTrackCompatibilityEstimatorm_TrackCompatibilityEstimator
ToolHandle< Trk::IImpactPoint3dEstimatorm_ImpactPoint3dEstimator
ToolHandle< Trk::IVertexUpdatorm_VertexUpdator
ToolHandle< Trk::IVertexSmootherm_VertexSmoother
ToolHandle< Trk::IVertexAnnealingMakerm_AnnealingMaker
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Author
N. Giacinto Piacquadio (Freiburg ATLAS Group)

This class implements a multi vertex fitting algorithm which is adaptive and robust, quite insensitive to the presence of outliers.

The multi-vertex version of the fit is more complicate than the single-vertex version and needs the input to be provided in the form of a vector of already initialized MVFVxCandidate objects. Details of the the objects to provide in the fit() and addVtxToFit() functions.

During the multi-vertex fit all the vertices are fit, using the tracks which are contained in their respective vertex candidates. Tracks which are shared among more than one vertex get their weights adjusted dynamically iteration after iteration thanks to a Deterministic Annealing procedure, so that in the end they are dinamically assigned to the vertex they most probably belong to.

As for the single-vertex fitter, for greater modularity the algorithm is divided into 6 modules (AlgTools in Athena):

  1. LinearizedTrackFactory
  2. TrackCompatibilityEstimator 2b. ImpactPoint3dEstimator
  3. VertexUpdator
  4. VertexSmoother plus another one, which is responsible for letting the temperature go down (which implements the so called "annealing technique")
  5. AnnealingMaker

Changes:

David Shope david.nosp@m..ric.nosp@m.hard..nosp@m.shop.nosp@m.e@cer.nosp@m.n.ch (2016-04-19)

EDM Migration to xAOD - from Trk::VxCandidate to xAOD::Vertex, from Trk::RecVertex to xAOD::Vertex, from Trk::Vertex to Amg::Vector3D

Also, VxMultiVertex EDM has been migrated to the following:

Trk::MvfFitInfo
constraintVertex now uses xAOD::Vertex seedVertex now uses Amg::Vector3D linearizationVertex now uses Amg::Vector3D

Vertex objects stored using this class are now xAOD::Vertex

Instead of using the MVFVxCandidate class, xAOD::Vertex is employed by decorating it with the multi-vertex information:

bool isInitialized MvfFitInfo* MvfFitInfo std::Vector<VxTrackAtVertex*> VTAV

This last decoration is needed in order to be able to use MVFVxTrackAtVertex objects which have the additional information of xAOD::Vertices associated to the track and (through polymorphism) to still be able to pass them to the KalmanVertexUpdator as VxTracksAtVertex objects.

This is obviously not an ideal implementation and could be avoided if xAOD::Vertex stored a std::vector<VxTrackAtVertex*> instead of a std::vector<VxTrackAtVertex>, but I think it must remain this way until such a time as the xAOD::Vertex EDM is changed.

Definition at line 109 of file AdaptiveMultiVertexFitter.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ AdaptiveMultiVertexFitter()

Trk::AdaptiveMultiVertexFitter::AdaptiveMultiVertexFitter ( const std::string & t,
const std::string & n,
const IInterface * p )

default constructor due to Athena interface

Definition at line 25 of file AdaptiveMultiVertexFitter.cxx.

28 : AthAlgTool(t, n, p)
29 , m_maxIterations(30)
31 , m_initialError(0.0001)
32 , m_doSmoothing(false)
33 , m_minweight(0.001)
34 , m_maxRelativeShift(0.01)
35{
36 declareProperty("MaxIterations", m_maxIterations);
37 declareProperty("MaxDistToLinPoint", m_maxDistToLinPoint);
38 declareProperty("InitialError", m_initialError);
39 declareProperty("DoSmoothing", m_doSmoothing);
40 declareProperty("MinWeight", m_minweight);
41 declareProperty("MaxRelativeShift", m_maxRelativeShift);
42 declareInterface<AdaptiveMultiVertexFitter>(this);
43}
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
double m_minweight
Minimum weight a track as to have in order to be considered in the fit of one of the vertices.
long int m_maxIterations
Max number of iterations.
bool m_doSmoothing
True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided ...
double m_initialError
Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleadin...
double m_maxRelativeShift
Maximum shift allowed for last iteration... (in terms of Delta|VecR|/sigma|VecR|)
double m_maxDistToLinPoint
Maximum distance of linearization point of track to actual fitted vertex before needing to relineariz...

◆ ~AdaptiveMultiVertexFitter()

Trk::AdaptiveMultiVertexFitter::~AdaptiveMultiVertexFitter ( )
virtualdefault

destructor

Member Function Documentation

◆ addVtxToFit()

void Trk::AdaptiveMultiVertexFitter::addVtxToFit ( xAOD::Vertex * pVtx) const

Adds a new MVFVxCandidate to a previous multi-vertex fit and fits everything together.

Please note that the new MVFVxCandidate provided has to be properly initialized, which means it has to have already a proper seed vertex, a constraint rec vertex, a list of initialized MVFVxTrackAtVertex, each with a link to the TrackToVtxLink object, which has to be already be updated to contain also a pointer to the MVFVxCandidate among the vertex candidates the track belongs to.

There are three steps:

1) the new vertex is added to the fit (all the tracks get initialized, so that the Plane through their IP point and the seed vertex (IP3dAtAPlane) is created, to be later able to estimate in a fast way the compatibility of the tracks to their respective vertices.

2) all tracks belonging to the new vertex are scanned and all the vertices which shares tracks with the new vertex to be fit are also added to the fit.

3) the multivertex fit is performed with all the involved vertices.

This has the clear advantage that only vertices which are really affected by adding the new vertex are being refitted, improving the overall finding performance.

Definition at line 314 of file AdaptiveMultiVertexFitter.cxx.

315{
316 ATH_MSG_VERBOSE(" Now entered addVtxToFit ");
317 // TODO: put this in a better place
318 // Prepare objects holding the decoration of xAOD::Vertex with MVF auxdata
319 // For optimization of access speed
321 "VTAV");
322
323 if (VTAV(*newvertex).empty()) {
325 "The candidate you're adding has no tracks: please fix the problem");
326 }
327 std::vector<xAOD::Vertex*>
328 allVerticesToFit; // how many vertices do you expect?
329 allVerticesToFit.reserve(10); // try 10
330 prepareCompatibility(newvertex);
331 //
332 ATH_MSG_VERBOSE("Iterating on tracks");
333 std::vector<xAOD::Vertex*> addedVerticesLastIteration;
334 std::vector<xAOD::Vertex*> addedVerticesNewIteration;
335 addedVerticesLastIteration.push_back(newvertex);
336 do {
337 for (const auto& vertexIterator : addedVerticesLastIteration) {
338 // now you have to check what are the other vertices which still have to
339 // do with your new one
340 const auto& vertexTracksAtVertex = VTAV(*vertexIterator);
341 for (const auto& thisTrack : vertexTracksAtVertex) {
342 const auto& pTheseVertices =
343 (static_cast<Trk::MVFVxTrackAtVertex*>(thisTrack))
344 ->linkToVertices()
345 ->vertices();
346 for (const auto& thisVertex : *pTheseVertices) {
347 // add the vertex if it's still not there
348 if (not findAmongVertices(thisVertex, allVerticesToFit)) {
349 allVerticesToFit.push_back(thisVertex);
350 if (thisVertex != vertexIterator) {
351 addedVerticesNewIteration.push_back(thisVertex);
352 }
353 }
354 }
355 } // iterate on tracks at considered vertex
356 } // end iteration on addedVerticesLastIteration
357
358 addedVerticesLastIteration = addedVerticesNewIteration;
359 addedVerticesNewIteration.clear();
360 } while (not addedVerticesLastIteration.empty());
361 //
362 // now fitting everything together
363 fit(allVerticesToFit);
364}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_VERBOSE(x)
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572
static bool findAmongVertices(const xAOD::Vertex *vertex, const std::vector< xAOD::Vertex * > &previousVertices)
Internal method to find a VxCandidate among a vector of VxCandidates.
void prepareCompatibility(xAOD::Vertex *newvertex) const
Internal function to prepare the compatibility information of all the tracks of the new vertex (an IP...
void fit(std::vector< xAOD::Vertex * > &allVertices) const
fit all the provided MVFVxCandidate, which have to be already properly initialized.

◆ addVtxTofit()

void Trk::AdaptiveMultiVertexFitter::addVtxTofit ( xAOD::Vertex * pVtx) const
inline

Definition at line 174 of file AdaptiveMultiVertexFitter.h.

174{ return addVtxToFit(pVtx);}
void addVtxToFit(xAOD::Vertex *pVtx) const
Adds a new MVFVxCandidate to a previous multi-vertex fit and fits everything together.

◆ collectWeights()

std::vector< double > Trk::AdaptiveMultiVertexFitter::collectWeights ( Trk::TrackToVtxLink & tracklink) const
private

Internal function to collect the weights of the tracks partecipating to all the possible vertices (needed to renormalize the probability of the track to belong to the vertex under consideration, to be provided to the AnnealingMaker class).

The input is the TrackToVtxLink, where the weights are stored.

Definition at line 281 of file AdaptiveMultiVertexFitter.cxx.

283{
284 ATH_MSG_DEBUG("Collecting weights for tracklink " << &tracklink);
285 // TODO: put this in a better place
286 // Prepare objects holding the decoration of xAOD::Vertex with MVF auxdata
287 // For optimization of access speed
289 "VTAV");
290 const auto& theseVertices = *(tracklink.vertices());
291 std::vector<double> myvector;
292 myvector.reserve(theseVertices.size());
293 for (const auto& pThisVertex : theseVertices) {
294 // really stupid, now you have still to find the weight value (right track
295 // in this vertex) but if you later remove tracks from candidate, you cannot
296 // do much better (maybe update on demand...)
297 const auto& trackPointersForThisVertex = VTAV(*pThisVertex);
298 for (const auto& pThisTrack : trackPointersForThisVertex) {
299 if ((static_cast<Trk::MVFVxTrackAtVertex*>(pThisTrack))
300 ->linkToVertices() == &tracklink) {
301 ATH_MSG_DEBUG("found one weight: it's : "
302 << pThisTrack->vtxCompatibility() << " for track "
303 << pThisTrack);
304 myvector.push_back(pThisTrack->vtxCompatibility());
305 break; // gain time in avoiding to look for other tracks if you already
306 // found the right one
307 }
308 }
309 }
310 return myvector;
311}
#define ATH_MSG_DEBUG(x)

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ finalize()

StatusCode Trk::AdaptiveMultiVertexFitter::finalize ( )

Definition at line 63 of file AdaptiveMultiVertexFitter.cxx.

64{
65 ATH_MSG_VERBOSE("Finalize successful");
66 return StatusCode::SUCCESS;
67}

◆ findAmongVertices()

bool Trk::AdaptiveMultiVertexFitter::findAmongVertices ( const xAOD::Vertex * vertex,
const std::vector< xAOD::Vertex * > & previousVertices )
staticprivate

Internal method to find a VxCandidate among a vector of VxCandidates.

Returns true if the vertex is found.

Definition at line 394 of file AdaptiveMultiVertexFitter.cxx.

397{
398 return (std::find(previousVertices.begin(), previousVertices.end(), vertex) !=
399 previousVertices.end());
400}

◆ fit()

void Trk::AdaptiveMultiVertexFitter::fit ( std::vector< xAOD::Vertex * > & allVertices) const

fit all the provided MVFVxCandidate, which have to be already properly initialized.

The information about the Vertices to Tracks association is provided in the following way: the MVFVxCandidate contains a list of MVFVxTrackAtVertex, which contain each a TrackToVtxLink class: this class contains the information about all the vertices (MVFVxCandidate objects) the tracks belongs to and is shared among all MVFVxTrackAtVertex which represents the same track at the different vertices.

This has the clear advantage that the equivalent matrix of the assignments between vertices and tracks can be made block diagonal, so that no time is wasted in case of tracks which are clearly incompatible with some of the other vertices.

Definition at line 70 of file AdaptiveMultiVertexFitter.cxx.

71{
72 // TODO: put this in a better place
73 // Prepare objects needed to add MVF auxdata to the xAOD::Vertex
74 // For optimization of access speed
75 static const xAOD::Vertex::Accessor<MvfFitInfo*> MvfFitInfo("MvfFitInfo");
76 static const xAOD::Vertex::Accessor<bool> isInitialized("isInitialized");
78 "VTAV");
79 ATH_MSG_DEBUG(" Now fitting all vertices ");
80 // create a vector of vertices, to store the old position...
81 std::map<xAOD::Vertex*, Amg::Vector3D> oldpositions;
82 std::map<xAOD::Vertex*, bool> relinearizations;
83 // count number of steps
84 int num_steps(0);
85 // reset the annealing
87 m_AnnealingMaker->reset(astate);
88 ATH_MSG_DEBUG("Entering cycle of AdaptiveMultiVertexFitter");
89 bool shiftIsSmall(true);
90 // now start to iterate
91 do {
92 for (auto* pThisVertex : allVertices) {
93 // now store all the "old positions"; if vertex is added for the first
94 // time this corresponds to the seed (at the same time fitted vertex will
95 // be updated with the constraint information) check if you need to
96 // reestimate compatibility + linearization
97 ATH_MSG_DEBUG("Now considering candidate with ptr " << pThisVertex);
98 relinearizations[pThisVertex] = false;
99 if (isInitialized(*pThisVertex)) {
100 ATH_MSG_DEBUG("vertex position z: " << (*pThisVertex).position()[2]);
101 oldpositions[pThisVertex] = pThisVertex->position();
102 } else {
103 isInitialized(*pThisVertex) = true;
104 ATH_MSG_DEBUG("Candidate has no position so far: using as old position "
105 "the seedVertex");
106 if (MvfFitInfo(*pThisVertex)->seedVertex() ==
107 nullptr) { // TODO: Is there a way of checking whether a decoration
108 // exists on an object?
109 ATH_MSG_ERROR("Candidate has no seed...CRASHING now!!!");
110 }
111 oldpositions[pThisVertex] = *(MvfFitInfo(*pThisVertex)->seedVertex());
112 }
113 if (MvfFitInfo(*pThisVertex)->linearizationVertex() ==
114 nullptr) { // TODO: Is there a way of checking whether a decoration
115 // exists on an object?
117 " Candidate has no linearization point...CRASHING now!!! ");
118 }
119 if ((oldpositions[pThisVertex] -
120 *MvfFitInfo(*pThisVertex)->linearizationVertex())
121 .perp() > m_maxDistToLinPoint) {
122 ATH_MSG_DEBUG("Candidate has to be relinearized ");
123 relinearizations[pThisVertex] = true;
124 prepareCompatibility(pThisVertex);
125 }
126 ATH_MSG_DEBUG("Setting the Vertex to the initial constraint");
127 // reput everything to the constraint level
128 pThisVertex->setPosition(
129 MvfFitInfo(*pThisVertex)->constraintVertex()->position());
130 pThisVertex->setCovariancePosition(
131 MvfFitInfo(*pThisVertex)->constraintVertex()->covariancePosition());
132 pThisVertex->setFitQuality(
133 MvfFitInfo(*pThisVertex)->constraintVertex()->chiSquared(),
134 MvfFitInfo(*pThisVertex)->constraintVertex()->numberDoF());
135 pThisVertex->setCovariancePosition(
136 pThisVertex->covariancePosition() * 1. /
137 float(m_AnnealingMaker->getWeight(astate, 1.)));
138 ATH_MSG_DEBUG("Running TrackCompatibilityEstimator on each track");
139 // prepare the iterators for the tracks
140 const auto& theseTrackPointersAtVtx = VTAV(*pThisVertex);
141 // iterate and update the vertex with the track information
142 for (const auto& pThisTrack : theseTrackPointersAtVtx) {
143 ATH_MSG_DEBUG("Adding compatibility info to a track of "
144 << theseTrackPointersAtVtx.size());
145 // now recover from cases where the linearization position is !=0, but
146 // you added more tracks later on...
147 if (not pThisTrack->ImpactPoint3dAtaPlane()) {
148 const bool success = m_ImpactPoint3dEstimator->addIP3dAtaPlane(
149 *pThisTrack, *MvfFitInfo(*pThisVertex)->linearizationVertex());
150 if (!success) {
152 "Adding compatibility to vertex information failed. Newton "
153 "distance finder didn't converge...");
154 }
155 }
156 // first -> estimate the compatibility of the track to the vertex
157 m_TrackCompatibilityEstimator->estimate(*pThisTrack,
158 oldpositions[pThisVertex]);
159 ATH_MSG_DEBUG("End of compatibility for a track");
160 }
161 }
162 ATH_MSG_DEBUG("Finished first candidates cycle");
163 // after having estimated the compatibility of all the vertices, you have to
164 // run again on all vertices, to compute the weights
165 for (auto* pThisVertex : allVertices) {
166 // TODO: crude and quite possibly time consuming, but best solution I
167 // could think of...
168 // updated VxTrackAtVertices are stored in VTAV decoration:
169 // so each time a vertex is to be updated with its tracks in this
170 // loop, delete VxTrackAtVertex vector and add correctly updated
171 // VxTrackAtVertex (from VTAV) to the vector just before calling
172 // the vertex updator
173 std::vector<Trk::VxTrackAtVertex>* tracksOfVertex =
174 &(pThisVertex->vxTrackAtVertex());
175 tracksOfVertex->clear();
176 // prepare the iterators for the tracks
177 const auto& theseTrackPointersAtVtx = VTAV(*pThisVertex);
179 "Beginning lin&update of vertex with pointer: " << pThisVertex);
180 for (const auto& pThisTrack : theseTrackPointersAtVtx) {
181 // set the weight according to all other track's weight
182 ATH_MSG_DEBUG("Calling collect weight for track " << pThisTrack);
183 const std::vector<double>& allweights(
184 collectWeights(*(static_cast<Trk::MVFVxTrackAtVertex*>(pThisTrack))
185 ->linkToVertices()));
186 ATH_MSG_DEBUG("The vtxcompatibility for the track is: "
187 << pThisTrack->vtxCompatibility());
188 pThisTrack->setWeight(m_AnnealingMaker->getWeight(
189 astate, pThisTrack->vtxCompatibility(), allweights));
190 ATH_MSG_DEBUG("The resulting weight for the track is "
191 << m_AnnealingMaker->getWeight(
192 astate, pThisTrack->vtxCompatibility(), allweights));
193 if (pThisTrack->weight() > m_minweight) {
194 ATH_MSG_DEBUG("check passed");
195 // now take care if linearization has been done at least once
196 if (not pThisTrack->linState()) {
197 // linearization never done so far: do it now!
198 ATH_MSG_VERBOSE("Linearizing track for the first time");
199 m_LinearizedTrackFactory->linearize(*pThisTrack,
200 oldpositions[pThisVertex]);
201 } else if (relinearizations[pThisVertex]) {
202 ATH_MSG_VERBOSE("Relinearizing track ");
203 m_LinearizedTrackFactory->linearize(*pThisTrack,
204 oldpositions[pThisVertex]);
205 MvfFitInfo(*pThisVertex)
206 ->setLinearizationVertex(
207 new Amg::Vector3D(oldpositions[pThisVertex]));
208 }
209 // now you can proceed with the update
210 ATH_MSG_DEBUG("Update of the track "
211 << pThisTrack << " to the vertex " << pThisVertex);
212 // TODO: obviously not ideal that I have to do this
213 tracksOfVertex->push_back(*pThisTrack);
214 // TODO: add() returns an xAOD::Vertex* - is it really ok to just
215 // have this line without *iter = m_VertexUpdator->add() ? Must
216 // be...
217 m_VertexUpdator->add(*pThisVertex, *pThisTrack);
218 }
219 } // iterator on tracks
220 // show some info about the position
221 ATH_MSG_DEBUG("Vertex pointer " << pThisVertex << " New position x: "
222 << pThisVertex->position().x()
223 << " y: " << pThisVertex->position().y()
224 << " z: " << pThisVertex->position().z());
225 } // iterator on Vertices
226 // call now one more step of annealing
227 if (!(m_AnnealingMaker->isEquilibrium(astate))) {
228 m_AnnealingMaker->anneal(astate);
229 }
230 // August 2009: sometimes the fitter has not converged when the annealing
231 // has finished iterate on all vertex candidates and check whether they moved
232 // significantly from last iteration
233 shiftIsSmall = true;
234 Amg::Vector3D vrtpos;
235 for (const auto& pThisVertex : allVertices) {
236 vrtpos[0] = oldpositions[pThisVertex][0] - pThisVertex->position()[0];
237 vrtpos[1] = oldpositions[pThisVertex][1] - pThisVertex->position()[1];
238 vrtpos[2] = oldpositions[pThisVertex][2] - pThisVertex->position()[2];
239 AmgSymMatrix(3) weightMatrixVertex;
240 weightMatrixVertex = pThisVertex->covariancePosition().inverse();
241 double relativeShift = vrtpos.dot(weightMatrixVertex * vrtpos);
242 if (relativeShift > m_maxRelativeShift) {
243 shiftIsSmall = false;
244 break;
245 }
246 }
247 num_steps += 1;
248 } while (num_steps < m_maxIterations &&
249 (!(m_AnnealingMaker->isEquilibrium(astate)) || !shiftIsSmall));
250
251 if (num_steps >= m_maxIterations) {
252 ATH_MSG_DEBUG("Didn't converge fully after " << num_steps);
253 }
255 "In principle the big multivertex fit step is finished now...");
256 // TODO: I don't think that I need to fiddle with updating
257 // MVFVxTracksAtVertex - vector of VxTrackAtVertex should be available in
258 // the usual way now and be enough
259 if (m_doSmoothing) {
260 auto trackAvailable = [](const xAOD::Vertex* pV) {
261 return pV->vxTrackAtVertexAvailable() and
262 not(pV->vxTrackAtVertex()).empty();
263 };
264 for (const auto& pThisVertex : allVertices) {
265 if (trackAvailable(pThisVertex)) {
266 m_VertexSmoother->smooth(*pThisVertex);
267 }
268 }
269 } else { // TODO: I added this during xAOD migration
270 for (auto* pThisVertex : allVertices) {
271 const auto& theseTrackPointersAtVtx = VTAV(*pThisVertex);
272 for (const auto& pTrack : theseTrackPointersAtVtx) {
273 if (pTrack->initialPerigee())
274 pTrack->setPerigeeAtVertex((pTrack->initialPerigee())->clone());
275 }
276 }
277 }
278}
#define AmgSymMatrix(dim)
if(febId1==febId2)
ToolHandle< Trk::IImpactPoint3dEstimator > m_ImpactPoint3dEstimator
ToolHandle< Trk::IVertexSmoother > m_VertexSmoother
ToolHandle< Trk::IVertexAnnealingMaker > m_AnnealingMaker
ToolHandle< Trk::IVertexUpdator > m_VertexUpdator
ToolHandle< Trk::IVertexLinearizedTrackFactory > m_LinearizedTrackFactory
ToolHandle< Trk::IVertexTrackCompatibilityEstimator > m_TrackCompatibilityEstimator
std::vector< double > collectWeights(TrackToVtxLink &tracklink) const
Internal function to collect the weights of the tracks partecipating to all the possible vertices (ne...
Eigen::Matrix< double, 3, 1 > Vector3D
Vertex_v1 Vertex
Define the latest version of the vertex class.

◆ initialize()

StatusCode Trk::AdaptiveMultiVertexFitter::initialize ( )

Definition at line 48 of file AdaptiveMultiVertexFitter.cxx.

49{
53 ATH_CHECK(m_VertexUpdator.retrieve());
54 // loading smoother in case required
55 if (m_doSmoothing)
56 ATH_CHECK(m_VertexSmoother.retrieve());
57 ATH_CHECK(m_AnnealingMaker.retrieve());
58 ATH_MSG_VERBOSE("Initialize successful");
59 return StatusCode::SUCCESS;
60}
#define ATH_CHECK
Evaluate an expression and check for errors.

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ interfaceID()

const InterfaceID & Trk::AdaptiveMultiVertexFitter::interfaceID ( )
inlinestatic

Definition at line 177 of file AdaptiveMultiVertexFitter.h.

177 {
179 }
static const InterfaceID IID_AdaptiveMultiVertexFitter("AdaptiveMultiVertexFitter", 1, 0)

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ prepareCompatibility()

void Trk::AdaptiveMultiVertexFitter::prepareCompatibility ( xAOD::Vertex * newvertex) const
private

Internal function to prepare the compatibility information of all the tracks of the new vertex (an IP3dAtaPlane is added, which makes later the estimation of the compatibilities of the tracks to the vertex for the downweighting faster).

Further information in the TrkVertexFitterUtils package (IP3dAtAPlaneFactory class).

Definition at line 367 of file AdaptiveMultiVertexFitter.cxx.

368{
369 ATH_MSG_VERBOSE("Entered prepareCompatibility() ");
370 // TODO: put this in a better place
371 // Prepare objects holding the decoration of xAOD::Vertex with MVF auxdata
372 // For optimization of access speed
373 static const xAOD::Vertex::Accessor<MvfFitInfo*> MvfFitInfo("MvfFitInfo");
375 "VTAV");
376 const Amg::Vector3D* seedPoint = MvfFitInfo(*newvertex)->seedVertex();
377 ATH_MSG_VERBOSE("Now adding compatibility info to the track");
378 // lambda adds impact point and 'ANDs' with previous success result
379 auto addImpactPoint = [this, seedPoint](const auto& thisVxTrack) {
380 return this->m_ImpactPoint3dEstimator->addIP3dAtaPlane(*thisVxTrack,
381 *seedPoint);
382 };
383 const auto& vertexTracksAtVertex = VTAV(*newvertex);
384 // std::reduce might be quicker, if compiler implemented it
385 const bool success = std::all_of(
386 vertexTracksAtVertex.begin(), vertexTracksAtVertex.end(), addImpactPoint);
387 if (not success) {
388 ATH_MSG_DEBUG("Adding compatibility to vertex information failed. Newton "
389 "distance finder didn't converge...");
390 }
391}

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_AnnealingMaker

ToolHandle<Trk::IVertexAnnealingMaker> Trk::AdaptiveMultiVertexFitter::m_AnnealingMaker
private
Initial value:
{
this,
"AnnealingMaker",
"Trk::DetAnnealingMaker"
}

Definition at line 285 of file AdaptiveMultiVertexFitter.h.

285 {
286 this,
287 "AnnealingMaker",
288 "Trk::DetAnnealingMaker"
289 };

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_doSmoothing

bool Trk::AdaptiveMultiVertexFitter::m_doSmoothing
private

True if smoothing after fit iterations has to be performed: otherwise the Smoother AlgoTool provided to the fitter will be ignored.

Definition at line 242 of file AdaptiveMultiVertexFitter.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_ImpactPoint3dEstimator

ToolHandle<Trk::IImpactPoint3dEstimator> Trk::AdaptiveMultiVertexFitter::m_ImpactPoint3dEstimator
private
Initial value:
{
this,
"ImpactPoint3dEstimator",
"Trk::ImpactPoint3dEstimator/ImpactPoint3dEstimator"
}

Definition at line 269 of file AdaptiveMultiVertexFitter.h.

269 {
270 this,
271 "ImpactPoint3dEstimator",
272 "Trk::ImpactPoint3dEstimator/ImpactPoint3dEstimator"
273 };

◆ m_initialError

double Trk::AdaptiveMultiVertexFitter::m_initialError
private

Initial error in form of diagonal elements of the inverse of the covariance matrix (name is misleading: take the error, square it and initialize the variable with its inverse)

Definition at line 234 of file AdaptiveMultiVertexFitter.h.

◆ m_LinearizedTrackFactory

ToolHandle<Trk::IVertexLinearizedTrackFactory> Trk::AdaptiveMultiVertexFitter::m_LinearizedTrackFactory
private
Initial value:
{
this,
"LinearizedTrackFactory",
"Trk::FullLinearizedTrackFactory"
}

Definition at line 260 of file AdaptiveMultiVertexFitter.h.

260 {
261 this,
262 "LinearizedTrackFactory",
263 "Trk::FullLinearizedTrackFactory"
264 };

◆ m_maxDistToLinPoint

double Trk::AdaptiveMultiVertexFitter::m_maxDistToLinPoint
private

Maximum distance of linearization point of track to actual fitted vertex before needing to relinearize (in mm)

Definition at line 226 of file AdaptiveMultiVertexFitter.h.

◆ m_maxIterations

long int Trk::AdaptiveMultiVertexFitter::m_maxIterations
private

Max number of iterations.

Definition at line 217 of file AdaptiveMultiVertexFitter.h.

◆ m_maxRelativeShift

double Trk::AdaptiveMultiVertexFitter::m_maxRelativeShift
private

Maximum shift allowed for last iteration... (in terms of Delta|VecR|/sigma|VecR|)

Definition at line 258 of file AdaptiveMultiVertexFitter.h.

◆ m_minweight

double Trk::AdaptiveMultiVertexFitter::m_minweight
private

Minimum weight a track as to have in order to be considered in the fit of one of the vertices.

This should make the fit slightly faster.

Definition at line 250 of file AdaptiveMultiVertexFitter.h.

◆ m_TrackCompatibilityEstimator

ToolHandle<Trk::IVertexTrackCompatibilityEstimator> Trk::AdaptiveMultiVertexFitter::m_TrackCompatibilityEstimator
private
Initial value:
{ this,
"TrackCompatibilityEstimator",
"Trk::Chi2TrackCompatibilityEstimator" }

Definition at line 266 of file AdaptiveMultiVertexFitter.h.

266 { this,
267 "TrackCompatibilityEstimator",
268 "Trk::Chi2TrackCompatibilityEstimator" };

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_VertexSmoother

ToolHandle<Trk::IVertexSmoother> Trk::AdaptiveMultiVertexFitter::m_VertexSmoother
private
Initial value:
{
this,
"VertexSmoother",
"Trk::SequentialVertexSmoother"
}

Definition at line 280 of file AdaptiveMultiVertexFitter.h.

280 {
281 this,
282 "VertexSmoother",
283 "Trk::SequentialVertexSmoother"
284 };

◆ m_VertexUpdator

ToolHandle<Trk::IVertexUpdator> Trk::AdaptiveMultiVertexFitter::m_VertexUpdator
private
Initial value:
{
this,
"VertexUpdator",
"Trk::KalmanVertexUpdator"
}

Definition at line 275 of file AdaptiveMultiVertexFitter.h.

275 {
276 this,
277 "VertexUpdator",
278 "Trk::KalmanVertexUpdator"
279 };

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: