ATLAS Offline Software
Loading...
Searching...
No Matches
TruthGuidedProtoTrackCreatorTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3 */
4
7#include "Acts/Surfaces/PerigeeSurface.hpp"
9
10
12 const std::string& name,
13 const IInterface* parent)
14 : base_class(type,name,parent)
15{}
16
18{
20 return StatusCode::SUCCESS;
21}
22
24 const xAOD::PixelClusterContainer & pixelContainer,
25 const xAOD::StripClusterContainer & stripContainer,
26 std::vector<ActsTrk::ProtoTrack> & foundProtoTracks ) const {
27
28 // Read the PRD information
29 std::vector<const PRD_MultiTruthCollection*> prdMultiTruthCollections;
30 prdMultiTruthCollections.reserve(m_prdMultiTruthCollectionNames.size());
31 // load the PRD collections from SG
32 for(const auto& pmtCollNameIter:m_prdMultiTruthCollectionNames)
33 {
34 // try to retrieve the PRD multi truth collection
35 SG::ReadHandle<PRD_MultiTruthCollection> curColl (pmtCollNameIter, ctx);
36 if (!curColl.isValid())
37 {
38 ATH_MSG_WARNING("Could not retrieve " << pmtCollNameIter << ". Ignoring ... ");
39 }
40 else
41 {
42 ATH_MSG_INFO("Added " << pmtCollNameIter << " to collection list for truth track creation.");
43 prdMultiTruthCollections.push_back(curColl.cptr());
44 }
45 }
46
47 // create the map for the ine
48 std::map<Identifier, HepMC::ConstGenParticlePtr> identToHepMCMap;
49 for (auto & PRD_truthCollec: prdMultiTruthCollections )
50 {
51 // loop over the map and get the identifier, GenParticle relation
52 PRD_MultiTruthCollection::const_iterator prdMtCIter = PRD_truthCollec->begin();
53 PRD_MultiTruthCollection::const_iterator prdMtCIterE = PRD_truthCollec->end();
54 for ( ; prdMtCIter != prdMtCIterE; ++ prdMtCIter ){
55
56 // check if entry exists and if
57 HepMC::ConstGenParticlePtr curGenP = (*prdMtCIter).second.scptr();
58 Identifier curIdentifier = (*prdMtCIter).first;
59
60 // Min pT cut
61 if ( curGenP->momentum().perp() < 500. ) continue;
62
63
64
65 identToHepMCMap[curIdentifier] = curGenP;
66 }
67 }
68
69 // Now loop over the pixel and strip container and make collectiong
71 std::vector<const xAOD::UncalibratedMeasurement*>> trackCollections;
72
73 for(const auto cluster: pixelContainer)
74 {
75 // Get the idetifier list for the RDOs
76 auto identifierList = cluster->rdoList();
77
78 // Loop and push back the cluster in the corresponding trith particle
79 for(auto& id_value: identifierList)
80 {
81 Identifier id(id_value);
82 // Found a match, so push it into the track collection
83 if(identToHepMCMap.find(id) != identToHepMCMap.end())
84 {
85 auto truthParticle = identToHepMCMap.at(id);
86 trackCollections[truthParticle].emplace_back(cluster);
87 }
88 }
89 }
90
91 for(const auto cluster: stripContainer)
92 {
93 // Get the idetifier list for the RDOs
94 auto identifierList = cluster->rdoList();
95
96 // Loop and push back the cluster in the corresponding trith particle
97 for(auto& id_value: identifierList)
98 {
99 Identifier id(id_value);
100 // Found a match, so push it into the track collection
101 if(identToHepMCMap.find(id) != identToHepMCMap.end())
102 {
103 auto truthParticle = identToHepMCMap.at(id);
104 trackCollections[truthParticle].emplace_back(cluster);
105 }
106 }
107 }
108
109 for(const auto& var: trackCollections)
110 {
111 // Skip if we find less than 3 clusters per truth track
112 if(var.second.size() < 3) continue;
113
114 // Make the intput perigee
115 auto inputPerigee = makeDummyParams(var.first);
116 ATH_MSG_INFO("Found " << var.second.size() << " clusters for truth partcle "<<var.first);
117 foundProtoTracks.push_back({var.second,std::move(inputPerigee)});
118 }
119
120 // and add to the list (will only make one prototrack per event for now)
121
122 return StatusCode::SUCCESS;
123}
124
125
126std::unique_ptr<Acts::BoundTrackParameters>
128
129 using namespace Acts::UnitLiterals;
130 std::shared_ptr<const Acts::Surface> actsSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
131 Acts::Vector3(0., 0., 0.));
132 Acts::BoundVector params;
133
134
135 // No, this is not a physically correct parameter estimate!
136 // We just want a placeholder to point in roughly the expected direction...
137 // A real track finder would do something more reasonable here.
138 params << 0., 0.,
139 truthParticle->momentum().phi(), truthParticle->momentum().theta(),
140 static_cast<float>(MC::charge(truthParticle)) / (truthParticle->momentum().e()), 0.;
141
142
143 // Covariance - let's be honest and say we have no clue ;-)
144 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
145 cov *= 100000;
146
147 // some ACTS paperwork
149 float mass = Trk::ParticleMasses::mass[hypothesis] * Acts::UnitConstants::MeV;
150 Acts::PdgParticle absPdg = Acts::makeAbsolutePdgParticle(Acts::ePionPlus);
151 Acts::ParticleHypothesis actsHypothesis{
152 absPdg, mass, static_cast<float>(MC::charge(truthParticle))};
153
154 return std::make_unique<Acts::BoundTrackParameters>(actsSurface, params,
155 cov, actsHypothesis);
156
157}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
ATLAS-specific HepMC functions.
TruthGuidedProtoTrackCreatorTool(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode findProtoTracks(const EventContext &ctx, const xAOD::PixelClusterContainer &pixelContainer, const xAOD::StripClusterContainer &stripContainer, std::vector< ActsTrk::ProtoTrack > &foundProtoTracks) const override final
EF-style pattern recognition to create prototracks.
SG::ReadHandleKeyArray< PRD_MultiTruthCollection > m_prdMultiTruthCollectionNames
Truth track collection.
std::unique_ptr< Acts::BoundTrackParameters > makeDummyParams(const HepMC::ConstGenParticlePtr &truthParticle) const
creates a random, dummy set of parameters Warning: This is not a real parameter estimate.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
const_pointer_type cptr()
Dereference the pointer.
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
double charge(const T &p)
constexpr double mass[PARTICLEHYPOTHESES]
the array of masses
ParticleHypothesis
Enumeration for Particle hypothesis respecting the interaction with material.
PixelClusterContainer_v1 PixelClusterContainer
Define the version of the pixel cluster container.
StripClusterContainer_v1 StripClusterContainer
Define the version of the strip cluster container.