ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
HeavyIonRec
HIGlobal
src
SpacePointCopier.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 "
InDetPrepRawData/PixelCluster.h
"
6
#include "
InDetIdentifier/PixelID.h
"
7
#include "
InDetIdentifier/SCT_ID.h
"
8
#include "
SpacePointCopier.h
"
9
#include "
AthContainers/ConstAccessor.h
"
10
#include "
AthContainers/Accessor.h
"
11
#include <algorithm>
12
SpacePointCopier::SpacePointCopier
(
const
std::string& name, ISvcLocator* pSvcLocator) :
13
AthReentrantAlgorithm
(name, pSvcLocator)
14
{
15
}
16
17
SpacePointCopier::~SpacePointCopier
()
18
{
19
}
20
21
StatusCode
SpacePointCopier::initialize
()
22
{
23
ATH_CHECK
(
m_pixelSPKey
.initialize() );
24
ATH_CHECK
(
m_SCTSPKey
.initialize() );
25
ATH_CHECK
(
m_tracksKey
.initialize() );
26
ATH_CHECK
(
m_outputKey
.initialize() );
27
return
StatusCode::SUCCESS;
28
}
29
30
StatusCode
SpacePointCopier::finalize
()
31
{
32
return
StatusCode::SUCCESS;
33
}
34
35
StatusCode
SpacePointCopier::execute
(
const
EventContext& context)
const
36
{
37
auto
pixelSPContainer =
SG::makeHandle
(
m_pixelSPKey
, context);
38
auto
SCTSPContainer =
SG::makeHandle
(
m_SCTSPKey
, context);
39
40
auto
output = std::make_unique<xAOD::BaseContainer>();
41
auto
outputAux = std::make_unique<xAOD::AuxContainerBase>();
42
output->setStore(outputAux.get());
43
44
size_t
pixSize = 0;
45
for
(
auto
coll: *pixelSPContainer ) {
46
pixSize += coll->size();
47
}
48
size_t
SCTSize = 0;
49
for
(
auto
coll: *SCTSPContainer ) {
50
SCTSize += coll->size();
51
}
52
// avoid recording for large events (for them the output collection will be empty)
53
auto
goodNumberOfSpacePoints = [
this
, SCTSize, pixSize](){
54
return
pixSize <=
m_maxPixSP
55
or SCTSize <=
m_maxSCTSP
56
or pixSize + SCTSize <=
m_maxTotalSP
;
57
};
58
59
auto
goodNumberOfTracks = [
this
, &context]() {
60
auto
tracksHandle =
SG::makeHandle
(
m_tracksKey
, context);
61
return
tracksHandle->size() <=
m_maxTracks
;
62
};
63
64
if
( goodNumberOfSpacePoints() and goodNumberOfTracks() ) {
65
ATH_MSG_DEBUG
(
"Converting "
<< pixSize + SCTSize <<
" SPs"
);
66
static
const
SG::Accessor< float >
x
(
"x"
);
67
static
const
SG::Accessor< float >
y
(
"y"
);
68
static
const
SG::Accessor< float >
z
(
"z"
);
69
static
const
SG::Accessor< float >
tot (
"tot"
);
70
static
const
SG::Accessor< short >
csize (
"csize"
);
71
static
const
SG::Accessor< unsigned int >
module1 (
"module1"
);
72
static
const
SG::Accessor< unsigned int >
module2 (
"module2"
);
73
74
const
PixelID
*pixelID =
nullptr
;
75
const
SCT_ID
*stripID =
nullptr
;
76
77
ATH_CHECK
(
detStore
()->retrieve(pixelID,
"PixelID"
));
78
ATH_CHECK
(
detStore
()->retrieve(stripID,
"SCT_ID"
));
79
80
81
for
(
auto
coll: *pixelSPContainer ) {
82
for
(
auto
sp
: *coll ) {
83
auto
*item =
new
SG::AuxElement
();
84
output->push_back( item );
85
x
(*item) = float(
sp
->globalPosition().x());
86
y
(*item) = float(
sp
->globalPosition().y());
87
z
(*item) = float(
sp
->globalPosition().z());
88
const
InDet::PixelCluster
* cluster =
static_cast<
const
InDet::PixelCluster
*
>
(
sp
->clusterList().first);
89
tot(*item) = float(cluster->
totalToT
());
90
csize(*item) = short(cluster->
totList
().size());
91
auto
[hashId1, hashId2] =
sp
->elementIdList();
92
module1(*item) = hashId1;
93
module2(*item) = hashId2;
94
95
}
96
}
97
static
const
SG::ConstAccessor<float>
xAcc (
"x"
);
98
static
const
SG::ConstAccessor<float>
yAcc (
"y"
);
99
static
const
SG::ConstAccessor<float>
zAcc (
"z"
);
100
101
for
(
auto
coll: *SCTSPContainer ) {
102
for
(
auto
sp
: *coll ) {
103
auto
*item =
new
SG::AuxElement
();
104
output->push_back( item );
105
x
(*item) = float(
sp
->globalPosition().x());
106
y
(*item) = float(
sp
->globalPosition().y());
107
z
(*item) = float(
sp
->globalPosition().z());
108
tot(*item) = 0;
109
csize(*item) = 0;
110
111
auto
[hashId1, hashId2] =
sp
->elementIdList();
112
module1(*item) = hashId1;
113
module2(*item) = hashId2;
114
}
115
}
116
117
for
(
size_t
i = 0; i < std::min(10ul, output->size()); ++i ) {
118
ATH_MSG_DEBUG
(
"Saves SP x y z: "
<< xAcc(*output->at(i))
119
<<
" "
<< yAcc(*output->at(i))
120
<<
" "
<< zAcc(*output->at(i)) );
121
}
122
ATH_MSG_DEBUG
(
"... and more ..."
);
123
}
124
125
auto
outputHandle =
SG::makeHandle
(
m_outputKey
, context);
126
ATH_CHECK
( outputHandle.record(std::move(output), std::move(outputAux)));
127
128
return
StatusCode::SUCCESS;
129
}
130
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
ConstAccessor.h
Helper class to provide constant type-safe access to aux data.
Accessor.h
Helper class to provide type-safe access to aux data.
PixelCluster.h
sp
static Double_t sp
Definition
LArPhysWaveHECTool.cxx:37
PixelID.h
This is an Identifier helper class for the Pixel subdetector.
SCT_ID.h
This is an Identifier helper class for the SCT subdetector.
SpacePointCopier.h
y
#define y
x
#define x
z
#define z
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
InDet::PixelCluster
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:49
InDet::PixelCluster::totList
const std::vector< int > & totList() const
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:202
InDet::PixelCluster::totalToT
int totalToT() const
Definition
InnerDetector/InDetRecEvent/InDetPrepRawData/InDetPrepRawData/PixelCluster.h:206
PixelID
This is an Identifier helper class for the Pixel subdetector.
Definition
PixelID.h:69
SCT_ID
This is an Identifier helper class for the SCT subdetector.
Definition
SCT_ID.h:68
SG::Accessor< float >
SG::ConstAccessor
Helper class to provide constant type-safe access to aux data.
Definition
ConstAccessor.h:55
SpacePointCopier::m_tracksKey
SG::ReadHandleKey< xAOD::TrackParticleContainer > m_tracksKey
Definition
SpacePointCopier.h:31
SpacePointCopier::execute
virtual StatusCode execute(const EventContext &context) const override
Definition
SpacePointCopier.cxx:35
SpacePointCopier::SpacePointCopier
SpacePointCopier(const std::string &name, ISvcLocator *pSvcLocator)
Definition
SpacePointCopier.cxx:12
SpacePointCopier::m_maxTracks
Gaudi::Property< size_t > m_maxTracks
Definition
SpacePointCopier.h:37
SpacePointCopier::m_outputKey
SG::WriteHandleKey< xAOD::BaseContainer > m_outputKey
Definition
SpacePointCopier.h:32
SpacePointCopier::m_maxPixSP
Gaudi::Property< size_t > m_maxPixSP
Definition
SpacePointCopier.h:34
SpacePointCopier::m_maxTotalSP
Gaudi::Property< size_t > m_maxTotalSP
Definition
SpacePointCopier.h:36
SpacePointCopier::~SpacePointCopier
virtual ~SpacePointCopier() override
Definition
SpacePointCopier.cxx:17
SpacePointCopier::finalize
virtual StatusCode finalize() override
Definition
SpacePointCopier.cxx:30
SpacePointCopier::m_pixelSPKey
SG::ReadHandleKey< SpacePointContainer > m_pixelSPKey
Definition
SpacePointCopier.h:29
SpacePointCopier::m_maxSCTSP
Gaudi::Property< size_t > m_maxSCTSP
Definition
SpacePointCopier.h:35
SpacePointCopier::m_SCTSPKey
SG::ReadHandleKey< SpacePointContainer > m_SCTSPKey
Definition
SpacePointCopier.h:30
SpacePointCopier::initialize
virtual StatusCode initialize() override
Definition
SpacePointCopier.cxx:21
SG::AuxElement
AuxElement(SG::AuxVectorData *container, size_t index)
Base class for elements of a container that can have aux data.
SG::makeHandle
SG::ReadCondHandle< T > makeHandle(const SG::ReadCondHandleKey< T > &key, const EventContext &ctx=Gaudi::Hive::currentContext())
Definition
ReadCondHandle.h:269
Generated on
for ATLAS Offline Software by
1.17.0