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  {
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() || (m_hitType == HitType::guessed)) 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  if ( m_hitType == HitType::spacepoint) m_layer = inner->getLayer();
114  m_pairedDetZone = inner->getDetectorZone();
115  m_pairedDetType = inner->getDetType();
116  m_pairedPhysLayer = inner->getPhysLayer();
117 
118  // Update the type.
120 }
121 
123  // Only works for spacepoints. TODO: subclass...
124  FPGATrackSimHit original = *(this);
125  if (getHitType() != HitType::spacepoint) {
126  return *this;
127  }
128 
129  // Restore the x/y/z coordinates. That should be all we have to do!
130  original.setX(m_originalX);
131  original.setY(m_originalY);
132  original.setZ(m_originalZ);
133 
134  // Change the type... is "clustered" the right type?
135  original.setHitType(HitType::clustered);
136 
137  // Technically, we could also restore the original truth.
138 
139  return original;
140 }
141 
142 std::ostream& operator<<(std::ostream& out, const FPGATrackSimHit& hit)
143 {
144  out << "type=" << hit.m_hitType
145  << " tech=" << hit.m_detType
146  << " zone=" << hit.m_detectorZone
147  << " etamod=" << hit.getEtaModule()
148  << " phimod=" << hit.getPhiModule()
149  << " physLayer=" << hit.getPhysLayer()
150  << " eta=" << hit.getEtaCoord()
151  << " phi=" << hit.getPhiCoord();
152 
153  return out;
154 }
155 
156 
157 std::string to_string(HitType t)
158 {
159  switch (t)
160  {
161  case HitType::unmapped: return "unmapped";
162  case HitType::mapped: return "mapped";
163  case HitType::clustered: return "clustered";
164  case HitType::wildcard: return "wildcard";
165  case HitType::guessed: return "guessed";
166  case HitType::extrapolated: return "extrapolated";
167  case HitType::spacepoint: return "spacepoint";
168  default: return "undefined";
169  }
170 }
171 
172 
173 std::ostream& operator<<(std::ostream& os, HitType t)
174 {
175  return (os << to_string(t));
176 }
177 
178 
FPGATrackSimHit::m_detType
SiliconTech m_detType
Definition: FPGATrackSimHit.h:209
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:243
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:251
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: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:254
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:256
FPGATrackSimHit::setX
void setX(float v)
Definition: FPGATrackSimHit.h:137
to_string
std::string to_string(HitType t)
Definition: FPGATrackSimHit.cxx:157
z
#define z
FPGATrackSimHit::getOriginalHit
const FPGATrackSimHit getOriginalHit() const
Definition: FPGATrackSimHit.cxx:122
FPGATrackSimHit::m_pairedLayer
unsigned m_pairedLayer
Definition: FPGATrackSimHit.h:260
FPGATrackSimHit::m_originalX
float m_originalX
Definition: FPGATrackSimHit.h:242
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:223
FPGATrackSimHit::getDetectorZone
DetectorZone getDetectorZone() const
Definition: FPGATrackSimHit.h:59
FPGATrackSimMultiTruth
Definition: FPGATrackSimMultiTruth.h:46
FPGATrackSimHit::m_pairedSection
unsigned m_pairedSection
Definition: FPGATrackSimHit.h:259
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:142
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:244
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:250
FPGATrackSimHit::getDetType
SiliconTech getDetType() const
Definition: FPGATrackSimHit.h:58
FPGATrackSimHit::m_phiWindow
float m_phiWindow
Definition: FPGATrackSimHit.h:247
FPGATrackSimHit::m_pairedDetType
SiliconTech m_pairedDetType
Definition: FPGATrackSimHit.h:255
FPGATrackSimHit::m_isRemapped
bool m_isRemapped
Definition: FPGATrackSimHit.h:227
FPGATrackSimHit::m_side
unsigned m_side
Definition: FPGATrackSimHit.h:215
FPGATrackSimHit::setTruth
void setTruth(const FPGATrackSimMultiTruth &v)
Definition: FPGATrackSimHit.h:154
FPGATrackSimHit::m_section
int m_section
Definition: FPGATrackSimHit.h:224
FPGATrackSimHit::getHitType
HitType getHitType() const
Definition: FPGATrackSimHit.h:57
HitType::unmapped
@ unmapped
FPGATrackSimHit::setHitType
void setHitType(HitType type)
Definition: FPGATrackSimHit.h:54