ATLAS Offline Software
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 $
17 
18 
19 namespace D3PD {
20 
21 
29  (const std::string& type,
30  const std::string& name,
31  const IInterface* parent)
32  : base_class (type, name, parent),
33  AddVariable (m_prefix, m_blockName),
34  m_associator (this),
35  m_index (0),
36  m_map (this, m_targetLabel, m_registry, m_allowMissing)
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 
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 
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 
86  const std::type_info& ti)
87 {
89  CHECK( m_associator->configureD3PD (this, ti) );
91 
92  if (m_map.target()) {
93  CHECK( m_converter.init (m_associator->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 
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
D3PD::IndexMap::target
ICollectionGetterTool * target()
Return the getter defining the first collection within which to index.
Definition: IndexMap.cxx:175
D3PD::IndexMultiAssociationFillerTool::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: IndexMultiAssociationFillerTool.cxx:59
D3PD::IndexMultiAssociationFillerTool::m_registry
ToolHandle< ICollectionGetterRegistryTool > m_registry
Property: The ICollectionGetterRegistryTool instance.
Definition: IndexMultiAssociationFillerTool.h:147
D3PD::IAddVariable
Common interface for adding a variable to a tuple.
Definition: IAddVariable.h:70
D3PD::IndexMultiAssociationFillerTool::m_targetLabel
std::string m_targetLabel
Property: The label of the collection getter defining the collection within which to index.
Definition: IndexMultiAssociationFillerTool.h:138
calibdata.pout
def pout(output, newline=True)
Definition: calibdata.py:130
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
D3PD::IIteration::elementTypeinfo
virtual const std::type_info & elementTypeinfo() const =0
Return the element type of the collection.
D3PD::IndexMap::findIndex
int findIndex(const void *p)
Find the index corresponding to an element.
Definition: IndexMap.cxx:255
D3PD::IndexMultiAssociationFillerTool::m_converter
TypeConverter m_converter
Helper to convert from pointer returned by the associator to pointer into the index container.
Definition: IndexMultiAssociationFillerTool.h:158
D3PD::AddVariable
Common implementation of IAddVariable.
Definition: AddVariable.h:38
D3PD::TypeConverter::dstName
std::string dstName() const
Return the name of the destination type, or an empty string.
Definition: TypeConverter.cxx:151
D3PD::AddVariable::configureD3PD
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
Definition: AddVariable.cxx:61
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
ICollectionGetterTool.h
Abstract interface to get a collection of objects and iterate over it.
D3PD::IndexMap::reset
StatusCode reset()
Call before asking for an index. Rebuilds cache if needed.
Definition: IndexMap.cxx:227
D3PD::AddVariable::addVariable
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.
Definition: AddVariable.cxx:85
D3PD::IndexMultiAssociationFillerTool::IndexMultiAssociationFillerTool
IndexMultiAssociationFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: IndexMultiAssociationFillerTool.cxx:29
D3PD::IndexMultiAssociationFillerTool::m_index
std::vector< int > * m_index
Index collection variable.
Definition: IndexMultiAssociationFillerTool.h:154
D3PD::TypeConverter::init
StatusCode init(const std::type_info &src_ti, const std::type_info &dst_ti)
Initialize the converter.
Definition: TypeConverter.cxx:51
IndexMultiAssociationFillerTool.h
Represent a multiple association by index.
D3PD::TypeConverter::srcName
std::string srcName() const
Return the name of the source type, or an empty string.
Definition: TypeConverter.cxx:141
D3PD::IndexMultiAssociationFillerTool::configureD3PD
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti) override
Configure during initialization: type-check.
Definition: IndexMultiAssociationFillerTool.cxx:85
D3PD::TypeConverter::convertUntyped
const void * convertUntyped(const void *p) const
Convert pointer.
Definition: TypeConverter.cxx:116
D3PD
Block filler tool for noisy FEB information.
Definition: InnerDetector/InDetMonitoring/InDetGlobalMonitoring/macros/EnhancedPrimaryVertexMonitoring/TrigD3PD/ChainGroup.h:21
D3PD::IndexMultiAssociationFillerTool::m_associator
ToolHandle< IMultiAssociationTool > m_associator
Property: The association tool instance.
Definition: IndexMultiAssociationFillerTool.h:134
D3PD::IndexMultiAssociationFillerTool::fillUntyped
virtual StatusCode fillUntyped(const void *p, bool again=false) override
Fill one block.
Definition: IndexMultiAssociationFillerTool.cxx:150
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
D3PD::IndexMultiAssociationFillerTool::m_allowMissing
bool m_allowMissing
Property: Don't give an error if the target getter fails to find the input objects.
Definition: IndexMultiAssociationFillerTool.h:151
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::IndexMultiAssociationFillerTool::m_map
IndexMap m_map
Map from objects to indices.
Definition: IndexMultiAssociationFillerTool.h:161
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
REPORT_MESSAGE_WITH_CONTEXT
#define REPORT_MESSAGE_WITH_CONTEXT(LVL, CONTEXT_NAME)
Report a message, with an explicitly specified context name.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:345
D3PD::IndexMap::configureD3PD
StatusCode configureD3PD()
Configure during initialization: type-check.
Definition: IndexMap.cxx:137
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
errorcheck.h
Helpers for checking error return status codes and reporting errors.
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
D3PD::IndexMultiAssociationFillerTool::m_prefix
std::string m_prefix
Property: The variable name prefix.
Definition: IndexMultiAssociationFillerTool.h:141
D3PD::IndexMultiAssociationFillerTool::m_blockName
std::string m_blockName
Property: the name of this block.
Definition: IndexMultiAssociationFillerTool.h:144
D3PD::IndexMultiAssociationFillerTool::book
virtual StatusCode book() override
Declare tuple variables.
Definition: IndexMultiAssociationFillerTool.cxx:111