ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
17
18#include <vector>
19#include <algorithm>
20#include <cmath>
21
22egammaRecBuilder::egammaRecBuilder(const std::string& name,
23 ISvcLocator* pSvcLocator)
24 : AthReentrantAlgorithm(name, pSvcLocator)
25{}
26
27StatusCode
29{
30 // First the data handle keys
34 // retrieve track match builder
36 // retrieve conversion builder
38 return StatusCode::SUCCESS;
39}
40
41template <typename T>
42StatusCode
43egammaRecBuilder::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
57StatusCode
58egammaRecBuilder::execute(const EventContext& ctx) const
59{
60 ATH_MSG_DEBUG("Executing egammaRecBuilder");
61
64
65 // validity check is only really needed for serial running. Remove when MT is
66 // only way.
67 ATH_CHECK(clusters.isValid());
68
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) {
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
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
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}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
An algorithm that can be simultaneously executed in multiple threads.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
pointer_type ptr()
Dereference the pointer.
SG::WriteHandleKey< EgammaRecContainer > m_egammaRecContainerKey
Key for egammaRec container.
Gaudi::Property< bool > m_doTrackMatching
private member flag to do the track matching
StatusCode RetrieveTool(ToolHandle< T > &tool, bool tool_requested)
Wrap tool retrieval, ensuring it was named and requested.
virtual StatusCode execute(const EventContext &ctx) const override final
SG::WriteHandleKey< ConstDataVector< EgammaRecContainer > > m_trackMatchedEgammaRecs
Gaudi::Property< bool > m_doTrackMatchedView
private member flag to produce of view of track matched egammaRecs
egammaRecBuilder(const std::string &name, ISvcLocator *pSvcLocator)
Gaudi::Property< bool > m_doConversions
private member flag to do the conversion matching
ToolHandle< IEMConversionBuilder > m_conversionBuilder
Tool to perfrom conversion vertex matching.
virtual StatusCode initialize() override final
ToolHandle< IEMTrackMatchBuilder > m_trackMatchBuilder
Tool to perform track matching.
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterContainerKey
Key for the topo cluster input collection.
Represent an egamma object for internal egamma usage during reconstruction.
Definition egammaRec.h:31
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts