ATLAS Offline Software
Loading...
Searching...
No Matches
IndexMultiAssociationFillerTool.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: IndexMultiAssociationFillerTool.cxx 618070 2014-09-22 19:05:34Z ssnyder $
12
13
17
18
19namespace D3PD {
20
21
29 (const std::string& type,
30 const std::string& name,
31 const IInterface* parent)
32 : base_class (type, name, parent),
34 m_associator (this),
35 m_index (0),
37{
38 declareProperty ("Associator", m_associator,
39 "The ISingleAssociationTool instance.");
40 declareProperty ("Target", m_targetLabel,
41 "Label of the collection getter defining the collection "
42 "within which to index.");
43 declareProperty ("Prefix", m_prefix,
44 "Variable name prefix for the index variable.");
45 declareProperty ("BlockName", m_blockName = this->name(),
46 "The name of this block.");
47 declareProperty ("CollectionGetterRegistry", m_registry,
48 "The ICollectionGetterRegistryTool instance.");
49 declareProperty ("AllowMissing", m_allowMissing = false,
50 "If true, then it is not considered an error for the "
51 "target getter to fail to find the input objects.");
52}
53
54
58StatusCode
60{
61 REPORT_MESSAGE(MSG::WARNING)
62 << "IndexMultiAssociationFillerTool is deprecated; use instead "
63 << "ContainedVectorMultiAssociationFillerTool with IndexFillerTool. "
64 << "IndexMultiAssociation.py should do that for you.";
65
66 CHECK( AthAlgTool::initialize() );
67 CHECK( m_associator.retrieve() );
68
69 // Be sure the registry is retrieved, to avoid warnings from Gaudi
70 // that the tool is unused.
71 CHECK( m_registry.retrieve() );
72 return StatusCode::SUCCESS;
73}
74
75
84StatusCode
86 const std::type_info& ti)
87{
89 CHECK( m_associator->configureD3PD (this, ti) );
90 CHECK( m_map.configureD3PD() );
91
92 if (m_map.target()) {
93 CHECK( m_converter.init (m_associator->elementTypeinfo(),
94 m_map.target()->elementTypeinfo()) );
95 }
96 else {
97 REPORT_MESSAGE_WITH_CONTEXT (MSG::WARNING,
98 "D3PD::IndexAssociationFillerTool")
99 << "Not booking index variable because association target does not exist.";
100 }
101
102 return StatusCode::SUCCESS;
103}
104
105
112{
113 CHECK( m_associator->book () );
114 if (m_map.target())
115 CHECK( addVariable ("index", m_index) );
116 else
117 m_index = 0;
118
119 return StatusCode::SUCCESS;
120}
121
122
149StatusCode
151 bool /*again = false*/)
152{
153 // Build the map if it doesn't exist.
154 CHECK( m_map.reset() );
155
156 // Iterate over the result of the association.
157 CHECK( m_associator->resetUntyped (p) );
158 while (const void* pout = m_associator->nextUntyped ())
159 {
160 if (m_index) {
161 // Convert to the proper pointer type to search in the container.
162 const void* pnew = m_converter.convertUntyped (pout);
163 if (!pnew)
164 {
165 REPORT_MESSAGE (MSG::WARNING)
166 << "Pointer conversion from " << m_converter.srcName() << " to "
167 << m_converter.dstName() << "failed.";
168 m_associator->releaseElementUntyped (pout);
169 continue;
170 }
171
172 m_index->push_back (m_map.findIndex (pnew));
173 }
174 m_associator->releaseElementUntyped (pout);
175 }
176
177 return StatusCode::SUCCESS;
178}
179
180
181} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
#define CHECK(...)
Evaluate an expression and check for errors.
Abstract interface to get a collection of objects and iterate over it.
Represent a multiple association by index.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
AddVariable(const std::string &prefix, const std::string &blockName=s_emptyString)
Constructor.
Common interface for adding a variable to a tuple.
ToolHandle< IMultiAssociationTool > m_associator
Property: The association tool instance.
ToolHandle< ICollectionGetterRegistryTool > m_registry
Property: The ICollectionGetterRegistryTool instance.
IndexMultiAssociationFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
std::string m_targetLabel
Property: The label of the collection getter defining the collection within which to index.
std::string m_prefix
Property: The variable name prefix.
std::vector< int > * m_index
Index collection variable.
std::string m_blockName
Property: the name of this block.
virtual StatusCode initialize() override
Standard Gaudi initialize method.
virtual StatusCode fillUntyped(const void *p, bool again=false) override
Fill one block.
TypeConverter m_converter
Helper to convert from pointer returned by the associator to pointer into the index container.
virtual StatusCode book() override
Declare tuple variables.
bool m_allowMissing
Property: Don't give an error if the target getter fails to find the input objects.
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti) override
Configure during initialization: type-check.
Block filler tool for noisy FEB information.
TChain * tree