ATLAS Offline Software
FPGATrackSimHit.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 
7 
8 #include <stdexcept>
9 
10 
11 
12 
14 {
15  if(m_layer>=0){
16  return true;
17  }
18  return false;
19 }
21 {
22  return m_isRemapped;
23 }
25 {
26  m_isRemapped=true;
27 }
29 {
30  switch (m_hitType)
31  {
32  case HitType::clustered: // TODO do wildcard and guessed hits have cluster info too?
34  return true;
35  default:
36  return false;
37  }
38 }
39 
41 {
42  switch (m_hitType)
43  {
44  case HitType::unmapped:
45  case HitType::mapped:
46  case HitType::clustered:
48  return true;
49  default:
50  return false;
51  }
52 }
53 
54 // Sets using the physical layer index as defined by FPGATrackSimPlaneMap
56 {
58  {
59  m_layer_disk = v / 2;
60  m_side = v % 2;
61  }
62  else
63  {
64  m_layer_disk = v;
65  }
66 }
67 
68 // Returns the physical layer index as defined by FPGATrackSimPlaneMap
70 {
72  return 2 * m_layer_disk + m_side;
73  return m_layer_disk;
74 }
75 
76 
77 unsigned FPGATrackSimHit::getLayer() const
78 {
79  if (isMapped()) return m_layer;
80  throw std::domain_error("FPGATrackSimHit::getLayer() called on a hit with invalid type: " + to_string(m_hitType));
81 }
82 
84 {
85  if (isMapped()) return m_section;
86  throw std::domain_error("FPGATrackSimHit::getSection() called on a hit with invalid type");
87 }
88 
89 void FPGATrackSimHit::makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth) {
90  // Update coordinates. This keeps a copy of the old ones.
91  setX(x);
92  setY(y);
93  setZ(z);
94 
95  // Store the phi window.
96  m_phiWindow = window;
97 
98  // Update the truth, so we can do truth matching.
99  setTruth(new_truth);
100 
101  // Store the local coordinates of the inner hit.
102  // the need for a subclass in the futer should be considered.
103  const FPGATrackSimHit* inner = ((getPhysLayer() % 2) == 0) ? this : &other;
104  m_pairedEtaModule = inner->getEtaModule();
105  m_pairedPhiModule = inner->getPhiModule();
106 
107  // If the hit is unmapped we need to store the physical
108  // layer coordinates, and when the hit *becomes* mapped, update the paired logical layer too.
109  if (isMapped()) {
110  m_pairedSection = inner->getSection();
111  m_pairedLayer = inner->getLayer();
112  }
113 
114  m_pairedDetZone = inner->getDetectorZone();
115  m_pairedDetType = inner->getDetType();
116  m_pairedPhysLayer = inner->getPhysLayer();
117 
118 
119  // Update the type.
121 }
122 
124  // Only works for spacepoints. TODO: subclass...
125  FPGATrackSimHit original = *(this);
126  if (getHitType() != HitType::spacepoint) {
127  return *this;
128  }
129 
130  // Restore the x/y/z coordinates. That should be all we have to do!
131  original.setX(m_originalX);
132  original.setY(m_originalY);
133  original.setZ(m_originalZ);
134 
135  // Change the type... is "clustered" the right type?
136  original.setHitType(HitType::clustered);
137 
138  // Technically, we could also restore the original truth.
139 
140  return original;
141 }
142 
143 std::ostream& operator<<(std::ostream& out, const FPGATrackSimHit& hit)
144 {
145  out << "type=" << hit.m_hitType
146  << " tech=" << hit.m_detType
147  << " zone=" << hit.m_detectorZone
148  << " etamod=" << hit.getEtaModule()
149  << " phimod=" << hit.getPhiModule()
150  << " physLayer=" << hit.getPhysLayer()
151  << " eta=" << hit.getEtaCoord()
152  << " phi=" << hit.getPhiCoord();
153 
154  return out;
155 }
156 
157 
158 std::string to_string(HitType t)
159 {
160  switch (t)
161  {
162  case HitType::unmapped: return "unmapped";
163  case HitType::mapped: return "mapped";
164  case HitType::clustered: return "clustered";
165  case HitType::wildcard: return "wildcard";
166  case HitType::guessed: return "guessed";
167  case HitType::extrapolated: return "extrapolated";
168  case HitType::spacepoint: return "spacepoint";
169  default: return "undefined";
170  }
171 }
172 
173 
174 std::ostream& operator<<(std::ostream& os, HitType t)
175 {
176  return (os << to_string(t));
177 }
178 
179 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:192
FPGATrackSimHit::getSection
unsigned getSection() const
Definition: FPGATrackSimHit.cxx:83
FPGATrackSimHit::getPhiModule
unsigned getPhiModule() const
Definition: FPGATrackSimHit.h:88
SiliconTech::strip
@ strip
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer() const
Definition: FPGATrackSimHit.cxx:69
HitType::extrapolated
@ extrapolated
FPGATrackSimHit::isClustered
bool isClustered() const
Definition: FPGATrackSimHit.cxx:28
FPGATrackSimHit::m_originalY
float m_originalY
Definition: FPGATrackSimHit.h:222
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
FPGATrackSimHit::getLayer
unsigned getLayer() const
Definition: FPGATrackSimHit.cxx:77
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
FPGATrackSimHit::m_pairedEtaModule
int m_pairedEtaModule
Definition: FPGATrackSimHit.h:230
FPGATrackSimHit::makeSpacepoint
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
Definition: FPGATrackSimHit.cxx:89
HitType::spacepoint
@ spacepoint
FPGATrackSimHit::getEtaModule
int getEtaModule() const
Definition: FPGATrackSimHit.h:87
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:135
FPGATrackSimHit::m_hitType
HitType m_hitType
Definition: FPGATrackSimHit.h:190
x
#define x
HitType::guessed
@ guessed
FPGATrackSimHit::m_pairedDetZone
DetectorZone m_pairedDetZone
Definition: FPGATrackSimHit.h:233
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
HitType::wildcard
@ wildcard
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:108
FPGATrackSimHit::isRemapped
bool isRemapped() const
Definition: FPGATrackSimHit.cxx:20
FPGATrackSimHit::m_pairedPhysLayer
unsigned m_pairedPhysLayer
Definition: FPGATrackSimHit.h:235
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:134
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:158
z
#define z
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:123
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:239
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:221
FPGATrackSimHit::setPhysLayer
void setPhysLayer(unsigned v)
Definition: FPGATrackSimHit.cxx:55
HitType
HitType
Definition: FPGATrackSimHit.h:38
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
FPGATrackSimHit::setRemap
void setRemap()
Definition: FPGATrackSimHit.cxx:24
FPGATrackSimHit::m_layer
int m_layer
Definition: FPGATrackSimHit.h:206
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:59
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:238
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
HitType::clustered
@ clustered
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:109
operator<<
std::ostream & operator<<(std::ostream &out, const FPGATrackSimHit &hit)
Definition: FPGATrackSimHit.cxx:143
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:136
HitType::mapped
@ mapped
python.PyAthena.v
v
Definition: PyAthena.py:154
FPGATrackSimHit::isMapped
bool isMapped() const
Definition: FPGATrackSimHit.cxx:13
InDetDD::other
@ other
Definition: InDetDD_Defs.h:16
y
#define y
FPGATrackSimHit::m_originalZ
float m_originalZ
Definition: FPGATrackSimHit.h:223
FPGATrackSimHit::m_detectorZone
DetectorZone m_detectorZone
Definition: FPGATrackSimHit.h:191
FPGATrackSimHit::m_layer_disk
unsigned m_layer_disk
Definition: FPGATrackSimHit.h:197
FPGATrackSimHit::m_pairedPhiModule
unsigned m_pairedPhiModule
Definition: FPGATrackSimHit.h:229
FPGATrackSimHit::getDetType
SiliconTech getDetType() const
Definition: FPGATrackSimHit.h:58
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:226
FPGATrackSimHit::m_pairedDetType
SiliconTech m_pairedDetType
Definition: FPGATrackSimHit.h:234
FPGATrackSimHit::m_isRemapped
bool m_isRemapped
Definition: FPGATrackSimHit.h:210
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:198
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:151
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:207
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54