ATLAS Offline Software
Loading...
Searching...
No Matches
AFPSiClusterBasicNearestNeighbour.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 return StatusCode::SUCCESS;
33}
34
36 return StatusCode::SUCCESS;
37}
38
39StatusCode AFPSiClusterBasicNearestNeighbour::doClustering (const std::list<const xAOD::AFPSiHit*>& hits, std::list<AFPSiClusterBasicObj>& outputClusters) const
40{
41 std::list<const xAOD::AFPSiHit*> hitsAboveThreshold;
42
43 // select only hits above charge threshold
44 for (const xAOD::AFPSiHit* theHit : hits)
45 if (theHit->depositedCharge() > m_chargeThreshold)
46 hitsAboveThreshold.push_back(theHit);
47
48 while (!hitsAboveThreshold.empty()) {
49 const xAOD::AFPSiHit* theHit = hitsAboveThreshold.front();
50 hitsAboveThreshold.pop_front(); // remove current hit from the list
51
52 const int pixelHorizID = theHit->pixelHorizID();
53 float horizID = pixelHorizID; // value used to make cluster may be not integer
54 float vertID = theHit->pixelVertID(); // value used to make cluster may be not integer
55 float charge = theHit->depositedCharge();
56 outputClusters.emplace_back(theHit, xAOD::AFPClusterAlgID::nearestNeighbour);
57
58 const std::list<const xAOD::AFPSiHit*>::iterator neighbourEnd = hitsAboveThreshold.end();
59 std::list<const xAOD::AFPSiHit*>::iterator neighbourIter = hitsAboveThreshold.begin();
60 while (neighbourIter != neighbourEnd) {
61 const xAOD::AFPSiHit* neighbour = *neighbourIter;
62 // check if pixels are next to each other
63 if (abs(neighbour->pixelHorizID()-pixelHorizID) == 1) {
64 const float neighbourCharge = neighbour->depositedCharge();
65 // charge weighted mean position
66 horizID = (horizID*charge + neighbour->pixelHorizID()*neighbourCharge)/(charge + neighbourCharge);
67 vertID = (vertID*charge + neighbour->pixelVertID()*neighbourCharge)/(charge + neighbourCharge);
68
69 charge += neighbourCharge;
70
71 hitsAboveThreshold.erase(neighbourIter);
72
73 // update cluster before finishing the loop
74 AFPSiClusterBasicObj& theCluster = outputClusters.back();
75 theCluster.setHorizID(horizID);
76 theCluster.setVertID(vertID);
77 theCluster.setCharge(charge);
78 theCluster.hits().push_back(neighbour);
79 break;
80 }
81 ++neighbourIter;
82 }
83
84 }
85
86
87 return StatusCode::SUCCESS;
88}
Definitions of identification numbers of pixel clustering algorithms.
Header file for AFPSiClusterBasicNearestNeighbour used for clustering hits.
Full definition of AFPSiClusterBasicObj.
double charge(const T &p)
Definition AtlasPID.h:997
virtual StatusCode finalize() override
does nothing
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...
AFPSiClusterBasicNearestNeighbour(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize() override
does nothing
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 nearestNeighbour
Nearest neighbour algorithm.
float depositedCharge() const
Charge deposited in the pixel.
int pixelHorizID() const
Index of the pixel along X axis in LHC coordinate system.
int pixelVertID() const
Index of the pixel along Y axis in LHC coordinate system.
AFPSiHit_v2 AFPSiHit
Definition AFPSiHit.h:12