ATLAS Offline Software
Loading...
Searching...
No Matches
SeedToTrackConversionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
6// SeedToTrackConversionTool.cxx
8
10
16
17#include <iomanip>
18#include <iostream>
19#include <utility>
20
21//================ Constructor =================================================
22
24 const std::string& n,
25 const IInterface* p)
26 : base_class(t, n, p)
27{
28}
29
30//================ Initialisation =================================================
31
33{
34
35 StatusCode sc = AlgTool::initialize();
36 if (sc.isFailure()) return sc;
37
38 if (m_extrapolator.retrieve().isFailure()) {
39 ATH_MSG_FATAL ("Could not retrieve "<< m_extrapolator);
40 return StatusCode::FAILURE;
41 } else {
42 ATH_MSG_VERBOSE( "initialize() Retrieved service " << m_extrapolator);
43 }
44
45 // Retrieve the Track RotCreator tool
46 if (m_rotcreator.retrieve().isFailure()) {
47 ATH_MSG_FATAL ("Could not retrieve "<< m_rotcreator);
48 return StatusCode::FAILURE;
49 } else {
50 ATH_MSG_VERBOSE( "initialize() Retrieved service " << m_rotcreator);
51 }
52
53 ATH_CHECK(m_seedsegmentsOutput.initialize());
54
55 return StatusCode::SUCCESS;
56}
57
58//================ Finalisation =================================================
59
61{
62 return AlgTool::finalize();
63}
64
65void InDet::SeedToTrackConversionTool::newEvent(SeedToTrackConversionData& data, const Trk::TrackInfo& info, const std::string& patternName) const
66{
67 data.seedSegmentsCollection() = std::make_unique<TrackCollection>();
68 m_totseed = 0;
69 m_survived = 0;
70
71 data.trackInfo() = info;
72 data.patternName() = patternName;
73 if (static_cast<int>(data.patternName().find("Forward"))>-1) {
74 data.trackInfo().setPatternRecognitionInfo(Trk::TrackInfo::SiSpacePointsSeedMaker_ForwardTracks);
75 }
76}
77
79{
80 // Print event information
81 //
82 if (msgLevel()<=0) {
83 m_nprint=1;
84 dump(data, msg(MSG::DEBUG));
85 }
86
87 ATH_MSG_DEBUG(" Check SiSPSeedSegments Collection (" << m_seedsegmentsOutput << ") " << data.seedSegmentsCollection()->size() << " trackinfo: "
88 << data.trackInfo());
90 if (seedsegmentsOutput.record(std::move(data.seedSegmentsCollection())).isFailure()) {
91 ATH_MSG_ERROR("Could not save converted SiSPSeedSegments tracks");
92 }
93}
94
97 const int& mtrk,
98 const std::vector<const Trk::SpacePoint*>& Sp) const
99{
100 const EventContext& ctx = Gaudi::Hive::currentContext();
101 ++m_totseed; // accumulate all seeds
102 if (mtrk>0) ++m_survived; // survided seeds
103 std::vector<const Trk::PrepRawData*> prdsInSp;
104 for (const Trk::SpacePoint* s: Sp) {
105 const std::pair<const Trk::PrepRawData*, const Trk::PrepRawData*>& prds = s->clusterList();
106 if (prds.first) prdsInSp.push_back(prds.first);
107 if (prds.second && prds.first != prds.second) prdsInSp.push_back(prds.second);
108 }
109 Trk::PerigeeSurface persurf;
110 std::unique_ptr<Trk::TrackParameters> per(m_extrapolator->extrapolate(ctx,*Tp, persurf, Trk::anyDirection, false, Trk::nonInteracting));
111 std::unique_ptr<Trk::TrackParameters> prevpar(Tp->uniqueClone());
112 if (per) {
113 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
114 typePattern.set(Trk::TrackStateOnSurface::Perigee);
115 const Trk::TrackStateOnSurface* pertsos = new Trk::TrackStateOnSurface(nullptr, std::move(per), nullptr, typePattern);
116 auto traj = std::make_unique<Trk::TrackStates>();
117 traj->push_back(pertsos);
118 for (const Trk::PrepRawData* prd: prdsInSp) {
119 const Trk::Surface& surf = prd->detectorElement()->surface(prd->identify());
120 std::unique_ptr<Trk::TrackParameters> thispar(m_extrapolator->extrapolate(ctx,*prevpar, surf, Trk::alongMomentum, false, Trk::nonInteracting));
121 if (thispar) {
122 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern;
124 std::unique_ptr<Trk::RIO_OnTrack> rot(m_rotcreator->correct(*prd, *thispar, ctx));
125 if (rot) {
126 const Trk::TrackStateOnSurface* tsos = new Trk::TrackStateOnSurface(std::move(rot), thispar->uniqueClone(), nullptr, typePattern);
127 traj->push_back(tsos);
128 prevpar = std::move(thispar);
129 }
130 }
131 }
132
133 if (mtrk>0) { // survived seeds set as
134 data.trackInfo().setTrackFitter(Trk::TrackInfo::xKalman); // xkalman
135 } else {
136 data.trackInfo().setTrackFitter(Trk::TrackInfo::Unknown);
137 }
138 Trk::Track* t = new Trk::Track(data.trackInfo(), std::move(traj), nullptr);
139 if (t) data.seedSegmentsCollection()->push_back(t);
140 }
141}
142
144// Dumps relevant information into the MsgStream
146
148{
149 out << std::endl;
150 if (m_nprint) dumpevent(data, out);
151 return dumpconditions(data, out);
152}
153
155// Dumps conditions information into the MsgStream
158{
159 out << "|----------------------------------------------------------------------"
160 << "-------------------|"
161 << std::endl;
162 out << "| Output Collection Name | " << m_seedsegmentsOutput << std::endl;
163 out << "} Name of pattern recognition | " << data.patternName() << std::endl;
164 out << "|----------------------------------------------------------------------"
165 << "-------------------|"
166 << std::endl;
167 return out;
168}
169
170// Dumps event information into the MsgStream
172
174{
175 out << "|---------------------------------------------------------------------|"
176 << std::endl;
177 out << "| Name of SeedFinder | " << data.patternName()
178 << " | " << std::endl;
179 out << "| Number of All seeds | " << std::setw(12) << m_totseed
180 << " | " << std::endl;
181 out << "| Number of survived seeds | " << std::setw(12) << m_survived
182 << " | " << std::endl;
183 out << "|---------------------------------------------------------------------|"
184 << std::endl;
185 return out;
186}
187
188//============================================================================================
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_DEBUG(x)
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
static Double_t Tp(Double_t *t, Double_t *par)
static Double_t sc
Handle class for recording to StoreGate.
InDet::SeedToTrackConversionData holds event dependent data used in InDet::SeedToTrackConversionTool.
virtual StatusCode initialize() override
SeedToTrackConversionTool(const std::string &, const std::string &, const IInterface *)
MsgStream & dumpconditions(SeedToTrackConversionData &data, MsgStream &out) const
SG::WriteHandleKey< TrackCollection > m_seedsegmentsOutput
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
virtual void executeSiSPSeedSegments(SeedToTrackConversionData &data, const Trk::TrackParameters *, const int &, const std::vector< const Trk::SpacePoint * > &) const override
seed trackparameters, number of tracks found:m_track.size(), list of spacepoints
virtual void endEvent(SeedToTrackConversionData &data) const override
virtual MsgStream & dump(SeedToTrackConversionData &data, MsgStream &out) const override
std::atomic_int m_survived
number of survived seeds
virtual void newEvent(SeedToTrackConversionData &data, const Trk::TrackInfo &, const std::string &) const override
std::atomic_int m_nprint
Kind output information.
MsgStream & dumpevent(SeedToTrackConversionData &data, MsgStream &out) const
std::atomic_int m_totseed
number of total seeds in the pass
ToolHandle< Trk::IRIO_OnTrackCreator > m_rotcreator
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Class describing the Line to which the Perigee refers to.
Abstract Base Class for tracking surfaces.
Contains information about the 'fitter' of this track.
@ SiSpacePointsSeedMaker_ForwardTracks
Entries allowing to distinguish different seed makers.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
@ alongMomentum
@ anyDirection
ParametersBase< TrackParametersDim, Charged > TrackParameters
-event-from-file
MsgStream & msg
Definition testRead.cxx:32