ATLAS Offline Software
Loading...
Searching...
No Matches
IndexAssociationFillerTool.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: IndexAssociationFillerTool.cxx 618070 2014-09-22 19:05:34Z ssnyder $
12
13
17
18
19namespace D3PD {
20
21
28IndexAssociationFillerTool::IndexAssociationFillerTool
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
59IndexAssociationFillerTool::initialize()
60{
61 REPORT_MESSAGE(MSG::WARNING)
62 << "IndexAssociationFillerTool is deprecated; use instead "
63 << "ContainedAssociationFillerTool with IndexFillerTool. "
64 << "IndexAssociation.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
85IndexAssociationFillerTool::configureD3PD (IAddVariable* tree,
86 const std::type_info& ti)
87{
88 CHECK( AddVariable::configureD3PD (tree) );
89 CHECK( m_associator->configureD3PD (this, ti) );
91
92 if (m_map.target()) {
93 CHECK( m_converter.init (m_associator->typeinfo(),
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
111StatusCode IndexAssociationFillerTool::book()
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
150IndexAssociationFillerTool::fillUntyped (const void* p,
151 bool /*again = false*/)
152{
153 // Build the map if it doesn't exist.
154 CHECK( m_map.reset() );
155
156 // Default index value.
158 *m_index = -1;
159
160 // Do the association.
161 const void* pout = m_associator->getUntyped (p);
162 if (pout) {
163
164 if (m_index) {
165 // Convert to the proper pointer type to search in the container.
166 const void* pnew = m_converter.convertUntyped (pout);
167 if (!pnew) {
168 REPORT_MESSAGE (MSG::WARNING)
169 << "Pointer conversion from " << m_converter.srcName() << " to "
170 << m_converter.dstName() << "failed.";
171 }
172 else {
173 // Search the index container for the pointer.
174 *m_index = m_map.findIndex (pnew);
175 }
176 }
177
178 m_associator->releaseObjectUntyped (pout);
179 }
180
181 return StatusCode::SUCCESS;
182}
183
184
185
186} // 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 single association by index.
Common implementation of IAddVariable.
Definition AddVariable.h:38
virtual const std::type_info & elementTypeinfo() const =0
Return the element type of the collection.
ICollectionGetterTool * target()
Return the getter defining the first collection within which to index.
Definition IndexMap.cxx:175
StatusCode configureD3PD()
Configure during initialization: type-check.
Definition IndexMap.cxx:137
StatusCode reset()
Call before asking for an index. Rebuilds cache if needed.
Definition IndexMap.cxx:227
StatusCode init(const std::type_info &src_ti, const std::type_info &dst_ti)
Initialize the converter.
Block filler tool for noisy FEB information.
ToolHandle< ICollectionGetterRegistryTool > m_registry
Property: The ICollectionGetterRegistryTool instance.
bool m_allowMissing
Property: Don't give an error if the target getter fails to find the input objects.
IndexMap m_map
Map from objects to indices.
TypeConverter m_converter
Helper to convert from pointer returned by the associator to pointer into the index container.
std::string m_prefix
Property: The variable name prefix.
std::string m_blockName
Property: the name of this block.
int * m_index
Index variable.
std::string m_targetLabel
Fill one block.
::StatusCode StatusCode
StatusCode definition for legacy code.
size_t m_index
The index of this element within its container. Should be 0 if this object is not within a container.
TChain * tree