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