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_blockName (blockName),
35 m_tree (0)
36{
37}
38
39
45AddVariable::AddVariable (const std::string& prefix,
46 const std::string& /*blockName*/,
47 const std::string& suffix)
48 : m_metadata (),
49 m_prefix (prefix),
50 m_suffix (suffix),
51 //m_blockName (blockName),
52 m_tree (0)
53{
54}
55
56
62{
63 m_tree = tree;
64 m_metadata.clear();
65 return StatusCode::SUCCESS;
66}
67
68
69/**
70 * @brief Add a variable to the tuple.
71 * @param name The name of the variable.
72 * @param type The type of the variable.
73 * @param ptr Pointer to the type of the variable.
74 * The pointer need not be initialized;
75 * the D3PD software will set the pointer
76 * prior to calling @c fill().
77 * @param docstring Documentation string for this variable.
78 * @param defval Pointer to the default value to use for this variable.
79 * Null for no default (generally means to fill with zeros).
80 * Of the type given by @c ti.
81 * Only works for basic types.
82 *
83 * If called from the constructor, the only effect is to clear @c ptr.
84 */
85StatusCode AddVariable::addVariable (const std::string& name,
86 const std::type_info& ti,
87 void* & ptr,
88 const std::string& docstring /*= ""*/,
89 const void* defval /*= 0*/)
90{
91 if (!m_tree) {
92 // Called from constructor --- just initialize pointer.
93 ptr = 0;
94 return StatusCode::SUCCESS;
95 }
96
98 ti, ptr, docstring, defval ) );
99 return m_tree->addVariable (m_prefix + name + m_suffix,
100 ti, ptr, docstring, defval);
101}
102
103
120 * If called from the constructor, the only effect is to clear @c ptr.
121 */
122StatusCode
123AddVariable::addDimensionedVariable (const std::string& name,
124 const std::type_info& ti,
125 void* & ptr,
126 const std::string& dim,
127 const std::string& docstring /*= ""*/,
128 const void* defval /*= 0*/)
129{
130 if (!m_tree) {
131 // Called from constructor --- just initialize pointer.
132 ptr = 0;
133 return StatusCode::SUCCESS;
134 }
135
136 CHECK( m_metadata.addDimensionedVariable( m_prefix + name + m_suffix,
137 ti, ptr, dim,
138 docstring, defval ) );
139 return m_tree->addDimensionedVariable (m_prefix + name + m_suffix,
140 ti, ptr, dim,
141 docstring, defval);
142}
143
144
145} // 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
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.
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
Reference to the block name.
virtual StatusCode addDimensionedVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &dim, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Common interface for adding a variable to a tuple.
StatusCode addVariable(const std::string &name, T *&ptr, const std::string &docstring="")
Add a variable to the tuple.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
This function can be used to save the metadata about a D3PD variable.
Block filler tool for noisy FEB information.
TChain * tree