ATLAS Offline Software
Loading...
Searching...
No Matches
ContainerFlagFillerTool.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$
12
13
16
17
18namespace D3PD {
19
20
22 const std::string& name,
23 const IInterface* parent)
24 : BlockFillerToolImpl (type, name, parent),
25 m_getters (this),
27{
28 declareProperty ("FlagNames", m_flagNames,
29 "Names of the flags added to the D3PD."
30"May be followed by a string of the form `@TYPE/KEY', in which case the "
31"corresponding entry in Getters is automatically initialized (only available "
32"when the Python configuration wrapper is used). May be followed by a "
33"docstring following a colon.");
34 declareProperty ("Getters", m_getters,
35 "Getter tools for the INav4MomLinkContainer objects.");
36 declareProperty ("AllowMissing", m_allowMissing,
37 "If true, missing containers will not be considered errors.");
38}
39
40
45{
46 // Check that the configuration makes sense:
47 if( m_getters.size() != m_flagNames.size() ) {
48 REPORT_MESSAGE( MSG::FATAL )
49 << "Different number of getter tools and flags specified";
50 return StatusCode::FAILURE;
51 }
52
53 CHECK( BlockFillerToolImpl::initialize() );
54
55 return StatusCode::SUCCESS;
56}
57
58
68 const std::type_info& ti)
69{
70 CHECK( m_map.configureD3PD (ti) );
72 return StatusCode::SUCCESS;
73}
74
75
82{
83 // Resize the flag vector to the right size:
84 m_flags.resize( m_flagNames.size(), 0 );
85
86 // Book the flag variable(s):
87 for( size_t i = 0; i < m_flagNames.size(); ++i ) {
88 std::string flagname = m_flagNames[i];
89 std::string desc = "Was this object selected according to X criteria?";
90 std::string::size_type ipos = flagname.find (':');
91 if (ipos != std::string::npos) {
92 desc = flagname.substr (ipos+1, std::string::npos);
93 flagname.resize (ipos);
94 }
95 CHECK( addVariable (flagname, m_flags[ i ], desc) );
96 }
97
98 return StatusCode::SUCCESS;
99}
100
101
112StatusCode ContainerFlagFillerTool::fillUntyped (const void* p,
113 bool /*again = false*/)
114{
115 if (m_flags.empty())
116 return StatusCode(EMPTY);
117
118 CHECK( m_map.reset() );
119 for (size_t i = 0; i < m_flags.size(); i++)
120 *m_flags[i] = (m_map.findIndex (p, i) != -1);
121 return StatusCode::SUCCESS;
122}
123
124
125} // namespace D3PD
Flag objects that are present in other containers.
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.
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.
BlockFillerToolImpl(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual StatusCode initialize()
Function initializing the tool.
std::vector< std::string > m_flagNames
Property: The flag names.
bool m_allowMissing
Property: If true, missing containers will not be considered errors.
std::vector< bool * > m_flags
Variables: The flags created in the D3PD.
virtual StatusCode configureD3PD(IAddVariable *tree, const std::type_info &ti)
Configure during initialization: type-check.
virtual StatusCode book()
Declare tuple variables.
ToolHandleArray< ICollectionGetterTool > m_getters
Property: The container getters that are used to compute the flags.
IndexMap m_map
Map to manage index lookups.
ContainerFlagFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual StatusCode fillUntyped(const void *p, bool again=false)
Fill one block.
Common interface for adding a variable to a tuple.
Block filler tool for noisy FEB information.
TChain * tree