ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
ForwardDetectors
AFP
AFP_Reconstruction
AFP_SiClusterTools
src
AFPSiClusterAllNeighbours.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
12
13
14
#include "
AFP_SiClusterTools/AFPSiClusterAllNeighbours.h
"
15
#include "
AFP_SiClusterTools/AFPSiClusterBasicObj.h
"
16
#include "
xAODForward/AFPClusterAlgID.h
"
17
#include "
xAODForward/AFPSiHit.h
"
18
19
// STL includes
20
#include <list>
21
22
// FrameWork includes
23
#include "GaudiKernel/IToolSvc.h"
24
25
AFPSiClusterAllNeighbours::AFPSiClusterAllNeighbours
(
const
std::string &
type
,
26
const
std::string &name,
27
const
IInterface *parent)
28
: base_class(
type
, name, parent) {
29
}
30
31
StatusCode
AFPSiClusterAllNeighbours::initialize
()
32
{
33
if
(
m_neighbourhoodType
==
"x"
||
m_neighbourhoodType
==
"X"
)
m_doOnlyHorz
=
true
;
34
else
if
(
m_neighbourhoodType
==
"xy"
||
m_neighbourhoodType
==
"XY"
)
m_doOnlyHorz
=
false
;
35
else
36
{
37
ATH_MSG_ERROR
(
"neighbourhoodType is "
<<
m_neighbourhoodType
<<
" but allowed values are only \"X\" (only long-edge) or \"XY\" (both long- and short-edge); will abort"
);
38
return
StatusCode::FAILURE;
39
}
40
41
return
StatusCode::SUCCESS;
42
}
43
44
StatusCode
AFPSiClusterAllNeighbours::finalize
() {
45
return
StatusCode::SUCCESS;
46
}
47
48
StatusCode
AFPSiClusterAllNeighbours::doClustering
(
const
std::list<const xAOD::AFPSiHit*>& hits, std::list<AFPSiClusterBasicObj>& outputClusters)
const
49
{
50
std::list<const xAOD::AFPSiHit*> hitsAboveThreshold;
51
52
// select only hits above charge threshold
53
for
(
const
xAOD::AFPSiHit
* theHit : hits)
54
if
(theHit->depositedCharge() >
m_chargeThreshold
)
55
hitsAboveThreshold.push_back(theHit);
56
57
while
(!hitsAboveThreshold.empty())
58
{
59
// add the first hit to a new proto-cluster
60
std::list<const xAOD::AFPSiHit*> currentProtoCluster{hitsAboveThreshold.front()};
61
// and remove the hit from the list
62
hitsAboveThreshold.pop_front();
63
64
// for each hit in the growing list of hits in the current proto-cluster
65
for
(
const
xAOD::AFPSiHit
* currHit : currentProtoCluster)
66
{
67
// loop over remaining hits
68
for
(std::list<const xAOD::AFPSiHit*>::iterator remHit=hitsAboveThreshold.begin();remHit!=hitsAboveThreshold.end();)
69
{
70
if
(abs(currHit->pixelVertID()-(*remHit)->pixelVertID())<=1 && abs(currHit->pixelHorizID()-(*remHit)->pixelHorizID())<=1)
71
{
72
if
(
m_doOnlyHorz
&& currHit->pixelVertID()!=(*remHit)->pixelVertID())
73
{
74
++remHit;
75
}
76
else
77
{
78
// these hits are neighbours
79
currentProtoCluster.push_back(*remHit);
80
hitsAboveThreshold.erase(remHit++);
// move iterator first, then erase the element
81
}
82
}
83
else
84
{
85
++remHit;
86
}
87
}
88
// end loop over remaining hits, all neighbours of the current hit are added to currentProtoCluster
89
// let's continue with the next hit in currentProtoCluster, possible the one that has been just added
90
}
91
// reach end of currentProtoCluster, no more hits to be added
92
93
// calculate positions on plane and save the cluster
94
outputClusters.emplace_back(0,0,0,
xAOD::AFPClusterAlgID::allNeighbours
);
95
AFPSiClusterBasicObj
& newCluster = outputClusters.back();
96
double
horizID = 0.;
97
double
vertID = 0.;
98
double
charge
= 0.;
99
for
(
const
xAOD::AFPSiHit
* currHit : currentProtoCluster)
100
{
101
charge
+= currHit->depositedCharge();
102
horizID += currHit->pixelHorizID() * currHit->depositedCharge();
103
vertID += currHit->pixelVertID() * currHit->depositedCharge();
104
105
newCluster.
hits
().push_back(currHit);
106
}
107
if
(
charge
== 0.){
108
continue
;
109
}
110
newCluster.
setHorizID
(horizID/
charge
);
111
newCluster.
setVertID
(vertID/
charge
);
112
newCluster.
setCharge
(
charge
);
113
}
114
115
116
return
StatusCode::SUCCESS;
117
}
AFPClusterAlgID.h
Definitions of identification numbers of pixel clustering algorithms.
AFPSiClusterAllNeighbours.h
Header file for AFPSiClusterAllNeighbours used for clustering hits.
AFPSiClusterBasicObj.h
Full definition of AFPSiClusterBasicObj.
AFPSiHit.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
AFPSiClusterAllNeighbours::doClustering
virtual StatusCode doClustering(const std::list< const xAOD::AFPSiHit * > &hits, std::list< AFPSiClusterBasicObj > &outputClusters) const override
Creates a cluster from the neighbouring pixels, joining only two pixels with charge above m_chargeThr...
Definition
AFPSiClusterAllNeighbours.cxx:48
AFPSiClusterAllNeighbours::finalize
virtual StatusCode finalize() override
does nothing
Definition
AFPSiClusterAllNeighbours.cxx:44
AFPSiClusterAllNeighbours::m_doOnlyHorz
bool m_doOnlyHorz
Definition
AFPSiClusterAllNeighbours.h:58
AFPSiClusterAllNeighbours::m_chargeThreshold
Gaudi::Property< float > m_chargeThreshold
Definition
AFPSiClusterAllNeighbours.h:54
AFPSiClusterAllNeighbours::AFPSiClusterAllNeighbours
AFPSiClusterAllNeighbours(const std::string &type, const std::string &name, const IInterface *parent)
Definition
AFPSiClusterAllNeighbours.cxx:25
AFPSiClusterAllNeighbours::initialize
virtual StatusCode initialize() override
does nothing
Definition
AFPSiClusterAllNeighbours.cxx:31
AFPSiClusterAllNeighbours::m_neighbourhoodType
Gaudi::Property< std::string > m_neighbourhoodType
Definition
AFPSiClusterAllNeighbours.h:56
AFPSiClusterBasicObj
Class representing basic silicon pixels cluster, designed to be used for creating the clusters.
Definition
AFPSiClusterBasicObj.h:28
AFPSiClusterBasicObj::setCharge
void setCharge(const double charge)
Definition
AFPSiClusterBasicObj.h:64
AFPSiClusterBasicObj::hits
std::list< const xAOD::AFPSiHit * > & hits()
list of pixels used to form the cluster
Definition
AFPSiClusterBasicObj.h:72
AFPSiClusterBasicObj::setVertID
void setVertID(const float vertID)
Definition
AFPSiClusterBasicObj.h:54
AFPSiClusterBasicObj::setHorizID
void setHorizID(const float horizID)
Definition
AFPSiClusterBasicObj.h:44
xAOD::AFPClusterAlgID::allNeighbours
static const int allNeighbours
All neighbours algorithm.
Definition
AFPClusterAlgID.h:50
xAOD::AFPSiHit
AFPSiHit_v2 AFPSiHit
Definition
AFPSiHit.h:12
type
Generated on
for ATLAS Offline Software by
1.17.0