ATLAS Offline Software
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 
25 #include <vector>
26 #include <ostream>
27 
30 
31 #include <Rtypes.h>
32 #include "TMath.h"
33 
34  // Some types are inclusive of others. For example, clustered implies mapped.
36 
38 {
39 public:
40 
42  // Constructors
43 
44  FPGATrackSimHit() = default;
45  virtual ~FPGATrackSimHit() = default;
46 
48  // Getters/Setters
49 
50  // --- Hit Type ---
52  void setDetType(SiliconTech detType) { m_detType = detType; }
53  void setDetectorZone(DetectorZone detZone) { m_detectorZone = detZone; }
54  HitType getHitType() const { return m_hitType; }
55  SiliconTech getDetType() const { return m_detType; }
57 
58  bool isMapped() const;
59  bool isClustered() const;
60  bool isReal() const; // ie not wildcard or guessed
61  bool isPixel() const { return m_detType == SiliconTech::pixel; }
62  bool isStrip() const { return m_detType == SiliconTech::strip; }
63  bool isBarrel() const { return m_detectorZone == DetectorZone::barrel; }
64  unsigned getDim() const { return isPixel() ? 2 : 1; } // TODO all calls of this should be replaced with a call to plane map
65  int getRoadID() const { return m_roadID; }
66 
67  // --- Unmapped Location ---
68  void setIdentifierHash(unsigned v) { m_identifierHash = v; }
69  void setLayerDisk(unsigned v) { m_layer_disk = v; } // ITk layer number
70  void setSide(unsigned v) { m_side = v; }
71  void setPhysLayer(unsigned v); // Sets using the FPGATrackSim-defined physical layer index (see FPGATrackSimPlaneMap.h)
72  void setEtaModule(int v) { m_etaModule = v; }
73  void setPhiModule(unsigned v) { m_phiModule = v; }
74  void setEtaWidth(unsigned v) { m_etaWidth = v; }
75  void setPhiWidth(unsigned v) { m_phiWidth = v; }
76  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.
77  unsigned getLayerDisk() const { return m_layer_disk; } // ITk layer number
78  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.
79  unsigned getPhysLayer() const; // Returns the FPGATrackSim-defined physical layer index (see FPGATrackSimPlaneMap.h)
80  unsigned getEtaWidth() const { return m_etaWidth; }
81  unsigned getPhiWidth() const { return m_phiWidth; }
82  unsigned getEtaModule() const { return m_etaModule; }
83  unsigned getPhiModule() const { return m_phiModule; }
84 
85  // --- Mapped Location ---
86  // NB: isMapped() should return true to access these members
87  void setLayer(unsigned v) { m_layer = v; } // This is the logical layer
88  void setSection(unsigned v) { m_section = v; }
89  unsigned getLayer() const;
90  unsigned getSection() const;
91  void setRoadID(int roadID) { m_roadID = roadID; }
92 
93  // --- Local Coordinates ---
94  // The local coordinate is stored as an unsigned int, as in the hardware.
95  // To get the actual coordinate in units of sensor channels, use the float
96  // getCoord functions instead.
97  void setPhiIndex(unsigned v) { m_phiIndex = v; }
98  void setEtaIndex(unsigned v) { m_etaIndex = v; }
99  void setPhiCoord(float v) { m_phiIndex = v; }
100  void setEtaCoord(float v) { m_etaIndex = v; }
101  unsigned getPhiIndex() const { return m_phiIndex; }
102  unsigned getEtaIndex() const { return m_etaIndex; }
103  float getPhiCoord() const { return m_phiIndex; }
104  float getEtaCoord() const { return m_etaIndex; }
105 
106  float getPhiWindow() const { return m_phiWindow; }
107 
108  // Converts the hit into a spacepoint. Keeps copies of the local information.
109  void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth);
110 
111  // Retrieves a (copy of) the original hit with the original local coordinates used to make a SP.
112  // If not a SP, returns a copy of this hit.
113  const FPGATrackSimHit getOriginalHit() const;
114 
115  // These return coordinates for the inner hit in the pair, if a SP
116  int getPairedEtaModule() const { return m_pairedEtaModule; }
117  unsigned getPairedPhiModule() const { return m_pairedPhiModule; }
118  unsigned getPairedSection() const { return m_pairedSection; }
119  unsigned getPairedLayer() const { return m_pairedLayer; }
120 
121  // --- Global Coordinates ---
122  void setX(float v) { m_originalX = m_x; m_x = v; }
123  void setY(float v) { m_originalY = m_y; m_y = v; }
124  void setZ(float v) { m_originalZ = m_z; m_z = v; }
125  float getX() const { return m_x; }
126  float getY() const { return m_y; }
127  float getZ() const { return m_z; }
128  float getR() const { return TMath::Sqrt(m_x * m_x + m_y * m_y); } // This is cylindrical radius
129  float getGPhi() const { return TMath::ATan2(m_y, m_x); }
130  float getGCotTheta() const { return m_z / getR(); } // cot(theta) = z/r
131 
132  // --- Truth and Other ---
133  void setToT(unsigned v) { m_ToT = v; }
134  void setBarcode(unsigned long v) { m_barcode = v; }
135  void setBarcodePt(float v) { m_barcode_pt = v; }
136  void setEventIndex(long v) { m_eventindex = v; }
137  void setParentageMask(unsigned long v) { m_parentage_mask = v; }
139  unsigned long getBarcode() const { return m_barcode; }
140  long getEventIndex() const { return m_eventindex; }
141  float getBarcodePt() const { return m_barcode_pt; }
142  unsigned long getParentageMask() const { return m_parentage_mask; }
143  const FPGATrackSimMultiTruth& getTruth() const { return m_truth; }
144 
146  // Other Interface
147 
148  friend std::ostream& operator<<(std::ostream&, const FPGATrackSimHit&);
149 
150 protected:
151 
152  // --- Hit Type ---
154  DetectorZone m_detectorZone = DetectorZone::undefined; // barrel / posEC / negEC (0,1,2)
156 
157  // --- Unmapped Location ---
158  unsigned m_identifierHash = 0; // Global module ID, from ITk
159  unsigned m_layer_disk = 0; // ITk layer number
160  unsigned m_side = 0; // Side of the strip module
161  int m_etaModule = 0; // eta index of the module that the hit is located on
162  unsigned m_phiModule = 0; // phi index of the module that the hit is located on
163  unsigned m_etaWidth = 0; // clustering width along eta
164  unsigned m_phiWidth = 0; // clustering width in phi direction
165 
166  // --- Mapped Location ---
167  // isMapped() should return true to access these members
168  int m_layer = -1; // Logical layer this hit is on
169  int m_section = -1; // Index of detector element in the logical layer (see FPGATrackSimPlaneMap.h)
170 
171  // --- Local Coordinates ---
172  int m_phiIndex = -1; // phi index for pixel, strip for strip
173  int m_etaIndex = -1; // eta index for pixel, row for strip
174 
175  // --- Global Coordinates ---
176  float m_x = 0; // Hit position in global coordinates
177  float m_y = 0;
178  float m_z = 0;
179 
180  // Original X/Y/Z coordinates, if this is a spacepoint
181  float m_originalX = 0;
182  float m_originalY = 0;
183  float m_originalZ = 0;
184 
185  // Phi window used in spacepoint calculation
186  float m_phiWindow = 0;
187 
188  // These are the coordinates of the inner layer in a SP
189  unsigned m_pairedPhiModule = -1;
191  unsigned m_pairedSection = 0;
192  unsigned m_pairedLayer = 0;
193 
194  // --- Truth and Other ---
195  unsigned m_hw_word = 0; // store Strip and Pixel cluster positions as integers using the same FPGATrackSim_IM HW definition
196  unsigned m_ToT = 0; // time over Threshold
197  long m_eventindex = 0; // athena event index assigned to this channel
198  unsigned long m_barcode = 0; // geant particle barcode assigned to this channel
199  float m_barcode_pt = 0; // maximum 'pt' for any 'good' geant particle contributing to the channel.
200  // corresponds to the particle with m_barcode
201  unsigned long m_parentage_mask = 0; // ancestor information of this channel
202 
204  // geant truth data (clusters only). filled during clustering using the m_barcode and
205  // m_barcode_frac data for each raw hit in the cluster.
206 
207 
208  int m_roadID = 0;
209 
211 };
212 
213 // Container of <FPGATrackSimHit const *>
214 template <class Container>
215 std::vector<std::vector<const FPGATrackSimHit*>> sortByLayer(Container const& hits)
216 {
217  std::vector<std::vector<const FPGATrackSimHit*>> out;
218  for (FPGATrackSimHit const* hit : hits)
219  {
220  size_t layer = hit->getLayer();
221  if (layer >= out.size()) out.resize(layer + 1);
222  out[layer].push_back(hit);
223  }
224  return out;
225 }
226 
227 
228 std::ostream& operator<<(std::ostream& os, HitType t);
229 std::string to_string(HitType t);
230 
231 #endif // FPGATrackSimHIT_H
232 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:155
FPGATrackSimHit::getSection
unsigned getSection() const
Definition: FPGATrackSimHit.cxx:81
FPGATrackSimHit::getEventIndex
long getEventIndex() const
Definition: FPGATrackSimHit.h:140
FPGATrackSimHit::getPhiModule
unsigned getPhiModule() const
Definition: FPGATrackSimHit.h:83
FPGATrackSimHit::getSide
unsigned getSide() const
Definition: FPGATrackSimHit.h:78
FPGATrackSimHit::setSection
void setSection(unsigned v)
Definition: FPGATrackSimHit.h:88
SiliconTech::strip
@ strip
FPGATrackSimHit::isStrip
bool isStrip() const
Definition: FPGATrackSimHit.h:62
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer() const
Definition: FPGATrackSimHit.cxx:67
FPGATrackSimHit::ClassDef
ClassDef(FPGATrackSimHit, 5)
HitType::extrapolated
@ extrapolated
FPGATrackSimHit::isClustered
bool isClustered() const
FPGATrackSimHit::setEtaIndex
void setEtaIndex(unsigned v)
Definition: FPGATrackSimHit.h:98
FPGATrackSimHit::setPhiCoord
void setPhiCoord(float v)
Definition: FPGATrackSimHit.h:99
FPGATrackSimHit::setIdentifierHash
void setIdentifierHash(unsigned v)
Definition: FPGATrackSimHit.h:68
FPGATrackSimHit::getPairedSection
unsigned getPairedSection() const
Definition: FPGATrackSimHit.h:118
FPGATrackSimHit::m_originalY
float m_originalY
Definition: FPGATrackSimHit.h:182
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:125
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:152
FPGATrackSimHit::getBarcodePt
float getBarcodePt() const
Definition: FPGATrackSimHit.h:141
FPGATrackSimHit::isReal
bool isReal() const
operator<<
std::ostream & operator<<(std::ostream &os, HitType t)
Definition: FPGATrackSimHit.cxx:168
FPGATrackSimHit::m_eventindex
long m_eventindex
Definition: FPGATrackSimHit.h:197
FPGATrackSimHit::getLayer
unsigned getLayer() const
Definition: FPGATrackSimHit.cxx:75
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
FPGATrackSimHit::getPairedLayer
unsigned getPairedLayer() const
Definition: FPGATrackSimHit.h:119
FPGATrackSimHit::m_pairedEtaModule
int m_pairedEtaModule
Definition: FPGATrackSimHit.h:190
FPGATrackSimHit::setBarcode
void setBarcode(unsigned long v)
Definition: FPGATrackSimHit.h:134
FPGATrackSimHit::setEtaWidth
void setEtaWidth(unsigned v)
Definition: FPGATrackSimHit.h:74
FPGATrackSimHit::setSide
void setSide(unsigned v)
Definition: FPGATrackSimHit.h:70
FPGATrackSimHit::makeSpacepoint
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
Definition: FPGATrackSimHit.cxx:87
HitType::spacepoint
@ spacepoint
FPGATrackSimMultiTruth.h
FPGATrackSimHit::getDim
unsigned getDim() const
Definition: FPGATrackSimHit.h:64
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FPGATrackSimHit::getBarcode
unsigned long getBarcode() const
Definition: FPGATrackSimHit.h:139
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:123
FPGATrackSimHit::m_identifierHash
unsigned m_identifierHash
Definition: FPGATrackSimHit.h:158
FPGATrackSimHit::getLayerDisk
unsigned getLayerDisk() const
Definition: FPGATrackSimHit.h:77
FPGATrackSimHit::~FPGATrackSimHit
virtual ~FPGATrackSimHit()=default
FPGATrackSimHit::setDetectorZone
void setDetectorZone(DetectorZone detZone)
Definition: FPGATrackSimHit.h:53
FPGATrackSimHit::m_hitType
HitType m_hitType
Definition: FPGATrackSimHit.h:153
x
#define x
HitType::guessed
@ guessed
FPGATrackSimHit::getEtaModule
unsigned getEtaModule() const
Definition: FPGATrackSimHit.h:82
HitType::undefined
@ undefined
FPGATrackSimHit::m_y
float m_y
Definition: FPGATrackSimHit.h:177
FPGATrackSimHit
Definition: FPGATrackSimHit.h:38
FPGATrackSimHit::getGPhi
float getGPhi() const
Definition: FPGATrackSimHit.h:129
Container
storage of the time histories of all the cells
FPGATrackSimHit::m_etaWidth
unsigned m_etaWidth
Definition: FPGATrackSimHit.h:163
HitType::wildcard
@ wildcard
FPGATrackSimHit::getTruth
const FPGATrackSimMultiTruth & getTruth() const
Definition: FPGATrackSimHit.h:143
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:103
FPGATrackSimHit::getPairedEtaModule
int getPairedEtaModule() const
Definition: FPGATrackSimHit.h:116
FPGATrackSimHit::setDetType
void setDetType(SiliconTech detType)
Definition: FPGATrackSimHit.h:52
FPGATrackSimHit::m_barcode
unsigned long m_barcode
Definition: FPGATrackSimHit.h:198
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:122
FPGATrackSimHit::m_hw_word
unsigned m_hw_word
Definition: FPGATrackSimHit.h:195
FPGATrackSimHit::setToT
void setToT(unsigned v)
Definition: FPGATrackSimHit.h:133
FPGATrackSimHit::setPhiIndex
void setPhiIndex(unsigned v)
Definition: FPGATrackSimHit.h:97
FPGATrackSimHit::getPhiIndex
unsigned getPhiIndex() const
Definition: FPGATrackSimHit.h:101
SiliconTech
SiliconTech
Definition: FPGATrackSimTypes.h:25
z
#define z
FPGATrackSimHit::m_etaIndex
int m_etaIndex
Definition: FPGATrackSimHit.h:173
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:117
LArG4ShowerLibProcessing.hits
hits
Definition: LArG4ShowerLibProcessing.py:136
TRT::Hit::layer
@ layer
Definition: HitInfo.h:79
FPGATrackSimHit::setEtaModule
void setEtaModule(int v)
Definition: FPGATrackSimHit.h:72
FPGATrackSimHit::setEtaCoord
void setEtaCoord(float v)
Definition: FPGATrackSimHit.h:100
FPGATrackSimHit::m_z
float m_z
Definition: FPGATrackSimHit.h:178
FPGATrackSimHit::m_phiModule
unsigned m_phiModule
Definition: FPGATrackSimHit.h:162
FPGATrackSimHit::getPairedPhiModule
unsigned getPairedPhiModule() const
Definition: FPGATrackSimHit.h:117
sortByLayer
std::vector< std::vector< const FPGATrackSimHit * > > sortByLayer(Container const &hits)
Definition: FPGATrackSimHit.h:215
FPGATrackSimHit::getParentageMask
unsigned long getParentageMask() const
Definition: FPGATrackSimHit.h:142
FPGATrackSimHit::m_barcode_pt
float m_barcode_pt
Definition: FPGATrackSimHit.h:199
FPGATrackSimHit::m_ToT
unsigned m_ToT
Definition: FPGATrackSimHit.h:196
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:126
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:192
FPGATrackSimHit::setRoadID
void setRoadID(int roadID)
Definition: FPGATrackSimHit.h:91
FPGATrackSimHit::getEtaIndex
unsigned getEtaIndex() const
Definition: FPGATrackSimHit.h:102
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:181
FPGATrackSimHit::setPhysLayer
void setPhysLayer(unsigned v)
FPGATrackSimHit::setPhiModule
void setPhiModule(unsigned v)
Definition: FPGATrackSimHit.h:73
FPGATrackSimHit::getIdentifierHash
unsigned getIdentifierHash() const
Definition: FPGATrackSimHit.h:76
FPGATrackSimHit::isPixel
bool isPixel() const
Definition: FPGATrackSimHit.h:61
HitType
HitType
Definition: FPGATrackSimHit.h:35
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
FPGATrackSimHit::FPGATrackSimHit
FPGATrackSimHit()=default
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:127
FPGATrackSimHit::m_layer
int m_layer
Definition: FPGATrackSimHit.h:168
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:56
FPGATrackSimHit::setLayerDisk
void setLayerDisk(unsigned v)
Definition: FPGATrackSimHit.h:69
FPGATrackSimHit::m_phiWidth
unsigned m_phiWidth
Definition: FPGATrackSimHit.h:164
FPGATrackSimHit::m_roadID
int m_roadID
Definition: FPGATrackSimHit.h:208
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_truth
FPGATrackSimMultiTruth m_truth
Definition: FPGATrackSimHit.h:203
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:191
HitType::clustered
@ clustered
FPGATrackSimHit::setPhiWidth
void setPhiWidth(unsigned v)
Definition: FPGATrackSimHit.h:75
FPGATrackSimHit::getRoadID
int getRoadID() const
Definition: FPGATrackSimHit.h:65
FPGATrackSimHit::setEventIndex
void setEventIndex(long v)
Definition: FPGATrackSimHit.h:136
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:104
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:124
HitType::mapped
@ mapped
python.PyAthena.v
v
Definition: PyAthena.py:157
FPGATrackSimHit::isMapped
bool isMapped() const
FPGATrackSimHit::getR
float getR() const
Definition: FPGATrackSimHit.h:128
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
FPGATrackSimHit::setLayer
void setLayer(unsigned v)
Definition: FPGATrackSimHit.h:87
DetectorZone
DetectorZone
Definition: FPGATrackSimTypes.h:28
y
#define y
FPGATrackSimHit::m_originalZ
float m_originalZ
Definition: FPGATrackSimHit.h:183
FPGATrackSimHit::m_detectorZone
DetectorZone m_detectorZone
Definition: FPGATrackSimHit.h:154
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
FPGATrackSimHit::m_layer_disk
unsigned m_layer_disk
Definition: FPGATrackSimHit.h:159
FPGATrackSimHit::m_pairedPhiModule
unsigned m_pairedPhiModule
Definition: FPGATrackSimHit.h:189
FPGATrackSimHit::getDetType
SiliconTech getDetType() const
Definition: FPGATrackSimHit.h:55
DetectorZone::barrel
@ barrel
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:186
FPGATrackSimHit::getPhiWindow
float getPhiWindow() const
Definition: FPGATrackSimHit.h:106
FPGATrackSimHit::getEtaWidth
unsigned getEtaWidth() const
Definition: FPGATrackSimHit.h:80
FPGATrackSimHit::m_x
float m_x
Definition: FPGATrackSimHit.h:176
FPGATrackSimHit::m_phiIndex
int m_phiIndex
Definition: FPGATrackSimHit.h:172
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:160
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:138
FPGATrackSimHit::setParentageMask
void setParentageMask(unsigned long v)
Definition: FPGATrackSimHit.h:137
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:169
FPGATrackSimHit::isBarrel
bool isBarrel() const
Definition: FPGATrackSimHit.h:63
FPGATrackSimHit::m_etaModule
int m_etaModule
Definition: FPGATrackSimHit.h:161
FPGATrackSimTypes.h
FPGATrackSimHit::getPhiWidth
unsigned getPhiWidth() const
Definition: FPGATrackSimHit.h:81
FPGATrackSimHit::setBarcodePt
void setBarcodePt(float v)
Definition: FPGATrackSimHit.h:135
SiliconTech::undefined
@ undefined
SiliconTech::pixel
@ pixel
FPGATrackSimHit::operator<<
friend std::ostream & operator<<(std::ostream &, const FPGATrackSimHit &)
Definition: FPGATrackSimHit.cxx:137
FPGATrackSimHit::m_parentage_mask
unsigned long m_parentage_mask
Definition: FPGATrackSimHit.h:201
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:54
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:51
FPGATrackSimHit::getGCotTheta
float getGCotTheta() const
Definition: FPGATrackSimHit.h:130
DetectorZone::undefined
@ undefined
LArGeo::ATan2
GeoGenfun::FunctionNoop ATan2(GeoGenfun::GENFUNCTION y, GeoGenfun::GENFUNCTION x)
Definition: BarrelAuxFunctions.cxx:50