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  {
61  m_layer_disk = v / 2;
62  m_side = v % 2;
63  }
64  else
65  {
67  m_layer_disk = v;
68  }
69 }
70 
71 // Returns the physical layer index as defined by FPGATrackSimPlaneMap
72 unsigned FPGATrackSimHit::getPhysLayer(bool old) const
73 {
74  if (old && isRemapped()) {
76  return 2 * m_layer_disk_old + m_side_old;
77  return m_layer_disk_old;
78  }
79  else {
81  return 2 * m_layer_disk + m_side;
82  return m_layer_disk;
83  }
84 }
85 
86 
88 {
89  return m_layer;
90 }
91 
93 {
94  if (isMapped()) return m_section;
95  throw std::domain_error("FPGATrackSimHit::getSection() called on a hit with invalid type");
96 }
97 
98 void FPGATrackSimHit::makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth) {
99  // Update coordinates. This keeps a copy of the old ones.
100  setX(x);
101  setY(y);
102  setZ(z);
103 
104  // Store the phi window.
105  m_phiWindow = window;
106 
107  // Update the truth, so we can do truth matching.
108  setTruth(new_truth);
109 
110  // Store the local coordinates of the inner hit.
111  // the need for a subclass in the futer should be considered.
112  const FPGATrackSimHit* inner = ((getPhysLayer() % 2) == 0) ? this : &other;
113  m_pairedEtaModule = inner->getEtaModule();
114  m_pairedPhiModule = inner->getPhiModule();
115 
116  // If the hit is unmapped we need to store the physical
117  // layer coordinates, and when the hit *becomes* mapped, update the paired logical layer too.
118  if (isMapped()) {
119  m_pairedSection = inner->getSection();
120  m_pairedLayer = inner->getLayer();
121  }
122  if ( m_hitType == HitType::spacepoint) m_layer = inner->getLayer();
123  m_pairedDetZone = inner->getDetectorZone();
124  m_pairedDetType = inner->getDetType();
125  m_pairedPhysLayer = inner->getPhysLayer();
126 
127  // Update the type.
129 }
130 
132  // Only works for spacepoints. TODO: subclass...
133  FPGATrackSimHit original = *(this);
134  if (getHitType() != HitType::spacepoint) {
135  return *this;
136  }
137 
138  // Restore the x/y/z coordinates. That should be all we have to do!
139  original.setX(m_originalX);
140  original.setY(m_originalY);
141  original.setZ(m_originalZ);
142 
143  // Change the type... is "clustered" the right type?
144  original.setHitType(HitType::clustered);
145 
146  // Technically, we could also restore the original truth.
147 
148  return original;
149 }
150 
151 std::ostream& operator<<(std::ostream& out, const FPGATrackSimHit& hit)
152 {
153  out << "type=" << hit.m_hitType
154  << " tech=" << hit.m_detType
155  << " zone=" << hit.m_detectorZone
156  << " etamod=" << hit.getEtaModule()
157  << " phimod=" << hit.getPhiModule()
158  << " physLayer=" << hit.getPhysLayer()
159  << " eta=" << hit.getEtaCoord()
160  << " phi=" << hit.getPhiCoord();
161 
162  return out;
163 }
164 
165 
166 std::string to_string(HitType t)
167 {
168  switch (t)
169  {
170  case HitType::unmapped: return "unmapped";
171  case HitType::mapped: return "mapped";
172  case HitType::clustered: return "clustered";
173  case HitType::wildcard: return "wildcard";
174  case HitType::guessed: return "guessed";
175  case HitType::extrapolated: return "extrapolated";
176  case HitType::spacepoint: return "spacepoint";
177  default: return "undefined";
178  }
179 }
180 
181 
182 std::ostream& operator<<(std::ostream& os, HitType t)
183 {
184  return (os << to_string(t));
185 }
186 
187 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:218
FPGATrackSimHit::getSection
unsigned getSection() const
Definition: FPGATrackSimHit.cxx:92
FPGATrackSimHit::getPhiModule
unsigned getPhiModule() const
Definition: FPGATrackSimHit.h:88
SiliconTech::strip
@ strip
FPGATrackSimHit::getEtaModule
int getEtaModule(bool old=false) const
Definition: FPGATrackSimHit.h:87
HitType::extrapolated
@ extrapolated
FPGATrackSimHit::isClustered
bool isClustered() const
Definition: FPGATrackSimHit.cxx:28
FPGATrackSimHit::m_originalY
float m_originalY
Definition: FPGATrackSimHit.h:261
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:70
FPGATrackSimHit::m_pairedEtaModule
int m_pairedEtaModule
Definition: FPGATrackSimHit.h:269
FPGATrackSimHit::makeSpacepoint
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
Definition: FPGATrackSimHit.cxx:98
HitType::spacepoint
@ spacepoint
FPGATrackSimHit::getLayer
int getLayer() const
Definition: FPGATrackSimHit.cxx:87
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:147
FPGATrackSimHit::m_hitType
HitType m_hitType
Definition: FPGATrackSimHit.h:216
x
#define x
HitType::guessed
@ guessed
FPGATrackSimHit::m_pairedDetZone
DetectorZone m_pairedDetZone
Definition: FPGATrackSimHit.h:272
FPGATrackSimHit::m_side_old
unsigned m_side_old
Definition: FPGATrackSimHit.h:226
FPGATrackSimHit
Definition: FPGATrackSimHit.h:41
HitType::wildcard
@ wildcard
FPGATrackSimHit::getPhiCoord
float getPhiCoord() const
Definition: FPGATrackSimHit.h:111
FPGATrackSimHit::isRemapped
bool isRemapped() const
Definition: FPGATrackSimHit.cxx:20
FPGATrackSimHit::m_pairedPhysLayer
unsigned m_pairedPhysLayer
Definition: FPGATrackSimHit.h:274
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:146
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:166
z
#define z
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:131
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:278
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:260
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:235
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:59
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:277
FPGATrackSimHit.h
: FPGATrackSim-specific class to represent an hit in the detector.
HitType::clustered
@ clustered
FPGATrackSimHit::getEtaCoord
float getEtaCoord() const
Definition: FPGATrackSimHit.h:112
operator<<
std::ostream & operator<<(std::ostream &out, const FPGATrackSimHit &hit)
Definition: FPGATrackSimHit.cxx:151
FPGATrackSimHit::m_layer_disk_old
unsigned m_layer_disk_old
Definition: FPGATrackSimHit.h:224
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:148
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:262
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
FPGATrackSimHit::m_detectorZone
DetectorZone m_detectorZone
Definition: FPGATrackSimHit.h:217
FPGATrackSimHit::m_layer_disk
unsigned m_layer_disk
Definition: FPGATrackSimHit.h:223
FPGATrackSimHit::m_pairedPhiModule
unsigned m_pairedPhiModule
Definition: FPGATrackSimHit.h:268
FPGATrackSimHit::getDetType
SiliconTech getDetType() const
Definition: FPGATrackSimHit.h:58
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:265
FPGATrackSimHit::m_pairedDetType
SiliconTech m_pairedDetType
Definition: FPGATrackSimHit.h:273
FPGATrackSimHit::m_isRemapped
bool m_isRemapped
Definition: FPGATrackSimHit.h:239
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer(bool old=false) const
Definition: FPGATrackSimHit.cxx:72
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:225
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:163
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:236
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54