ATLAS Offline Software
Loading...
Searching...
No Matches
MakerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
10
11
12#include "MakerAlg.h"
15#include "GaudiKernel/Guards.h"
16
17
18namespace D3PD {
19
20
26MakerAlg::MakerAlg (const std::string& name,
27 ISvcLocator* svcloc)
28 : FilteredAlgorithm (name, svcloc),
29 m_d3pdSvc ("D3PD::RootD3PDSvc", name),
30 m_tools (this),
31 m_metadataTools (this),
32 m_audit (false),
33 m_d3pd (0),
34 m_booked (false),
36{
37 declareProperty ("D3PDSvc", m_d3pdSvc,
38 "The D3PD creation service.");
39 declareProperty ("Tools", m_tools,
40 "List of IObjFillerTool instances to run.");
41 declareProperty ("MetadataTools", m_metadataTools,
42 "List of IMetadataTool instances to run.");
43 declareProperty ("TuplePath", m_tuplePath,
44 "The name of the tuple. The interpretation of this "
45 "depends on the D3PDSvc.");
46 declareProperty ("Audit", m_audit,
47 "Audit the tools using PerfMon?");
48}
49
50
55{
57 CHECK( m_d3pdSvc.retrieve() );
58 CHECK( m_tools.retrieve() );
59 CHECK( m_metadataTools.retrieve() );
60
61 // Create the tuple.
63
64 // Configure each tool. Since the check on m_audit only has to be
65 // done once in the job, it's enough to implement it like this.
66 if (m_audit) {
67 const std::string iniStr{"ini"};
68 for (size_t i = 0; i < m_tools.size(); i++) {
69 Gaudi::Guards::AuditorGuard auditor( m_tools[ i ]->name() +
70 ":cfg", auditorSvc(), iniStr );
72 }
73 } else {
74 for (size_t i = 0; i < m_tools.size(); i++) {
76 }
77 }
78
79 // Decide which fill function is to be used later on. This way the
80 // if statement is only executed once, and not in every execute()
81 // function.
82 if (m_audit) {
84 } else {
86 }
87
88 return StatusCode::SUCCESS;
89}
90
91
96{
97 // Run metadata tools.
98 for (size_t i = 0; i < m_metadataTools.size(); i++)
99 CHECK( m_metadataTools[i]->writeMetadata (m_d3pd) );
100
101 CHECK( FilteredAlgorithm::finalize() );
102 return StatusCode::SUCCESS;
103}
104
105
109StatusCode MakerAlg::execute(const EventContext& ctx)
110{
111 if (!m_booked) {
112 m_booked = true;
113 // This check also only has to be done once. So no reason to do it
114 // in a more complicated way.
115 if (m_audit) {
116 const std::string evtStr{"evt"};
117 for (size_t i = 0; i < m_tools.size(); i++) {
118 Gaudi::Guards::AuditorGuard auditor( m_tools[ i ]->name() +
119 ":book", auditorSvc(), evtStr );
120 CHECK( m_tools[i]->book() );
121 }
122 } else {
123 for (size_t i = 0; i < m_tools.size(); i++) {
124 CHECK( m_tools[i]->book() );
125 }
126 }
127 }
128
129 // Only write out "accepted" events:
130 if( ! isEventAccepted(ctx) ) return StatusCode::SUCCESS;
131
132 CHECK( m_d3pd->clear() );
133
134 // Call fill() on the tools with the pre-configured function. Notice that
135 // no if statements are put into the code here...
136 for (size_t i = 0; i < m_tools.size(); i++) {
137 CHECK( ( this->*m_fillFunction )( *m_tools[i] ) );
138 }
139
140 CHECK( m_d3pd->capture() );
141
142 return StatusCode::SUCCESS;
143}
144
145
153StatusCode MakerAlg::fillToolWithAuditor( IObjFillerTool& tool )
154{
155 Gaudi::Guards::AuditorGuard auditor( tool.name() +
156 ":fill", auditorSvc(), "evt" );
157 return tool.fill();
158}
159
160
168StatusCode MakerAlg::fillToolWithoutAuditor( IObjFillerTool& tool )
169{
170 return tool.fill();
171}
172
173
174} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Abstract interface for a D3PD tree.
Algorithm to create a D3PD tree.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
ID3PD * m_d3pd
The created tuple. Note: we don't take ownership.
Definition MakerAlg.h:93
virtual StatusCode execute(const EventContext &ctx)
Standard Gaudi execute method.
Definition MakerAlg.cxx:109
StatusCode(D3PD::MakerAlg::* m_fillFunction)(IObjFillerTool &)
Pointer to the fill function to be used.
Definition MakerAlg.h:99
StatusCode fillToolWithoutAuditor(IObjFillerTool &tool)
Cakk fill on a tool without an auditor.
Definition MakerAlg.cxx:168
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition MakerAlg.cxx:54
StatusCode fillToolWithAuditor(IObjFillerTool &tool)
Call fill() on a tool with an auditor.
Definition MakerAlg.cxx:153
ServiceHandle< ID3PDSvc > m_d3pdSvc
Property: The D3PD creation service.
Definition MakerAlg.h:78
bool m_audit
Property: Audit the tools with PerfMon or not?
Definition MakerAlg.h:87
MakerAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition MakerAlg.cxx:26
virtual StatusCode finalize()
Standard Gaudi finalize method.
Definition MakerAlg.cxx:95
bool m_booked
Flag that we've called book().
Definition MakerAlg.h:96
ToolHandleArray< IObjFillerTool > m_tools
Property: List of object filler tools to run.
Definition MakerAlg.h:81
std::string m_tuplePath
Property: The tuple name.
Definition MakerAlg.h:90
ToolHandleArray< IMetadataTool > m_metadataTools
Property: List of metadata tools to run.
Definition MakerAlg.h:84
Base class for stream algorithms using DecisionSvc.
bool isEventAccepted(const EventContext &ctx) const
Test whether this event should be output.
virtual StatusCode initialize() override
Block filler tool for noisy FEB information.
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti)
Configure during initialization: type-check.
virtual StatusCode book()
Declare tuple variables.