ATLAS Offline Software
Loading...
Searching...
No Matches
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}
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 {
45 case HitType::mapped:
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
72unsigned 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
98void 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;
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();
124 m_pairedDetType = inner->getDetType();
126
127 // Update the type.
129}
130
132 // Only works for spacepoints. TODO: subclass...
133 FPGATrackSimHit original = *(this);
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?
145
146 // Technically, we could also restore the original truth.
147
148 return original;
149}
150
151std::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
166std::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
182std::ostream& operator<<(std::ostream& os, HitType t)
183{
184 return (os << to_string(t));
185}
186
187
std::string to_string(HitType t)
std::ostream & operator<<(std::ostream &out, const FPGATrackSimHit &hit)
: FPGATrackSim-specific class to represent an hit in the detector.
HitType
#define y
#define x
#define z
void makeSpacepoint(float x, float y, float z, float window, FPGATrackSimHit &other, FPGATrackSimMultiTruth &new_truth)
unsigned m_pairedPhysLayer
DetectorZone m_pairedDetZone
SiliconTech m_pairedDetType
unsigned m_pairedPhiModule
float getPhiCoord() const
unsigned m_layer_disk_old
void setHitType(HitType type)
int getEtaModule(bool old=false) const
unsigned getPhiModule() const
void setZ(float v)
FPGATrackSimHit()=default
bool isClustered() const
unsigned getPhysLayer(bool old=false) const
bool isMapped() const
void setX(float v)
bool isReal() const
void setPhysLayer(unsigned v)
SiliconTech m_detType
DetectorZone m_detectorZone
const FPGATrackSimHit getOriginalHit() const
SiliconTech getDetType() const
void setY(float v)
float getEtaCoord() const
DetectorZone getDetectorZone() const
unsigned getSection() const
void setTruth(const FPGATrackSimMultiTruth &v)
bool isRemapped() const
HitType getHitType() const