ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
TRT_TrackExtensionAlg
src
TRT_TrackExtensionAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
TRT_TrackExtensionAlg/TRT_TrackExtensionAlg.h
"
6
#include "
TrkTrack/TrackExtensionMap.h
"
7
#include "
TrkTrack/TrackCollection.h
"
8
9
// Store gate handles
10
#include "
StoreGate/ReadHandle.h
"
11
#include "
StoreGate/WriteHandle.h
"
12
14
// Constructor
16
17
InDet::TRT_TrackExtensionAlg::TRT_TrackExtensionAlg
18
(
const
std::string& name,ISvcLocator* pSvcLocator) :
19
AthReentrantAlgorithm
(name, pSvcLocator) {
20
}
21
23
// Initialisation
25
26
StatusCode
InDet::TRT_TrackExtensionAlg::initialize
() {
27
// Get tool for track ectension to TRT
28
29
ATH_CHECK
(
m_trtExtension
.retrieve());
30
31
ATH_CHECK
(
m_inputTracksKey
.initialize() );
32
ATH_CHECK
(
m_outputTracksKey
.initialize() );
33
34
return
StatusCode::SUCCESS;
35
}
36
38
// Execute
40
41
StatusCode
InDet::TRT_TrackExtensionAlg::execute
(
const
EventContext& ctx)
const
{
42
43
Counter_t
counter;
44
// Get input tracks collection
45
SG::ReadHandle<TrackCollection>
inputTracks(
m_inputTracksKey
,ctx);
46
if
(not inputTracks.
isValid
()) {
47
ATH_MSG_DEBUG
(
"Could not find input track collection "
<<
m_inputTracksKey
);
48
return
StatusCode::SUCCESS;
49
}
50
51
std::unique_ptr<InDet::ITRT_TrackExtensionTool::IEventData>
52
event_data_p(
m_trtExtension
->newEvent(ctx) );
53
54
// Loop through all input track and output tracks collection production
55
SG::WriteHandle<TrackExtensionMap>
outputTracks(
m_outputTracksKey
,ctx);
56
ATH_CHECK
( outputTracks.
record
(std::make_unique<TrackExtensionMap>()) );
57
58
TrackCollection::const_iterator
trk,trkEnd = inputTracks->end();
59
//We create this structure outside the loop,
60
//the vectors are cleared/resized inside the loop but
61
//we try to "retain capacity"
62
InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap
used
{};
63
for
(trk = inputTracks->begin(); trk != trkEnd; ++trk) {
64
if
( !(*trk) )
continue
;
65
++counter.m_nTracks;
66
67
std::vector<const Trk::MeasurementBase*>& trkExt =
m_trtExtension
->extendTrack(ctx, *(*trk), *event_data_p,
used
);
68
if
( trkExt.empty() ) {
continue
;}
69
outputTracks->insert( std::make_pair((*trk), trkExt) );
70
++counter.m_nTracksExtended;
71
}
72
73
{
74
std::lock_guard<std::mutex>
lock
(m_counterMutex);
75
m_totalCounts += counter;
76
}
77
78
if
(
msgLvl
(MSG::DEBUG)) {
79
dumpEvent
(
msg
(MSG::DEBUG), counter);
80
msg
(MSG::DEBUG) <<
endmsg
;
81
}
82
return
StatusCode::SUCCESS;
83
}
84
86
// Finalize
88
89
StatusCode
InDet::TRT_TrackExtensionAlg::finalize
() {
90
if
(
msgLvl
(MSG::INFO)) {
91
Counter_t
totalCounts;
92
{
93
std::lock_guard<std::mutex>
lock
(m_counterMutex);
94
totalCounts = m_totalCounts;
95
}
96
97
dumpEvent
(
msg
(MSG::INFO), totalCounts);
98
dumpConditions
(
msg
(MSG::INFO));
99
}
100
101
return
StatusCode::SUCCESS;
102
}
103
104
106
// Dumps conditions information into the MsgStream
108
109
MsgStream&
InDet::TRT_TrackExtensionAlg::dumpConditions
( MsgStream& out )
const
{
110
int
n = 65-
m_trtExtension
.type().size();
111
std::string s1;
for
(
int
i=0; i<n; ++i) s1.append(
" "
); s1.append(
"|"
);
112
n = 65-
m_inputTracksKey
.key().size();
113
std::string s2;
for
(
int
i=0; i<n; ++i) s2.append(
" "
); s2.append(
"|"
);
114
n = 65-
m_outputTracksKey
.key().size();
115
std::string s3;
for
(
int
i=0; i<n; ++i) s3.append(
" "
); s3.append(
"|"
);
116
117
out<<
"|----------------------------------------------------------------"
118
<<
"----------------------------------------------------|"
119
<<std::endl;
120
out<<
"| Tool for tracks extension to TRT | "
<<
m_trtExtension
.type()
121
<<s1<<std::endl;
122
out<<
"| Location of input tracks | "
<<
m_inputTracksKey
.key()
123
<<s2<<std::endl;
124
out<<
"| Extended tracks location | "
<<
m_outputTracksKey
.key()
125
<<s3<<std::endl;
126
out<<
"|----------------------------------------------------------------"
127
<<
"----------------------------------------------------|"
128
<<std::endl;
129
return
out;
130
}
131
133
// Dumps event information into the ostream
135
136
MsgStream&
InDet::TRT_TrackExtensionAlg::dumpEvent
( MsgStream& out,
const
InDet::TRT_TrackExtensionAlg::Counter_t
&counter ) {
137
138
out<<
"|-------------------------------------------------------------------"
;
139
out<<
"-----------------------------|"
140
<<std::endl;
141
out<<
"| Investigated "
142
<<std::setw(7)<< counter.m_nTracks <<
" input tracks and extended "
143
<<std::setw(7)<< counter.m_nTracksExtended <<
" tracks |"
144
<<std::endl;
145
out<<
"|-------------------------------------------------------------------"
;
146
out<<
"-----------------------------|"
147
<<std::endl;
148
return
out;
149
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
lock
virtual void lock()=0
Interface to allow an object to lock itself when made const in SG.
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TRT_TrackExtensionAlg.h
TrackCollection.h
TrackExtensionMap.h
AthCommonAlgorithm< Gaudi::Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition
AthCommonMsg.h:30
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DataVector< Trk::Track >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap
std::array< std::vector< std::vector< Used_t > >, 3 > TRT_DetElemUsedMap
Definition
TRT_DetElementLink_xk.h:42
InDet::TRT_TrackExtensionAlg::dumpEvent
static MsgStream & dumpEvent(MsgStream &out, const Counter_t &counter)
Definition
TRT_TrackExtensionAlg.cxx:136
InDet::TRT_TrackExtensionAlg::dumpConditions
MsgStream & dumpConditions(MsgStream &out) const
Definition
TRT_TrackExtensionAlg.cxx:109
InDet::TRT_TrackExtensionAlg::TRT_TrackExtensionAlg
TRT_TrackExtensionAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TRT_TrackExtensionAlg.cxx:18
InDet::TRT_TrackExtensionAlg::execute
StatusCode execute(const EventContext &ctx) const
Definition
TRT_TrackExtensionAlg.cxx:41
InDet::TRT_TrackExtensionAlg::initialize
StatusCode initialize()
Definition
TRT_TrackExtensionAlg.cxx:26
InDet::TRT_TrackExtensionAlg::m_inputTracksKey
SG::ReadHandleKey< TrackCollection > m_inputTracksKey
Definition
TRT_TrackExtensionAlg.h:78
InDet::TRT_TrackExtensionAlg::m_outputTracksKey
SG::WriteHandleKey< TrackExtensionMap > m_outputTracksKey
Definition
TRT_TrackExtensionAlg.h:79
InDet::TRT_TrackExtensionAlg::m_trtExtension
ToolHandle< ITRT_TrackExtensionTool > m_trtExtension
Definition
TRT_TrackExtensionAlg.h:75
InDet::TRT_TrackExtensionAlg::finalize
StatusCode finalize()
Definition
TRT_TrackExtensionAlg.cxx:89
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
used
holding In fact this class is here in order to allow STL container for all features This class is sho...
InDet::TRT_TrackExtensionAlg::Counter_t
Definition
TRT_TrackExtensionAlg.h:63
Generated on
for ATLAS Offline Software by
1.17.0