ATLAS Offline Software
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 
17 #include "xAODForward/AFPSiHit.h"
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 
39 StatusCode 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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
AFPSiClusterBasicObj::setCharge
void setCharge(const double charge)
Definition: AFPSiClusterBasicObj.h:64
AFPSiClusterBasicNearestNeighbour::finalize
virtual StatusCode finalize() override
does nothing
Definition: AFPSiClusterBasicNearestNeighbour.cxx:35
xAOD::AFPSiHit_v2
Class representing a hit in silicon detector.
Definition: AFPSiHit_v2.h:30
xAOD::AFPSiHit_v2::pixelHorizID
int pixelHorizID() const
Index of the pixel along X axis in LHC coordinate system.
Definition: AFPSiHit_v2.cxx:37
AFPSiClusterBasicObj.h
Full definition of AFPSiClusterBasicObj.
AFPSiClusterBasicObj
Class representing basic silicon pixels cluster, designed to be used for creating the clusters.
Definition: AFPSiClusterBasicObj.h:28
xAOD::AFPSiHit_v2::pixelVertID
int pixelVertID() const
Index of the pixel along Y axis in LHC coordinate system.
Definition: AFPSiHit_v2.cxx:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
xAOD::AFPSiHit_v2::depositedCharge
float depositedCharge() const
Charge deposited in the pixel.
test_pyathena.parent
parent
Definition: test_pyathena.py:15
AFPSiHit.h
AFPClusterAlgID.h
Definitions of identification numbers of pixel clustering algorithms.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
charge
double charge(const T &p)
Definition: AtlasPID.h:538
AFPSiClusterBasicNearestNeighbour::initialize
virtual StatusCode initialize() override
does nothing
Definition: AFPSiClusterBasicNearestNeighbour.cxx:31
AFPSiClusterBasicNearestNeighbour::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: AFPSiClusterBasicNearestNeighbour.cxx:39
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AFPSiClusterBasicObj::setVertID
void setVertID(const float vertID)
Definition: AFPSiClusterBasicObj.h:54
AFPSiClusterBasicNearestNeighbour.h
Header file for AFPSiClusterBasicNearestNeighbour used for clustering hits.
AFPSiClusterBasicNearestNeighbour::m_chargeThreshold
Gaudi::Property< float > m_chargeThreshold
Definition: AFPSiClusterBasicNearestNeighbour.h:53
AFPSiClusterBasicObj::setHorizID
void setHorizID(const float horizID)
Definition: AFPSiClusterBasicObj.h:44
AFPSiClusterBasicNearestNeighbour::AFPSiClusterBasicNearestNeighbour
AFPSiClusterBasicNearestNeighbour(const std::string &type, const std::string &name, const IInterface *parent)
Definition: AFPSiClusterBasicNearestNeighbour.cxx:25
xAOD::AFPClusterAlgID::nearestNeighbour
static const int nearestNeighbour
Nearest neighbour algorithm.
Definition: AFPClusterAlgID.h:49
AFPSiClusterBasicObj::hits
std::list< const xAOD::AFPSiHit * > & hits()
list of pixels used to form the cluster
Definition: AFPSiClusterBasicObj.h:72