ATLAS Offline Software
FPGATrackSimTrack.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef TRIGFPGATrackSimOBJECTS_FPGATrackSimTRACK_H
6 #define TRIGFPGATrackSimOBJECTS_FPGATrackSimTRACK_H
7 
11 #include <vector>
12 #include <iosfwd>
13 #include <cmath>
14 
16 #include "TObject.h"
17 
19 
20  public:
21 
22  FPGATrackSimTrack() = default;
23  virtual ~FPGATrackSimTrack();
24 
27  bool getDoDeltaGPhis() const { return m_doDeltaGPhis; }
28  int getBankID() const { return m_bankID; }
29  int getRegion() const { return m_bankID % 100; }
30  int getPatternID() const { return m_patternID; }
31  int getFirstSectorID() const { return m_firstSectorID; }
32  int getSecondSectorID() const { return m_secondSectorID; }
33  int getTrackID() const { return m_trackID; }
34  float getParameter(int) const;
35  float getHoughX() const { return m_houghX; }
36  float getHoughY() const { return m_houghY; }
37  float getQOverPt() const { return m_qoverpt; }
38  float getPt() const { return m_qoverpt != 0 ? std::abs(1 / m_qoverpt) : 99999999.; }
39  float getD0() const { return m_d0; }
40  float getPhi() const { return m_phi; }
41  float getZ0() const { return m_z0; }
42  float getEta() const { return m_eta; }
43  float getTheta() const { return 2*std::atan(std::exp(-m_eta)); }
44  float getChi2() const { return m_chi2; }
45  float getOrigChi2() const { return m_origchi2; }
46  float getChi2ndof() const { return m_chi2 / (getNCoords() - m_nmissing - 5); }
47  float getOrigChi2ndof() const { return m_origchi2 / (getNCoords() - m_nmissing - 5); }
48  int getSubRegion() const { return m_subregion; }
49  unsigned getHoughXBin() const { return m_xBin; }
50  unsigned getHoughYBin() const { return m_yBin; }
51 
52  int getNMissing() const { return m_nmissing; } // missing coordinates
53  unsigned int getTypeMask() const { return m_typemask; }
54  unsigned int getHitMap() const { return m_hitmap; } // coordinate mask!!
55  //write a detmap
56  int getNCoords() const;
57  signed long getEventIndex() const { return m_eventindex; }
60  unsigned long barcode() const { return getBarcode(); }
61  float getBarcodeFrac() const { return m_barcode_frac; }
62  //Should be passed as const ref to avoid excessive copying.
63  const std::vector <FPGATrackSimHit>& getFPGATrackSimHits() const { return m_hits; }
64  std::vector<float> getCoords(unsigned ilayer) const;
65  // helper function to calculate coordinates for the methods based in idealized detector geometry. See https://cds.cern.ch/record/2633242
66  // in the delta global phis method, the coordinates are the ideal z, and the delta global phis.
67  // the delta global phis are the difference between the global phi of the input hit transformed to the ideal detector layer (this is hitGPhi)
68  // and the global phi of the Hough Transform "track" at the ideal layers radius (target_r, R') (this is expectedGPhi)
69  // expectedGPhi = phi_0 (from HT) - R' * A*q/pT - ((R' * A*q/pT)^3) / 6
70  // hitGPhi = GPhi (from hit) + (R - R') * A*q/pT + ((R * A*q/pT)^3) / 6
71  std::vector<float> computeIdealCoords(unsigned ilayer) const;
72  //Has some size protections
73  float getEtaCoord(int ilayer) const;
74  float getPhiCoord(int ilayer) const;
75 
76  // Retrieve the idealized radius for a given layer.
77  double getIdealRadius(int ilayer) const { return m_idealRadii.at(ilayer); };
78 
79  bool isValidCand() const { return m_isValidCand; }
80 
83  void setDoDeltaGPhis(bool v) { m_doDeltaGPhis = v; }
84  void setBankID(int v) { m_bankID = v; }
85  void setPatternID(int v) { m_patternID = v; }
88  void setTrackID(int v) { m_trackID = v; }
89  void setParameter(int, float);
90  void setHoughX(float v) { m_houghX = v; }
91  void setHoughY(float v) { m_houghY = v; }
92  void setQOverPt(float v) { m_qoverpt = v; }
93  void setD0(float v) { m_d0 = v; }
94  void setPhi(float v, bool ForceRange = true);
95  void setZ0(float v) { m_z0 = v; }
96  void setEta(float v) { m_eta = v; }
97  void setChi2(float v) { m_chi2 = v; }
98  void setOrigChi2(float v) { m_origchi2 = v; }
99  void setNMissing(int v) { m_nmissing = v; }
100  void setTypeMask(unsigned int v) { m_typemask = v; }
101  void setHitMap(unsigned int v) { m_hitmap = v; }
102  void setEventIndex(const signed long& v) { m_eventindex = v; }
105  void setBarcodeFrac(const float& v) { m_barcode_frac = v; }
106 
107  void setSubRegion(unsigned v) { m_subregion = v; }
108  void setHoughXBin(unsigned v) { m_xBin = v; }
109  void setHoughYBin(unsigned v) { m_yBin = v;}
110 
111  void setValidCand(bool v) { m_isValidCand = v; }
112  void setIdealRadii(const std::vector<double>& v) { m_idealRadii = v; }
113 
114  void calculateTruth(); // this will calculate the above quantities based on the hits
115  void setNLayers(int); //Reset/resize the track hits vector
116  void setFPGATrackSimHit(unsigned i, const FPGATrackSimHit& hit);
118  {
119  setQOverPt(pars.qOverPt);
120  setPhi(pars.phi, false);
121  setEta(pars.eta);
122  setD0(pars.d0);
123  setZ0(pars.z0);
124  }
125 
126  // Functions for overlap removal
127  unsigned int passedOR() const { return m_ORcode; }
128  void setPassedOR(unsigned int);
129 
130  friend std::ostream& operator<<(std::ostream&, const FPGATrackSimTrack&);
131 
132  private:
133 
134  TrackCorrType m_trackCorrType = TrackCorrType::None; // type of correction to make for track coordinates
135  TrackStage m_trackStage = TrackStage::FIRST; // Is this a 1st stage or second stage track?
136  bool m_doDeltaGPhis = false; // if it uses the delta phis method for fitting
137 
138  int m_bankID = -1; // Bank ID of the road related to this track
139  int m_patternID = 0; // TODO add documentation
140  int m_firstSectorID = -1; // Sector identifier in the first stage tracking
141  int m_secondSectorID = -1; // Sector identifier in thesecond stage tracking
142  int m_trackID = -1; // Unique track ID in this bank
143 
144  int m_IdealGeoCorr = 0; //
145 
146  float m_houghX = 0.0F; // phi0 from FPGATrackSimRoad_Hough
147  float m_houghY = 0.0F; // QOverPt from FPGATrackSimRoad_Hough
148  float m_qoverpt = 0.0F; // charge over pT
149  float m_d0 = 0.0F; // impact paramter in the ATLAS reference system
150  float m_phi = 0.0F; // phi of the track
151  float m_z0 = 0.0F; // z0 in standard ATLAS reference system
152  float m_eta = 0.0F; // eta of the track
153  float m_chi2 = 0.0F; // chi2 of the track
154  float m_origchi2 = 0.0F; // In the case of majority recovery, this is the chi2 of
155 
156  //TODO: Switch to matchedhits mask
157  unsigned int m_nmissing = 0; // number of missing coordinates
158  unsigned int m_typemask = 0; // set on in bits related to the step recovery were used, ex.: 0 no recovery, 01, rec 1st step, 11, recovery in the 1st and the 2nd stage
159  unsigned int m_hitmap = 0;
160 
161  // Subregion (aka slice) number of the corresponding road.
162  int m_subregion = 0;
163 
164  // Hough x, y bin numbers (needed for recreation of roads in extrapolation)
165  unsigned m_xBin = 0;
166  unsigned m_yBin = 0;
167 
168  std::vector<FPGATrackSimHit> m_hits; //[m_nlayers] hits associated to the track
169 
170  signed long m_eventindex = -1; // matched particle event index
173  // HepMcParticleLink::barcode_type m_uniqueID = std::numeric_limits<HepMcParticleLink::barcode_type>::max();
174  float m_barcode_frac = 0.0F; // largest "matching fraction" with any "good"
175  // geant particle, corresponding to the
176  // particle with m_barcode
177 
178  // Is this a valid track candidate for fitting?
179  // At the moment, this is only *not* true if the track candidate has an illegal mix of duplicated spacepoints.
180  bool m_isValidCand = true;
181 
182  // Idealized radii used for the fit for this track. Unclear if it makes sense to store here,
183  // but the information is loaded into the region map class at runtime and needs to be propagated
184  // over to the track object (where the coordinate transform _currently_ lives) somehow.
185  std::vector<double> m_idealRadii;
186 
187  // Overlap removal member
188  // There is currently only one algorithm
189  unsigned int m_ORcode = 1; // Each digit should represent pass/fail(1/0) result from a specific OR algorithm
190 
191  ClassDefNV(FPGATrackSimTrack, 5)
192 };
193 
194 #endif // TRIGFPGATrackSimOBJECTS_FPGATrackSimTRACK_H
FPGATrackSimTrack::m_trackStage
TrackStage m_trackStage
Definition: FPGATrackSimTrack.h:135
FPGATrackSimTrack::setHitMap
void setHitMap(unsigned int v)
Definition: FPGATrackSimTrack.h:101
FPGATrackSimTrack::getEta
float getEta() const
Definition: FPGATrackSimTrack.h:42
FPGATrackSimTrack::getPhiCoord
float getPhiCoord(int ilayer) const
Definition: FPGATrackSimTrack.cxx:67
make_hlt_rep.pars
pars
Definition: make_hlt_rep.py:90
FPGATrackSimTrack::calculateTruth
void calculateTruth()
Definition: FPGATrackSimTrack.cxx:221
FPGATrackSimTrack::getEventIndex
signed long getEventIndex() const
Definition: FPGATrackSimTrack.h:57
FPGATrackSimTrack::setD0
void setD0(float v)
Definition: FPGATrackSimTrack.h:93
FPGATrackSimTrack::getPt
float getPt() const
Definition: FPGATrackSimTrack.h:38
FPGATrackSimTrack::setPars
void setPars(FPGATrackSimTrackPars const &pars)
Definition: FPGATrackSimTrack.h:117
FPGATrackSimTrack::getTrackID
int getTrackID() const
Definition: FPGATrackSimTrack.h:33
FPGATrackSimTrack::setBankID
void setBankID(int v)
Definition: FPGATrackSimTrack.h:84
FPGATrackSimTrack::getNMissing
int getNMissing() const
Definition: FPGATrackSimTrack.h:52
FPGATrackSimTrack::getBarcode
HepMcParticleLink::barcode_type getBarcode() const
Definition: FPGATrackSimTrack.h:58
FPGATrackSimTrack::getDoDeltaGPhis
bool getDoDeltaGPhis() const
Definition: FPGATrackSimTrack.h:27
FPGATrackSimTrack::m_trackCorrType
TrackCorrType m_trackCorrType
Definition: FPGATrackSimTrack.h:134
FPGATrackSimTrack
Definition: FPGATrackSimTrack.h:18
FPGATrackSimTrackPars
Definition: FPGATrackSimTrackPars.h:22
FPGATrackSimTrack::setPatternID
void setPatternID(int v)
Definition: FPGATrackSimTrack.h:85
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
FPGATrackSimTrack::getPhi
float getPhi() const
Definition: FPGATrackSimTrack.h:40
FPGATrackSimTrack::m_eta
float m_eta
Definition: FPGATrackSimTrack.h:152
FPGATrackSimTrack::getCoords
std::vector< float > getCoords(unsigned ilayer) const
Definition: FPGATrackSimTrack.cxx:20
FPGATrackSimTrack::setNMissing
void setNMissing(int v)
Definition: FPGATrackSimTrack.h:99
FPGATrackSimTrack::m_IdealGeoCorr
int m_IdealGeoCorr
Definition: FPGATrackSimTrack.h:144
FPGATrackSimTrack::setPassedOR
void setPassedOR(unsigned int)
Definition: FPGATrackSimTrack.cxx:260
FPGATrackSimTrack::getD0
float getD0() const
Definition: FPGATrackSimTrack.h:39
FPGATrackSimTrack::getRegion
int getRegion() const
Definition: FPGATrackSimTrack.h:29
FPGATrackSimTrack::setHoughXBin
void setHoughXBin(unsigned v)
Definition: FPGATrackSimTrack.h:108
FPGATrackSimTrack::setFirstSectorID
void setFirstSectorID(int v)
Definition: FPGATrackSimTrack.h:86
FPGATrackSimTrack::m_hitmap
unsigned int m_hitmap
Definition: FPGATrackSimTrack.h:159
FPGATrackSimTrack::getNCoords
int getNCoords() const
Definition: FPGATrackSimTrack.cxx:90
FPGATrackSimTrack::getHitMap
unsigned int getHitMap() const
Definition: FPGATrackSimTrack.h:54
FPGATrackSimMultiTruth.h
FPGATrackSimTrack::getTrackStage
TrackStage getTrackStage() const
Definition: FPGATrackSimTrack.h:26
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
FPGATrackSimTrack::getSubRegion
int getSubRegion() const
Definition: FPGATrackSimTrack.h:48
FPGATrackSimTrack::setFPGATrackSimHit
void setFPGATrackSimHit(unsigned i, const FPGATrackSimHit &hit)
Definition: FPGATrackSimTrack.cxx:99
FPGATrackSimTrack::passedOR
unsigned int passedOR() const
Definition: FPGATrackSimTrack.h:127
FPGATrackSimTrack::getHoughY
float getHoughY() const
Definition: FPGATrackSimTrack.h:36
FPGATrackSimTrack::m_chi2
float m_chi2
Definition: FPGATrackSimTrack.h:153
FPGATrackSimTrack::setOrigChi2
void setOrigChi2(float v)
Definition: FPGATrackSimTrack.h:98
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
FPGATrackSimTrack::setZ0
void setZ0(float v)
Definition: FPGATrackSimTrack.h:95
FPGATrackSimTrack::getQOverPt
float getQOverPt() const
Definition: FPGATrackSimTrack.h:37
FPGATrackSimTrack::getUniqueID
HepMcParticleLink::barcode_type getUniqueID() const
Definition: FPGATrackSimTrack.h:59
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
FPGATrackSimTrack::setPhi
void setPhi(float v, bool ForceRange=true)
Definition: FPGATrackSimTrack.cxx:116
FPGATrackSimTrack::setSecondSectorID
void setSecondSectorID(int v)
Definition: FPGATrackSimTrack.h:87
FPGATrackSimTrack::barcode
unsigned long barcode() const
Definition: FPGATrackSimTrack.h:60
TrackStage
TrackStage
Definition: FPGATrackSimTypes.h:34
FPGATrackSimTrack::setUniqueID
void setUniqueID(const HepMcParticleLink::barcode_type &v)
Definition: FPGATrackSimTrack.h:104
FPGATrackSimTrack::getFPGATrackSimHits
const std::vector< FPGATrackSimHit > & getFPGATrackSimHits() const
Definition: FPGATrackSimTrack.h:63
FPGATrackSimTrack::getBarcodeFrac
float getBarcodeFrac() const
Definition: FPGATrackSimTrack.h:61
FPGATrackSimTrack::setHoughYBin
void setHoughYBin(unsigned v)
Definition: FPGATrackSimTrack.h:109
FPGATrackSimTrack::getChi2
float getChi2() const
Definition: FPGATrackSimTrack.h:44
FPGATrackSimTrack::getChi2ndof
float getChi2ndof() const
Definition: FPGATrackSimTrack.h:46
FPGATrackSimTrack::m_z0
float m_z0
Definition: FPGATrackSimTrack.h:151
FPGATrackSimTrack::m_phi
float m_phi
Definition: FPGATrackSimTrack.h:150
FPGATrackSimTrack::getSecondSectorID
int getSecondSectorID() const
Definition: FPGATrackSimTrack.h:32
FPGATrackSimTrack::m_patternID
int m_patternID
Definition: FPGATrackSimTrack.h:139
FPGATrackSimTrack::getIdealRadius
double getIdealRadius(int ilayer) const
Definition: FPGATrackSimTrack.h:77
FPGATrackSimTrack::m_uniqueID
HepMcParticleLink::barcode_type m_uniqueID
Definition: FPGATrackSimTrack.h:172
FPGATrackSimTrack::getZ0
float getZ0() const
Definition: FPGATrackSimTrack.h:41
FPGATrackSimTrack::setValidCand
void setValidCand(bool v)
Definition: FPGATrackSimTrack.h:111
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimTrack::getTypeMask
unsigned int getTypeMask() const
Definition: FPGATrackSimTrack.h:53
FPGATrackSimTrack::getOrigChi2ndof
float getOrigChi2ndof() const
Definition: FPGATrackSimTrack.h:47
FPGATrackSimTrack::m_barcode_frac
float m_barcode_frac
Definition: FPGATrackSimTrack.h:174
TrackStage::FIRST
@ FIRST
FPGATrackSimTrack::setDoDeltaGPhis
void setDoDeltaGPhis(bool v)
Definition: FPGATrackSimTrack.h:83
FPGATrackSimTrack::m_barcode
HepMcParticleLink::barcode_type m_barcode
Definition: FPGATrackSimTrack.h:171
FPGATrackSimTrack::m_qoverpt
float m_qoverpt
Definition: FPGATrackSimTrack.h:148
FPGATrackSimTrack::getEtaCoord
float getEtaCoord(int ilayer) const
Definition: FPGATrackSimTrack.cxx:57
FPGATrackSimTrack::getOrigChi2
float getOrigChi2() const
Definition: FPGATrackSimTrack.h:45
FPGATrackSimTrack::getHoughXBin
unsigned getHoughXBin() const
Definition: FPGATrackSimTrack.h:49
FPGATrackSimTrack::operator<<
friend std::ostream & operator<<(std::ostream &, const FPGATrackSimTrack &)
Definition: FPGATrackSimTrack.cxx:178
FPGATrackSimTrack::m_firstSectorID
int m_firstSectorID
Definition: FPGATrackSimTrack.h:140
FPGATrackSimTrack::m_houghX
float m_houghX
Definition: FPGATrackSimTrack.h:146
FPGATrackSimTrack::getParameter
float getParameter(int) const
Definition: FPGATrackSimTrack.cxx:132
FPGATrackSimTrack::m_bankID
int m_bankID
Definition: FPGATrackSimTrack.h:138
FPGATrackSimTrack::setBarcodeFrac
void setBarcodeFrac(const float &v)
Definition: FPGATrackSimTrack.h:105
FPGATrackSimTrack::setTrackCorrType
void setTrackCorrType(TrackCorrType v)
Definition: FPGATrackSimTrack.h:81
FPGATrackSimTrack::setBarcode
void setBarcode(const HepMcParticleLink::barcode_type &v)
Definition: FPGATrackSimTrack.h:103
FPGATrackSimTrack::setParameter
void setParameter(int, float)
Definition: FPGATrackSimTrack.cxx:156
FPGATrackSimTrack::setTypeMask
void setTypeMask(unsigned int v)
Definition: FPGATrackSimTrack.h:100
FPGATrackSimTrack::m_ORcode
unsigned int m_ORcode
Definition: FPGATrackSimTrack.h:189
FPGATrackSimTrack::setTrackStage
void setTrackStage(TrackStage v)
Definition: FPGATrackSimTrack.h:82
FPGATrackSimTrack::setIdealRadii
void setIdealRadii(const std::vector< double > &v)
Definition: FPGATrackSimTrack.h:112
FPGATrackSimTrack::getTrackCorrType
TrackCorrType getTrackCorrType() const
Definition: FPGATrackSimTrack.h:25
FPGATrackSimTrack::setEventIndex
void setEventIndex(const signed long &v)
Definition: FPGATrackSimTrack.h:102
FPGATrackSimTrack::m_idealRadii
std::vector< double > m_idealRadii
Definition: FPGATrackSimTrack.h:185
FPGATrackSimTrack::m_d0
float m_d0
Definition: FPGATrackSimTrack.h:149
TrackCorrType::None
@ None
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
FPGATrackSimTrack::m_secondSectorID
int m_secondSectorID
Definition: FPGATrackSimTrack.h:141
FPGATrackSimTrack::setHoughY
void setHoughY(float v)
Definition: FPGATrackSimTrack.h:91
FPGATrackSimTrack::setTrackID
void setTrackID(int v)
Definition: FPGATrackSimTrack.h:88
FPGATrackSimTrack::setQOverPt
void setQOverPt(float v)
Definition: FPGATrackSimTrack.h:92
FPGATrackSimTrack::setEta
void setEta(float v)
Definition: FPGATrackSimTrack.h:96
FPGATrackSimTrack::m_trackID
int m_trackID
Definition: FPGATrackSimTrack.h:142
FPGATrackSimTrack::m_hits
std::vector< FPGATrackSimHit > m_hits
Definition: FPGATrackSimTrack.h:168
FPGATrackSimTrack::m_subregion
int m_subregion
Definition: FPGATrackSimTrack.h:162
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimTrack::getFirstSectorID
int getFirstSectorID() const
Definition: FPGATrackSimTrack.h:31
FPGATrackSimTrack::m_houghY
float m_houghY
Definition: FPGATrackSimTrack.h:147
FPGATrackSimTrack::setChi2
void setChi2(float v)
Definition: FPGATrackSimTrack.h:97
FPGATrackSimTrack::isValidCand
bool isValidCand() const
Definition: FPGATrackSimTrack.h:79
FPGATrackSimTrack::m_doDeltaGPhis
bool m_doDeltaGPhis
Definition: FPGATrackSimTrack.h:136
FPGATrackSimTrack::setSubRegion
void setSubRegion(unsigned v)
Definition: FPGATrackSimTrack.h:107
FPGATrackSimTrack::getPatternID
int getPatternID() const
Definition: FPGATrackSimTrack.h:30
FPGATrackSimTrack::m_nmissing
unsigned int m_nmissing
Definition: FPGATrackSimTrack.h:157
FPGATrackSimTrack::getHoughYBin
unsigned getHoughYBin() const
Definition: FPGATrackSimTrack.h:50
FPGATrackSimTrack::m_yBin
unsigned m_yBin
Definition: FPGATrackSimTrack.h:166
FPGATrackSimTrack::~FPGATrackSimTrack
virtual ~FPGATrackSimTrack()
Definition: FPGATrackSimTrack.cxx:18
FPGATrackSimTrack::m_isValidCand
bool m_isValidCand
Definition: FPGATrackSimTrack.h:180
TrackCorrType
TrackCorrType
Definition: FPGATrackSimTypes.h:37
FPGATrackSimTrack::setNLayers
void setNLayers(int)
set the number of layers in the track.
Definition: FPGATrackSimTrack.cxx:108
FPGATrackSimTrack::computeIdealCoords
std::vector< float > computeIdealCoords(unsigned ilayer) const
Definition: FPGATrackSimTrack.cxx:39
FPGATrackSimTrack::getHoughX
float getHoughX() const
Definition: FPGATrackSimTrack.h:35
FPGATrackSimTrack::m_eventindex
signed long m_eventindex
Definition: FPGATrackSimTrack.h:170
FPGATrackSimTrack::getTheta
float getTheta() const
Definition: FPGATrackSimTrack.h:43
FPGATrackSimTrack::m_xBin
unsigned m_xBin
Definition: FPGATrackSimTrack.h:165
FPGATrackSimTrackPars.h
Structs that store the 5 track parameters.
FPGATrackSimTrack::m_origchi2
float m_origchi2
Definition: FPGATrackSimTrack.h:154
FPGATrackSimTrack::setHoughX
void setHoughX(float v)
Definition: FPGATrackSimTrack.h:90
FPGATrackSimTrack::getBankID
int getBankID() const
Definition: FPGATrackSimTrack.h:28
FPGATrackSimTrack::FPGATrackSimTrack
FPGATrackSimTrack()=default
FPGATrackSimTrack::m_typemask
unsigned int m_typemask
Definition: FPGATrackSimTrack.h:158