ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Reconstruction
egamma
egammaAlgs
src
egammaRecBuilder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
egammaRecBuilder.h
"
6
7
#include "
AthenaKernel/errorcheck.h
"
8
#include "
StoreGate/ReadHandle.h
"
9
#include "
StoreGate/WriteHandle.h
"
10
11
#include "
CaloUtils/CaloClusterStoreHelper.h
"
12
#include "
egammaInterfaces/IEMConversionBuilder.h
"
13
#include "
egammaInterfaces/IEMTrackMatchBuilder.h
"
14
#include "
egammaInterfaces/IegammaCheckEnergyDepositTool.h
"
15
#include "
egammaRecEvent/egammaRecContainer.h
"
16
#include "
xAODCaloEvent/CaloClusterContainer.h
"
17
18
#include <vector>
19
#include <algorithm>
20
#include <cmath>
21
22
egammaRecBuilder::egammaRecBuilder
(
const
std::string& name,
23
ISvcLocator* pSvcLocator)
24
:
AthReentrantAlgorithm
(name, pSvcLocator)
25
{}
26
27
StatusCode
28
egammaRecBuilder::initialize
()
29
{
30
// First the data handle keys
31
ATH_CHECK
(
m_inputClusterContainerKey
.initialize());
32
ATH_CHECK
(
m_egammaRecContainerKey
.initialize());
33
ATH_CHECK
(
m_trackMatchedEgammaRecs
.initialize(
m_doTrackMatchedView
));
34
// retrieve track match builder
35
ATH_CHECK
(
RetrieveTool<IEMTrackMatchBuilder>
(
m_trackMatchBuilder
,
m_doTrackMatching
));
36
// retrieve conversion builder
37
ATH_CHECK
(
RetrieveTool<IEMConversionBuilder>
(
m_conversionBuilder
,
m_doConversions
));
38
return
StatusCode::SUCCESS;
39
}
40
41
template
<
typename
T>
42
StatusCode
43
egammaRecBuilder::RetrieveTool
(ToolHandle<T> &tool,
bool
tool_requested)
44
{
45
if
(!tool_requested) {
46
tool.disable();
47
return
StatusCode::SUCCESS;
48
}
49
if
(tool.empty()) {
50
ATH_MSG_INFO
(tool.type() <<
" is empty"
);
51
return
StatusCode::FAILURE;
52
}
53
ATH_CHECK
(tool.retrieve());
54
return
StatusCode::SUCCESS;
55
}
56
57
StatusCode
58
egammaRecBuilder::execute
(
const
EventContext& ctx)
const
59
{
60
ATH_MSG_DEBUG
(
"Executing egammaRecBuilder"
);
61
62
SG::ReadHandle<xAOD::CaloClusterContainer>
clusters(
63
m_inputClusterContainerKey
, ctx);
64
65
// validity check is only really needed for serial running. Remove when MT is
66
// only way.
67
ATH_CHECK
(clusters.isValid());
68
69
SG::WriteHandle<EgammaRecContainer>
egammaRecs(
m_egammaRecContainerKey
, ctx);
70
ATH_CHECK
(egammaRecs.
record
(std::make_unique<EgammaRecContainer>()));
71
72
// one egamma Rec objects per cluster
73
const
size_t
nClusters = clusters->size();
74
egammaRecs->reserve(nClusters);
75
for
(
size_t
i = 0; i < nClusters; ++i) {
76
const
ElementLink<xAOD::CaloClusterContainer>
clusterLink(
77
*clusters, i, ctx);
78
const
std::vector<ElementLink<xAOD::CaloClusterContainer>>
79
clusterLinkVector{ clusterLink };
80
egammaRecs->push_back(std::make_unique<egammaRec>(clusterLinkVector));
81
}
82
83
// Append track Matching information if requested
84
if
(
m_doTrackMatching
) {
85
ATH_CHECK
(
m_trackMatchBuilder
->executeRec(ctx, egammaRecs.
ptr
()));
86
}
87
88
// Append conversion matching information if requested
89
if
(
m_doConversions
) {
90
for
(
auto
egRec : *egammaRecs) {
91
ATH_CHECK
(
m_conversionBuilder
->executeRec(ctx, egRec));
92
}
93
}
94
95
// create a view of the track matched egRecs if requested
96
if
(
m_doTrackMatchedView
) {
97
SG::WriteHandle<ConstDataVector<EgammaRecContainer>
> trackMatchedEgammaRecs(
98
m_trackMatchedEgammaRecs
, ctx);
99
100
auto
viewCopy =
101
std::make_unique<ConstDataVector<EgammaRecContainer>>(
SG::VIEW_ELEMENTS
);
102
103
if
(
m_doTrackMatching
) {
104
for
(
const
egammaRec
* eg : *egammaRecs) {
105
if
(eg->getNumberOfTrackParticles() > 0) {
106
viewCopy->push_back(eg);
107
}
108
}
109
}
110
ATH_CHECK
(trackMatchedEgammaRecs.
record
(std::move(viewCopy)));
111
}
112
113
return
StatusCode::SUCCESS;
114
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
CaloClusterStoreHelper.h
errorcheck.h
Helpers for checking error return status codes and reporting errors.
CaloClusterContainer.h
IEMConversionBuilder.h
IEMTrackMatchBuilder.h
IegammaCheckEnergyDepositTool.h
ReadHandle.h
Handle class for reading from StoreGate.
WriteHandle.h
Handle class for recording to StoreGate.
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
ElementLink
ElementLink implementation for ROOT usage.
Definition
A/AthLinks/ElementLink.h:40
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
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.
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
egammaRecBuilder::m_egammaRecContainerKey
SG::WriteHandleKey< EgammaRecContainer > m_egammaRecContainerKey
Key for egammaRec container.
Definition
egammaRecBuilder.h:61
egammaRecBuilder::m_doTrackMatching
Gaudi::Property< bool > m_doTrackMatching
private member flag to do the track matching
Definition
egammaRecBuilder.h:92
egammaRecBuilder::RetrieveTool
StatusCode RetrieveTool(ToolHandle< T > &tool, bool tool_requested)
Wrap tool retrieval, ensuring it was named and requested.
Definition
egammaRecBuilder.cxx:43
egammaRecBuilder::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
egammaRecBuilder.cxx:58
egammaRecBuilder::m_trackMatchedEgammaRecs
SG::WriteHandleKey< ConstDataVector< EgammaRecContainer > > m_trackMatchedEgammaRecs
Definition
egammaRecBuilder.h:69
egammaRecBuilder::m_doTrackMatchedView
Gaudi::Property< bool > m_doTrackMatchedView
private member flag to produce of view of track matched egammaRecs
Definition
egammaRecBuilder.h:105
egammaRecBuilder::egammaRecBuilder
egammaRecBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Definition
egammaRecBuilder.cxx:22
egammaRecBuilder::m_doConversions
Gaudi::Property< bool > m_doConversions
private member flag to do the conversion matching
Definition
egammaRecBuilder.h:98
egammaRecBuilder::m_conversionBuilder
ToolHandle< IEMConversionBuilder > m_conversionBuilder
Tool to perfrom conversion vertex matching.
Definition
egammaRecBuilder.h:84
egammaRecBuilder::initialize
virtual StatusCode initialize() override final
Definition
egammaRecBuilder.cxx:28
egammaRecBuilder::m_trackMatchBuilder
ToolHandle< IEMTrackMatchBuilder > m_trackMatchBuilder
Tool to perform track matching.
Definition
egammaRecBuilder.h:76
egammaRecBuilder::m_inputClusterContainerKey
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterContainerKey
Key for the topo cluster input collection.
Definition
egammaRecBuilder.h:53
egammaRec
Represent an egamma object for internal egamma usage during reconstruction.
Definition
egammaRec.h:31
egammaRecBuilder.h
egammaRecContainer.h
SG::VIEW_ELEMENTS
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
Definition
OwnershipPolicy.h:18
Generated on
for ATLAS Offline Software by
1.17.0