ATLAS Offline Software
Loading...
Searching...
No Matches
MakerAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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" );
70 CHECK( m_tools[i]->configureD3PD (m_d3pd) );
71 }
72 } else {
73 for (size_t i = 0; i < m_tools.size(); i++) {
74 CHECK( m_tools[i]->configureD3PD (m_d3pd) );
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
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 for (size_t i = 0; i < m_tools.size(); i++) {
116 Gaudi::Guards::AuditorGuard auditor( m_tools[ i ]->name() +
117 ":book", auditorSvc(), "evt" );
118 CHECK( m_tools[i]->book() );
119 }
120 } else {
121 for (size_t i = 0; i < m_tools.size(); i++) {
122 CHECK( m_tools[i]->book() );
123 }
124 }
125 }
126
127 // Only write out "accepted" events:
128 if( ! isEventAccepted() ) return StatusCode::SUCCESS;
129
130 CHECK( m_d3pd->clear() );
131
132 // Call fill() on the tools with the pre-configured function. Notice that
133 // no if statements are put into the code here...
134 for (size_t i = 0; i < m_tools.size(); i++) {
135 CHECK( ( this->*m_fillFunction )( *m_tools[i] ) );
136 }
137
138 CHECK( m_d3pd->capture() );
139
140 return StatusCode::SUCCESS;
141}
142
143
152{
153 Gaudi::Guards::AuditorGuard auditor( tool.name() +
154 ":fill", auditorSvc(), "evt" );
155 return tool.fill();
156}
157
158
167{
168 return tool.fill();
169}
170
171
172} // 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)
Abstract interface for tool to fill an object in the D3PD.
ID3PD * m_d3pd
The created tuple. Note: we don't take ownership.
Definition MakerAlg.h:93
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:166
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition MakerAlg.cxx:54
virtual StatusCode execute()
Standard Gaudi execute method.
Definition MakerAlg.cxx:108
StatusCode fillToolWithAuditor(IObjFillerTool &tool)
Call fill() on a tool with an auditor.
Definition MakerAlg.cxx:151
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.