ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
InnerDetector
InDetRecAlgs
TRT_TrackSegmentsFinder
src
TRT_TrackSegmentsFinder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
6
#include "
TRT_TrackSegmentsFinder/TRT_TrackSegmentsFinder.h
"
7
8
9
#include "
TRT_ReadoutGeometry/TRT_BaseElement.h
"
10
11
#include "
StoreGate/WriteHandle.h
"
12
#include "
StoreGate/ReadHandle.h
"
13
14
#include <memory>
15
17
// Constructor
19
20
InDet::TRT_TrackSegmentsFinder::TRT_TrackSegmentsFinder
21
(
const
std::string& name,ISvcLocator* pSvcLocator) :
22
AthReentrantAlgorithm
(name, pSvcLocator)
23
{
24
}
25
27
// Initialisation
29
30
StatusCode
InDet::TRT_TrackSegmentsFinder::initialize
()
31
{
32
// Get tool for drift circles seeds maker
33
//
34
ATH_CHECK
(
m_segmentsMakerTool
.retrieve() );
35
ATH_CHECK
(
m_roadtool
.retrieve( DisableTool{ !m_useCaloSeeds }) );
36
37
ATH_CHECK
(
m_caloClusterROIKey
.initialize(
m_useCaloSeeds
) );
38
ATH_CHECK
(
m_foundSegmentsKey
.initialize() );
39
41
ATH_CHECK
(
m_fieldCondObjInputKey
.initialize());
43
44
// Get output print level
45
//
46
if
(
msgLvl
(MSG::DEBUG)) {
47
MsgStream& out =
msg
(MSG::DEBUG);
48
out << std::endl;
49
dumptools
(out);
50
out <<
endmsg
;
51
}
52
m_nsegmentsTotal
= 0;
53
return
StatusCode::SUCCESS;
54
}
55
57
// Execute
59
60
StatusCode
InDet::TRT_TrackSegmentsFinder::execute
(
const
EventContext &ctx)
const
61
{
62
std::unique_ptr<Trk::SegmentCollection> found_segments(std::make_unique<Trk::SegmentCollection>());
63
std::unique_ptr<InDet::ITRT_TrackSegmentsMaker::IEventData> event_data_p;
64
InDet::TRT_DetElementLink_xk::TRT_DetElemUsedMap
map
;
65
if
(!
m_useCaloSeeds
) {
66
event_data_p =
m_segmentsMakerTool
->newEvent(ctx);
67
m_segmentsMakerTool
->find (ctx, *event_data_p,
map
);
68
// Loop through all segments and reconsrtucted segments collection preparation
69
//
70
Trk::Segment
* segment =
nullptr
;
71
while
((segment =
m_segmentsMakerTool
->next(*event_data_p))) {
72
found_segments->push_back(segment);
73
}
74
}
else
{
75
Amg::Vector3D
PSV(0.,0.,0.);
Trk::PerigeeSurface
PS(PSV);
76
std::vector<IdentifierHash> vTR;
77
SG::ReadHandle<ROIPhiRZContainer>
calo_rois(
m_caloClusterROIKey
, ctx);
78
if
(!calo_rois.
isValid
()) {
79
ATH_MSG_FATAL
(
"Failed to get EM Calo cluster collection "
<<
m_caloClusterROIKey
);
80
return
StatusCode::FAILURE;
81
}
82
MagField::AtlasFieldCache
fieldCache;
83
SG::ReadCondHandle<AtlasFieldCacheCondObj>
readHandle{
m_fieldCondObjInputKey
, ctx};
84
const
AtlasFieldCacheCondObj
* fieldCondObj{*readHandle};
85
if
(fieldCondObj ==
nullptr
) {
86
ATH_MSG_ERROR
(
"InDet::TRT_TrackExtensionTool_xk::findSegment: Failed to retrieve AtlasFieldCacheCondObj with key "
<<
m_fieldCondObjInputKey
.key());
87
return
StatusCode::FAILURE;
88
}
89
fieldCondObj->
getInitializedCache
(fieldCache);
90
for
(
const
ROIPhiRZ
&roi : *calo_rois) {
91
if
(std::abs(roi[0])>
M_PI
)
continue
;
// reject duplicates;
92
std::unique_ptr<Trk::TrackParameters> par = PS.createUniqueTrackParameters(0., 0., roi.phi(), roi.theta(), 0., std::nullopt);
93
// Get AtlasFieldCache
94
// TRT detector elements road builder
95
//
96
const
auto
& DE =
m_roadtool
->detElementsRoad(ctx, fieldCache, *par,
Trk::alongMomentum
,
map
);
97
if
(
int
(DE.size()) <
m_minNumberDCs
)
continue
;
98
vTR.clear();
99
vTR.reserve(DE.size());
100
for
(
const
InDetDD::TRT_BaseElement
*d: DE) {
101
vTR.push_back(d->identifyHash());
102
}
103
event_data_p =
m_segmentsMakerTool
->newRegion(ctx, vTR);
104
m_segmentsMakerTool
->find(ctx, *event_data_p,
map
);
105
// Loop through all segments and reconsrtucted segments collection preparation
106
Trk::Segment
* segment =
nullptr
;
107
while
((segment =
m_segmentsMakerTool
->next(*event_data_p))) {
108
found_segments->push_back(segment);
109
}
110
}
//end of loopover *calo
111
}
112
if
(event_data_p) {
113
m_segmentsMakerTool
->endEvent(*event_data_p);
114
}
115
116
// gather stat before found segments are moved.
117
if
(
msgLvl
(MSG::DEBUG)) {
118
MsgStream& out =
msg
(MSG::DEBUG);
119
out << std::endl;
120
dumpevent
(out,found_segments->size());
121
out <<
endmsg
;
122
}
123
m_nsegmentsTotal
+=found_segments->size();
124
125
if
(
SG::WriteHandle
(
m_foundSegmentsKey
, ctx ).record(std::move(found_segments)).isFailure()) {
126
ATH_MSG_ERROR
(
"Could not save TRT segments "
<<
m_foundSegmentsKey
.key() );
127
return
StatusCode::FAILURE;
128
}
129
130
// Print common event information
131
//
132
return
StatusCode::SUCCESS;
133
}
134
136
// Finalize
138
139
StatusCode
InDet::TRT_TrackSegmentsFinder::finalize
()
140
{
141
if
(
msgLvl
(MSG::INFO)) {
142
MsgStream& out =
msg
(MSG::INFO);
143
out << std::endl;
144
dumpevent
(out,
m_nsegmentsTotal
);
145
out <<
endmsg
;
146
}
147
return
StatusCode::SUCCESS;
148
}
149
151
// Dumps conditions information into the MsgStream
153
154
MsgStream&
InDet::TRT_TrackSegmentsFinder::dumptools
( MsgStream& out )
const
155
{
156
int
n = 65-
m_segmentsMakerTool
.type().size();
157
std::string s1;
for
(
int
i=0; i<n; ++i) s1.append(
" "
); s1.append(
"|"
);
158
n = 65-
m_foundSegmentsKey
.key().size();
159
std::string s2;
for
(
int
i=0; i<n; ++i) s2.append(
" "
); s2.append(
"|"
);
160
161
out<<
"|----------------------------------------------------------------"
162
<<
"----------------------------------------------------|"
163
<<std::endl;
164
out<<
"| Tool for TRT track segments finding | "
<<
m_segmentsMakerTool
.type()<<s1
165
<<std::endl;
166
out<<
"| Location of output segments | "
<<
m_foundSegmentsKey
.key()<<s2
167
<<std::endl;
168
out<<
"|----------------------------------------------------------------"
169
<<
"----------------------------------------------------|"
170
<<std::endl;
171
172
return
out;
173
}
174
176
// Dumps event information into the ostream
178
179
MsgStream&
InDet::TRT_TrackSegmentsFinder::dumpevent
( MsgStream& out,
int
nsegments)
const
180
{
181
out<<
"|-------------------------------------------------------------------"
;
182
out<<
"-----------------------------|"
183
<<std::endl;
184
185
out<< ((
m_useCaloSeeds
)
186
?
"| TRT track segments found with calo seeds |"
187
:
"| TRT track segments found without calo seeds |"
)
188
<<std::setw(7)<<nsegments
189
<<
" |"
190
<<std::endl;
191
out<<
"|-------------------------------------------------------------------"
;
192
out<<
"-----------------------------|"
193
<<std::endl;
194
return
out;
195
}
196
197
198
199
200
201
M_PI
#define M_PI
Definition
ActiveFraction.h:14
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_ERROR
#define ATH_MSG_ERROR(x,...)
Definition
AthMsgStreamMacros.h:47
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x,...)
Definition
AthMsgStreamMacros.h:48
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
TRT_BaseElement.h
TRT_TrackSegmentsFinder.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
AtlasFieldCacheCondObj
Definition
AtlasFieldCacheCondObj.h:19
AtlasFieldCacheCondObj::getInitializedCache
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Definition
AtlasFieldCacheCondObj.h:32
InDetDD::TRT_BaseElement
Virtual base class of TRT readout elements.
Definition
TRT_BaseElement.h:56
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_TrackSegmentsFinder::TRT_TrackSegmentsFinder
TRT_TrackSegmentsFinder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
TRT_TrackSegmentsFinder.cxx:21
InDet::TRT_TrackSegmentsFinder::m_segmentsMakerTool
ToolHandle< ITRT_TrackSegmentsMaker > m_segmentsMakerTool
Definition
TRT_TrackSegmentsFinder.h:59
InDet::TRT_TrackSegmentsFinder::dumpevent
MsgStream & dumpevent(MsgStream &out, int nsegments) const
Definition
TRT_TrackSegmentsFinder.cxx:179
InDet::TRT_TrackSegmentsFinder::m_foundSegmentsKey
SG::WriteHandleKey< Trk::SegmentCollection > m_foundSegmentsKey
Definition
TRT_TrackSegmentsFinder.h:56
InDet::TRT_TrackSegmentsFinder::m_roadtool
ToolHandle< ITRT_DetElementsRoadMaker > m_roadtool
Definition
TRT_TrackSegmentsFinder.h:62
InDet::TRT_TrackSegmentsFinder::m_minNumberDCs
Gaudi::Property< int > m_minNumberDCs
Definition
TRT_TrackSegmentsFinder.h:50
InDet::TRT_TrackSegmentsFinder::execute
StatusCode execute(const EventContext &ctx) const
Definition
TRT_TrackSegmentsFinder.cxx:60
InDet::TRT_TrackSegmentsFinder::dumptools
MsgStream & dumptools(MsgStream &out) const
Definition
TRT_TrackSegmentsFinder.cxx:154
InDet::TRT_TrackSegmentsFinder::finalize
StatusCode finalize()
Definition
TRT_TrackSegmentsFinder.cxx:139
InDet::TRT_TrackSegmentsFinder::initialize
StatusCode initialize()
Definition
TRT_TrackSegmentsFinder.cxx:30
InDet::TRT_TrackSegmentsFinder::m_nsegmentsTotal
std::atomic< int > m_nsegmentsTotal
Definition
TRT_TrackSegmentsFinder.h:66
InDet::TRT_TrackSegmentsFinder::m_fieldCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
Definition
TRT_TrackSegmentsFinder.h:64
InDet::TRT_TrackSegmentsFinder::m_caloClusterROIKey
SG::ReadHandleKey< ROIPhiRZContainer > m_caloClusterROIKey
Definition
TRT_TrackSegmentsFinder.h:53
InDet::TRT_TrackSegmentsFinder::m_useCaloSeeds
Gaudi::Property< bool > m_useCaloSeeds
Definition
TRT_TrackSegmentsFinder.h:47
MagField::AtlasFieldCache
Local cache for magnetic field (based on MagFieldServices/AtlasFieldSvcTLS.h).
Definition
AtlasFieldCache.h:43
ROIPhiRZ
Definition
ROIPhiRZContainer.h:19
SG::ReadCondHandle
Definition
ReadCondHandle.h:39
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
Trk::PerigeeSurface
Class describing the Line to which the Perigee refers to.
Definition
PerigeeSurface.h:43
Trk::Segment
Base class for all TrackSegment implementations, extends the common MeasurementBase.
Definition
Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
map
STL class.
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:48
Trk::alongMomentum
@ alongMomentum
Definition
PropDirection.h:20
Generated on
for ATLAS Offline Software by
1.17.0