ATLAS Offline Software
Loading...
Searching...
No Matches
AFPSiClusterAllNeighbours.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
12
13
18
19// STL includes
20#include <list>
21
22// FrameWork includes
23#include "GaudiKernel/IToolSvc.h"
24
26 const std::string &name,
27 const IInterface *parent)
28 : base_class(type, name, parent) {
29}
30
32{
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
45 return StatusCode::SUCCESS;
46}
47
48StatusCode 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
108 newCluster.setHorizID(horizID/charge);
109 newCluster.setVertID(vertID/charge);
110 newCluster.setCharge(charge);
111 }
112
113
114 return StatusCode::SUCCESS;
115}
Definitions of identification numbers of pixel clustering algorithms.
Header file for AFPSiClusterAllNeighbours used for clustering hits.
Full definition of AFPSiClusterBasicObj.
#define ATH_MSG_ERROR(x)
double charge(const T &p)
Definition AtlasPID.h:997
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...
virtual StatusCode finalize() override
does nothing
Gaudi::Property< float > m_chargeThreshold
AFPSiClusterAllNeighbours(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
does nothing
Gaudi::Property< std::string > m_neighbourhoodType
Class representing basic silicon pixels cluster, designed to be used for creating the clusters.
void setCharge(const double charge)
std::list< const xAOD::AFPSiHit * > & hits()
list of pixels used to form the cluster
void setVertID(const float vertID)
void setHorizID(const float horizID)
static const int allNeighbours
All neighbours algorithm.
AFPSiHit_v2 AFPSiHit
Definition AFPSiHit.h:12