ATLAS Offline Software
Loading...
Searching...
No Matches
AddVariable.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
11
12
15
16
17namespace D3PD {
18
19
21const std::string AddVariable::s_emptyString;
22
23
29AddVariable::AddVariable (const std::string& prefix,
30 const std::string& /*blockName*/ /*= s_emptyString*/)
31 : m_metadata (),
32 m_prefix (prefix),
34 m_tree (0)
35{
36}
37
38
44AddVariable::AddVariable (const std::string& prefix,
45 const std::string& /*blockName*/,
46 const std::string& suffix)
47 : m_metadata (),
48 m_prefix (prefix),
49 m_suffix (suffix),
50 //m_blockName (blockName),
51 m_tree (0)
52{
53}
54
55
61{
62 m_tree = tree;
63 m_metadata.clear();
64 return StatusCode::SUCCESS;
65}
66
67
69 * @brief Add a variable to the tuple.
70 * @param name The name of the variable.
71 * @param type The type of the variable.
72 * @param ptr Pointer to the type of the variable.
73 * The pointer need not be initialized;
74 * the D3PD software will set the pointer
75 * prior to calling @c fill().
76 * @param docstring Documentation string for this variable.
77 * @param defval Pointer to the default value to use for this variable.
78 * Null for no default (generally means to fill with zeros).
79 * Of the type given by @c ti.
80 * Only works for basic types.
81 *
82 * If called from the constructor, the only effect is to clear @c ptr.
83 */
84StatusCode AddVariable::addVariable (const std::string& name,
85 const std::type_info& ti,
86 void* & ptr,
87 std::string_view docstring /*= ""*/,
88 const void* defval /*= 0*/)
89{
90 if (!m_tree) {
91 // Called from constructor --- just initialize pointer.
92 ptr = 0;
93 return StatusCode::SUCCESS;
94 }
95
96 CHECK( m_metadata.addVariable( m_prefix + name + m_suffix,
97 ti, ptr, docstring, defval ) );
98 return m_tree->addVariable (m_prefix + name + m_suffix,
99 ti, ptr, docstring, defval);
100}
101
102
119 * If called from the constructor, the only effect is to clear @c ptr.
120 */
121StatusCode
122AddVariable::addDimensionedVariable (const std::string& name,
123 const std::type_info& ti,
124 void* & ptr,
125 const std::string& dim,
126 std::string_view docstring /*= ""*/,
127 const void* defval /*= 0*/)
128{
129 if (!m_tree) {
130 // Called from constructor --- just initialize pointer.
131 ptr = 0;
132 return StatusCode::SUCCESS;
133 }
134
135 CHECK( m_metadata.addDimensionedVariable( m_prefix + name + m_suffix,
136 ti, ptr, dim,
137 docstring, defval ) );
138 return m_tree->addDimensionedVariable (m_prefix + name + m_suffix,
139 ti, ptr, dim,
140 docstring, defval);
141}
142
143
144} // namespace D3PD
Common implementation of IAddVariable.
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
static const std::string s_emptyString
Used to provide a default value for blockName.
Definition AddVariable.h:41
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
AddVariable(const std::string &prefix, const std::string &blockName=s_emptyString)
Constructor.
ObjectMetadata m_metadata
Metadata about the variables created by this object.
const std::string & m_prefix
Reference to the variable prefix.
const std::string & m_suffix
Reference to the variable suffix.
IAddVariable * m_tree
The parent IAddVariable instance.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, std::string_view docstring="", const void *defval=0)
Add a variable to the tuple.
virtual StatusCode addDimensionedVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &dim, std::string_view docstring="", const void *defval=0)
Add a variable to the tuple.
Common interface for adding a variable to a tuple.
Block filler tool for noisy FEB information.
ID3PD * m_tree
Pointer to the ID3PD object used.
std::string m_prefix
Property: The variable name prefix.
ObjectMetadata m_metadata
Metadata about the variables created by this tool.
TChain * tree