ATLAS Offline Software
FPGATrackSimMatrixAccumulator.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 
3 #ifndef FPGATrackSimMATRIXACCUMULATOR_H
4 #define FPGATrackSimMATRIXACCUMULATOR_H
5 
6 
18 #include <vector>
19 #include <unordered_map>
20 #include <algorithm>
21 #include <boost/functional/hash.hpp>
22 
23 #include "TTree.h"
24 
27 
28 
29 /*
30  * This struct stores all the information in the matrix file for a single sector.
31  * It is an accumulation of relevant track properties from training truth tracks
32  * used to create the sector. These are later used to generate the fit constants.
33  * See comments in FPGATrackSimConstGenAlgo.h.
34  */
36 {
37  // nCoords is the number of hit coordinates for a full 13/13 track
38  // (i.e. +2 per pixel layer, +1 per strip layer)
39 FPGATrackSimMatrixAccumulator(unsigned nLayers, unsigned nCoords) :
40  FTK_modules(nLayers),
41  coords_usable(nCoords),
42  hit_coords(nCoords),
43  hit_coordsG(nCoords),
44  hit_x_QoP(nCoords),
45  hit_xG_HIP(nCoords),
46  hit_x_d0(nCoords),
47  hit_x_z0(nCoords),
48  hit_x_eta(nCoords),
49  hit_xG_eta(nCoords),
50  hit_x_phi(nCoords),
51  covariance(nCoords * nCoords),
52  covarianceG(nCoords * nCoords)
53  {
54  }
55 
56  std::vector<module_t> FTK_modules; // Old FTK-style module ids
57  std::vector<bool> coords_usable; // size ncoords, determine whether this is a usable coordinate or from a WC, only filled as we normali
58  size_t nusable() const {
59  size_t n = 0;
60  for (auto coord : coords_usable) {
61  if (coord) n++;
62  }
63  return n;
64  }
65 
67  // For each track in this sector, add up the following variables.
69 
71 
72  // The hit_* vectors have size nCoords. For example, hit_x_phi stores the hit
73  // coordinates times phi for each track, so after accumulation
74  // hit_x_phi[i] = sum_tracks(track.hit_coords[i] * track.phi)
75  std::vector<double> hit_coords; // hit coordinates
76  std::vector<double> hit_coordsG; // hit global coordinates
77  std::vector<double> hit_x_QoP; // hit coordinate * half inverse pt
78  std::vector<double> hit_xG_HIP; // global hit coordinate * half inverse pt
79  std::vector<double> hit_x_d0; // hit coordinate * d0
80  std::vector<double> hit_x_z0; // hit coordinate * z0
81  std::vector<double> hit_x_eta; // hit coordinate * eta
82  std::vector<double> hit_xG_eta; // global hit coordinate * eta
83  std::vector<double> hit_x_phi; // hit coordinate * phi
84  std::vector<double> covariance; // Size nCoords * nCoords, hit_coord[i] * hit_coord[j]
85  std::vector<double> covarianceG; // Size nCoords * nCoords, hit_coordG[i] * hit_coordG[j]
86 
88  // For each track in this sector, append to these variables.
90 
91  std::vector<FPGATrackSimTrackParsI> track_bins; // Size # tracks (coverage).
92  // Stores the binned track parameters of each track.
93  // Note track_bins.size() conveniently also stores the coverage of this sector.
94 };
95 
96 
97 // A hash customization for std containers, to be used in unordered_map
98 template <typename Container>
100 {
101  std::size_t operator()(Container const& c) const
102  { return boost::hash_range(c.begin(), c.end()); }
103 };
104 
105 
106 // A useful typedef for the matrix algorithms.
107 // Maps the sector definition (list of module identifier hashes) to an accumulator.
108 typedef std::unordered_map<std::vector<module_t>, FPGATrackSimMatrixAccumulator, container_hash<std::vector<module_t>>> AccumulateMap;
109 
110 
120 bool accumulate(AccumulateMap & map, std::vector<module_t> const & modules, FPGATrackSimMatrixAccumulator const & acc);
121 
122 
123 #endif
FPGATrackSimMatrixAccumulator::hit_x_QoP
std::vector< double > hit_x_QoP
Definition: FPGATrackSimMatrixAccumulator.h:77
FPGATrackSimMatrixAccumulator::hit_x_phi
std::vector< double > hit_x_phi
Definition: FPGATrackSimMatrixAccumulator.h:83
FPGATrackSimMatrixAccumulator::coords_usable
std::vector< bool > coords_usable
Definition: FPGATrackSimMatrixAccumulator.h:57
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
FPGATrackSimMatrixAccumulator::covarianceG
std::vector< double > covarianceG
Definition: FPGATrackSimMatrixAccumulator.h:85
FPGATrackSimMatrixAccumulator::hit_x_d0
std::vector< double > hit_x_d0
Definition: FPGATrackSimMatrixAccumulator.h:79
FPGATrackSimMatrixAccumulator::FPGATrackSimMatrixAccumulator
FPGATrackSimMatrixAccumulator(unsigned nLayers, unsigned nCoords)
Definition: FPGATrackSimMatrixAccumulator.h:39
FPGATrackSimMatrixAccumulator::track_bins
std::vector< FPGATrackSimTrackParsI > track_bins
Definition: FPGATrackSimMatrixAccumulator.h:91
FPGATrackSimMatrixAccumulator::hit_coordsG
std::vector< double > hit_coordsG
Definition: FPGATrackSimMatrixAccumulator.h:76
Container
storage of the time histories of all the cells
FPGATrackSimMatrixAccumulator::hit_x_eta
std::vector< double > hit_x_eta
Definition: FPGATrackSimMatrixAccumulator.h:81
FPGATrackSimMatrixAccumulator::hit_xG_HIP
std::vector< double > hit_xG_HIP
Definition: FPGATrackSimMatrixAccumulator.h:78
container_hash
Definition: FPGATrackSimMatrixAccumulator.h:100
FPGATrackSimMatrixAccumulator::hit_coords
std::vector< double > hit_coords
Definition: FPGATrackSimMatrixAccumulator.h:75
FPGATrackSimMatrixAccumulator::covariance
std::vector< double > covariance
Definition: FPGATrackSimMatrixAccumulator.h:84
beamspotman.n
n
Definition: beamspotman.py:731
FPGATrackSimMatrixAccumulator
Definition: FPGATrackSimMatrixAccumulator.h:36
container_hash::operator()
std::size_t operator()(Container const &c) const
Definition: FPGATrackSimMatrixAccumulator.h:101
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
FPGATrackSimMatrixAccumulator::hit_x_z0
std::vector< double > hit_x_z0
Definition: FPGATrackSimMatrixAccumulator.h:80
FPGATrackSimMatrixAccumulator::FTK_modules
std::vector< module_t > FTK_modules
Definition: FPGATrackSimMatrixAccumulator.h:56
FPGATrackSimMatrixAccumulator::hit_xG_eta
std::vector< double > hit_xG_eta
Definition: FPGATrackSimMatrixAccumulator.h:82
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Helper function for adding a track/accumulator to an accumulate map.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
FPGATrackSimMatrixAccumulator::pars
FPGATrackSimTrackPars pars
Definition: FPGATrackSimMatrixAccumulator.h:70
JetVoronoiDiagramHelpers::coord
double coord
Definition: JetVoronoiDiagramHelpers.h:45
AccumulateMap
std::unordered_map< std::vector< module_t >, FPGATrackSimMatrixAccumulator, container_hash< std::vector< module_t > > > AccumulateMap
Definition: FPGATrackSimMatrixAccumulator.h:108
FPGATrackSimTypes.h
python.compressB64.c
def c
Definition: compressB64.py:93
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
FPGATrackSimMatrixAccumulator::nusable
size_t nusable() const
Definition: FPGATrackSimMatrixAccumulator.h:58