ATLAS Offline Software
Loading...
Searching...
No Matches
D3PD::VoidObjFillerTool Class Reference

Object filler tool for tools taking no input. More...

#include <VoidObjFillerTool.h>

Inheritance diagram for D3PD::VoidObjFillerTool:
Collaboration diagram for D3PD::VoidObjFillerTool:

Public Member Functions

 VoidObjFillerTool (const std::string &type, const std::string &name, const IInterface *parent)
 Standard Gaudi tool constructor.
virtual StatusCode initialize ()
 Standard Gaudi initialize method.
virtual StatusCode configureD3PD (IAddVariable *tree)
 Configure the tool.
virtual StatusCode book ()
 Declare tuple variables.
virtual StatusCode fill ()
 Fill one object.
virtual bool isContainerFiller () const
 Find out if the filler handles containers or single objects.
virtual void handle (const Incident &inc)
 Handle end of run incidents to save the metadata at that point.
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.
template<class T>
StatusCode addVariable (const std::string &name, T *&ptr, const std::string &docstring="")
 Make the template implementation from IAddVariable visible.
template<class T, class U>
StatusCode addVariable (const std::string &name, T *&ptr, const std::string &docstring, const U &defval)
 Make the template implementation from IAddVariable visible.
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.
template<class T>
StatusCode addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="")
 Add a variable to the tuple.
template<class T, class U>
StatusCode addDimensionedVariable (const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring, const U &defval)
 Add a variable to the tuple.

Protected Attributes

ObjectMetadata m_metadata
 Metadata about the variables created by this object.

Private Attributes

ToolHandleArray< IBlockFillerToolm_blockFillers
 Property: The list of block filler tools.
std::string m_prefix
 Property: Variable prefix for this block.
std::string m_blockName
 Property: the name of this block.
std::string m_objectName
 Property: the name of the D3PDObject that created this tool.
bool m_saveMetadata
 Property: If true, the metadata about the variables is saved.
ID3PDm_tree
 Pointer to the ID3PD object used.
const std::string & m_suffix
 Reference to the variable suffix.

Static Private Attributes

static const std::string s_emptyString
 Used to provide a default value for blockName.

Detailed Description

Object filler tool for tools taking no input.

This is an object filler tool for tools that take no input. It has the following properties:

BlockFillers - List of IBlockFillerTool instances. Prefix - Prefix to add to variable names for this block.

For each event, we loop over all block filler tools.

Definition at line 45 of file VoidObjFillerTool.h.

Constructor & Destructor Documentation

◆ VoidObjFillerTool()

D3PD::VoidObjFillerTool::VoidObjFillerTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Standard Gaudi tool constructor.

Parameters
typeThe name of the tool type.
nameThe tool name.
parentThe tool's Gaudi parent.

Definition at line 29 of file VoidObjFillerTool.cxx.

33 : base_class (type, name, parent),
35 m_blockFillers (this),
36 m_tree (0)
37{
38 declareProperty ("BlockFillers", m_blockFillers,
39 "List of contained block filler tools.");
40 declareProperty ("Prefix", m_prefix = "",
41 "Variable name prefix for the contained blocks.");
42 declareProperty ("BlockName", m_blockName = this->name(),
43 "The name of this block.");
44 declareProperty ("ObjectName", m_objectName = "",
45 "Name of the D3PDObject that created this filler.");
46 declareProperty ("SaveMetadata", m_saveMetadata = false,
47 "Set to true to get metadata into the output D3PD "
48 "about the variables created by this tool");
49}
AddVariable(const std::string &prefix, const std::string &blockName=s_emptyString)
Constructor.
bool m_saveMetadata
Property: If true, the metadata about the variables is saved.
std::string m_objectName
Property: the name of the D3PDObject that created this tool.
ID3PD * m_tree
Pointer to the ID3PD object used.
std::string m_blockName
Property: the name of this block.
ToolHandleArray< IBlockFillerTool > m_blockFillers
Property: The list of block filler tools.
std::string m_prefix
Property: Variable prefix for this block.

Member Function Documentation

◆ addDimensionedVariable() [1/3]

StatusCode D3PD::AddVariable::addDimensionedVariable ( const std::string & name,
const std::type_info & ti,
void *& ptr,
const std::string & dim,
const std::string & docstring = "",
const void * defval = 0 )
virtualinherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
typeThe type of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

Implements D3PD::IAddVariable.

Definition at line 123 of file AddVariable.cxx.

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}
#define CHECK(...)
Evaluate an expression and check for errors.
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.
void * ptr(T *p)
Definition SGImplSvc.cxx:74

◆ addDimensionedVariable() [2/3]

template<class T, class U>
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string & name,
T *& ptr,
const std::string & dim,
const std::string & docstring,
const U & defval )
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

◆ addDimensionedVariable() [3/3]

template<class T>
StatusCode D3PD::IAddVariable::addDimensionedVariable ( const std::string & name,
T *& ptr,
const std::string & dim,
const std::string & docstring = "" )
inherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
dimDimension for the variable. (Presently unimplemented!)
docstringDocumentation string for this variable.

If called from the constructor, the only effect is to clear ptr.

◆ addVariable() [1/3]

StatusCode D3PD::AddVariable::addVariable ( const std::string & name,
const std::type_info & ti,
void *& ptr,
const std::string & docstring = "",
const void * defval = 0 )
virtualinherited

Add a variable to the tuple.

Parameters
nameThe name of the variable.
typeThe type of the variable.
ptrPointer to the type of the variable. The pointer need not be initialized; the D3PD software will set the pointer prior to calling fill().
docstringDocumentation string for this variable.
defvalPointer to the default value to use for this variable. Null for no default (generally means to fill with zeros). Of the type given by ti. Only works for basic types.

If called from the constructor, the only effect is to clear ptr.

Implements D3PD::IAddVariable.

Definition at line 85 of file AddVariable.cxx.

90{
91 if (!m_tree) {
92 // Called from constructor --- just initialize pointer.
93 ptr = 0;
94 return StatusCode::SUCCESS;
95 }
96
97 CHECK( m_metadata.addVariable( m_prefix + name + m_suffix,
98 ti, ptr, docstring, defval ) );
99 return m_tree->addVariable (m_prefix + name + m_suffix,
100 ti, ptr, docstring, defval);
101}

◆ addVariable() [2/3]

template<class T, class U>
StatusCode D3PD::IAddVariable::addVariable ( const std::string & name,
T *& ptr,
const std::string & docstring,
const U & defval )
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [3/3]

template<class T>
StatusCode D3PD::IAddVariable::addVariable ( const std::string & name,
T *& ptr,
const std::string & docstring = "" )
inherited

Make the template implementation from IAddVariable visible.

◆ book()

StatusCode D3PD::VoidObjFillerTool::book ( )
virtual

Declare tuple variables.

This is called at the start of the first event.

Definition at line 95 of file VoidObjFillerTool.cxx.

96{
97 // Configure the metadata object correctly:
98 m_metadata.setName( m_objectName );
99 m_metadata.setPrefix( m_prefix );
100 m_metadata.setContainer( isContainerFiller() );
101
102 for (size_t i = 0; i < m_blockFillers.size(); i++)
103 CHECK( m_blockFillers[i]->book() );
104
105 return StatusCode::SUCCESS;
106}
virtual bool isContainerFiller() const
Find out if the filler handles containers or single objects.
virtual StatusCode book()
Declare tuple variables.

◆ configureD3PD()

StatusCode D3PD::VoidObjFillerTool::configureD3PD ( IAddVariable * tree)
virtual

Configure the tool.

Parameters
treeThe parent D3PD tree.

This is called during initialization.

Definition at line 77 of file VoidObjFillerTool.cxx.

78{
80 for (size_t i = 0; i < m_blockFillers.size(); i++)
81 CHECK( m_blockFillers[i]->configureD3PD (this, typeid(void)) );
82
83 // Try to cast the received object into an ID3PD one:
84 m_tree = dynamic_cast< ID3PD* >( tree );
85
86 return StatusCode::SUCCESS;
87}
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
virtual StatusCode configureD3PD(IAddVariable *tree)
Configure the tool.
TChain * tree

◆ fill()

StatusCode D3PD::VoidObjFillerTool::fill ( )
virtual

Fill one object.

This is called once per event. It should:

  • Fetch the input.
  • If it's a container, loop over the contents.
  • Loop over the contained block filler tools.

This is called once per event. It loops over the contained block filler tools.

Definition at line 116 of file VoidObjFillerTool.cxx.

117{
118 for (size_t i = 0; i < m_blockFillers.size(); i++)
119 CHECK( m_blockFillers[i]->fillUntyped (0) );
120
121 return StatusCode::SUCCESS;
122}

◆ handle()

void D3PD::VoidObjFillerTool::handle ( const Incident & inc)
virtual

Handle end of run incidents to save the metadata at that point.

The metadata saving is now done when seeing an end of run incident.

This is needed because of MC11b...

Basically, we can't do this in finalize(), because the output TTree is no longer accessible by then. So it has to be done just before the event loop is finished.

Definition at line 145 of file VoidObjFillerTool.cxx.

146{
147 if( inc.type() == "EndEvtLoop" ) {
148 if( m_tree && m_metadata.variables().size() && m_saveMetadata ) {
149 const std::string metadata = m_metadata.toString();
150 // safe because this incident handler is only called serially
151 const std::string metadataName ATLAS_THREAD_SAFE = m_metadata.metadataName();
152 if( m_tree->addMetadata( metadataName,
153 &metadata ).isFailure() ) {
154 REPORT_MESSAGE( MSG::ERROR )
155 << "Couldn't add object metadata information to the output!";
156 return;
157 }
158 }
159 }
160
161 return;
162}
#define REPORT_MESSAGE(LVL)
Report a message.
#define ATLAS_THREAD_SAFE

◆ initialize()

StatusCode D3PD::VoidObjFillerTool::initialize ( )
virtual

Standard Gaudi initialize method.

Definition at line 56 of file VoidObjFillerTool.cxx.

57{
58 CHECK( AthAlgTool::initialize() );
59 CHECK( m_blockFillers.retrieve() );
60
61 // Listen to EndEvent and EndRun incidents:
62 ServiceHandle< IIncidentSvc > p_incSvc( "IncidentSvc", name() );
63 CHECK( p_incSvc.retrieve() );
64 p_incSvc->addListener( this, "EndEvtLoop" );
65
66 return StatusCode::SUCCESS;
67}

◆ isContainerFiller()

bool D3PD::VoidObjFillerTool::isContainerFiller ( ) const
virtual

Find out if the filler handles containers or single objects.

This is used by the D3PDReader code generator to know how to create the generated source files exactly.

Definition at line 131 of file VoidObjFillerTool.cxx.

132{
133 return false;
134}

Member Data Documentation

◆ m_blockFillers

ToolHandleArray<IBlockFillerTool> D3PD::VoidObjFillerTool::m_blockFillers
private

Property: The list of block filler tools.

Definition at line 111 of file VoidObjFillerTool.h.

◆ m_blockName

std::string D3PD::VoidObjFillerTool::m_blockName
private

Property: the name of this block.

Definition at line 117 of file VoidObjFillerTool.h.

◆ m_metadata

ObjectMetadata D3PD::AddVariable::m_metadata
protectedinherited

Metadata about the variables created by this object.

Definition at line 129 of file AddVariable.h.

◆ m_objectName

std::string D3PD::VoidObjFillerTool::m_objectName
private

Property: the name of the D3PDObject that created this tool.

Definition at line 120 of file VoidObjFillerTool.h.

◆ m_prefix

std::string D3PD::VoidObjFillerTool::m_prefix
private

Property: Variable prefix for this block.

Definition at line 114 of file VoidObjFillerTool.h.

◆ m_saveMetadata

bool D3PD::VoidObjFillerTool::m_saveMetadata
private

Property: If true, the metadata about the variables is saved.

Definition at line 123 of file VoidObjFillerTool.h.

◆ m_suffix

const std::string& D3PD::AddVariable::m_suffix
privateinherited

Reference to the variable suffix.

Definition at line 137 of file AddVariable.h.

◆ m_tree

ID3PD* D3PD::VoidObjFillerTool::m_tree
private

Pointer to the ID3PD object used.

Definition at line 126 of file VoidObjFillerTool.h.

◆ s_emptyString

const std::string D3PD::AddVariable::s_emptyString
staticprivateinherited

Used to provide a default value for blockName.

Definition at line 41 of file AddVariable.h.


The documentation for this class was generated from the following files: