ATLAS Offline Software
Loading...
Searching...
No Matches
ContainedMultiAssociationFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5// $Id: ContainedMultiAssociationFillerTool.cxx 618070 2014-09-22 19:05:34Z ssnyder $
12
13
16
17
18namespace D3PD {
19
20
28 (const std::string& type,
29 const std::string& name,
30 const IInterface* parent)
31 : base_class (type, name, parent),
33 m_associator (this),
34 m_blockFillers (this),
35 m_next (0)
36{
37 declareProperty ("Associator", m_associator,
38 "The IMultiAssociationTool instance.");
39 declareProperty ("BlockFillers", m_blockFillers,
40 "List of contained block filler tools.");
41 declareProperty ("BlockName", m_blockName = this->name(),
42 "The name of this block.");
43 declareProperty ("Prefix", m_prefix = "",
44 "Variable name prefix for the contained blocks.");
45}
46
47
51StatusCode
53{
54 CHECK( AthAlgTool::initialize() );
55 CHECK( m_associator.retrieve() );
56 CHECK( m_blockFillers.retrieve() );
57 return StatusCode::SUCCESS;
58}
59
60
64StatusCode
66{
67 CHECK( AlgTool::finalize() );
68 if (m_next) {
69 m_associator->releaseElementUntyped (m_next);
70 m_next = 0;
71 }
72 return StatusCode::SUCCESS;
73}
74
75
84StatusCode
86 const std::type_info& ti)
87{
89 CHECK( m_associator->configureD3PD (this, ti) );
90 const std::type_info& ati = m_associator->elementTypeinfo();
91 for (size_t i = 0; i < m_blockFillers.size(); i++)
92 CHECK( m_blockFillers[i]->configureD3PD (this, ati ) );
93
94 return StatusCode::SUCCESS;
95}
96
97
104{
105 CHECK( m_associator->book () );
106 for (size_t i = 0; i < m_blockFillers.size(); i++)
107 CHECK( m_blockFillers[i]->book ( ) );
108
109 return StatusCode::SUCCESS;
110}
111
112
142StatusCode
144 bool again /*= false*/)
145{
146 // ??? Doesn't handle nested AGAIN.
147
148 if (!again) {
149 if (m_next) {
150 m_associator->releaseElementUntyped (m_next);
151 m_next = 0;
152 }
153
154 // Start the association.
155 CHECK( m_associator->resetUntyped (p) );
156
157 // Get the first result.
158 m_next = m_associator->nextUntyped();
159 }
160
161 if (!m_next)
162 return StatusCode(EMPTY);
163
164 for (size_t i = 0; i < m_blockFillers.size(); i++) {
165 StatusCode sc = m_blockFillers[i]->fillUntyped (m_next);
167 if (!sc.isSuccess()) {
168 REPORT_MESSAGE (MSG::WARNING)
169 << "Got AGAIN/EMPTY: "
170 << "Nested ContainedMultiAssociationFillerTool not supported.";
171 }
172 }
173
174 m_associator->releaseElementUntyped (m_next);
175 m_next = m_associator->nextUntyped();
176
177 // Always return AGAIN for the first object, even if it's the last one.
178 // We'll return EMPTY on the next call.
179 // If we don't do this, then we can have problems if multiple
180 // ContainedMultiAssociationFillerTools are used; any that return
181 // a list of size 1 will have that object duplicated in all rows.
182 if (m_next || !again)
183 return StatusCode(AGAIN);
184
185 return StatusCode::SUCCESS;
186}
187
188
189
190} // namespace D3PD
Represent a multiple association by containment.
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
static Double_t sc
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
AddVariable(const std::string &prefix, const std::string &blockName=s_emptyString)
Constructor.
std::string m_prefix
Property: The variable name prefix.
virtual StatusCode finalize()
Standard Gaudi finalize method.
ContainedMultiAssociationFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual StatusCode initialize()
Standard Gaudi initialize method.
ToolHandle< IMultiAssociationTool > m_associator
Property: The association tool instance.
virtual StatusCode book()
Declare tuple variables.
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti)
Configure during initialization: type-check.
std::string m_blockName
Property: the name of this block.
virtual StatusCode fillUntyped(const void *p, bool again=false)
Fill one block.
ToolHandleArray< IBlockFillerTool > m_blockFillers
Property: The list of block filler tools.
Common interface for adding a variable to a tuple.
static StatusCode againok(StatusCode sc)
StatusCode check helper: change AGAIN or EMPTY to SUCCESS.
Block filler tool for noisy FEB information.
TChain * tree