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  switch (m_hitType)
16  {
17  case HitType::unmapped:
18  case HitType::undefined:
19  return false;
20  default:
21  return true;
22  }
23 }
24 
26 {
27  switch (m_hitType)
28  {
29  case HitType::clustered: // TODO do wildcard and guessed hits have cluster info too?
31  return true;
32  default:
33  return false;
34  }
35 }
36 
38 {
39  switch (m_hitType)
40  {
41  case HitType::unmapped:
42  case HitType::mapped:
43  case HitType::clustered:
45  return true;
46  default:
47  return false;
48  }
49 }
50 
51 // Sets using the physical layer index as defined by FPGATrackSimPlaneMap
53 {
55  {
56  m_layer_disk = v / 2;
57  m_side = v % 2;
58  }
59  else
60  {
61  m_layer_disk = v;
62  }
63 }
64 
65 // Returns the physical layer index as defined by FPGATrackSimPlaneMap
67 {
69  return 2 * m_layer_disk + m_side;
70  return m_layer_disk;
71 }
72 
73 
74 unsigned FPGATrackSimHit::getLayer() const
75 {
76  if (isMapped()) return m_layer;
77  throw std::domain_error("FPGATrackSimHit::getLayer() called on a hit with invalid type: " + to_string(m_hitType));
78 }
79 
81 {
82  if (isMapped()) return m_section;
83  throw std::domain_error("FPGATrackSimHit::getSection() called on a hit with invalid type");
84 }
85 
86 void FPGATrackSimHit::makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth) {
87  // Update coordinates. This keeps a copy of the old ones.
88  setX(x);
89  setY(y);
90  setZ(z);
91 
92  // Store the phi window.
93  m_phiWindow = window;
94 
95  // Update the truth, so we can do truth matching.
96  setTruth(new_truth);
97 
98  // Store the local coordinates of the inner hit.
99  // Having to do it this way is awkward and reinforces the need for a subclass.
100  if ((getPhysLayer() % 2) == 0) {
105  } else {
106  m_pairedEtaModule = other.getEtaModule();
107  m_pairedPhiModule = other.getPhiModule();
108  m_pairedSection = other.getSection();
109  m_pairedLayer = other.getLayer();
110  }
111 
112  // Update the type.
114 }
115 
117  // Only works for spacepoints. TODO: subclass...
118  FPGATrackSimHit original = *(this);
119  if (getHitType() != HitType::spacepoint) {
120  return *this;
121  }
122 
123  // Restore the x/y/z coordinates. That should be all we have to do!
124  original.setX(m_originalX);
125  original.setY(m_originalY);
126  original.setZ(m_originalZ);
127 
128  // Change the type... is "clustered" the right type?
129  original.setHitType(HitType::clustered);
130 
131  // Technically, we could also restore the original truth.
132 
133  return original;
134 }
135 
136 std::ostream& operator<<(std::ostream& out, const FPGATrackSimHit& hit)
137 {
138  out << "type=" << hit.m_hitType
139  << " tech=" << hit.m_detType
140  << " zone=" << hit.m_detectorZone
141  << " etamod=" << hit.getEtaModule()
142  << " phimod=" << hit.getPhiModule()
143  << " physLayer=" << hit.getPhysLayer()
144  << " eta=" << hit.getEtaCoord()
145  << " phi=" << hit.getPhiCoord();
146 
147  return out;
148 }
149 
150 
151 std::string to_string(HitType t)
152 {
153  switch (t)
154  {
155  case HitType::unmapped: return "unmapped";
156  case HitType::mapped: return "mapped";
157  case HitType::clustered: return "clustered";
158  case HitType::wildcard: return "wildcard";
159  case HitType::guessed: return "guessed";
160  case HitType::extrapolated: return "extrapolated";
161  case HitType::spacepoint: return "spacepoint";
162  default: return "undefined";
163  }
164 }
165 
166 
167 std::ostream& operator<<(std::ostream& os, HitType t)
168 {
169  return (os << to_string(t));
170 }
171 
172 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:181
FPGATrackSimHit::getSection
unsigned getSection() const
Definition: FPGATrackSimHit.cxx:80
FPGATrackSimHit::getPhiModule
unsigned getPhiModule() const
Definition: FPGATrackSimHit.h:88
SiliconTech::strip
@ strip
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer() const
Definition: FPGATrackSimHit.cxx:66
HitType::extrapolated
@ extrapolated
FPGATrackSimHit::isClustered
bool isClustered() const
Definition: FPGATrackSimHit.cxx:25
FPGATrackSimHit::m_originalY
float m_originalY
Definition: FPGATrackSimHit.h:209
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:37
FPGATrackSimHit::getLayer
unsigned getLayer() const
Definition: FPGATrackSimHit.cxx:74
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
FPGATrackSimHit::m_pairedEtaModule
int m_pairedEtaModule
Definition: FPGATrackSimHit.h:217
FPGATrackSimHit::makeSpacepoint
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
Definition: FPGATrackSimHit.cxx:86
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:128
FPGATrackSimHit::m_hitType
HitType m_hitType
Definition: FPGATrackSimHit.h:179
x
#define x
HitType::guessed
@ guessed
HitType::undefined
@ undefined
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
HitType::wildcard
@ wildcard
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:108
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:127
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:151
z
#define z
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:116
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:219
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:208
FPGATrackSimHit::setPhysLayer
void setPhysLayer(unsigned v)
Definition: FPGATrackSimHit.cxx:52
HitType
HitType
Definition: FPGATrackSimHit.h:38
ReadFromCoolCompare.os
os
Definition: ReadFromCoolCompare.py:231
FPGATrackSimHit::m_layer
int m_layer
Definition: FPGATrackSimHit.h:195
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:218
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:136
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:129
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:210
FPGATrackSimHit::m_detectorZone
DetectorZone m_detectorZone
Definition: FPGATrackSimHit.h:180
FPGATrackSimHit::m_layer_disk
unsigned m_layer_disk
Definition: FPGATrackSimHit.h:186
FPGATrackSimHit::m_pairedPhiModule
unsigned m_pairedPhiModule
Definition: FPGATrackSimHit.h:216
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:213
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:187
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:144
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:196
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54