ATLAS Offline Software
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 
14 #include "StoreGate/WriteHandle.h"
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 
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 
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;
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 
96  const Trk::TrackParameters* Tp,
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;
123  typePattern.set(Trk::TrackStateOnSurface::Measurement);
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 }
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 //============================================================================================
grepfile.info
info
Definition: grepfile.py:38
SeedToTrackConversionTool.h
Trk::anyDirection
@ anyDirection
Definition: PropDirection.h:22
Trk::SpacePoint
Definition: Tracking/TrkEvent/TrkSpacePoint/TrkSpacePoint/SpacePoint.h:35
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
Trk::TrackInfo
Contains information about the 'fitter' of this track.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:32
Trk::TrackStateOnSurface::Perigee
@ Perigee
This represents a perigee, and so will contain a Perigee object only.
Definition: TrackStateOnSurface.h:117
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
InDet::SeedToTrackConversionTool::dump
virtual MsgStream & dump(SeedToTrackConversionData &data, MsgStream &out) const override
Definition: SeedToTrackConversionTool.cxx:147
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
Trk::Track
The ATLAS Track class.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/Track.h:73
InDet::SeedToTrackConversionTool::dumpconditions
MsgStream & dumpconditions(SeedToTrackConversionData &data, MsgStream &out) const
Definition: SeedToTrackConversionTool.cxx:157
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
Trk::ParametersBase::uniqueClone
std::unique_ptr< ParametersBase< DIM, T > > uniqueClone() const
clone method for polymorphic deep copy returning unique_ptr; it is not overriden, but uses the existi...
Definition: ParametersBase.h:97
initialize
void initialize()
Definition: run_EoverP.cxx:894
InDet::SeedToTrackConversionTool::executeSiSPSeedSegments
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
Definition: SeedToTrackConversionTool.cxx:95
xAOD::JetInput::Track
@ Track
Definition: JetContainerInfo.h:61
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
Trk::alongMomentum
@ alongMomentum
Definition: PropDirection.h:20
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
InDet::SeedToTrackConversionTool::m_survived
std::atomic_int m_survived
number of survived seeds
Definition: SeedToTrackConversionTool.h:100
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
InDet::SeedToTrackConversionTool::m_nprint
std::atomic_int m_nprint
Kind output information.
Definition: SeedToTrackConversionTool.h:98
WriteHandle.h
Handle class for recording to StoreGate.
InDet::SeedToTrackConversionTool::m_rotcreator
ToolHandle< Trk::IRIO_OnTrackCreator > m_rotcreator
Definition: SeedToTrackConversionTool.h:88
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
SeedToTrackConversionData.h
InDet::SeedToTrackConversionTool::dumpevent
MsgStream & dumpevent(SeedToTrackConversionData &data, MsgStream &out) const
Definition: SeedToTrackConversionTool.cxx:173
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDet::SeedToTrackConversionTool::m_totseed
std::atomic_int m_totseed
number of total seeds in the pass
Definition: SeedToTrackConversionTool.h:99
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Trk::ParametersBase
Definition: ParametersBase.h:55
InDet::SeedToTrackConversionTool::endEvent
virtual void endEvent(SeedToTrackConversionData &data) const override
Definition: SeedToTrackConversionTool.cxx:78
InDet::SeedToTrackConversionTool::m_extrapolator
PublicToolHandle< Trk::IExtrapolator > m_extrapolator
Definition: SeedToTrackConversionTool.h:86
Trk::PrepRawData
Definition: PrepRawData.h:62
InDet::SeedToTrackConversionData
Definition: SeedToTrackConversionData.h:28
Trk::TrackStateOnSurface
represents the track state (measurement, material, fit parameters and quality) at a surface.
Definition: TrackStateOnSurface.h:71
RIO_OnTrack.h
Trk::nonInteracting
@ nonInteracting
Definition: ParticleHypothesis.h:25
InDet::SeedToTrackConversionTool::m_seedsegmentsOutput
SG::WriteHandleKey< TrackCollection > m_seedsegmentsOutput
Definition: SeedToTrackConversionTool.h:93
InDet::SeedToTrackConversionTool::initialize
virtual StatusCode initialize() override
Definition: SeedToTrackConversionTool.cxx:32
InDet::SeedToTrackConversionTool::SeedToTrackConversionTool
SeedToTrackConversionTool(const std::string &, const std::string &, const IInterface *)
Definition: SeedToTrackConversionTool.cxx:23
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
SiClusterContainer.h
Trk::TrackInfo::SiSpacePointsSeedMaker_ForwardTracks
@ SiSpacePointsSeedMaker_ForwardTracks
Entries allowing to distinguish different seed makers.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:241
DEBUG
#define DEBUG
Definition: page_access.h:11
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
InDet::SeedToTrackConversionTool::newEvent
virtual void newEvent(SeedToTrackConversionData &data, const Trk::TrackInfo &, const std::string &) const override
Definition: SeedToTrackConversionTool.cxx:65
Trk::TrackStateOnSurface::Measurement
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
Definition: TrackStateOnSurface.h:101
InDet::SeedToTrackConversionTool::finalize
virtual StatusCode finalize() override
Definition: SeedToTrackConversionTool.cxx:60
Trk::TrackInfo::xKalman
@ xKalman
tracks produced by xKalman
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:47
Trk::TrackInfo::Unknown
@ Unknown
Track fitter not defined.
Definition: Tracking/TrkEvent/TrkTrack/TrkTrack/TrackInfo.h:41