ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkEventCnv
TrkJiveXML
src
SegmentRetriever.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 "
TrkJiveXML/SegmentRetriever.h
"
6
7
#include "
TrkSegment/Segment.h
"
8
#include "
TrkSegment/TrackSegment.h
"
9
#include "
TrkRIO_OnTrack/RIO_OnTrack.h
"
10
11
#include "
JiveXML/DataType.h
"
12
13
namespace
JiveXML
{
14
21
SegmentRetriever::SegmentRetriever
(
const
std::string&
type
,
const
std::string& name,
const
IInterface* parent):
22
AthAlgTool
(
type
,name,parent){}
23
24
25
StatusCode
SegmentRetriever::initialize
(){
26
ATH_CHECK
(
m_keys
.initialize());
27
return
StatusCode::SUCCESS;
28
}
29
30
38
StatusCode
SegmentRetriever::retrieve
(ToolHandle<IFormatTool> &FormatTool) {
39
40
ATH_MSG_DEBUG
(
"Retrieving "
<<
dataTypeName
());
41
42
for
(
const
auto
& key :
m_keys
) {
43
SG::ReadHandle<Trk::SegmentCollection >
cont(key);
44
if
(cont.
isValid
()) {
45
46
//Get number of segments in this collection
47
Trk::SegmentCollection::size_type
NSegs=cont.
cptr
()->size();
48
49
//Define the data vectors we want to fill and create space
50
DataVect
x
;
x
.reserve(NSegs);
51
DataVect
y
;
y
.reserve(NSegs);
52
DataVect
z
;
z
.reserve(NSegs);
53
DataVect
phi
;
phi
.reserve(NSegs);
54
DataVect
theta
;
theta
.reserve(NSegs);
55
DataVect
numHits; numHits.reserve(NSegs);
56
DataVect
hits;
57
58
//Loop over the segments
59
Trk::SegmentCollection::const_iterator
SegmentItr;
60
//reserve once to avoid reallocation
61
std::size_t nMeasurements{};
62
for
(
const
Trk::Segment
* segment : *cont.
cptr
()){
63
nMeasurements+= segment->containedMeasurements().size();
64
}
65
hits.reserve(nMeasurements);
66
for
(SegmentItr=cont.
cptr
()->begin(); SegmentItr!=cont.
cptr
()->end(); ++SegmentItr) {
67
68
//Retrieve primitive variables
69
x
.emplace_back((*SegmentItr)->globalPosition().x()/10.);
70
y
.emplace_back((*SegmentItr)->globalPosition().y()/10.);
71
z
.emplace_back((*SegmentItr)->globalPosition().z()/10.);
72
phi
.emplace_back((*SegmentItr)->localParameters()[
Trk::phi
]);
73
theta
.emplace_back((*SegmentItr)->localParameters()[
Trk::theta
]);
74
75
//Count number of valid (non-null) RIO_OnTracks
76
int
NRoTs = 0;
77
//Loop over segment measurments
78
std::vector< const Trk::MeasurementBase * >::const_iterator measItr, measEnd;
79
measItr=(*SegmentItr)->containedMeasurements().begin();
80
measEnd=(*SegmentItr)->containedMeasurements().end();
81
82
//Now loop over measurements
83
for
(; measItr!=measEnd; ++measItr) {
84
85
//dynamic_cast to RIO_OnTrack - will return NULL if not a RIO_OnTrack object
86
const
Trk::RIO_OnTrack
*RoT =
dynamic_cast<
const
Trk::RIO_OnTrack
*
>
(*measItr);
87
88
//Ignore failed dynamic_casts
89
if
(!RoT) continue ;
90
91
//Add the hit
92
hits.emplace_back(RoT->
identify
().
get_compact
() );
93
//count as valid
94
NRoTs++;
95
}
96
97
//Store number of hits for this segement
98
numHits.emplace_back(NRoTs);
99
}
100
101
//Add data to our map
102
DataMap
DataMap
;
103
DataMap
[
"x"
] = std::move(
x
);
104
DataMap
[
"y"
] = std::move(
y
);
105
DataMap
[
"z"
] = std::move(
z
);
106
DataMap
[
"phi"
] = std::move(
phi
);
107
DataMap
[
"theta"
] = std::move(
theta
);
108
std::size_t n = numHits.size();
109
DataMap
[
"numHits"
] = std::move(numHits);
110
111
//Hits are stored as multiple with average size given in XML header
112
if
(NSegs > 0) {
113
std::string multiple =
"hits multiple=\""
+
DataType
( hits.size()*1./n).toString() +
"\""
;
114
DataMap
[multiple] = std::move(hits);
115
}
116
117
//forward data to formating tool
118
if
( FormatTool->AddToEvent(
dataTypeName
(), key.key(), &
DataMap
).isFailure())
119
return
StatusCode::RECOVERABLE;
120
121
ATH_MSG_DEBUG
(
dataTypeName
() <<
" collection "
<< key <<
" retrieved with "
<< NSegs <<
" entries"
);
122
123
}
124
else
{
125
ATH_MSG_WARNING
(
"Collection "
<< key <<
" not found in SG "
);
126
}
127
}
128
129
//All collections retrieved - done
130
return
StatusCode::SUCCESS;
131
132
}
// retrieve
133
}
//namespace
phi
Scalar phi() const
phi method
Definition
AmgMatrixBasePlugin.h:67
theta
Scalar theta() const
theta method
Definition
AmgMatrixBasePlugin.h:75
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition
CTPResultByteStreamTool.cxx:22
DataType.h
RIO_OnTrack.h
SegmentRetriever.h
TrackSegment.h
Segment.h
y
#define y
x
#define x
z
#define z
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
DataVector< Trk::Segment >::const_iterator
DataModel_detail::const_iterator< DataVector > const_iterator
Definition
DataVector.h:838
DataVector< Trk::Segment >::size_type
typename DataVectorBase< Trk::Segment >::Base::size_type size_type
Definition
DataVector.h:814
Identifier::get_compact
value_type get_compact() const
Get the compact id.
JiveXML::SegmentRetriever::SegmentRetriever
SegmentRetriever(const std::string &type, const std::string &name, const IInterface *parent)
Standard Constructor.
Definition
SegmentRetriever.cxx:21
JiveXML::SegmentRetriever::m_keys
SG::ReadHandleKeyArray< Trk::SegmentCollection > m_keys
Definition
SegmentRetriever.h:48
JiveXML::SegmentRetriever::initialize
virtual StatusCode initialize()
Definition
SegmentRetriever.cxx:25
JiveXML::SegmentRetriever::dataTypeName
virtual std::string dataTypeName() const
Return the name of the data type.
Definition
SegmentRetriever.h:42
JiveXML::SegmentRetriever::retrieve
virtual StatusCode retrieve(ToolHandle< IFormatTool > &FormatTool)
Retrieve all the data.
Definition
SegmentRetriever.cxx:38
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
Trk::RIO_OnTrack
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition
RIO_OnTrack.h:70
Trk::RIO_OnTrack::identify
Identifier identify() const
return the identifier -extends MeasurementBase
Definition
RIO_OnTrack.h:152
Trk::Segment
Base class for all TrackSegment implementations, extends the common MeasurementBase.
Definition
Tracking/TrkEvent/TrkSegment/TrkSegment/Segment.h:56
JiveXML
This header is shared inbetween the C-style server thread and the C++ Athena ServerSvc.
Definition
BadLArRetriever.cxx:22
JiveXML::DataMap
std::map< std::string, DataVect > DataMap
Definition
DataType.h:59
JiveXML::DataVect
std::vector< DataType > DataVect
Defines a map with a key and a vector of DataType objects e.g.
Definition
DataType.h:58
Trk::theta
@ theta
Definition
ParamDefs.h:66
Trk::phi
@ phi
Definition
ParamDefs.h:75
type
Generated on
for ATLAS Offline Software by
1.17.0