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