Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
87 unsigned FPGATrackSimHit::getLayer() const
88 {
89  if (isMapped() || (m_hitType == HitType::guessed)) return m_layer;
90  throw std::domain_error("FPGATrackSimHit::getLayer() called on a hit with invalid type: " + to_string(m_hitType));
91 }
92 
94 {
95  if (isMapped()) return m_section;
96  throw std::domain_error("FPGATrackSimHit::getSection() called on a hit with invalid type");
97 }
98 
99 void FPGATrackSimHit::makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit& other, FPGATrackSimMultiTruth& new_truth) {
100  // Update coordinates. This keeps a copy of the old ones.
101  setX(x);
102  setY(y);
103  setZ(z);
104 
105  // Store the phi window.
106  m_phiWindow = window;
107 
108  // Update the truth, so we can do truth matching.
109  setTruth(new_truth);
110 
111  // Store the local coordinates of the inner hit.
112  // the need for a subclass in the futer should be considered.
113  const FPGATrackSimHit* inner = ((getPhysLayer() % 2) == 0) ? this : &other;
114  m_pairedEtaModule = inner->getEtaModule();
115  m_pairedPhiModule = inner->getPhiModule();
116 
117  // If the hit is unmapped we need to store the physical
118  // layer coordinates, and when the hit *becomes* mapped, update the paired logical layer too.
119  if (isMapped()) {
120  m_pairedSection = inner->getSection();
121  m_pairedLayer = inner->getLayer();
122  }
123  if ( m_hitType == HitType::spacepoint) m_layer = inner->getLayer();
124  m_pairedDetZone = inner->getDetectorZone();
125  m_pairedDetType = inner->getDetType();
126  m_pairedPhysLayer = inner->getPhysLayer();
127 
128  // Update the type.
130 }
131 
133  // Only works for spacepoints. TODO: subclass...
134  FPGATrackSimHit original = *(this);
135  if (getHitType() != HitType::spacepoint) {
136  return *this;
137  }
138 
139  // Restore the x/y/z coordinates. That should be all we have to do!
140  original.setX(m_originalX);
141  original.setY(m_originalY);
142  original.setZ(m_originalZ);
143 
144  // Change the type... is "clustered" the right type?
145  original.setHitType(HitType::clustered);
146 
147  // Technically, we could also restore the original truth.
148 
149  return original;
150 }
151 
152 std::ostream& operator<<(std::ostream& out, const FPGATrackSimHit& hit)
153 {
154  out << "type=" << hit.m_hitType
155  << " tech=" << hit.m_detType
156  << " zone=" << hit.m_detectorZone
157  << " etamod=" << hit.getEtaModule()
158  << " phimod=" << hit.getPhiModule()
159  << " physLayer=" << hit.getPhysLayer()
160  << " eta=" << hit.getEtaCoord()
161  << " phi=" << hit.getPhiCoord();
162 
163  return out;
164 }
165 
166 
167 std::string to_string(HitType t)
168 {
169  switch (t)
170  {
171  case HitType::unmapped: return "unmapped";
172  case HitType::mapped: return "mapped";
173  case HitType::clustered: return "clustered";
174  case HitType::wildcard: return "wildcard";
175  case HitType::guessed: return "guessed";
176  case HitType::extrapolated: return "extrapolated";
177  case HitType::spacepoint: return "spacepoint";
178  default: return "undefined";
179  }
180 }
181 
182 
183 std::ostream& operator<<(std::ostream& os, HitType t)
184 {
185  return (os << to_string(t));
186 }
187 
188 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:209
FPGATrackSimHit::getSection
unsigned getSection() const
Definition: FPGATrackSimHit.cxx:93
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:246
FPGATrackSimHit::isReal
bool isReal() const
Definition: FPGATrackSimHit.cxx:40
FPGATrackSimHit::getLayer
unsigned getLayer() const
Definition: FPGATrackSimHit.cxx:87
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
FPGATrackSimHit::m_pairedEtaModule
int m_pairedEtaModule
Definition: FPGATrackSimHit.h:254
FPGATrackSimHit::makeSpacepoint
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
Definition: FPGATrackSimHit.cxx:99
HitType::spacepoint
@ spacepoint
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
FPGATrackSimHit::setY
void setY(float v)
Definition: FPGATrackSimHit.h:138
FPGATrackSimHit::m_hitType
HitType m_hitType
Definition: FPGATrackSimHit.h:207
x
#define x
HitType::guessed
@ guessed
FPGATrackSimHit::m_pairedDetZone
DetectorZone m_pairedDetZone
Definition: FPGATrackSimHit.h:257
FPGATrackSimHit::m_side_old
unsigned m_side_old
Definition: FPGATrackSimHit.h:217
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:259
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:137
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:167
z
#define z
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:132
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:263
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:245
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:226
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:59
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:262
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:152
FPGATrackSimHit::m_layer_disk_old
unsigned m_layer_disk_old
Definition: FPGATrackSimHit.h:215
FPGATrackSimHit::setZ
void setZ(float v)
Definition: FPGATrackSimHit.h:139
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:247
CSV_InDetExporter.old
old
Definition: CSV_InDetExporter.py:145
FPGATrackSimHit::m_detectorZone
DetectorZone m_detectorZone
Definition: FPGATrackSimHit.h:208
FPGATrackSimHit::m_layer_disk
unsigned m_layer_disk
Definition: FPGATrackSimHit.h:214
FPGATrackSimHit::m_pairedPhiModule
unsigned m_pairedPhiModule
Definition: FPGATrackSimHit.h:253
FPGATrackSimHit::getDetType
SiliconTech getDetType() const
Definition: FPGATrackSimHit.h:58
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:250
FPGATrackSimHit::m_pairedDetType
SiliconTech m_pairedDetType
Definition: FPGATrackSimHit.h:258
FPGATrackSimHit::m_isRemapped
bool m_isRemapped
Definition: FPGATrackSimHit.h:230
FPGATrackSimHit::getPhysLayer
unsigned getPhysLayer(bool old=false) const
Definition: FPGATrackSimHit.cxx:72
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:216
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:154
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:227
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54