ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimTrack.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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 getPatternID() const { return m_patternID; }
30 int getFirstSectorID() const { return m_firstSectorID; }
31 int getSecondSectorID() const { return m_secondSectorID; }
32 int getTrackID() const { return m_trackID; }
33 float getParameter(int) const;
34 float getHoughX() const { return m_houghX; }
35 float getHoughY() const { return m_houghY; }
36 float getQOverPt() const { return m_qoverpt; }
37 float getPt() const { return m_qoverpt != 0 ? std::abs(1 / m_qoverpt) : 99999999.; }
38 float getD0() const { return m_d0; }
39 float getPhi() const { return m_phi; }
40 float getZ0() const { return m_z0; }
41 float getEta() const { return m_eta; }
42 float getTheta() const { return 2*std::atan(std::exp(-m_eta)); }
43 float getChi2() const { return m_chi2; }
44 float getChi2Phi() const { return m_chi2_phi; }
45 float getChi2Eta() const { return m_chi2_eta; }
46 float getOrigChi2() const { return m_origchi2; }
47 float getChi2ndof() const { return m_chi2 / (getNCoords() - m_nmissing - 5); }
48 float getOrigChi2ndof() const { return m_origchi2 / (getNCoords() - m_nmissing - 5); }
49 int getSubRegion() const { return m_subregion; }
50 int getRegion() const { return m_region; }
51 unsigned getHoughXBin() const { return m_xBin; }
52 unsigned getHoughYBin() const { return m_yBin; }
53
54 // gets the number of non-null hits
55 int getNHits() const { return std::count_if(m_hit_ptrs.begin(), m_hit_ptrs.end(), [](const std::shared_ptr<const FPGATrackSimHit>& hit) { return hit && hit->isReal();});}
57
58 int getNMissing() const { return m_nmissing; } // missing coordinates
59 unsigned int getTypeMask() const { return m_typemask; }
60 unsigned int getHitMap() const { return m_hitmap; } // coordinate mask!!
61 //write a detmap
62 int getNCoords() const;
63 signed long getEventIndex() const { return m_eventindex; }
66 unsigned long barcode() const { return getBarcode(); }
67 float getBarcodeFrac() const { return m_barcode_frac; }
68 //Should be passed as const ref to avoid excessive copying.
69
70
71 // Returns the persistent hits stored in this track (for ROOT output only)
72 const std::vector<FPGATrackSimHit>& getFPGATrackSimHits() const { return m_hits; }
73
74 // Returns shared_ptrs to the active hits (SG or internal copies) - use this for runtime processing
75 const std::vector<std::shared_ptr<const FPGATrackSimHit>>& getFPGATrackSimHitPtrs() const {
76 return m_hit_ptrs;
77 }
78
79 // Copy hits for persistency and update pointers to internal storage
81 if (m_hit_ptrs.empty()) return;
82 m_hits.clear();
83 m_hits.reserve(m_hit_ptrs.size());
84 for (const auto& hit : m_hit_ptrs) {
85 if (hit) m_hits.push_back(*hit);
86 }
87 }
88 std::vector<float> getCoords(unsigned ilayer) const;
89 // helper function to calculate coordinates for the methods based in idealized detector geometry. See https://cds.cern.ch/record/2633242
90 // in the delta global phis method, the coordinates are the ideal z, and the delta global phis.
91 // the delta global phis are the difference between the global phi of the input hit transformed to the ideal detector layer (this is hitGPhi)
92 // and the global phi of the Hough Transform "track" at the ideal layers radius (target_r, R') (this is expectedGPhi)
93 // expectedGPhi = phi_0 (from HT) - R' * A*q/pT - ((R' * A*q/pT)^3) / 6
94 // hitGPhi = GPhi (from hit) + (R - R') * A*q/pT + ((R * A*q/pT)^3) / 6
95 std::vector<float> computeIdealCoords(unsigned ilayer) const;
96 //Has some size protections
97 float getEtaCoord(int ilayer) const;
98 float getPhiCoord(int ilayer) const;
99
100 // Retrieve the idealized radius for a given layer.
101 double getIdealRadius(int ilayer) const { return m_idealRadii.at(ilayer); };
102
103 bool isValidCand() const { return m_isValidCand; }
104
107 void setDoDeltaGPhis(bool v) { m_doDeltaGPhis = v; }
108 void setBankID(int v) { m_bankID = v; }
109 void setPatternID(int v) { m_patternID = v; }
112 void setTrackID(int v) { m_trackID = v; }
113 void setParameter(int, float);
114 void setHoughX(float v) { m_houghX = v; }
115 void setHoughY(float v) { m_houghY = v; }
116 void setQOverPt(float v) { m_qoverpt = v; }
117 void setD0(float v) { m_d0 = v; }
118 void setPhi(float v, bool ForceRange = true);
119 void setZ0(float v) { m_z0 = v; }
120 void setEta(float v) { m_eta = v; }
121 void setChi2(float v) { m_chi2 = v; }
122 void setChi2Phi(float v) { m_chi2_phi = v; }
123 void setChi2Eta(float v) { m_chi2_eta = v; }
124 void setOrigChi2(float v) { m_origchi2 = v; }
125 void setNMissing(int v) { m_nmissing = v; }
126 void setTypeMask(unsigned int v) { m_typemask = v; }
127 void setHitMap(unsigned int v) { m_hitmap = v; }
128 void setEventIndex(const signed long& v) { m_eventindex = v; }
131 void setBarcodeFrac(const float& v) { m_barcode_frac = v; }
132
133 void setSubRegion(unsigned v) { m_subregion = v; }
134 void setRegion(unsigned v) { m_region = v; }
135 void setHoughXBin(unsigned v) { m_xBin = v; }
136 void setHoughYBin(unsigned v) { m_yBin = v;}
137
138 void setValidCand(bool v) { m_isValidCand = v; }
139 void setIdealRadii(const std::vector<double>& v) { m_idealRadii = v; }
140
141 // Bin ID, if using FPGATrackSim binning.
142 void setBinIdx(std::vector<unsigned> x) { m_binIdx = std::move(x); }
143 const std::vector<unsigned>& getBinIdx() const { return m_binIdx; }
144
145 void calculateTruth(); // this will calculate the above quantities based on the hits
146 void setNLayers(int); //Reset/resize the track hits vector
147 void setFPGATrackSimHit(unsigned i, std::shared_ptr<const FPGATrackSimHit> hit);
149 {
150 setQOverPt(pars.qOverPt);
151 setPhi(pars.phi, false);
152 setEta(pars.eta);
153 setD0(pars.d0);
154 setZ0(pars.z0);
155 }
156
159 pars.qOverPt = getQOverPt();
160 pars.eta = getEta();
161 pars.phi = getPhi();
162 pars.d0 = getD0();
163 pars.z0 = getZ0();
164
165 return pars;
166 }
167
168 // Functions for overlap removal
169 unsigned int passedOR() const { return m_ORcode; }
170 void setPassedOR(unsigned int);
171
172 friend std::ostream& operator<<(std::ostream&, const FPGATrackSimTrack&);
173
174 private:
175
176 TrackCorrType m_trackCorrType = TrackCorrType::None; // type of correction to make for track coordinates
177 TrackStage m_trackStage = TrackStage::FIRST; // Is this a 1st stage or second stage track?
178 bool m_doDeltaGPhis = false; // if it uses the delta phis method for fitting
179
180 int m_bankID = -1; // Bank ID of the road related to this track
181 int m_patternID = 0; // TODO add documentation
182 int m_firstSectorID = -1; // Sector identifier in the first stage tracking
183 int m_secondSectorID = -1; // Sector identifier in thesecond stage tracking
184 int m_trackID = -1; // Unique track ID in this bank
185
186 int m_IdealGeoCorr = 0; //
187
188 float m_houghX = 0.0F; // phi0 from FPGATrackSimRoad_Hough
189 float m_houghY = 0.0F; // QOverPt from FPGATrackSimRoad_Hough
190 float m_qoverpt = 0.0F; // charge over pT
191 float m_d0 = 0.0F; // impact paramter in the ATLAS reference system
192 float m_phi = 0.0F; // phi of the track
193 float m_z0 = 0.0F; // z0 in standard ATLAS reference system
194 float m_eta = 0.0F; // eta of the track
195 float m_chi2 = 0.0F; // chi2 of the track
196 float m_chi2_phi = 0.0F; // chi2 of the track for phi coord only (if used)
197 float m_chi2_eta = 0.0F; // chi2 of the track for eta coord only (if used)
198 float m_origchi2 = 0.0F; // In the case of majority recovery, this is the chi2 of
199
200 //TODO: Switch to matchedhits mask
201 unsigned int m_nmissing = 0; // number of missing coordinates
202 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
203 unsigned int m_hitmap = 0;
204
205 // Subregion (aka slice) number of the corresponding road.
206 int m_subregion = 0;
207 //Setting region for the bfield to work
208 int m_region = 0;
209 // Hough x, y bin numbers (needed for recreation of roads in extrapolation)
210 unsigned m_xBin = 0;
211 unsigned m_yBin = 0;
212
213 std::vector<FPGATrackSimHit> m_hits; // persistent storage of hits (copies from SG or internal storage)
214
215 // hit pointers for runtime processing; these will point to SG hits as non-owning shared_ptr or to the internal storage hits (owning shared_ptr) if synthetic hits are created internally or real hits are modified (e.g. (re)-mapped)
216 std::vector<std::shared_ptr<const FPGATrackSimHit>> m_hit_ptrs;
217
218 // bin ID. Just store this as a vector<unsigned>.
219 std::vector<unsigned> m_binIdx;
220
221 signed long m_eventindex = -1; // matched particle event index
222 HepMcParticleLink::barcode_type m_barcode = std::numeric_limits<HepMcParticleLink::barcode_type>::max(); // matched geant particle barcode
223 HepMcParticleLink::barcode_type m_uniqueID = std::numeric_limits<HepMcParticleLink::barcode_type>::max();
224 // HepMcParticleLink::barcode_type m_uniqueID = std::numeric_limits<HepMcParticleLink::barcode_type>::max();
225 float m_barcode_frac = 0.0F; // largest "matching fraction" with any "good"
226 // geant particle, corresponding to the
227 // particle with m_barcode
228
229 // Is this a valid track candidate for fitting?
230 // At the moment, this is only *not* true if the track candidate has an illegal mix of duplicated spacepoints.
231 bool m_isValidCand = true;
232
233 // Idealized radii used for the fit for this track. Unclear if it makes sense to store here,
234 // but the information is loaded into the region map class at runtime and needs to be propagated
235 // over to the track object (where the coordinate transform _currently_ lives) somehow.
236 std::vector<double> m_idealRadii;
237
238 // Overlap removal member
239 // There is currently only one algorithm
240 unsigned int m_ORcode = 1; // Each digit should represent pass/fail(1/0) result from a specific OR algorithm
241
242 ClassDefNV(FPGATrackSimTrack, 7)
243};
244
245#endif // TRIGFPGATrackSimOBJECTS_FPGATrackSimTRACK_H
: FPGATrackSim-specific class to represent an hit in the detector.
Structs that store the 5 track parameters.
uint32_t layer_bitmask_t
TrackCorrType
#define x
TrackStage getTrackStage() const
void setParameter(int, float)
float getQOverPt() const
float getBarcodeFrac() const
void setRegion(unsigned v)
TrackCorrType m_trackCorrType
unsigned int getHitMap() const
void setSecondSectorID(int v)
void setPassedOR(unsigned int)
const std::vector< unsigned > & getBinIdx() const
void setHoughYBin(unsigned v)
void setHoughX(float v)
void setEventIndex(const signed long &v)
double getIdealRadius(int ilayer) const
void setOrigChi2(float v)
float getHoughX() const
layer_bitmask_t getHitMask() const
float getEtaCoord(int ilayer) const
void setQOverPt(float v)
unsigned int passedOR() const
HepMcParticleLink::barcode_type getUniqueID() const
std::vector< unsigned > m_binIdx
transient
unsigned long barcode() const
void setTrackStage(TrackStage v)
void setPhi(float v, bool ForceRange=true)
HepMcParticleLink::barcode_type getBarcode() const
bool getDoDeltaGPhis() const
const std::vector< std::shared_ptr< const FPGATrackSimHit > > & getFPGATrackSimHitPtrs() const
float getOrigChi2() const
std::vector< float > getCoords(unsigned ilayer) const
void setIdealRadii(const std::vector< double > &v)
HepMcParticleLink::barcode_type m_barcode
float getOrigChi2ndof() const
float getChi2ndof() const
signed long getEventIndex() const
void setBarcode(const HepMcParticleLink::barcode_type &v)
void setFPGATrackSimHit(unsigned i, std::shared_ptr< const FPGATrackSimHit > hit)
void setChi2Eta(float v)
void setHoughY(float v)
void setPars(FPGATrackSimTrackPars const &pars)
void setTrackCorrType(TrackCorrType v)
float getChi2Phi() const
float getHoughY() const
unsigned getHoughYBin() const
int getFirstSectorID() const
std::vector< std::shared_ptr< const FPGATrackSimHit > > m_hit_ptrs
std::vector< double > m_idealRadii
FPGATrackSimTrackPars getPars() const
void setBarcodeFrac(const float &v)
unsigned getHoughXBin() const
std::vector< float > computeIdealCoords(unsigned ilayer) const
void setHoughXBin(unsigned v)
TrackCorrType getTrackCorrType() const
void setChi2Phi(float v)
void setUniqueID(const HepMcParticleLink::barcode_type &v)
HepMcParticleLink::barcode_type m_uniqueID
void setNLayers(int)
set the number of layers in the track.
std::vector< FPGATrackSimHit > m_hits
void setHitMap(unsigned int v)
int getSecondSectorID() const
const std::vector< FPGATrackSimHit > & getFPGATrackSimHits() const
void setDoDeltaGPhis(bool v)
void setBinIdx(std::vector< unsigned > x)
float getChi2Eta() const
float getPhiCoord(int ilayer) const
void setSubRegion(unsigned v)
FPGATrackSimTrack()=default
float getTheta() const
float getParameter(int) const
void setValidCand(bool v)
float getChi2() const
void setFirstSectorID(int v)
unsigned int getTypeMask() const
friend std::ostream & operator<<(std::ostream &, const FPGATrackSimTrack &)
void setTypeMask(unsigned int v)