ATLAS Offline Software
Loading...
Searching...
No Matches
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
11FPGATrackSimGNNGraphHitSelectorTool::FPGATrackSimGNNGraphHitSelectorTool(const std::string& algname, const std::string &name, const IInterface *ifc)
12 : AthAlgTool(algname, name, ifc) {}
13
15// Functions
16
17StatusCode 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
83float 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}
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
Implements hit selection as a tool for graph construction for GNN pipeline.
static std::string to_string(const std::vector< T > &v)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
FPGATrackSimGNNGraphHitSelectorTool(const std::string &, const std::string &, const IInterface *)
virtual StatusCode selectHits(const std::vector< std::shared_ptr< const FPGATrackSimHit > > &hits, std::vector< std::shared_ptr< FPGATrackSimGNNHit > > &graph_hits)
float getEta(const std::shared_ptr< const FPGATrackSimHit > &hit)