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#ifdef HEPMC3
58 HepMC::ConstGenParticlePtr curGenP = (*prdMtCIter).second.scptr();
59#else
60//AV Looks like an implicit conversion
61 HepMC::ConstGenParticlePtr curGenP = (*prdMtCIter).second;
62#endif
63 Identifier curIdentifier = (*prdMtCIter).first;
64
65 // Min pT cut
66 if ( curGenP->momentum().perp() < 500. ) continue;
67
68
69
70 identToHepMCMap[curIdentifier] = curGenP;
71 }
72 }
73
74 // Now loop over the pixel and strip container and make collectiong
75 std::map<HepMC::ConstGenParticlePtr, std::vector<ActsTrk::ATLASUncalibSourceLink>> trackCollections;
76
77 for(const auto cluster: pixelContainer)
78 {
79 // Get the idetifier list for the RDOs
80 auto identifierList = cluster->rdoList();
81
82 // Loop and push back the cluster in the corresponding trith particle
83 for(auto& id_value: identifierList)
84 {
85 Identifier id(id_value);
86 // Found a match, so push it into the track collection
87 if(identToHepMCMap.find(id) != identToHepMCMap.end())
88 {
89 auto truthParticle = identToHepMCMap.at(id);
90 trackCollections[truthParticle].emplace_back(makeATLASUncalibSourceLink(&pixelContainer, cluster, ctx));
91 }
92 }
93 }
94
95 for(const auto cluster: stripContainer)
96 {
97 // Get the idetifier list for the RDOs
98 auto identifierList = cluster->rdoList();
99
100 // Loop and push back the cluster in the corresponding trith particle
101 for(auto& id_value: identifierList)
102 {
103 Identifier id(id_value);
104 // Found a match, so push it into the track collection
105 if(identToHepMCMap.find(id) != identToHepMCMap.end())
106 {
107 auto truthParticle = identToHepMCMap.at(id);
108 trackCollections[truthParticle].emplace_back(makeATLASUncalibSourceLink(&stripContainer, cluster, ctx));
109 }
110 }
111 }
112
113 for(const auto& var: trackCollections)
114 {
115 // Skip if we find less than 3 clusters per truth track
116 if(var.second.size() < 3) continue;
117
118 // Make the intput perigee
119 auto inputPerigee = makeDummyParams(var.first);
120 ATH_MSG_INFO("Found " << var.second.size() << " clusters for truth partcle "<<var.first);
121 foundProtoTracks.push_back({var.second,std::move(inputPerigee)});
122 }
123
124 // and add to the list (will only make one prototrack per event for now)
125
126 return StatusCode::SUCCESS;
127}
128
129
130std::unique_ptr<Acts::BoundTrackParameters>
132
133 using namespace Acts::UnitLiterals;
134 std::shared_ptr<const Acts::Surface> actsSurface = Acts::Surface::makeShared<Acts::PerigeeSurface>(
135 Acts::Vector3(0., 0., 0.));
136 Acts::BoundVector params;
137
138
139 // No, this is not a physically correct parameter estimate!
140 // We just want a placeholder to point in roughly the expected direction...
141 // A real track finder would do something more reasonable here.
142 params << 0., 0.,
143 truthParticle->momentum().phi(), truthParticle->momentum().theta(),
144 static_cast<float>(MC::charge(truthParticle)) / (truthParticle->momentum().e()), 0.;
145
146
147 // Covariance - let's be honest and say we have no clue ;-)
148 Acts::BoundMatrix cov = Acts::BoundMatrix::Identity();
149 cov *= 100000;
150
151 // some ACTS paperwork
153 float mass = Trk::ParticleMasses::mass[hypothesis] * Acts::UnitConstants::MeV;
154 Acts::PdgParticle absPdg = Acts::makeAbsolutePdgParticle(Acts::ePionPlus);
155 Acts::ParticleHypothesis actsHypothesis{
156 absPdg, mass, static_cast<float>(MC::charge(truthParticle))};
157
158 return std::make_unique<Acts::BoundTrackParameters>(actsSurface, params,
159 cov, actsHypothesis);
160
161}
#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.
ATLASUncalibSourceLink makeATLASUncalibSourceLink(const xAOD::UncalibratedMeasurementContainer *container, std::size_t index, const EventContext &ctx)
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
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.