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

ATLAS Reconstruction Software - (C) 2005 - 2007. More...

#include <KalmanVertexOnJetAxisSmoother.h>

Inheritance diagram for Trk::KalmanVertexOnJetAxisSmoother:
Collaboration diagram for Trk::KalmanVertexOnJetAxisSmoother:

Public Member Functions

virtual StatusCode initialize () override
 KalmanVertexOnJetAxisSmoother (const std::string &t, const std::string &n, const IInterface *p)
 Constructor.
 ~KalmanVertexOnJetAxisSmoother ()
 Destructor.
void update (VxVertexOnJetAxis *vertexToSmooth, const VxJetCandidate *candidateToUpdate, bool updateTrack=true) const
 Update the VxVertexOnJetAxis (chi2 and ndf) with the knowledge coming from the fitted VxJetCandidate, updating (or not) also all the related track parameters of the tracks at the vertex (smoothing).
void fastUpdate (VxVertexOnJetAxis *vertexToSmooth, const VxJetCandidate *candidateToUpdate, bool updateTrack=true) const
void update (VxVertexOnJetAxis *vertexToSmooth, bool isPrimary, const RecVertexPositions &myFinalPosition, const VertexPositions &linearizationPositions, bool updateTrack=false, bool doFastUpdate=false) const
 Update the VxVertexOnJetAxis (chi2 and ndf) with the knowledge coming from the fitted RecVertexPositions, taking into account the linearization positions, updating (or not) all the related track parameters of the tracks at the vertex (smoothing).
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

 AmgSymMatrix (3) m_initial_cov_momentum
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Private Attributes

ToolHandle< KalmanVertexOnJetAxisUpdatorm_Updator
double m_maxWeight
 Meaningless in case no adaptive fitting is used.
double m_initialMomentumError
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

ATLAS Reconstruction Software - (C) 2005 - 2007.

Author
Giacinto Piacquadio, (giaci.nosp@m.nto..nosp@m.piacq.nosp@m.uadi.nosp@m.o@phy.nosp@m.sik..nosp@m.uni-f.nosp@m.reib.nosp@m.urg.d.nosp@m.e)
Christian Weiser, (chris.nosp@m.tian.nosp@m..weis.nosp@m.er@p.nosp@m.hysik.nosp@m..uni.nosp@m.-frei.nosp@m.burg.nosp@m..de)

A concrete implementation of the Vertex Smoother for smoothing the vertexing along the Jet Axis.

This is a special implementation (part of the JetFitter(TM) algorithm) which is able to smooth a vertex correcting the jet axis parameters to find the best overall agreement.

Basic approach is based on R. Fruhwirth et al. Comp. Phys. Comm 96(1996) 189

First version: December 2006 Updated version for athena: Februar 2007

Alberts-Ludwig-Universita"t Freiburg

Definition at line 48 of file KalmanVertexOnJetAxisSmoother.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

◆ KalmanVertexOnJetAxisSmoother()

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

Constructor.

Definition at line 48 of file KalmanVertexOnJetAxisSmoother.cxx.

48 :
49 AthAlgTool(t,n,p),
50 m_Updator("Trk::KalmanVertexOnJetAxisUpdator", this),
51 m_maxWeight(0.001),
53 {
54 declareProperty("Updator",m_Updator);
55 declareProperty("MaximalWeight",m_maxWeight);
56 declareProperty("initialMomentumError",m_initialMomentumError);
57 declareInterface<KalmanVertexOnJetAxisSmoother>(this);
58 }
AthAlgTool()
Default constructor:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
double m_maxWeight
Meaningless in case no adaptive fitting is used.
ToolHandle< KalmanVertexOnJetAxisUpdator > m_Updator

◆ ~KalmanVertexOnJetAxisSmoother()

Trk::KalmanVertexOnJetAxisSmoother::~KalmanVertexOnJetAxisSmoother ( )
default

Destructor.

Member Function Documentation

◆ AmgSymMatrix()

Trk::KalmanVertexOnJetAxisSmoother::AmgSymMatrix ( 3 )
private

◆ 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

◆ fastUpdate()

void Trk::KalmanVertexOnJetAxisSmoother::fastUpdate ( VxVertexOnJetAxis * vertexToSmooth,
const VxJetCandidate * candidateToUpdate,
bool updateTrack = true ) const

Definition at line 75 of file KalmanVertexOnJetAxisSmoother.cxx.

77 {
78 const RecVertexPositions & myFinalPosition=candidateToUpdate->getRecVertexPositions();
79 const VertexPositions & linearizationPositions=candidateToUpdate->getLinearizationVertexPositions();
80 bool isPrimary = (vertexToSmooth==candidateToUpdate->getPrimaryVertex());
81 update(vertexToSmooth,isPrimary,myFinalPosition,linearizationPositions,updateTrack,true);
82 }
void update(VxVertexOnJetAxis *vertexToSmooth, const VxJetCandidate *candidateToUpdate, bool updateTrack=true) const
Update the VxVertexOnJetAxis (chi2 and ndf) with the knowledge coming from the fitted VxJetCandidate,...
@ isPrimary
true if matched track has a hit in first or second pixel layer

◆ initialize()

StatusCode Trk::KalmanVertexOnJetAxisSmoother::initialize ( )
overridevirtual

Definition at line 29 of file KalmanVertexOnJetAxisSmoother.cxx.

30 {
31 AthAlgTool::initialize().ignore();
32
33 //retrieving the udator itself
34 StatusCode sc = m_Updator.retrieve();
35 if(sc.isFailure()) {
36 ATH_MSG_ERROR( " Unable to retrieve "<<m_Updator );
37 return StatusCode::FAILURE;
38 }
39 m_initial_cov_momentum.setZero();
40 m_initial_cov_momentum(0,0) = m_initialMomentumError*m_initialMomentumError;
41 m_initial_cov_momentum(1,1) = m_initialMomentumError*m_initialMomentumError;
42 m_initial_cov_momentum(2,2) = m_initialMomentumError*m_initialMomentumError/10000.;
43
44 return StatusCode::SUCCESS;
45 }
#define ATH_MSG_ERROR(x)
static Double_t sc
::StatusCode StatusCode
StatusCode definition for legacy code.

◆ 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::KalmanVertexOnJetAxisSmoother::interfaceID ( )
inlinestatic

Definition at line 66 of file KalmanVertexOnJetAxisSmoother.h.

67 {
69 };
static const InterfaceID IID_KalmanVertexOnJetAxisSmoother("Trk::KalmanVertexOnJetAxisSmoother", 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.

◆ 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.

◆ update() [1/2]

void Trk::KalmanVertexOnJetAxisSmoother::update ( VxVertexOnJetAxis * vertexToSmooth,
bool isPrimary,
const RecVertexPositions & myFinalPosition,
const VertexPositions & linearizationPositions,
bool updateTrack = false,
bool doFastUpdate = false ) const

Update the VxVertexOnJetAxis (chi2 and ndf) with the knowledge coming from the fitted RecVertexPositions, taking into account the linearization positions, updating (or not) all the related track parameters of the tracks at the vertex (smoothing).

Definition at line 84 of file KalmanVertexOnJetAxisSmoother.cxx.

87 {
88
89 // void KalmanVertexOnJetAxisSmoother::update(VxVertexOnJetAxis* vertexToSmooth,const VxJetCandidate* candidateToUpdate) const
90 // {
91
92 if (vertexToSmooth==nullptr) {
93 ATH_MSG_WARNING( " Empty pointers then calling fit method update. No fit will be done..." );
94 return;
95 }
96
97 ATH_MSG_DEBUG("It's smoothing "<<(isPrimary? "with":"without")<<" primary vertex ");
98 ATH_MSG_DEBUG("It's " << (updateTrack?"with":"without") << " updating the track.");
99 ATH_MSG_DEBUG("It's the "<<(doFastUpdate?"fast":"normal (weight-formalism)")<<" smoother");
100
101 const std::vector<VxTrackAtVertex*> & allTracksToSmooth(vertexToSmooth->getTracksAtVertex());
102
103 //care first about the transformation matrix (which is the same for all tracks...)
104
105
106 if (allTracksToSmooth.empty()) {
107 ATH_MSG_DEBUG(" Nothing to smooth ");
108 if (!isPrimary)
109 ATH_MSG_WARNING ("Nothing to smooth and it's not a primary vertex: BUG... ");
110 return;
111 }
112
113 const Amg::VectorX & initialjetdir=linearizationPositions.position();
114
115 int numVertex=vertexToSmooth->getNumVertex();
116
117
118 //calculate 3-dim position on jet axis from linearizationPositionVector and calculate Jacobian of transformation
119 std::pair<Amg::Vector3D,Eigen::Matrix3Xd> PosOnJetAxisAndTransformMatrix =
120 m_Updator->createTransformJacobian(initialjetdir, numVertex, isPrimary, /*truncate=*/false);
121
122 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
123 std::cout << " smoother: " << PosOnJetAxisAndTransformMatrix.first << " and transform matrix: " << PosOnJetAxisAndTransformMatrix.second <<
124 std::endl;
125 #endif
126
127
128 //prepare a RecVertexPositions to be updated with removal
129 //of all tracks of the present vertex...
130 //THIS TIME copy the RecVertexPositions to a new object... :-)
131 RecVertexPositions myPositionWithRemovedTracks=myFinalPosition; // for fast updator (cov formalism)
132 RecVertexPositions myPositionInWeightFormalism=myFinalPosition; // for full updator (weight formalism)
133 const Amg::VectorX & final_vrt_pos=myFinalPosition.position();
134 const Amg::MatrixX & final_vrt_covariance = myFinalPosition.covariancePosition();
135
136 Amg::MatrixX final_vrt_weightmatrix;
137 if (!doFastUpdate) {
138 // Hack the JetFitter EDM... avoid to invert big cov matrix at each iteration
139 // by storing position --> weight*position
140 // and covariance -> weightmatrix
141 Eigen::FullPivLU<Amg::MatrixX> lu_decomp(final_vrt_covariance);
142 if (!lu_decomp.isInvertible()) {
143 ATH_MSG_DEBUG("Jet vertex positions matrix not invertible right at start of smoother!" <<
144 " -> stop smoothing.");
145 return;
146 }
147 final_vrt_weightmatrix = final_vrt_covariance.inverse();
148 myPositionInWeightFormalism.setPosition(final_vrt_weightmatrix*
149 myPositionInWeightFormalism.position());
150 myPositionInWeightFormalism.setCovariancePosition(final_vrt_weightmatrix);
151 }
152 //from here onwards (until finishing adding tracks) it is weight*position TO MAKE THINGS FASTER
153
154 double track_compatibility_chi2(0.);
155 double track_ndf(0.);
156
157 //nice! that was easy...
158 //now iterate over all tracks in order to calculated the updated TrackParameters + the residual chi2...
159 const std::vector<VxTrackAtVertex*>::const_iterator TracksBegin=allTracksToSmooth.begin();
160 const std::vector<VxTrackAtVertex*>::const_iterator TracksEnd=allTracksToSmooth.end();
161
162 for (std::vector<VxTrackAtVertex*>::const_iterator TracksIter=TracksBegin;TracksIter!=TracksEnd;++TracksIter) {
163
164 //get linearized track
165 const LinearizedTrack * trk=(*TracksIter)->linState();
166
167 if (trk==nullptr) {
168 ATH_MSG_WARNING (" Empty pointers then calling smoothing method update. No smoothing will be performed...");
169 return;
170 }
171
172 double trackWeight = (*TracksIter)->weight();
173
174 //only position jacobian changed from A ->oldA
175 const AmgMatrix(5,3)& oldA = trk->positionJacobian();
176
177 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
178 std::cout << "the old jacobian xyz d0z0phithetaqoverp vs xyz " << oldA << std::endl;
179 #endif
180
181 //now create the new jacobian which you should use
182 Eigen::Matrix<double,5,Eigen::Dynamic> A = oldA*PosOnJetAxisAndTransformMatrix.second;
183
184 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
185 std::cout << "the new jacobian " << A << std::endl;
186 #endif
187
188 const AmgMatrix(5,3) & B = trk->momentumJacobian();
189 const AmgVector(5)& trackParameters = trk->expectedParametersAtPCA();
190
191 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
192 std::cout << "expected perigee at pca " << trackParameters << std::endl;
193 std::cout << "expected position at pca " << trk->expectedPositionAtPCA() << std::endl;
194 std::cout << " constant term " << trk->constantTerm() <<
195 " old A " << oldA << " * PosOnJetAxis " << PosOnJetAxisAndTransformMatrix.first <<
196 " A " << A << " * initialjetdir " << initialjetdir << std::endl;
197 #endif
198
199 AmgVector(5) constantTerm=trk->constantTerm() + oldA*PosOnJetAxisAndTransformMatrix.first
200 -A*initialjetdir;
201 const AmgSymMatrix(5)& trackParametersWeight = trk->expectedWeightAtPCA();
202 AmgSymMatrix(3) S = B.transpose()*trackParametersWeight*B;
203 if(S.determinant()==0.0) {
204 ATH_MSG_WARNING ("The S matrix inversion failed during smoothing iteration cycle");
205 continue;
206 }
207 S=S.inverse().eval();
208
209 if (doFastUpdate) {
210 const Amg::VectorX old_vrt_pos = myPositionWithRemovedTracks.position();
211 const Amg::MatrixX & old_vrt_cov = myPositionWithRemovedTracks.covariancePosition();
212
213 AmgSymMatrix(5) old_residual_cov = -trk->expectedCovarianceAtPCA() +
214 A*old_vrt_cov*A.transpose() + B*m_initial_cov_momentum*B.transpose();
215 if (old_residual_cov.determinant() == 0.0 ) {
216 ATH_MSG_ERROR ("The old_residual matrix can not be inverted during smoothing interation cycle");
217 continue;
218 }
219 AmgSymMatrix(5) old_residual_cov_inv = old_residual_cov.inverse().eval();
220 Eigen::Matrix<double,Eigen::Dynamic,5> Kk1=old_vrt_cov*A.transpose()*old_residual_cov_inv;
221 AmgVector(5) residual_vector=trackParameters-constantTerm-A*old_vrt_pos;
222 Amg::VectorX new_vrt_pos = old_vrt_pos+Kk1*residual_vector;
223 Amg::MatrixX new_vrt_cov = old_vrt_cov+Kk1*old_residual_cov*Kk1.transpose()
224 - 2.*Kk1*A*old_vrt_cov;
225 myPositionWithRemovedTracks = RecVertexPositions(new_vrt_pos,new_vrt_cov);
226
227 } else {
228
229 //REMEMBER: there's also the RecVertexPositions w/ removed tracks: **myPositionWithRemovedTracks**
230
231 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
232 std::cout << " Old weight Matrix is " << myPositionInWeightFormalism.covariancePosition() << std::endl;
233 #endif
234
235 // the full smoother writes weight matrices into RecVertexPositions
236 const Amg::MatrixX & old_vrt_weight = myPositionInWeightFormalism.covariancePosition();
237 const Amg::VectorX old_vrt_weight_times_vrt_pos = myPositionInWeightFormalism.position();
238
239 //G_b = G_k - G_k*B_k*W_k*B_k^(T)*G_k
240 AmgSymMatrix(5) gB = trackParametersWeight - trackParametersWeight*(B*(S*B.transpose()))*trackParametersWeight.transpose();
241 //(S.similarity(B)).similarity(trackParametersWeight);
242
243 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
244 std::cout<<"Gain factor obtained: "<<trackParametersWeight*(B*(S*B.transpose()))*trackParametersWeight.transpose()<<std::endl;
245 std::cout<<"Resulting Gain Matrix: "<<gB<<std::endl;
246 #endif
247
248 //new vertex weight matrix
249 Amg::MatrixX new_vrt_weight = old_vrt_weight - trackWeight * A.transpose()*gB*A;
250
251 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
252 std::cout<<"New vertex weight obtained: "<<new_vrt_weight<<std::endl;
253 #endif
254
255 //new vertex position
256 Amg::VectorX new_weight_matrix_times_vrt_position =old_vrt_weight_times_vrt_pos - trackWeight * A.transpose() * gB *(trackParameters - constantTerm);
257 // new_vrt_cov*(old_vrt_weight * old_vrt_pos + trackWeight * sign * A.T() * gB *(trackParameters - constantTerm) );
258 // avoid to invert the weight matrix to obtain the COVARIANCE MATRIX!!!
259 //this line COPIES things two times, it would be nice to have a operator=(pos,errm) method in RecVertexPositions...
260 myPositionInWeightFormalism =
261 RecVertexPositions(new_weight_matrix_times_vrt_position,new_vrt_weight);
262 }
263
264 //refitted track momentum
265 Amg::Vector3D newTrackMomentum = S*B.transpose()*trackParametersWeight*(trackParameters - constantTerm - A*final_vrt_pos);
266 //refitted track parameters
267 AmgVector(5) refTrackParameters = constantTerm + A * final_vrt_pos + B * newTrackMomentum;
268
269 if (updateTrack) {
270
271 const AmgSymMatrix(3) final_vrt_covariance_xyz =
272 (PosOnJetAxisAndTransformMatrix.second)*final_vrt_covariance*(PosOnJetAxisAndTransformMatrix.second).transpose();
273
274 AmgVector(5) refTrackParametersToStore(refTrackParameters);
275
276
277 //bring parameter phi again in the limits, if
278 //phi is slightly outside (as can be expected
279 //due to refitting)
280 //thanks to Wolfgang L. / Sebastian F. for the piece of code with fmod!
281 // bool isSth=false;
282 if (refTrackParametersToStore[Trk::phi0] > M_PI) {
283 // isSth=true;
284 ATH_MSG_DEBUG ("-U- phi = " << refTrackParametersToStore[Trk::phi0]);
285 refTrackParametersToStore[Trk::phi0] = fmod(refTrackParametersToStore[Trk::phi0]+M_PI,2*M_PI)-M_PI;
286 ATH_MSG_DEBUG (" out of range, now corrected to " << refTrackParametersToStore[Trk::phi0]);
287 } else if(refTrackParametersToStore[Trk::phi0]<-M_PI) {
288 ATH_MSG_DEBUG ("-U- phi = " << refTrackParametersToStore[Trk::phi0]);
289 refTrackParametersToStore[Trk::phi0] = fmod(refTrackParametersToStore[Trk::phi0]-M_PI,2*M_PI)+M_PI;
290 ATH_MSG_DEBUG (" out of range, now corrected to " << refTrackParametersToStore[Trk::phi0]);
291 }
292
293 if (refTrackParametersToStore[Trk::theta] > M_PI)
294 {
295 ATH_MSG_DEBUG (" Theta out of range: correcting theta: " << refTrackParametersToStore[Trk::theta]);
296 refTrackParametersToStore[Trk::theta]=fmod(refTrackParametersToStore[Trk::theta]+M_PI,2*M_PI)-M_PI;
297 ATH_MSG_DEBUG (" to: " << refTrackParametersToStore[Trk::theta]);
298 }
299 else if (refTrackParametersToStore[Trk::theta]<0) {
300 ATH_MSG_DEBUG (" Theta out of range: correcting theta: " << refTrackParametersToStore[Trk::theta]);
301 refTrackParametersToStore[Trk::theta]=fmod(refTrackParametersToStore[Trk::theta]-M_PI,2*M_PI)+M_PI;
302 ATH_MSG_DEBUG (" to: " << refTrackParametersToStore[Trk::theta]);
303 }
304
305 if (refTrackParametersToStore[Trk::theta] < 0) {
306 refTrackParametersToStore[Trk::theta] =
307 - refTrackParametersToStore[Trk::theta];
308 refTrackParametersToStore[Trk::phi0] +=
309 (refTrackParametersToStore[Trk::phi0] > 0 ? -M_PI : M_PI);
310 }
311 else if (refTrackParametersToStore[Trk::theta] > M_PI) {//this is in principle not needed anymore
312 refTrackParametersToStore[Trk::theta] =
313 2*M_PI - refTrackParametersToStore[Trk::theta];
314 refTrackParametersToStore[Trk::phi0] +=
315 (refTrackParametersToStore[Trk::phi0] > 0 ? -M_PI : M_PI);
316 }
317
318 //making a new track covariance matrix
319 AmgMatrix(Eigen::Dynamic,3) partialCovariance = A.transpose() * trackParametersWeight * B *S;
320
321 AmgMatrix(Eigen::Dynamic,3) posMomentumCovariance = -final_vrt_covariance * partialCovariance;
322
323 AmgMatrix(Eigen::Dynamic,3) posMomentumCovariance_xyz = PosOnJetAxisAndTransformMatrix.second * posMomentumCovariance;
324
325 //new momentum covariance
326 AmgSymMatrix(3) momentumCovariance = doFastUpdate ?
327 S + (partialCovariance.transpose()*final_vrt_covariance*partialCovariance) :
328 S + (posMomentumCovariance.transpose()*final_vrt_weightmatrix*posMomentumCovariance);
329
330 //full (x,y,z,phi, theta, q/p) covariance matrix
331 AmgSymMatrix(6) fullTrkCov; fullTrkCov.setZero();
332
333 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
334 std::cout << " posMomentumCovariance " << posMomentumCovariance <<
335 " final_vrt_covariance " << final_vrt_covariance << " momentumCovariance " <<
336 momentumCovariance << std::endl;
337 #endif
338
339 fullTrkCov.block<3,3>(0,3) = posMomentumCovariance_xyz.transpose();//GP: to be checked: .T() is here or down?
340 fullTrkCov.block<3,3>(3,0) = posMomentumCovariance_xyz;
341 fullTrkCov.block<3,3>(0,0) = final_vrt_covariance_xyz;
342 fullTrkCov.block<3,3>(3,3) = momentumCovariance;
343 //debug hacking
344 AmgMatrix(5,6) trJac; trJac.setZero();
345 trJac(4,5) = 1.;
346 trJac(3,4) = 1.;
347 trJac(2,3) = 1.;
348
349 //first row
350 trJac(0,0) = - sin(refTrackParametersToStore[Trk::phi0]);
351 trJac(0,1) = cos(refTrackParametersToStore[Trk::phi0]);
352
353 //second row
354 trJac(1,0) = -cos(refTrackParametersToStore[Trk::phi0])/tan(refTrackParametersToStore[Trk::theta]);
355 trJac(1,1) = -sin(refTrackParametersToStore[Trk::phi0])/tan(refTrackParametersToStore[Trk::theta]);
356 trJac(1,2) = 1.;
357
358 AmgSymMatrix(5) perFullTrkCov = AmgSymMatrix(5)(trJac*fullTrkCov*trJac.transpose());
359 Trk::PerigeeSurface pSurf(trk->linearizationPoint());
360 Trk::TrackParameters* refittedPerigee = new Perigee(refTrackParametersToStore[0],
361 refTrackParametersToStore[1],
362 refTrackParametersToStore[2],
363 refTrackParametersToStore[3],
364 refTrackParametersToStore[4],
365 pSurf,
366 std::move(perFullTrkCov));
367
368 //set the refitted track parameters
369 (*TracksIter)->setPerigeeAtVertex(refittedPerigee);
370 }
371
372
373 //parameters difference
374 AmgVector(5) paramDifference = trackParameters - refTrackParameters;
375
376 track_compatibility_chi2 +=
377 (paramDifference.transpose()*trackParametersWeight*paramDifference)(0,0)*trackWeight;
378 track_ndf+=2.;
379 ATH_MSG_DEBUG ("new chi2 with compatibility of the tracks to the vertices " <<
380 track_compatibility_chi2 << " new ndf: " << track_ndf);
381 }//end iteration of tracks at vertex on jet axis
382
383 if (!isPrimary) {
384 track_ndf-=1.;//consider the vertex
385 }
386 if (!doFastUpdate) { // strange, the original fastSmoother didn't have such calculation
387 //in the end calculate the real position... :-)
388 const Amg::VectorX & vrt_removed_tracks_weight_times_vrt_pos =
389 myPositionInWeightFormalism.position();
390 const Amg::MatrixX & vrt_removed_tracks_weight =
391 myPositionInWeightFormalism.covariancePosition();
392 //perform a FAST inversion of the weight matrix - done here for the first time
393 Amg::MatrixX vrt_removed_tracks_covariance = vrt_removed_tracks_weight;
394
395 //4.October 2014 remove smartInversion for now (problems with numerical accuracy)
396// vrt_removed_tracks_covariance=vrt_removed_tracks_weight.inverse().eval();
397 vrt_removed_tracks_covariance=(vrt_removed_tracks_covariance.transpose().eval()+vrt_removed_tracks_covariance)/2.0;
398// After symmetrizing the matrix before inversion, the smart inversion works again, and move back. wesong@cern.ch 28/05/2016
399 try
400 {
401 m_Updator->smartInvert(vrt_removed_tracks_covariance);
402 }
403 catch (std::string a)
404 {
405 ATH_MSG_ERROR( a << " Doing inversion the normal way " );
406 vrt_removed_tracks_covariance=vrt_removed_tracks_weight.inverse().eval();
407 }
408
409 const Amg::VectorX vrt_removed_tracks_pos=vrt_removed_tracks_covariance*vrt_removed_tracks_weight_times_vrt_pos;
410
411 #ifdef KalmanVertexOnJetAxisSmoother_DEBUG
412 std::cout << " final_vrt_pos " << final_vrt_pos << " vrt_removed_tracks_pos " << vrt_removed_tracks_pos << std::endl;
413 std::cout << " weight removed tracks " << vrt_removed_tracks_weight << std::endl;
414 #endif
415
416 track_compatibility_chi2 +=
417 ((final_vrt_pos-vrt_removed_tracks_pos).transpose()*vrt_removed_tracks_weight*(final_vrt_pos-vrt_removed_tracks_pos))(0,0);
418
419
420 ATH_MSG_DEBUG (" new chi2 with the vertex residual" << track_compatibility_chi2 <<
421 " new ndf: " << track_ndf);
422 }
423 vertexToSmooth->setFitQuality(FitQuality(track_compatibility_chi2,track_ndf));
424#ifdef KalmanVertexOnJetAxisSmoother_DEBUG
425 std::cout << " vertexToSmooth pointer is " << vertexToSmooth << std::endl;
426#endif
427
428 }
#define M_PI
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
#define AmgSymMatrix(dim)
#define AmgVector(rows)
#define AmgMatrix(rows, cols)
static Double_t a
if(febId1==febId2)
AmgSymMatrix(3) m_initial_cov_momentum
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
@ phi0
Definition ParamDefs.h:65
@ theta
Definition ParamDefs.h:66
ParametersBase< TrackParametersDim, Charged > TrackParameters

◆ update() [2/2]

void Trk::KalmanVertexOnJetAxisSmoother::update ( VxVertexOnJetAxis * vertexToSmooth,
const VxJetCandidate * candidateToUpdate,
bool updateTrack = true ) const

Update the VxVertexOnJetAxis (chi2 and ndf) with the knowledge coming from the fitted VxJetCandidate, updating (or not) also all the related track parameters of the tracks at the vertex (smoothing).

Definition at line 64 of file KalmanVertexOnJetAxisSmoother.cxx.

66 {
67
68 const RecVertexPositions & myFinalPosition=candidateToUpdate->getRecVertexPositions();
69 const VertexPositions & linearizationPositions=candidateToUpdate->getLinearizationVertexPositions();
70 bool isPrimary = (vertexToSmooth==candidateToUpdate->getPrimaryVertex());
71 update(vertexToSmooth,isPrimary,myFinalPosition,linearizationPositions,updateTrack,false);
72
73 }

◆ 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_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_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_initialMomentumError

double Trk::KalmanVertexOnJetAxisSmoother::m_initialMomentumError
private

Definition at line 104 of file KalmanVertexOnJetAxisSmoother.h.

◆ m_maxWeight

double Trk::KalmanVertexOnJetAxisSmoother::m_maxWeight
private

Meaningless in case no adaptive fitting is used.

Adaptive finding will be implemented probably later also in the fit along the flight axis.

Definition at line 103 of file KalmanVertexOnJetAxisSmoother.h.

◆ m_Updator

ToolHandle<KalmanVertexOnJetAxisUpdator> Trk::KalmanVertexOnJetAxisSmoother::m_Updator
private

Definition at line 96 of file KalmanVertexOnJetAxisSmoother.h.

◆ m_varHandleArraysDeclared

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

Definition at line 399 of file AthCommonDataStore.h.

◆ 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: