Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
FPGATrackSimGNNGraphHitSelectorTool.cxx
Go to the documentation of this file.
1 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
4 
5 #include "TMath.h"
6 #include <cmath>
7 
9 // AthAlgTool
10 
11 FPGATrackSimGNNGraphHitSelectorTool::FPGATrackSimGNNGraphHitSelectorTool(const std::string& algname, const std::string &name, const IInterface *ifc)
12  : AthAlgTool(algname, name, ifc) {}
13 
15 // Functions
16 
17 StatusCode FPGATrackSimGNNGraphHitSelectorTool::selectHits(const std::vector<std::shared_ptr<const FPGATrackSimHit>> & hits, std::vector<std::shared_ptr<FPGATrackSimGNNHit>> & graph_hits)
18 {
19  // Not all FPGATrackSimHits will be passed to our GNN Pipeline
20  // So we need to select the hits that we want
21  // For pixel, this is all the same
22  // For strip, we only want to keep one spacepoint for the two clusters. However, we also need to keep the position of both clusters (necessary input for the GNN)
23 
24  for (unsigned long int i = 0; i < hits.size(); i++) {
25  // For pixel, the hit = SP = cluster_1 = cluster_2
26  if(hits[i]->isPixel() && to_string(hits[i]->getHitType()) == "clustered") {
27  std::shared_ptr<FPGATrackSimGNNHit> graph_hit = std::make_shared<FPGATrackSimGNNHit>();
28  graph_hit->setHitID(i);
29  graph_hit->setIdentifier(hits[i]->getIdentifier());
30  graph_hit->setX(hits[i]->getX());
31  graph_hit->setY(hits[i]->getY());
32  graph_hit->setZ(hits[i]->getZ());
33  graph_hit->setR(hits[i]->getR());
34  graph_hit->setPhi(hits[i]->getGPhi());
35  graph_hit->setEta(getEta(hits[i]));
36  graph_hit->setCluster1X(hits[i]->getX());
37  graph_hit->setCluster1Y(hits[i]->getY());
38  graph_hit->setCluster1Z(hits[i]->getZ());
39  graph_hit->setCluster1R(hits[i]->getR());
40  graph_hit->setCluster1Phi(hits[i]->getGPhi());
41  graph_hit->setCluster1Eta(graph_hit->getEta());
42  graph_hit->setCluster2X(hits[i]->getX());
43  graph_hit->setCluster2Y(hits[i]->getY());
44  graph_hit->setCluster2Z(hits[i]->getZ());
45  graph_hit->setCluster2R(hits[i]->getR());
46  graph_hit->setCluster2Phi(hits[i]->getGPhi());
47  graph_hit->setCluster2Eta(graph_hit->getEta());
48  graph_hits.emplace_back(graph_hit);
49  }
50  // For strip, two clusters -> one spacepoint -> duplicate SP record in the hit
51  // This means we are ignoring single clusters in the strip that are labeled as hits (need to discuss if this is bad or not)
52  else if(i+1 < hits.size() && hits[i]->isStrip() && hits[i+1]->isStrip() && to_string(hits[i]->getHitType()) == "spacepoint" && to_string(hits[i+1]->getHitType()) == "spacepoint" && hits[i]->getX() == hits[i+1]->getX()) {
53  std::shared_ptr<FPGATrackSimGNNHit> graph_hit = std::make_shared<FPGATrackSimGNNHit>();
54  std::shared_ptr<const FPGATrackSimHit> cluster1_hit = std::make_shared<FPGATrackSimHit>(hits[i]->getOriginalHit());
55  std::shared_ptr<const FPGATrackSimHit> cluster2_hit = std::make_shared<FPGATrackSimHit>(hits[i+1]->getOriginalHit());
56  graph_hit->setHitID(i);
57  graph_hit->setIdentifier(hits[i]->getIdentifier());
58  graph_hit->setX(hits[i]->getX());
59  graph_hit->setY(hits[i]->getY());
60  graph_hit->setZ(hits[i]->getZ());
61  graph_hit->setR(hits[i]->getR());
62  graph_hit->setPhi(hits[i]->getGPhi());
63  graph_hit->setEta(getEta(hits[i]));
64  graph_hit->setCluster1X(cluster1_hit->getX());
65  graph_hit->setCluster1Y(cluster1_hit->getY());
66  graph_hit->setCluster1Z(cluster1_hit->getZ());
67  graph_hit->setCluster1R(cluster1_hit->getR());
68  graph_hit->setCluster1Phi(cluster1_hit->getGPhi());
69  graph_hit->setCluster1Eta(getEta(cluster1_hit));
70  graph_hit->setCluster2X(cluster2_hit->getX());
71  graph_hit->setCluster2Y(cluster2_hit->getY());
72  graph_hit->setCluster2Z(cluster2_hit->getZ());
73  graph_hit->setCluster2R(cluster2_hit->getR());
74  graph_hit->setCluster2Phi(cluster2_hit->getGPhi());
75  graph_hit->setCluster2Eta(getEta(cluster2_hit));
76  graph_hits.emplace_back(graph_hit);
77  }
78  }
79 
80  return StatusCode::SUCCESS;
81 }
82 
83 float FPGATrackSimGNNGraphHitSelectorTool::getEta(const std::shared_ptr<const FPGATrackSimHit> & hit)
84 {
85  float r3 = std::sqrt(hit->getR()*hit->getR() + hit->getZ()*hit->getZ());
86  float theta = 0.5 * TMath::ACos(hit->getZ() / r3);
87  float eta = -1.0 * TMath::Log(TMath::Tan(theta));
88  return eta;
89 }
getMenu.algname
algname
Definition: getMenu.py:54
TRTCalib_Extractor.hits
hits
Definition: TRTCalib_Extractor.py:35
FPGATrackSimGNNHit::setIdentifier
void setIdentifier(unsigned long int v)
Definition: FPGATrackSimGNNHit.h:28
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:83
FPGATrackSimGNNHit::setX
void setX(float v)
Definition: FPGATrackSimGNNHit.h:35
FPGATrackSimHit::getX
float getX() const
Definition: FPGATrackSimHit.h:140
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:75
FPGATrackSimGNNGraphHitSelectorTool::getEta
float getEta(const std::shared_ptr< const FPGATrackSimHit > &hit)
Definition: FPGATrackSimGNNGraphHitSelectorTool.cxx:83
FPGATrackSimGNNHit::setCluster1Eta
void setCluster1Eta(float v)
Definition: FPGATrackSimGNNHit.h:55
FPGATrackSimGNNHit::setCluster2Z
void setCluster2Z(float v)
Definition: FPGATrackSimGNNHit.h:65
FPGATrackSimHit::getGPhi
float getGPhi() const
Definition: FPGATrackSimHit.h:144
FPGATrackSimGNNHit::setCluster1X
void setCluster1X(float v)
Definition: FPGATrackSimGNNHit.h:50
lumiFormat.i
int i
Definition: lumiFormat.py:85
FPGATrackSimGNNHit::getEta
float getEta() const
Definition: FPGATrackSimGNNHit.h:46
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
FPGATrackSimGNNHit::setCluster1R
void setCluster1R(float v)
Definition: FPGATrackSimGNNHit.h:53
FPGATrackSimGNNHit::setCluster1Z
void setCluster1Z(float v)
Definition: FPGATrackSimGNNHit.h:52
FPGATrackSimGNNGraphHitSelectorTool::selectHits
virtual StatusCode selectHits(const std::vector< std::shared_ptr< const FPGATrackSimHit >> &hits, std::vector< std::shared_ptr< FPGATrackSimGNNHit >> &graph_hits)
Definition: FPGATrackSimGNNGraphHitSelectorTool.cxx:17
FPGATrackSimGNNHit::setCluster2Y
void setCluster2Y(float v)
Definition: FPGATrackSimGNNHit.h:64
FPGATrackSimHit::getY
float getY() const
Definition: FPGATrackSimHit.h:141
FPGATrackSimGNNHit::setHitID
void setHitID(unsigned int hitID)
Definition: FPGATrackSimGNNHit.h:27
FPGATrackSimHit::getZ
float getZ() const
Definition: FPGATrackSimHit.h:142
FPGATrackSimGNNHit::setEta
void setEta(float v)
Definition: FPGATrackSimGNNHit.h:40
FPGATrackSimGNNHit::setY
void setY(float v)
Definition: FPGATrackSimGNNHit.h:36
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
FPGATrackSimGNNHit::setCluster2R
void setCluster2R(float v)
Definition: FPGATrackSimGNNHit.h:66
FPGATrackSimGNNGraphHitSelectorTool.h
Implements hit selection as a tool for graph construction for GNN pipeline.
FPGATrackSimGNNHit::setCluster2Eta
void setCluster2Eta(float v)
Definition: FPGATrackSimGNNHit.h:68
FPGATrackSimGNNGraphHitSelectorTool::FPGATrackSimGNNGraphHitSelectorTool
FPGATrackSimGNNGraphHitSelectorTool(const std::string &, const std::string &, const IInterface *)
Definition: FPGATrackSimGNNGraphHitSelectorTool.cxx:11
FPGATrackSimHit::getR
float getR() const
Definition: FPGATrackSimHit.h:143
FPGATrackSimGNNHit::setCluster1Y
void setCluster1Y(float v)
Definition: FPGATrackSimGNNHit.h:51
FPGATrackSimGNNHit::setCluster2Phi
void setCluster2Phi(float v)
Definition: FPGATrackSimGNNHit.h:67
FPGATrackSimGNNHit::setZ
void setZ(float v)
Definition: FPGATrackSimGNNHit.h:37
FPGATrackSimGNNHit::setR
void setR(float v)
Definition: FPGATrackSimGNNHit.h:38
FPGATrackSimGNNHit::setPhi
void setPhi(float v)
Definition: FPGATrackSimGNNHit.h:39
FPGATrackSimGNNHit::setCluster2X
void setCluster2X(float v)
Definition: FPGATrackSimGNNHit.h:63
AthAlgTool
Definition: AthAlgTool.h:26
FPGATrackSimGNNHit::setCluster1Phi
void setCluster1Phi(float v)
Definition: FPGATrackSimGNNHit.h:54