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 for (size_t i = 0; i < m_tools.size(); i++) {
68 Gaudi::Guards::AuditorGuard auditor( m_tools[ i ]->name() +
69 ":cfg", auditorSvc(), "ini" );
71 }
72 } else {
73 for (size_t i = 0; i < m_tools.size(); i++) {
75 }
76 }
77
78 // Decide which fill function is to be used later on. This way the
79 // if statement is only executed once, and not in every execute()
80 // function.
81 if (m_audit) {
83 } else {
85 }
86
87 return StatusCode::SUCCESS;
88}
89
90
95{
96 // Run metadata tools.
97 for (size_t i = 0; i < m_metadataTools.size(); i++)
98 CHECK( m_metadataTools[i]->writeMetadata (m_d3pd) );
99
101 return StatusCode::SUCCESS;
102}
103
104
108StatusCode MakerAlg::execute(const EventContext& /*ctx*/)
109{
110 if (!m_booked) {
111 m_booked = true;
112 // This check also only has to be done once. So no reason to do it
113 // in a more complicated way.
114 if (m_audit) {
115 const std::string evtStr{"evt"};
116 for (size_t i = 0; i < m_tools.size(); i++) {
117 Gaudi::Guards::AuditorGuard auditor( m_tools[ i ]->name() +
118 ":book", auditorSvc(), evtStr );
119 CHECK( m_tools[i]->book() );
120 }
121 } else {
122 for (size_t i = 0; i < m_tools.size(); i++) {
123 CHECK( m_tools[i]->book() );
124 }
125 }
126 }
127
128 // Only write out "accepted" events:
129 if( ! isEventAccepted() ) return StatusCode::SUCCESS;
130
131 CHECK( m_d3pd->clear() );
132
133 // Call fill() on the tools with the pre-configured function. Notice that
134 // no if statements are put into the code here...
135 for (size_t i = 0; i < m_tools.size(); i++) {
136 CHECK( ( this->*m_fillFunction )( *m_tools[i] ) );
137 }
138
139 CHECK( m_d3pd->capture() );
140
141 return StatusCode::SUCCESS;
142}
143
144
152StatusCode MakerAlg::fillToolWithAuditor( IObjFillerTool& tool )
153{
154 Gaudi::Guards::AuditorGuard auditor( tool.name() +
155 ":fill", auditorSvc(), "evt" );
156 return tool.fill();
157}
158
159
167StatusCode MakerAlg::fillToolWithoutAuditor( IObjFillerTool& tool )
168{
169 return tool.fill();
170}
171
172
173} // 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:108
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:167
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:152
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:94
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
virtual StatusCode finalize()
bool isEventAccepted() const
Test whether this event should be output.
virtual StatusCode initialize()
FilteredAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Standard algorithm Constructor.
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.