ATLAS Offline Software
Loading...
Searching...
No Matches
AlignTrackDresser.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "GaudiKernel/MsgStream.h"
6#include "CLHEP/Matrix/SymMatrix.h"
7
12
13#include "TrkTrack/Track.h"
14
19
21
22namespace Trk {
23
24 //________________________________________________________________________
25 AlignTrackDresser::AlignTrackDresser(const std::string & type, const std::string & name, const IInterface * parent)
26 : AthAlgTool(type,name,parent)
27 {
28 declareInterface<IAlignTrackDresser>(this);
29 }
30
31 //________________________________________________________________________
33 {
34 ATH_MSG_DEBUG("in AlignTrackDresser initialize()");
35
36 // Get DerivCalcTool (will have to be moved to AlignTool)
37 if ( m_derivCalcTool.retrieve().isFailure() ) {
38 ATH_MSG_FATAL("Failed to retrieve tool " << m_derivCalcTool);
39 return StatusCode::FAILURE;
40 }
41 ATH_MSG_INFO("Retrieved tool " << m_derivCalcTool);
42
43 return StatusCode::SUCCESS;
44 }
45
46 //________________________________________________________________________
47 void AlignTrackDresser::setLogStream(std::ostream * os)
48 {
49 m_logStream = os;
50 m_derivCalcTool->setLogStream(m_logStream);
51 }
52
53 //________________________________________________________________________
55 {
57 ATH_MSG_INFO("Total of "<<m_numBadCovWMatrix<<" tracks had invalid weight matrix.");
58 return StatusCode::SUCCESS;
59 }
60
61 //________________________________________________________________________
63 {
64 // set hit residuals
65 setResiduals(alignTrack);
66
67 ATH_MSG_DEBUG("residuals set, getting partial derivatives from m_derivCalcTool="<<m_derivCalcTool);
68
69 // set partial derivatives of hit residuals w.r.t. alignment parameters
70 if (!m_derivCalcTool->setDerivatives(alignTrack))
71 return false;
72
73 // for global method we let the deriv.calc.tool calculate the weight matrix
74 // get W = V^{-1} R V^{-1} (simply V^{-1} for numerical derivatives)
75 bool Wisvalid = m_derivCalcTool->setResidualCovMatrix(alignTrack);
76
77 if (!Wisvalid) {
78 ATH_MSG_INFO("something is wrong with the cov matrix for the residuals.");
80 }
81
82 return Wisvalid;
83 }
84
85 //________________________________________________________________________
87 {
88 if (alignTrack->residualVector())
89 ATH_MSG_ERROR("alignTrack already has residuals!");
90
91 const int NMEAS = alignTrack->nAlignTSOSMeas();
92 Amg::VectorX * residuals = new Amg::VectorX(NMEAS);
93
94 int imeas = 0;
95 AlignTSOSCollection::const_iterator atsosItr = alignTrack->firstAtsos();
96 for ( ; atsosItr != alignTrack->lastAtsos(); ++atsosItr) {
97
98 if (!(*atsosItr)->isValid())
99 continue;
100
101 std::vector<Residual>::const_iterator itRes = (**atsosItr).firstResidual();
102 for ( ; itRes != (**atsosItr).lastResidual() ; ++itRes, ++imeas) {
103 (*residuals)[imeas] = itRes->residual();
104 if (msgLvl(MSG::DEBUG)) {
105 double z=(**atsosItr).measurementOnTrack()->globalPosition().z();
106 ATH_MSG_DEBUG("pos.z: "<<z<<", res["<<imeas<<"]="<<itRes->residual()<<" res/sq["<<imeas<<"]="<<itRes->residualNorm());
107 }
108 }
109 }
110
111 if (imeas!=NMEAS) {
112 ATH_MSG_ERROR("problem with nmeas. imeas="<<imeas<<", NMEAS="<<NMEAS);
113 throw std::runtime_error("Error in AlignTrackDresser::setResiduals");
114 }
115
116 alignTrack->setResidualVector(residuals); // residuals owned by alignTrack
117 ATH_MSG_DEBUG("residuals set for AlignTrack");
118 }
119
120} // end namespace
121
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
bool msgLvl(const MSG::Level lvl) const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
virtual StatusCode finalize() override
virtual bool dressAlignTrack(AlignTrack *alignTrack) override
dresses alignTrack with derivatives and other information
unsigned int m_numBadCovWMatrix
number of tracks with invalid weight matrix from the deriv.calc.tool
void setResiduals(AlignTrack *alignTrack) const
sets residuals for TSOS on alignTrack
AlignTrackDresser(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
ToolHandle< IDerivCalcTool > m_derivCalcTool
virtual void setLogStream(std::ostream *os) override
sets the output stream for the logfile
AlignTSOSCollection::const_iterator lastAtsos() const
returns iterator pointer to last element in collection
Definition AlignTrack.h:280
int nAlignTSOSMeas() const
number of alignTSOS (including scatterers if included on AlignTrack
Definition AlignTrack.h:128
const Amg::VectorX * residualVector() const
Vector of residuals of the alignTSOS on the alignTrack, to be set by AlignTrackDresser.
Definition AlignTrack.h:150
AlignTSOSCollection::const_iterator firstAtsos() const
retrieve iterator pointer to first element in collection
Definition AlignTrack.h:279
void setResidualVector(Amg::VectorX *vec)
Definition AlignTrack.h:151
std::ostream * m_logStream
logfile output stream
Eigen::Matrix< double, Eigen::Dynamic, 1 > VectorX
Dynamic Vector - dynamic allocation.
Ensure that the ATLAS eigen extensions are properly loaded.
@ z
global position (cartesian)
Definition ParamDefs.h:57