ATLAS Offline Software
MakerAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "MakerAlg.h"
15 #include "GaudiKernel/Guards.h"
16 
17 
18 namespace D3PD {
19 
20 
26 MakerAlg::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),
35  m_fillFunction (0)
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.
62  CHECK( m_d3pdSvc->make (m_tuplePath, m_d3pd) );
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
D3PD::MakerAlg::fillToolWithoutAuditor
StatusCode fillToolWithoutAuditor(IObjFillerTool &tool)
Cakk fill on a tool without an auditor.
Definition: MakerAlg.cxx:166
D3PD::IObjFillerTool
Abstract interface for tool to fill an object in the D3PD.
Definition: IObjFillerTool.h:45
D3PD::MakerAlg::m_tools
ToolHandleArray< IObjFillerTool > m_tools
Property: List of object filler tools to run.
Definition: MakerAlg.h:81
D3PD::MakerAlg::execute
virtual StatusCode execute()
Standard Gaudi execute method.
Definition: MakerAlg.cxx:108
MakerAlg.h
Algorithm to create a D3PD tree.
FilteredAlgorithm
algorithm that marks for write data objects in SG
Definition: FilteredAlgorithm.h:33
D3PD::MakerAlg::m_metadataTools
ToolHandleArray< IMetadataTool > m_metadataTools
Property: List of metadata tools to run.
Definition: MakerAlg.h:84
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
D3PD::MakerAlg::m_tuplePath
std::string m_tuplePath
Property: The tuple name.
Definition: MakerAlg.h:90
FilteredAlgorithm::finalize
virtual StatusCode finalize()
Definition: FilteredAlgorithm.cxx:115
D3PD::MakerAlg::m_fillFunction
StatusCode(D3PD::MakerAlg::* m_fillFunction)(IObjFillerTool &)
Pointer to the fill function to be used.
Definition: MakerAlg.h:99
FilteredAlgorithm::initialize
virtual StatusCode initialize()
Definition: FilteredAlgorithm.cxx:46
FilteredAlgorithm::isEventAccepted
bool isEventAccepted() const
Test whether this event should be output.
Definition: FilteredAlgorithm.cxx:128
D3PD::MakerAlg::fillToolWithAuditor
StatusCode fillToolWithAuditor(IObjFillerTool &tool)
Call fill() on a tool with an auditor.
Definition: MakerAlg.cxx:151
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::MakerAlg::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: MakerAlg.cxx:54
book
T * book(const std::string &n, const std::string &t, unsigned nbins)
Definition: main_benchmark.cxx:138
D3PD::MakerAlg::m_d3pd
ID3PD * m_d3pd
The created tuple. Note: we don't take ownership.
Definition: MakerAlg.h:93
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::MakerAlg::MakerAlg
MakerAlg(const std::string &name, ISvcLocator *svcloc)
Standard Gaudi algorithm constructor.
Definition: MakerAlg.cxx:26
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::MakerAlg::m_booked
bool m_booked
Flag that we've called book().
Definition: MakerAlg.h:96
D3PD::MakerAlg::m_d3pdSvc
ServiceHandle< ID3PDSvc > m_d3pdSvc
Property: The D3PD creation service.
Definition: MakerAlg.h:78
D3PD::ID3PD::capture
virtual StatusCode capture()=0
Capture the current state of all variables and write to the tuple.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
D3PD::MakerAlg::m_audit
bool m_audit
Property: Audit the tools with PerfMon or not?
Definition: MakerAlg.h:87
D3PD::MakerAlg::finalize
virtual StatusCode finalize()
Standard Gaudi finalize method.
Definition: MakerAlg.cxx:94
ID3PD.h
Abstract interface for a D3PD tree.
D3PD::ID3PD::clear
virtual StatusCode clear()=0
Clear all the tuple variables.