ATLAS Offline Software
FPGATrackSimFitConstantBank.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 #ifndef FPGATrackSimFITCONSTANTBANK_H
4 #define FPGATrackSimFITCONSTANTBANK_H
5 
6 #include <Eigen/StdVector>
7 // cppcheck-suppress unknownMacro
8 EIGEN_DEFINE_STL_VECTOR_SPECIALIZATION(Eigen::MatrixXf)
9 #include <Eigen/Core>
10 #include <Eigen/LU>
11 
12 #include <bitset>
13 #include <iomanip>
14 #include <fstream>
15 
19 
20 class FPGATrackSimTrack;
21 
22 
24 {
25  public:
26 
27  // missing plane -1 means we guess hits, we don't have separate banks for a missing plane
28  FPGATrackSimFitConstantBank(FPGATrackSimPlaneMap const * pmap, int ncoords, std::string const & fname, bool isFirstStage, int missingPlane = -1);
29 
31  // Simple Getters
32 
33  int getBankID() const { return m_bankID; }
34  int getNConstr() const { return m_nconstr; }
35  int getNCoords() const { return m_ncoords; }
36  int getNPars() const { return m_npars; }
37  int getNSectors() const { return m_nsectors; }
38  int getMissingPlane() const { return m_missingPlane; }
39 
40 
41  bool getIsGood(sector_t sector) const { return m_sector_good[sector]; }
42  float getFitConst(int isec, int ipar) const { return m_fit_const(isec, ipar); }
43  float getFitPar(int isec, int ipar, int icoord) const { return m_fit_pars(isec, ipar, icoord); }
44  float getKaverage(int isec, int iconstr ) const { return m_kaverage(isec, iconstr); }
45  float getKernel(int isec, int iconstr, int icoord) const { return m_kernel(isec, iconstr, icoord); }
46 
48  // Main Interface
49 
50  bool linfit(sector_t sector, FPGATrackSimTrack & track, bool isSecondStage) const;
51  void linfit_chisq(sector_t sector, FPGATrackSimTrack &trk) const;
52  void linfit_pars_eval(sector_t sector, FPGATrackSimTrack &trk) const;
53  int missing_point_guess(sector_t sector, FPGATrackSimTrack &track, bool isFirstStage, bool doExtrapolation) const;
54 
55  void invlinfit(sector_t sector, FPGATrackSimTrack &track, double const *constr) const;
57 
58  private:
59 
60  FPGATrackSimPlaneMap const * m_pmap = nullptr;
61 
63  // Configuration
64 
65  int m_bankID; // ID of the related pattern bank
66  int m_nsectors; // number of sectors in this bank
67  int m_npars = 0; // numbers of parameters
68  int m_ncoords; // number of coordinates used in the linear fit
69  int m_nconstr; // number of constraints: m_ncoords-m_npars
70  int m_npixcy; // number of 2d coordinates
71  int m_missingPlane; // plane that is missing
72 // bool m_isFirstStage; // is this a first stage fit?
73  bool m_isIdealCoordFit; // fitting for ideal coordinates? by default always true for now
74 
76  // Data
77 
78  std::vector<int> m_missid; // ids of the missing coordinates, [ncoords]
79 
80  // these are what we read in
81  // they are also used in the inverse function since that is not for the hardware but for bank generation
82  std::vector<bool> m_sector_good; //[m_nsectors] false if all constants are 0
83  vector3D<float> m_fit_pars; //[m_nsectors][m_npars][m_ncoords] fit parameters
84  vector2D<float> m_fit_const; //[m_nsectors][m_npars] parameter offset in this sector
85  vector3D<float> m_kernel; //[m_nsectors][m_nconstr][m_ncoords] covariance matrix
86  vector2D<float> m_kaverage; //[m_nsectors][m_nconstr]
87 
88  vector2D<float> m_maj_a; // offset for missing coordinate
89  vector3D<float> m_maj_kk; // for majority fits
90  vector3D<float> m_maj_invkk; // for majority inverse
91 
92  std::vector<Eigen::MatrixXf, Eigen::aligned_allocator<Eigen::MatrixXf>> m_invfit_consts;
93 
94  vector2D<int> m_WCs; //[m_nsectors][m_ncoords] which coordinates are WCs
95 
96 
98  // Helper Functions
99 
100  void readHeader(std::ifstream & geocfile);
101  void readSectorInfo(std::ifstream & geocfile);
102  void calculateMajority();
103  void prepareInvFitConstants();
104 
105 };
106 
107 
108 #endif // FPGATrackSimFITCONSTANTBANK_H
FPGATrackSimFitConstantBank::readSectorInfo
void readSectorInfo(std::ifstream &geocfile)
Definition: FPGATrackSimFitConstantBank.cxx:103
FPGATrackSimTrack
Definition: FPGATrackSimTrack.h:18
FPGATrackSimPlaneMap.h
Maps physical layers to logical layers.
FPGATrackSimFitConstantBank::m_kernel
vector3D< float > m_kernel
Definition: FPGATrackSimFitConstantBank.h:85
FPGATrackSimFitConstantBank::invlinfit
void invlinfit(sector_t sector, FPGATrackSimTrack &track, double const *constr) const
This method uses the track parameters and additional constraints to use the constants to calculate th...
Definition: FPGATrackSimFitConstantBank.cxx:527
FPGATrackSimFitConstantBank::readHeader
void readHeader(std::ifstream &geocfile)
Definition: FPGATrackSimFitConstantBank.cxx:59
FPGATrackSimFitConstantBank::getNCoords
int getNCoords() const
Definition: FPGATrackSimFitConstantBank.h:35
FPGATrackSimFitConstantBank::m_maj_a
vector2D< float > m_maj_a
Definition: FPGATrackSimFitConstantBank.h:88
FPGATrackSimFitConstantBank::m_fit_const
vector2D< float > m_fit_const
Definition: FPGATrackSimFitConstantBank.h:84
FPGATrackSimFitConstantBank::m_missingPlane
int m_missingPlane
Definition: FPGATrackSimFitConstantBank.h:71
FPGATrackSimFitConstantBank::m_nconstr
int m_nconstr
Definition: FPGATrackSimFitConstantBank.h:69
FPGATrackSimFitConstantBank::m_fit_pars
vector3D< float > m_fit_pars
Definition: FPGATrackSimFitConstantBank.h:83
FPGATrackSimFitConstantBank::m_nsectors
int m_nsectors
Definition: FPGATrackSimFitConstantBank.h:66
FPGATrackSimFitConstantBank::m_ncoords
int m_ncoords
Definition: FPGATrackSimFitConstantBank.h:68
FPGATrackSimFitConstantBank::m_missid
std::vector< int > m_missid
Definition: FPGATrackSimFitConstantBank.h:78
FPGATrackSimFitConstantBank::FPGATrackSimFitConstantBank
FPGATrackSimFitConstantBank(FPGATrackSimPlaneMap const *pmap, int ncoords, std::string const &fname, bool isFirstStage, int missingPlane=-1)
Definition: FPGATrackSimFitConstantBank.cxx:22
FPGATrackSimFitConstantBank::m_npixcy
int m_npixcy
Definition: FPGATrackSimFitConstantBank.h:70
FPGATrackSimVectors.h
Defines several vector wrappers for homogenous multi-dimensional vectors, declared as 1D arrays for l...
vector2D< float >
FPGATrackSimFitConstantBank::linfit_chisq
void linfit_chisq(sector_t sector, FPGATrackSimTrack &trk) const
Definition: FPGATrackSimFitConstantBank.cxx:462
FPGATrackSimFitConstantBank::getFitConst
float getFitConst(int isec, int ipar) const
Definition: FPGATrackSimFitConstantBank.h:42
FPGATrackSimFitConstantBank::getKernel
float getKernel(int isec, int iconstr, int icoord) const
Definition: FPGATrackSimFitConstantBank.h:45
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
FPGATrackSimFitConstantBank::getBankID
int getBankID() const
Definition: FPGATrackSimFitConstantBank.h:33
FPGATrackSimFitConstantBank::m_npars
int m_npars
Definition: FPGATrackSimFitConstantBank.h:67
FPGATrackSimPlaneMap
Definition: FPGATrackSimPlaneMap.h:62
sector_t
int32_t sector_t
Definition: FPGATrackSimTypes.h:21
FPGATrackSimFitConstantBank::m_maj_kk
vector3D< float > m_maj_kk
Definition: FPGATrackSimFitConstantBank.h:89
FPGATrackSimFitConstantBank::prepareInvFitConstants
void prepareInvFitConstants()
Definition: FPGATrackSimFitConstantBank.cxx:210
FPGATrackSimFitConstantBank::linfit_pars_eval
void linfit_pars_eval(sector_t sector, FPGATrackSimTrack &trk) const
Definition: FPGATrackSimFitConstantBank.cxx:494
FPGATrackSimFitConstantBank
Definition: FPGATrackSimFitConstantBank.h:24
FPGATrackSimFitConstantBank::missing_point_guess
int missing_point_guess(sector_t sector, FPGATrackSimTrack &track, bool isFirstStage, bool doExtrapolation) const
Definition: FPGATrackSimFitConstantBank.cxx:326
FPGATrackSimFitConstantBank::m_pmap
FPGATrackSimPlaneMap const * m_pmap
Definition: FPGATrackSimFitConstantBank.h:60
FPGATrackSimFitConstantBank::getIsGood
bool getIsGood(sector_t sector) const
Definition: FPGATrackSimFitConstantBank.h:41
FPGATrackSimFitConstantBank::linfit
bool linfit(sector_t sector, FPGATrackSimTrack &track, bool isSecondStage) const
Definition: FPGATrackSimFitConstantBank.cxx:303
FPGATrackSimFitConstantBank::m_invfit_consts
std::vector< Eigen::MatrixXf, Eigen::aligned_allocator< Eigen::MatrixXf > > m_invfit_consts
Definition: FPGATrackSimFitConstantBank.h:92
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:67
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimFitConstantBank::setIdealCoordFit
void setIdealCoordFit(bool v)
Definition: FPGATrackSimFitConstantBank.h:56
FPGATrackSimFitConstantBank::m_sector_good
std::vector< bool > m_sector_good
Definition: FPGATrackSimFitConstantBank.h:82
FPGATrackSimFitConstantBank::getNSectors
int getNSectors() const
Definition: FPGATrackSimFitConstantBank.h:37
FPGATrackSimFitConstantBank::calculateMajority
void calculateMajority()
Definition: FPGATrackSimFitConstantBank.cxx:168
FPGATrackSimFitConstantBank::m_WCs
vector2D< int > m_WCs
Definition: FPGATrackSimFitConstantBank.h:94
AthMessaging.h
FPGATrackSimFitConstantBank::m_bankID
int m_bankID
Definition: FPGATrackSimFitConstantBank.h:65
FPGATrackSimFitConstantBank::getMissingPlane
int getMissingPlane() const
Definition: FPGATrackSimFitConstantBank.h:38
FPGATrackSimFitConstantBank::getFitPar
float getFitPar(int isec, int ipar, int icoord) const
Definition: FPGATrackSimFitConstantBank.h:43
vector3D< float >
xAOD::track
@ track
Definition: TrackingPrimitives.h:512
FPGATrackSimFitConstantBank::m_maj_invkk
vector3D< float > m_maj_invkk
Definition: FPGATrackSimFitConstantBank.h:90
FPGATrackSimFitConstantBank::m_kaverage
vector2D< float > m_kaverage
Definition: FPGATrackSimFitConstantBank.h:86
FPGATrackSimFitConstantBank::m_isIdealCoordFit
bool m_isIdealCoordFit
Definition: FPGATrackSimFitConstantBank.h:73
FPGATrackSimFitConstantBank::getKaverage
float getKaverage(int isec, int iconstr) const
Definition: FPGATrackSimFitConstantBank.h:44
FPGATrackSimFitConstantBank::getNConstr
int getNConstr() const
Definition: FPGATrackSimFitConstantBank.h:34
FPGATrackSimFitConstantBank::getNPars
int getNPars() const
Definition: FPGATrackSimFitConstantBank.h:36