ATLAS Offline Software
MatrixTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRKALIGNGENTOOLS_MATRIXTOOL_H
6 #define TRKALIGNGENTOOLS_MATRIXTOOL_H
7 
22 #include "GaudiKernel/ToolHandle.h"
24 
26 
27 #include <TMatrixDSym.h>
28 #include "CLHEP/Matrix/SymMatrix.h"
29 
30 #include <string>
31 
32 class TString;
33 
46 namespace Trk {
47 
48  class AlSymMatBase;
49  class AlSymMat;
50  class AlMat;
51  class AlVec;
52 
53  class IAlignModuleTool;
54 
55  class MatrixTool : public AthAlgTool, virtual public IMatrixTool {
56  public:
57 
58  enum SolveOption {
59  NONE = 0,
60  SOLVE = 1,
61  SOLVE_FAST = 2,
65  SOLVE_ROOT = 6,
66  SOLVE_CLHEP = 7
67  };
68 
70  MatrixTool(const std::string& type, const std::string& name,
71  const IInterface* parent);
72 
74  virtual ~MatrixTool();
75 
78 
81 
83  StatusCode allocateMatrix(int nDoF=0);
84 
86  void prepareBinaryFiles(int solveOption);
87 
90 
92  void addFirstDerivatives(std::list<int,double>& derivatives);
93 
94  void addFirstDerivative(int irow, double firstderiv);
95 
98 
100  void addSecondDerivatives(std::list<std::pair<int,int>,double >& derivatives);
101 
102  void addSecondDerivative(int irow, int icol, double secondderiv);
103 
104 
106  bool accumulateFromFiles();
107 
109  bool accumulateFromBinaries();
110 
112  int solve();
113 
114 
116  void storeInTFile(const TString& filename);
117 
119  bool accumulateFromTFiles();
120 
121  void printModuleSolution(std::ostream & os, const AlignModule * module, const CLHEP::HepSymMatrix * cov) const;
122  void printGlobalSolution(std::ostream & os, const CLHEP::HepSymMatrix * cov);
123  void printGlobalSolution(std::ostream & os, const TMatrixDSym * cov);
124 
125  private:
126 
127  // private methods
128  int solveROOT();
129  int solveCLHEP();
130  int solveLapack();
131  int solveSparseEigen();
132  int solveLocal();
133 
135  static int fillVecMods();
136  void postSolvingLapack(AlVec * dChi2, AlSymMat * d2Chi2, AlVec &w, AlMat &z, int size);
137 
138  void writeHitmap();
139  void readHitmaps();
140 
141  // private variables
142  ToolHandle<IAlignModuleTool> m_alignModuleTool;
143 
146 
149 
151  bool m_useSparse;
152 
155 
157  int m_modcut;
160  float m_pullcut;
163 
164  bool m_calDet;
165  bool m_wSqMatrix;
166  bool m_writeMat;
171 
175 
178 
179  bool m_runLocal;
180 
181  double m_scale;
183 
185 
187 
188  bool m_calculateFullCovariance; //?< calculate full covariance matrix for Lapack
189 
190  std::string m_pathbin;
191  std::string m_pathtxt;
192  std::string m_prefixName;
193 
194  std::string m_tfileName;
195 
196 
197  std::string m_scalaMatName;
198  std::string m_scalaVecName;
199 
200 
201 
202  std::vector<std::string> m_inputMatrixFiles;
203  std::vector<std::string> m_inputVectorFiles;
204 
205  std::vector<std::string> m_inputHitmapFiles;
206 
207  std::vector<std::string> m_inputTFiles;
208 
209  std::vector<int> m_activeIndices;
210  int m_aNDoF;
211 
213 
217 
224 
231 
232 
233  }; // end of class
234 
235 
236 
237 } // End of namespace
238 
239 
240 
241 #endif // TRKALIGNGENTOOLS_MATRIXTOOL_H
242 
243 
244 
Trk::MatrixTool::SOLVE_CLHEP
@ SOLVE_CLHEP
computation using CLHEP
Definition: MatrixTool.h:66
Trk::MatrixTool::writeHitmap
void writeHitmap()
Definition: MatrixTool.cxx:2418
Trk::MatrixTool::m_alignModuleTool
ToolHandle< IAlignModuleTool > m_alignModuleTool
Definition: MatrixTool.h:142
Trk::MatrixTool::DIRECT_SOLVE_FAST
@ DIRECT_SOLVE_FAST
direct Fast (Eigen method) solving, already available matrix & vector
Definition: MatrixTool.h:63
Trk::MatrixTool::SOLVE_ROOT
@ SOLVE_ROOT
computation using ROOT
Definition: MatrixTool.h:65
Trk::MatrixTool::m_Remove_Pixel_Tz
bool m_Remove_Pixel_Tz
Definition: MatrixTool.h:220
Trk::z
@ z
global position (cartesian)
Definition: ParamDefs.h:57
Trk::MatrixTool::accumulateFromTFiles
bool accumulateFromTFiles()
Store Files in a tfile.
Definition: MatrixTool.cxx:957
Trk::IMatrixTool
Definition: IMatrixTool.h:35
Trk::MatrixTool::m_Remove_IBL_Tz
bool m_Remove_IBL_Tz
Definition: MatrixTool.h:227
Trk::MatrixTool::solve
int solve()
solves for alignment parameters
Definition: MatrixTool.cxx:1268
Trk::MatrixTool::DIRECT_SOLVE_CLUSTER
@ DIRECT_SOLVE_CLUSTER
computation of alignment parameters from SCALAPAK already solved matrix
Definition: MatrixTool.h:64
Trk::MatrixTool::m_writeTFile
bool m_writeTFile
write out files to a root file
Definition: MatrixTool.h:176
Trk::AlVec
Definition: AlVec.h:23
Trk::MatrixTool::m_inputVectorFiles
std::vector< std::string > m_inputVectorFiles
input binary files containing vector terms
Definition: MatrixTool.h:203
Trk::MatrixTool::m_calDet
bool m_calDet
Compute bigmatrix's determinant ?
Definition: MatrixTool.h:164
Trk::MatrixTool::solveCLHEP
int solveCLHEP()
Definition: MatrixTool.cxx:391
Trk::AlSymMatBase
Definition: AlSymMatBase.h:38
Trk::MatrixTool::DIRECT_SOLVE
@ DIRECT_SOLVE
direct solving (LAPACK), already available matrix & vector
Definition: MatrixTool.h:62
Trk::MatrixTool::m_eigenvaluethreshold
double m_eigenvaluethreshold
cut on the minimum eigenvalue
Definition: MatrixTool.h:154
Trk::MatrixTool::accumulateFromFiles
bool accumulateFromFiles()
accumulates derivates from files.
Definition: MatrixTool.cxx:750
Trk::MatrixTool::SOLVE_FAST
@ SOLVE_FAST
Fast (Eigen method) solving after data accumulation.
Definition: MatrixTool.h:61
Trk::MatrixTool::m_scale
double m_scale
scale for big matrix and vector normalization
Definition: MatrixTool.h:181
Trk::MatrixTool::m_tfileName
std::string m_tfileName
prefix string to filenames
Definition: MatrixTool.h:194
Trk::MatrixTool::printModuleSolution
void printModuleSolution(std::ostream &os, const AlignModule *module, const CLHEP::HepSymMatrix *cov) const
namespace { class RestoreIOSFlags { public: RestoreIOSFlags (std::ostream &os) : m_os(&os),...
Definition: MatrixTool.cxx:1706
Trk::MatrixTool::m_Remove_Pixel_Rx
bool m_Remove_Pixel_Rx
Definition: MatrixTool.h:221
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
Trk::MatrixTool::m_writeMatTxt
bool m_writeMatTxt
also write big matrix and vector into txt files ?
Definition: MatrixTool.h:167
Trk::MatrixTool::m_maxReadErrors
int m_maxReadErrors
maximum number of reading TFile errors
Definition: MatrixTool.h:212
Trk::AlignModule
Definition: AlignModule.h:45
Trk::MatrixTool::m_removeSpurious
bool m_removeSpurious
run spurious removal
Definition: MatrixTool.h:186
Trk::MatrixTool::m_Remove_IBL_Tx
bool m_Remove_IBL_Tx
Definition: MatrixTool.h:225
Trk::MatrixTool::m_useSparse
bool m_useSparse
flag to use AlSpaMat for the big matrix (default is AlSymMat)
Definition: MatrixTool.h:151
Trk::MatrixTool
Definition: MatrixTool.h:55
Trk::MatrixTool::m_readHitmaps
bool m_readHitmaps
accumulate hitymap from files
Definition: MatrixTool.h:174
Trk::MatrixTool::solveSparseEigen
int solveSparseEigen()
Definition: MatrixTool.cxx:2284
atlasStyleMacro.icol
int icol
Definition: atlasStyleMacro.py:13
Trk::AlSymMat
Definition: AlSymMat.h:26
Trk::MatrixTool::m_Remove_Pixel_Ry
bool m_Remove_Pixel_Ry
Definition: MatrixTool.h:222
Trk::MatrixTool::m_scalaVecName
std::string m_scalaVecName
Scalapack vector name.
Definition: MatrixTool.h:198
Trk::MatrixTool::m_calculateFullCovariance
bool m_calculateFullCovariance
Definition: MatrixTool.h:188
Trk::MatrixTool::m_softEigenmodeCut
double m_softEigenmodeCut
add constant to diagonal to effectively cut on weak eigenmodes
Definition: MatrixTool.h:184
Trk::MatrixTool::m_Remove_Pixel_Tx
bool m_Remove_Pixel_Tx
Definition: MatrixTool.h:218
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
python.PyAthena.module
module
Definition: PyAthena.py:131
Trk::MatrixTool::m_writeEigenMatTxt
bool m_writeEigenMatTxt
also write eigenvalues and eigenvectors into txt files ?
Definition: MatrixTool.h:169
Trk::MatrixTool::m_writeMat
bool m_writeMat
write big matrix and vector into files ?
Definition: MatrixTool.h:166
Trk::MatrixTool::m_modcut
int m_modcut
cut on the weak modes which number is <par_modcut
Definition: MatrixTool.h:157
Trk::MatrixTool::m_minNumHits
int m_minNumHits
cut on the minimum number of hits per module
Definition: MatrixTool.h:158
Trk::MatrixTool::accumulateFromBinaries
bool accumulateFromBinaries()
accumulates derivates from binary files
Definition: MatrixTool.cxx:763
Trk::MatrixTool::m_writeEigenMat
bool m_writeEigenMat
write eigenvalues and eigenvectors into files ?
Definition: MatrixTool.h:168
Trk::MatrixTool::m_readTFiles
bool m_readTFiles
write out files to a root file
Definition: MatrixTool.h:177
Trk::MatrixTool::m_bigvector
AlVec * m_bigvector
vector to contain first derivative terms to be used for alignment
Definition: MatrixTool.h:148
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
vector
Definition: MultiHisto.h:13
Trk::MatrixTool::m_inputHitmapFiles
std::vector< std::string > m_inputHitmapFiles
input binary files containing the hitmaps
Definition: MatrixTool.h:205
Trk::MatrixTool::SOLVE
@ SOLVE
solving after data accumulation (LAPACK)
Definition: MatrixTool.h:60
Trk::MatrixTool::postSolvingLapack
void postSolvingLapack(AlVec *dChi2, AlSymMat *d2Chi2, AlVec &w, AlMat &z, int size)
Definition: MatrixTool.cxx:1958
Trk::MatrixTool::m_bigmatrix
AlSymMatBase * m_bigmatrix
matrix to contain second derivative terms to be used for alignment
Definition: MatrixTool.h:145
Trk::MatrixTool::solveLocal
int solveLocal()
Definition: MatrixTool.cxx:633
AthAlgTool.h
Trk::MatrixTool::m_AlignPixelbutNotIBL
bool m_AlignPixelbutNotIBL
Definition: MatrixTool.h:215
Trk::MatrixTool::spuriousRemoval
StatusCode spuriousRemoval()
Definition: MatrixTool.cxx:1866
Trk::MatrixTool::storeInTFile
void storeInTFile(const TString &filename)
Store Files in a tfile.
Definition: MatrixTool.cxx:862
test_pyathena.parent
parent
Definition: test_pyathena.py:15
Trk::MatrixTool::initialize
StatusCode initialize()
initialize
Definition: MatrixTool.cxx:202
Trk::AlMat
Definition: AlMat.h:27
Trk::MatrixTool::m_writeHitmapTxt
bool m_writeHitmapTxt
write hitmap into text file
Definition: MatrixTool.h:173
Trk::MatrixTool::addSecondDerivative
void addSecondDerivative(int irow, int icol, double secondderiv)
Definition: MatrixTool.cxx:1615
Trk::MatrixTool::m_scaleMatrix
bool m_scaleMatrix
scale matrix by number of hits before solving
Definition: MatrixTool.h:182
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
Trk::MatrixTool::printGlobalSolution
void printGlobalSolution(std::ostream &os, const CLHEP::HepSymMatrix *cov)
Definition: MatrixTool.cxx:1621
Trk::MatrixTool::addSecondDerivatives
void addSecondDerivatives(AlSymMatBase *matrix)
adds second derivatives to matrix
Definition: MatrixTool.cxx:1594
Trk::MatrixTool::m_Align_db_step
float m_Align_db_step
corr in the diagonal basis step for the third pass in the auto weak mode removal method
Definition: MatrixTool.h:162
Trk::MatrixTool::solveROOT
int solveROOT()
Definition: MatrixTool.cxx:265
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
Trk::MatrixTool::m_wSqMatrix
bool m_wSqMatrix
write a triangular matrix by default (true: square format) ?
Definition: MatrixTool.h:165
Trk::MatrixTool::addFirstDerivatives
void addFirstDerivatives(AlVec *vector)
adds first derivative to vector
Definition: MatrixTool.cxx:1589
IMatrixTool.h
Trk::MatrixTool::~MatrixTool
virtual ~MatrixTool()
Virtual destructor.
Definition: MatrixTool.cxx:195
Trk::MatrixTool::m_activeIndices
std::vector< int > m_activeIndices
vector of indices which pass the min-hits cut
Definition: MatrixTool.h:209
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::MatrixTool::m_aNDoF
int m_aNDoF
number of active DoF (size of m_activeIndices)
Definition: MatrixTool.h:210
Trk::MatrixTool::m_Remove_IBL_Ry
bool m_Remove_IBL_Ry
Definition: MatrixTool.h:229
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
Trk::MatrixTool::fillVecMods
static int fillVecMods()
Definition: MatrixTool.cxx:1759
Trk::MatrixTool::m_Remove_IBL_Rz
bool m_Remove_IBL_Rz
Definition: MatrixTool.h:230
Trk::MatrixTool::readHitmaps
void readHitmaps()
Definition: MatrixTool.cxx:2455
Trk::MatrixTool::m_runLocal
bool m_runLocal
Run solving using Local method.
Definition: MatrixTool.h:179
Trk::MatrixTool::allocateMatrix
StatusCode allocateMatrix(int nDoF=0)
allocates memory for big matrix and big vector
Definition: MatrixTool.cxx:232
Trk::MatrixTool::m_AlignIBLbutNotPixel
bool m_AlignIBLbutNotPixel
Definition: MatrixTool.h:214
Trk::MatrixTool::NONE
@ NONE
not solve in any case (to be used when ipc)
Definition: MatrixTool.h:59
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:66
Trk::MatrixTool::m_prefixName
std::string m_prefixName
prefix string to filenames
Definition: MatrixTool.h:192
Trk::MatrixTool::m_writeHitmap
bool m_writeHitmap
write hitmap into file
Definition: MatrixTool.h:172
Trk::MatrixTool::SolveOption
SolveOption
Definition: MatrixTool.h:58
Trk::MatrixTool::m_solveOption
int m_solveOption
solving option
Definition: MatrixTool.h:156
Trk::MatrixTool::m_DeactivateSCT_ECA_LastDisk
bool m_DeactivateSCT_ECA_LastDisk
Definition: MatrixTool.h:216
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Trk::MatrixTool::m_Remove_Pixel_Ty
bool m_Remove_Pixel_Ty
Definition: MatrixTool.h:219
Trk::MatrixTool::m_pathbin
std::string m_pathbin
path binary files (in/out)
Definition: MatrixTool.h:190
Trk::MatrixTool::m_pathtxt
std::string m_pathtxt
path ascii files (in/out)
Definition: MatrixTool.h:191
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
Trk::MatrixTool::m_Remove_IBL_Ty
bool m_Remove_IBL_Ty
Definition: MatrixTool.h:226
Trk::MatrixTool::prepareBinaryFiles
void prepareBinaryFiles(int solveOption)
reads/writes matrix entries from/to binary files as necessary
Definition: MatrixTool.cxx:260
Trk::MatrixTool::m_minNumTrks
int m_minNumTrks
cut on the minimum number of tracks per module
Definition: MatrixTool.h:159
Trk::MatrixTool::m_scalaMatName
std::string m_scalaMatName
Scalapack matrix name.
Definition: MatrixTool.h:197
Trk::MatrixTool::finalize
StatusCode finalize()
initialize
Definition: MatrixTool.cxx:223
Trk::MatrixTool::m_writeModuleNames
bool m_writeModuleNames
write module name instead of Identifier to vector file
Definition: MatrixTool.h:170
Trk::MatrixTool::m_Remove_IBL_Rx
bool m_Remove_IBL_Rx
Definition: MatrixTool.h:228
Trk::MatrixTool::m_inputMatrixFiles
std::vector< std::string > m_inputMatrixFiles
input binary files containing matrix terms
Definition: MatrixTool.h:202
Trk::MatrixTool::m_eigenvalueStep
float m_eigenvalueStep
eigenvalue step for the second pass in the automatic weak mode removal method
Definition: MatrixTool.h:161
Trk::MatrixTool::solveLapack
int solveLapack()
Definition: MatrixTool.cxx:1765
Trk::MatrixTool::m_diagonalize
bool m_diagonalize
run diagonalization instead of inversion
Definition: MatrixTool.h:153
AthAlgTool
Definition: AthAlgTool.h:26
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
Trk::MatrixTool::m_Remove_Pixel_Rz
bool m_Remove_Pixel_Rz
Definition: MatrixTool.h:223
Trk::MatrixTool::m_pullcut
float m_pullcut
pull cut for the automatic weak mode removal method
Definition: MatrixTool.h:160
Trk::MatrixTool::MatrixTool
MatrixTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: MatrixTool.cxx:58
Trk::MatrixTool::addFirstDerivative
void addFirstDerivative(int irow, double firstderiv)
Definition: MatrixTool.cxx:1609
Trk::MatrixTool::m_inputTFiles
std::vector< std::string > m_inputTFiles
input binary files containing matrix terms
Definition: MatrixTool.h:207