ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
AFP
Run3AFPMonitoring
src
AFPFastReco.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
* *
4
* *
5
* * AFPFastReco.cxx
6
* *
7
* *
8
* */
9
10
#include <
Run3AFPMonitoring/AFPFastReco.h
>
11
12
#include <cmath>
13
14
namespace
AFPMon
{
15
16
void
AFPFastReco::reco
()
17
{
18
recoClusters
();
19
recoTracks
();
20
}
21
22
void
AFPFastReco::recoClusters
()
23
{
24
constexpr
float
dx = 0.25;
// [mm]
25
constexpr
float
dy = 0.05;
// [mm]
26
constexpr
float
dz = 9.00;
// [mm]
27
constexpr
float
tilt = 14. / 180. *
M_PI
;
28
29
std::list toCluster(
m_hitContainer
->begin(),
m_hitContainer
->end());
30
31
while
(!toCluster.empty())
32
{
33
const
auto
*init = *(toCluster.begin());
34
toCluster.pop_front();
35
auto
clusteredHits =
findAround
(init, toCluster);
36
37
float
sumX = 0;
38
float
sumY = 0;
39
float
sumCharge = 0;
40
int
sumToT_temp = 0;
41
for
(
const
xAOD::AFPSiHit
*
h
: clusteredHits)
42
{
43
const
float
charge
=
h
->depositedCharge();
44
const
float
pixX = dx *
h
->pixelColIDChip();
45
const
float
pixY = dy *
h
->pixelRowIDChip();
46
sumX +=
charge
* pixX;
47
sumY +=
charge
* pixY;
48
sumCharge +=
charge
;
49
sumToT_temp +=
h
->timeOverThreshold();
50
}
51
if
(sumCharge == 0.f){
52
continue
;
53
}
54
const
float
xPlane = sumX / sumCharge;
55
const
float
yPlane = sumY / sumCharge;
56
57
const
int
stationID = init->stationID();
58
const
int
layerID = init->pixelLayerID();
59
60
const
float
x
= xPlane;
61
const
float
y
= yPlane * std::cos(tilt);
62
const
float
z
= yPlane * std::sin(tilt) + dz * layerID;
63
64
m_clusters
.emplace_back(
x
,
y
,
z
, stationID, layerID, sumToT_temp);
65
}
66
}
67
68
void
AFPFastReco::recoTracks
()
69
{
70
std::list toTrack(
m_clusters
.begin(),
m_clusters
.end());
71
72
while
(!toTrack.empty())
73
{
74
auto
init = *(toTrack.begin());
75
toTrack.pop_front();
76
auto
trackCandidate =
findAround
(init, toTrack);
77
78
if
(trackCandidate.size() <
s_trackSize
)
continue
;
79
80
std::array<int, 4>
clusters
{};
81
82
std::vector<std::pair<double, double>> XZ;
83
std::vector<std::pair<double, double>> YZ;
84
85
for
(
const
auto
& cluster : trackCandidate)
86
{
87
clusters
[cluster.layer]++;
88
89
XZ.emplace_back(cluster.x, cluster.z);
90
YZ.emplace_back(cluster.y, cluster.z);
91
}
92
93
const
auto
[
x
, xSlope] =
linReg
(XZ);
94
const
auto
[
y
, ySlope] =
linReg
(YZ);
95
const
int
station = trackCandidate[0].station;
96
97
m_tracks
.emplace_back(
x
,
y
, station,
clusters
);
98
}
99
}
100
101
std::pair<double, double>
AFPFastReco::linReg
(
const
std::vector<std::pair<double, double>>& YX)
const
102
{
103
double
meanx = 0;
104
double
meany = 0;
105
for
(
const
auto
& yx : YX)
106
{
107
meany += yx.first;
108
meanx += yx.second;
109
}
110
111
meanx /= YX.size();
112
meany /= YX.size();
113
114
double
numerator = 0;
115
double
denumerator = 0;
116
for
(
const
auto
& yx : YX)
117
{
118
const
double
dy = yx.first - meany;
119
const
double
dx = yx.second - meanx;
120
numerator += dx * dy;
121
denumerator += dx * dx;
122
}
123
124
if
(denumerator==0.0) denumerator=1e-6;
125
const
double
slope = numerator / denumerator;
126
const
double
position = meany - slope * meanx;
127
128
return
{position, slope};
129
}
130
131
bool
AFPFastReco::areNeighbours
(
const
xAOD::AFPSiHit
* lhs,
const
xAOD::AFPSiHit
* rhs)
const
132
{
133
if
(lhs->
stationID
() != rhs->
stationID
())
return
false
;
134
if
(lhs->
pixelLayerID
() != rhs->
pixelLayerID
())
return
false
;
135
if
(lhs->
pixelColIDChip
() != rhs->
pixelColIDChip
())
return
false
;
136
if
(abs(lhs->
pixelRowIDChip
() - rhs->
pixelRowIDChip
()) != 1)
return
false
;
137
138
return
true
;
139
}
140
141
bool
AFPFastReco::areNeighbours
(
const
AFPCluster
& lhs,
const
AFPCluster
& rhs)
const
142
{
143
if
(lhs.
station
!= rhs.
station
)
return
false
;
144
145
const
float
dx = lhs.
x
- rhs.
x
;
146
const
float
dy = lhs.
y
- rhs.
y
;
147
return
dx * dx + dy * dy <=
s_clusterDistance
;
148
}
149
150
}
// namespace AFPMon
151
AFPFastReco.h
M_PI
#define M_PI
Definition
ActiveFraction.h:14
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
y
#define y
x
#define x
z
#define z
AFPMon::AFPFastReco::reco
void reco()
Performs fast reconstruction of clusters and tracks.
Definition
AFPFastReco.cxx:16
AFPMon::AFPFastReco::s_trackSize
static constexpr int s_trackSize
Minimum number of clusters in track.
Definition
AFPFastReco.h:101
AFPMon::AFPFastReco::recoClusters
void recoClusters()
Performs fast cluster reconstruction.
Definition
AFPFastReco.cxx:22
AFPMon::AFPFastReco::s_clusterDistance
static constexpr float s_clusterDistance
Maximum distance between cluster.
Definition
AFPFastReco.h:104
AFPMon::AFPFastReco::m_hitContainer
const xAOD::AFPSiHitContainer * m_hitContainer
Pointer to hit container.
Definition
AFPFastReco.h:86
AFPMon::AFPFastReco::m_tracks
std::vector< AFPTrack > m_tracks
Vector of tracks.
Definition
AFPFastReco.h:92
AFPMon::AFPFastReco::findAround
std::vector< T > findAround(T init, std::list< T > &toJoin) const
Finds hits/clusters around given init element.
Definition
AFPFastReco.h:107
AFPMon::AFPFastReco::recoTracks
void recoTracks()
Performs fast track reconstruction.
Definition
AFPFastReco.cxx:68
AFPMon::AFPFastReco::linReg
std::pair< double, double > linReg(const std::vector< std::pair< double, double > > &YX) const
Returns parameters of fitted line.
Definition
AFPFastReco.cxx:101
AFPMon::AFPFastReco::m_clusters
std::vector< AFPCluster > m_clusters
Vector of clusters.
Definition
AFPFastReco.h:89
AFPMon::AFPFastReco::clusters
const std::vector< AFPCluster > & clusters() const
Returns vector of clusters.
Definition
AFPFastReco.h:60
AFPMon::AFPFastReco::areNeighbours
bool areNeighbours(const xAOD::AFPSiHit *lhs, const xAOD::AFPSiHit *rhs) const
Checks if given hits are neighbours.
Definition
AFPFastReco.cxx:131
h
Header file for AthHistogramAlgorithm.
xAOD::AFPSiHit_v2::pixelColIDChip
int pixelColIDChip() const
Index of the pixel column in chip coordinate system.
xAOD::AFPSiHit_v2::stationID
int stationID() const
Index of the station with pixel hit.
xAOD::AFPSiHit_v2::pixelLayerID
int pixelLayerID() const
Index of the layer of pixels, i.e.
xAOD::AFPSiHit_v2::pixelRowIDChip
int pixelRowIDChip() const
Index of the pixel row in chip coordinate system.
AFPMon
Definition
AFPFastReco.h:12
xAOD::AFPSiHit
AFPSiHit_v2 AFPSiHit
Definition
AFPSiHit.h:12
AFPMon::AFPCluster
Definition
AFPFastReco.h:15
AFPMon::AFPCluster::station
int station
Definition
AFPFastReco.h:22
AFPMon::AFPCluster::x
float x
Definition
AFPFastReco.h:19
AFPMon::AFPCluster::y
float y
Definition
AFPFastReco.h:20
Generated on
for ATLAS Offline Software by
1.17.0