ATLAS Offline Software
Loading...
Searching...
No Matches
FPGATrackSimHit.h
Go to the documentation of this file.
1// Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3#ifndef TRIGFPGATrackSimOBJECTS_FPGATrackSimHIT_H
4#define TRIGFPGATrackSimOBJECTS_FPGATrackSimHIT_H
5
24
25#include <vector>
26#include <ostream>
27#include <memory>
28
31
32#include <Rtypes.h>
33#include "TMath.h"
34
36#include "Identifier/Identifier.h"
37
38 // Some types are inclusive of others. For example, clustered implies mapped.
40
42{
43public:
44
46 // Constructors
47
48 FPGATrackSimHit() = default;
49 virtual ~FPGATrackSimHit() = default;
50
52 // Getters/Setters
53
54 // --- Hit Type ---
56 void setDetType(SiliconTech detType) { m_detType = detType; }
57 void setDetectorZone(DetectorZone detZone) { m_detectorZone = detZone; }
58 HitType getHitType() const { return m_hitType; }
59 SiliconTech getDetType() const { return m_detType; }
61
62 bool isMapped() const;
63 bool isClustered() const;
64 bool isReal() const; // ie not wildcard or guessed
65 bool isPixel() const { return m_detType == SiliconTech::pixel; }
66 bool isStrip() const { return m_detType == SiliconTech::strip; }
67 bool isBarrel() const { return m_detectorZone == DetectorZone::barrel; }
68 unsigned getDim() const { return isPixel() ? 2 : 1; } // TODO all calls of this should be replaced with a call to plane map
69 int getRoadID() const { return m_roadID; }
70
71 // --- Unmapped Location ---
72 void setIdentifier(unsigned int v) { m_identifier = v; } // 32 bit (short) module identifier
73 void setIdentifierHash(unsigned v) { m_identifierHash = v; }
74 void setRdoIdentifier(Identifier::value_type v) { m_rdoIdentifier = v; } // this stores the entire 64 bit hit identifier
75 void setLayerDisk(unsigned v) { m_layer_disk = v; } // ITk layer number
76 void setSide(unsigned v) { m_side = v; }
77 void setPhysLayer(unsigned v); // Sets using the FPGATrackSim-defined physical layer index (see FPGATrackSimPlaneMap.h)
79 void setPhiModule(unsigned v) { m_phiModule = v; }
80 void setEtaWidth(unsigned v) { m_etaWidth = v; }
81 void setPhiWidth(unsigned v) { m_phiWidth = v; }
82 unsigned int getIdentifier() const { return m_identifier; } // 32 bit (short) module identifier
83 unsigned getIdentifierHash() const { return m_identifierHash; } // TODO note this might break things in the same way as getSide() a few lines below. If so, recomment.
84 Identifier::value_type getRdoIdentifier() const { return m_rdoIdentifier; } // this returns the entire 64 bit hit identifier. TODO instead of storing it, calculate it based on the module ID and eta/phi index
85 unsigned getLayerDisk(bool old=false) const { if (old && isRemapped()) return m_layer_disk_old; else return m_layer_disk;} // ITk layer number
86 unsigned getSide() const { return m_side; } // strip side TODO note this has been uncommented on 4/20/21. If wrappers suddenly break, recomment this. Same for getIdentifierHash above.
87 unsigned getPhysLayer(bool old=false) const; // Returns the FPGATrackSim-defined physical layer index (see FPGATrackSimPlaneMap.h)
88 unsigned getEtaWidth() const { return m_etaWidth; }
89 unsigned getPhiWidth() const { return m_phiWidth; }
90 int getEtaModule(bool old=false) const { if (old && isRemapped()) return m_etaModule_old; else return m_etaModule; }
91 unsigned getPhiModule() const { return m_phiModule; }
92
93 // --- Mapped Location ---
94 // NB: isMapped() should return true to access these members
95 void setLayer(unsigned v) { m_layer = v; } // This is the logical layer
96 void setSection(unsigned v) { m_section = v; }
97 int getLayer() const;
98 unsigned getSection() const;
99 void setRoadID(int roadID) { m_roadID = roadID; }
100
101 // --- Local Coordinates ---
102 // The local coordinate is stored as an unsigned int, as in the hardware.
103 // To get the actual local coordinate, use the float getCoord functions instead.
104 void setPhiIndex(unsigned v) { m_phiIndex = v; }
105 void setEtaIndex(unsigned v) { m_etaIndex = v; }
108 void setPhiCoord(float v) { m_phiCoord = v; }
109 void setEtaCoord(float v) { m_etaCoord = v; }
110 unsigned getPhiIndex() const { return m_phiIndex; }
111 unsigned getEtaIndex() const { return m_etaIndex; }
112 float getCentroidPhiIndex() const { return m_centroidPhiIndex; }
113 float getCentroidEtaIndex() const { return m_centroidEtaIndex; }
114 float getPhiCoord() const { return m_phiCoord; }
115 float getEtaCoord() const { return m_etaCoord; }
116
117 void setMaxPhiIndex(int v) { m_maxPhiIndex = v; }
118 void setMinPhiIndex(int v) { m_minPhiIndex = v; }
119 void setMaxEtaIndex(int v) { m_maxEtaIndex = v; }
120 void setMinEtaIndex(int v) { m_minEtaIndex = v; }
121 int getMaxPhiIndex() const { return m_maxPhiIndex; }
122 int getMinPhiIndex() const { return m_minPhiIndex; }
123 int getMaxEtaIndex() const { return m_maxEtaIndex; }
124 int getMinEtaIndex() const { return m_minEtaIndex; }
125
126 float getPhiWindow() const { return m_phiWindow; }
127
128 // Converts the hit into a spacepoint. Keeps copies of the local information.
129 void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth);
130
131 // Retrieves a (copy of) the original hit with the original local coordinates used to make a SP.
132 // If not a SP, returns a copy of this hit.
133 const FPGATrackSimHit getOriginalHit() const;
134
135 // These return coordinates for the inner hit in the pair, if a SP
136 int getPairedEtaModule() const { return m_pairedEtaModule; }
137 unsigned getPairedPhiModule() const { return m_pairedPhiModule; }
138 unsigned getPairedSection() const { return m_pairedSection; }
139 unsigned getPairedLayer() const { return m_pairedLayer; }
140 unsigned getPairedPhysLayer() const { return m_pairedPhysLayer; }
143
144 // These setters are used by FPGATrackSimPlaneMap to map hits that are SPs.
145 void setPairedLayer(unsigned v) { m_pairedLayer = v; }
146 void setPairedSection(unsigned v) { m_pairedSection = v; }
147
148 // --- Global Coordinates ---
149 void setX(float v) { m_originalX = m_x; m_x = v; }
150 void setY(float v) { m_originalY = m_y; m_y = v; }
151 void setZ(float v) { m_originalZ = m_z; m_z = v; }
152 float getX() const { return m_x; }
153 float getY() const { return m_y; }
154 float getZ() const { return m_z; }
155 float getR() const { return TMath::Sqrt(m_x * m_x + m_y * m_y); } // This is cylindrical radius
156 float getGPhi() const { return TMath::ATan2(m_y, m_x); }
157 float getGCotTheta() const { return m_z / getR(); } // cot(theta) = z/r
158
159 // --- Truth and Other ---
160 void setToT(unsigned v) { m_ToT = v; }
163 void setBarcodePt(float v) { m_barcode_pt = v; }
164 void setEventIndex(long v) { m_eventindex = v; }
165 void setParentageMask(unsigned long v) { m_parentage_mask = v; }
167 unsigned getToT() const { return m_ToT ;}
170 long getEventIndex() const { return m_eventindex; }
171 float getBarcodePt() const { return m_barcode_pt; }
172 unsigned long getParentageMask() const { return m_parentage_mask; }
173 const FPGATrackSimMultiTruth& getTruth() const { return m_truth; }
174
175
177 // Add information for creating the bytestream TV for ITk pixel and strip
178 // The current athena EDM is using ID bytestream encoders and these happens
179 // to have issues and we need to work around them to make TV
180 // Hence these special function - Please talk to Haider [sabidi@cern.ch]
181 // If these need to functions are being used anywhere outside bytestream encoders
182
183 bool isValidForITkHit() const {return m_isValidForITK;}
187
192
195
198
199 // methods for hit cluster equiv
200 const std::vector<int>& getPhiIndexVec() const { return m_PhiIndexVec;}
201 const std::vector<int>& getEtaIndexVec() const { return m_EtaIndexVec;}
202 const std::vector<unsigned>& getIDHashVec() const { return m_IDhashVec;}
203
204 void addPhiIndexToVec(int phi) {m_PhiIndexVec.push_back(phi);}
205 void addEtaIndexToVec(int eta) {m_EtaIndexVec.push_back(eta);}
206 void addIDHashToVec(unsigned id) {m_IDhashVec.push_back(id);}
208 // Other Interface
209
210 friend std::ostream& operator<<(std::ostream&, const FPGATrackSimHit&);
211
212 //remap interface
213 bool isRemapped() const;
214 void setRemap();
215
216protected:
217
218 // --- Hit Type ---
220 DetectorZone m_detectorZone = DetectorZone::undefined; // barrel / posEC / negEC (0,1,2)
222
223 // --- Unmapped Location ---
224 unsigned int m_identifier = 0; // Global module ID, from offline (32 bit variant)
225 unsigned m_identifierHash = 0; // Global module ID hash, from ITk
226 Identifier::value_type m_rdoIdentifier = 0; // Full 64 bit hit identifier
227 unsigned m_layer_disk = 0; // ITk layer number
228 unsigned m_layer_disk_old = 0; // ITk layer number
229 unsigned m_side = 0; // Side of the strip module
230 unsigned m_side_old = 0; // Side of the strip module
231 int m_etaModule = 0; // eta index of the module that the hit is located on
232 int m_etaModule_old = 0; // eta index of the module that the hit is located on
233 unsigned m_phiModule = 0; // phi index of the module that the hit is located on
234 unsigned m_etaWidth = 0; // clustering width along eta
235 unsigned m_phiWidth = 0; // clustering width in phi direction
236
237 // --- Mapped Location ---
238 // isMapped() should return true to access these members
239 int m_layer = -1; // Logical layer this hit is on
240 int m_section = -1; // Index of detector element in the logical layer (see FPGATrackSimPlaneMap.h)
241
242 // --- Map Tag
243 bool m_isRemapped = false;
244 // --- Local Coordinates ---
245 int m_phiIndex = -1; // phi index for pixel, strip for strip
246 int m_etaIndex = -1; // eta index for pixel, row for strip
247 float m_centroidPhiIndex = -1; // centroid's phi index for pixel, strip for strip
248 float m_centroidEtaIndex = -1; // centroid's eta index for pixel, row for strip
249 float m_phiCoord = -999; // local position along phi direction
250 float m_etaCoord = -999; // local position along eta direction
251
252 // --- Min/Max Indices used for cluster equivalent to estimate widths ---
253 int m_maxPhiIndex = std::numeric_limits<int>::min();
254 int m_minPhiIndex = std::numeric_limits<int>::max();
255 int m_maxEtaIndex = std::numeric_limits<int>::min();
256 int m_minEtaIndex = std::numeric_limits<int>::max();
257
258 // --- Global Coordinates ---
259 float m_x = 0; // Hit position in global coordinates
260 float m_y = 0;
261 float m_z = 0;
262
263 // Original X/Y/Z coordinates, if this is a spacepoint
264 float m_originalX = 0;
265 float m_originalY = 0;
266 float m_originalZ = 0;
267
268 // Phi window used in spacepoint calculation
269 float m_phiWindow = 0;
270
271 // These are the coordinates of the inner layer in a SP
272 unsigned m_pairedPhiModule = -1;
274
275 // These are the unmapped / physical detector coordinates of the SP inner layer.
276 DetectorZone m_pairedDetZone = DetectorZone::undefined; // barrel / posEC / negEC (0,1,2)
278 unsigned m_pairedPhysLayer = 0;
279
280 // These are the mapped versions of the inner layer in a SP.
281 unsigned m_pairedSection = 0;
282 unsigned m_pairedLayer = 0;
283
284 // --- Truth and Other ---
285 unsigned m_hw_word = 0; // store Strip and Pixel cluster positions as integers using the same FPGATrackSim_IM HW definition
286 unsigned m_ToT = 0; // time over Threshold
287 long m_eventindex = 0; // athena event index assigned to this channel
288 HepMcParticleLink::barcode_type m_barcode = 0; // geant particle barcode assigned to this channel
290 float m_barcode_pt = 0; // maximum 'pt' for any 'good' geant particle contributing to the channel.
291 // corresponds to the particle with m_barcode
292 unsigned long m_parentage_mask = 0; // ancestor information of this channel
293
295 // geant truth data (clusters only). filled during clustering using the m_barcode and
296 // m_barcode_frac data for each raw hit in the cluster.
297
298
299 // For ITk EDM encoding
300 int m_clusterIndex1ForFPGA = -1; // Index1 to keep a track of all the clusters used in track in FPGA
301 int m_clusterIndex2ForFPGA = -1; // Index2 to keep a track of all the clusters used in track in FPGA
302
303 bool m_isValidForITK = false; // Should this hit be used for ITk EDM testing
304 int m_stripRowinITKEDM = -1; // Strip hit row ID in ITk EDM format
305 int m_stripChipinITKEDM = -1; // Strip chip ID in ITk EDM format
306 int m_stripHitMapinITKEDM = -1; // Strip hit map in ITk EDM format
307
308
309 int m_roadID = 0;
310
311 std::vector<unsigned> m_IDhashVec; // for a cluster, when we get the equivalent hit info we want to store all the ID hash containing it
312 std::vector<int> m_PhiIndexVec; // for a cluster, all the phi indices in it
313 std::vector<int> m_EtaIndexVec; // for a cluster, all the eta indices in it
315};
316
317// Container of <FPGATrackSimHit const *>
318template <class Container>
319std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> sortByLayer(Container const& hits)
320{
321 std::vector<std::vector<std::shared_ptr<const FPGATrackSimHit>>> out;
322 for (auto const &hit : hits)
323 {
324 size_t layer = hit->getLayer();
325 if (layer >= out.size()) out.resize(layer + 1);
326 out[layer].push_back(hit);
327 }
328 return out;
329}
330
331
332std::ostream& operator<<(std::ostream& os, HitType t);
333std::string to_string(HitType t);
334
335#endif // FPGATrackSimHIT_H
336
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
std::vector< std::vector< std::shared_ptr< const FPGATrackSimHit > > > sortByLayer(Container const &hits)
std::string to_string(HitType t)
HitType
std::ostream & operator<<(std::ostream &os, HitType t)
SiliconTech
DetectorZone
#define y
#define x
#define z
void setRoadID(int roadID)
unsigned int getIdentifier() const
float getY() const
void setLayer(unsigned v)
unsigned getToT() const
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
unsigned getIdentifierHash() const
const std::vector< int > & getEtaIndexVec() const
HepMcParticleLink::barcode_type m_barcode
unsigned m_pairedPhysLayer
DetectorZone m_pairedDetZone
unsigned long getParentageMask() const
SiliconTech m_pairedDetType
unsigned m_pairedPhiModule
unsigned getPairedLayer() const
unsigned getPhiIndex() const
std::vector< unsigned > m_IDhashVec
void setMinEtaIndex(int v)
int getMinPhiIndex() const
void setPhiModule(unsigned v)
void addEtaIndexToVec(int eta)
unsigned long m_parentage_mask
HepMcParticleLink::barcode_type getUniqueID() const
void setIdentifierHash(unsigned v)
void setCluster1ID(int v)
float getPhiWindow() const
void setEtaIndex(unsigned v)
int getPairedEtaModule() const
void setEventIndex(long v)
unsigned getDim() const
void setPhiIndex(unsigned v)
void setStripChipIDForITk(int v)
unsigned getSide() const
void setMinPhiIndex(int v)
float getPhiCoord() const
HepMcParticleLink::barcode_type m_uniqueID
unsigned getPairedPhysLayer() const
unsigned m_layer_disk_old
std::vector< int > m_PhiIndexVec
unsigned getPairedPhiModule() const
long getEventIndex() const
float getX() const
float getCentroidPhiIndex() const
void setHitType(HitType type)
float getGPhi() const
float getBarcodePt() const
bool isBarrel() const
void setPairedSection(unsigned v)
FPGATrackSimMultiTruth m_truth
unsigned getPairedSection() const
int getEtaModule(bool old=false) const
Identifier::value_type getRdoIdentifier() const
float getZ() const
ClassDefNV(FPGATrackSimHit, 15)
unsigned int m_identifier
virtual ~FPGATrackSimHit()=default
void setPairedLayer(unsigned v)
void setPhiCoord(float v)
void setIdentifier(unsigned int v)
unsigned m_identifierHash
float getGCotTheta() const
int getStripChipIDForITk() const
std::vector< int > m_EtaIndexVec
int getMaxPhiIndex() const
int getMaxEtaIndex() const
DetectorZone getPairedDetZone() const
unsigned getPhiModule() const
void setZ(float v)
FPGATrackSimHit()=default
int getCluster1ID() const
float getR() const
SiliconTech getPairedDetType() const
bool isClustered() const
void setBarcode(const HepMcParticleLink::barcode_type &v)
unsigned getLayerDisk(bool old=false) const
unsigned getPhysLayer(bool old=false) const
friend std::ostream & operator<<(std::ostream &, const FPGATrackSimHit &)
bool isMapped() const
void setX(float v)
bool isReal() const
int getCluster2ID() const
void setisValidForITkHit(bool v)
void setPhysLayer(unsigned v)
SiliconTech m_detType
const std::vector< int > & getPhiIndexVec() const
void setCentroidPhiIndex(float v)
DetectorZone m_detectorZone
void setRdoIdentifier(Identifier::value_type v)
void setParentageMask(unsigned long v)
const FPGATrackSimHit getOriginalHit() const
SiliconTech getDetType() const
void setBarcodePt(float v)
bool isValidForITkHit() const
HepMcParticleLink::barcode_type getBarcode() const
int getRoadID() const
void setToT(unsigned v)
bool isPixel() const
void setMaxEtaIndex(int v)
void setY(float v)
void setLayerDisk(unsigned v)
void setCluster2ID(int v)
unsigned getEtaWidth() const
float getEtaCoord() const
DetectorZone getDetectorZone() const
Identifier::value_type m_rdoIdentifier
void setEtaModule(int v)
void setSection(unsigned v)
void setStripHitMapForITk(int v)
void setStripRowIDForITk(int v)
const std::vector< unsigned > & getIDHashVec() const
void setSide(unsigned v)
unsigned getSection() const
const FPGATrackSimMultiTruth & getTruth() const
void setEtaCoord(float v)
int getStripRowIDForITk() const
int getMinEtaIndex() const
int getStripHitMapForITk() const
void setMaxPhiIndex(int v)
void setTruth(const FPGATrackSimMultiTruth &v)
bool isRemapped() const
void setEtaWidth(unsigned v)
bool isStrip() const
void setPhiWidth(unsigned v)
void setUniqueID(const HepMcParticleLink::barcode_type &v)
HitType getHitType() const
void addPhiIndexToVec(int phi)
float getCentroidEtaIndex() const
void setDetectorZone(DetectorZone detZone)
unsigned getEtaIndex() const
void setCentroidEtaIndex(float v)
void setDetType(SiliconTech detType)
void addIDHashToVec(unsigned id)
unsigned getPhiWidth() const
storage of the time histories of all the cells
std::vector< std::string > mapped
Definition hcg.cxx:54