ATLAS Offline Software
Public Member Functions | Protected Attributes | Private Attributes | Static Private Attributes | List of all members
D3PD::ObjFillerTool Class Reference

Object filler tool for a single object. More...

#include <ObjFillerTool.h>

Inheritance diagram for D3PD::ObjFillerTool:
Collaboration diagram for D3PD::ObjFillerTool:

Public Member Functions

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

Protected Attributes

ObjectMetadata m_metadata
 Metadata about the variables created by this object. More...
 

Private Attributes

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

Static Private Attributes

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

Detailed Description

Object filler tool for a single object.

This is an object filler tool for a single object. It has the following properties:

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

For each event, we call the getter to retrieve the object. Then we loop over all block filler tools, passing the object to each.

Definition at line 49 of file ObjFillerTool.h.

Constructor & Destructor Documentation

◆ ObjFillerTool()

D3PD::ObjFillerTool::ObjFillerTool ( 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 30 of file ObjFillerTool.cxx.

33  : base_class (type, name, parent),
35  m_getter (this),
36  m_blockFillers (this),
37  m_tree (0)
38 {
39  declareProperty ("Getter", m_getter,
40  "The IObjGetterTool instance.");
41  declareProperty ("BlockFillers", m_blockFillers,
42  "List of contained block filler tools.");
43  declareProperty ("Prefix", m_prefix = "",
44  "Variable name prefix for the contained blocks.");
45  declareProperty ("BlockName", m_blockName = this->name(),
46  "The name of this block.");
47  declareProperty ("ObjectName", m_objectName = "",
48  "Name of the D3PDObject that created this filler.");
49  declareProperty ("AllowMissing", m_allowMissing = false,
50  "If true, then it is not considered an error for the "
51  "requested input object to be missing.");
52  declareProperty ("SaveMetadata", m_saveMetadata = false,
53  "Set to true to get metadata into the output D3PD "
54  "about the variables created by this tool");
55 }

Member Function Documentation

◆ addDimensionedVariable() [1/6]

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 
137  ti, ptr, dim,
138  docstring, defval ) );
140  ti, ptr, dim,
141  docstring, defval);
142 }

◆ addDimensionedVariable() [2/6]

virtual StatusCode D3PD::IAddVariable::addDimensionedVariable
inherited

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.

◆ addDimensionedVariable() [3/6]

template<class T , class U >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( class T  ,
class U   
)
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() [4/6]

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() [5/6]

template<class T >
StatusCode D3PD::IAddVariable::addDimensionedVariable ( class T  )
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.

◆ addDimensionedVariable() [6/6]

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/6]

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 
98  ti, ptr, docstring, defval ) );
100  ti, ptr, docstring, defval);
101 }

◆ addVariable() [2/6]

virtual StatusCode D3PD::IAddVariable::addVariable
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [3/6]

template<class T , class U >
StatusCode D3PD::IAddVariable::addVariable ( class T  ,
class U   
)
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [4/6]

template<class T , class U >
StatusCode D3PD::IAddVariable::addVariable ( const std::string &  name,
T *&  ptr,
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().
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.

◆ addVariable() [5/6]

template<class T >
StatusCode D3PD::IAddVariable::addVariable ( class T  )
inherited

Make the template implementation from IAddVariable visible.

◆ addVariable() [6/6]

template<class T >
StatusCode D3PD::IAddVariable::addVariable ( const std::string &  name,
T *&  ptr,
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().
docstringDocumentation string for this variable.

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

◆ book()

StatusCode D3PD::ObjFillerTool::book ( )
virtual

Declare tuple variables.

This is called at the start of the first event.

Definition at line 105 of file ObjFillerTool.cxx.

106 {
107  // Be sure aux variables are defined.
108  (void)m_getter->getUntyped (m_allowMissing);
109 
110  // Configure the metadata object correctly:
114 
115  for (size_t i = 0; i < m_blockFillers.size(); i++)
116  CHECK( m_blockFillers[i]->book() );
117 
118  return StatusCode::SUCCESS;
119 }

◆ configureD3PD()

StatusCode D3PD::ObjFillerTool::configureD3PD ( IAddVariable tree)
virtual

Configure the tool.

Parameters
treeThe parent D3PD tree.

This is called during initialization.

Definition at line 84 of file ObjFillerTool.cxx.

85 {
86  // The type that the getter will provide.
87  const std::type_info& ti = m_getter->typeinfo();
88 
90  for (size_t i = 0; i < m_blockFillers.size(); i++)
91  CHECK( m_blockFillers[i]->configureD3PD (this, ti) );
92 
93  // Try to cast the received object into an ID3PD one:
94  m_tree = dynamic_cast< ID3PD* >( tree );
95 
96  return StatusCode::SUCCESS;
97 }

◆ fill()

StatusCode D3PD::ObjFillerTool::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.

Definition at line 131 of file ObjFillerTool.cxx.

132 {
133  const void* obj = m_getter->getUntyped (m_allowMissing);
134  if (!obj) {
135  if (m_allowMissing)
136  return StatusCode::SUCCESS;
137  REPORT_MESSAGE(MSG::ERROR) << "Can't get input object.";
138  return StatusCode::FAILURE;
139  }
140 
141  for (size_t i = 0; i < m_blockFillers.size(); i++)
142  CHECK( m_blockFillers[i]->fillUntyped (obj) );
143 
144  m_getter->releaseObjectUntyped (obj);
145 
146  return StatusCode::SUCCESS;
147 }

◆ handle()

void D3PD::ObjFillerTool::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 170 of file ObjFillerTool.cxx.

171 {
172  if( inc.type() == "EndEvtLoop" ) {
173  if( m_tree && m_metadata.variables().size() && m_saveMetadata ) {
174  const std::string metadata = m_metadata.toString();
175  // safe because this incident handler is only called serially
176  const std::string metadataName ATLAS_THREAD_SAFE = m_metadata.metadataName();
177  if( m_tree->addMetadata( metadataName,
178  &metadata ).isFailure() ) {
179  REPORT_MESSAGE( MSG::ERROR )
180  << "Couldn't add object metadata information to the output!";
181  return;
182  }
183  }
184  }
185 
186  return;
187 }

◆ initialize()

StatusCode D3PD::ObjFillerTool::initialize ( )
virtual

Standard Gaudi initialize method.

Definition at line 62 of file ObjFillerTool.cxx.

63 {
65  CHECK( m_getter.retrieve() );
66  CHECK( m_blockFillers.retrieve() );
67 
68  // Listen to EndEvent and EndRun incidents:
69  ServiceHandle< IIncidentSvc > p_incSvc( "IncidentSvc", name() );
70  CHECK( p_incSvc.retrieve() );
71  p_incSvc->addListener( this, "EndEvtLoop" );
72 
73  return StatusCode::SUCCESS;
74 }

◆ isContainerFiller()

bool D3PD::ObjFillerTool::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 156 of file ObjFillerTool.cxx.

157 {
158  return false;
159 }

Member Data Documentation

◆ m_allowMissing

bool D3PD::ObjFillerTool::m_allowMissing
private

Property: If true, the input object is allowed to be missing.

Definition at line 129 of file ObjFillerTool.h.

◆ m_blockFillers

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

Property: The list of block filler tools.

Definition at line 117 of file ObjFillerTool.h.

◆ m_blockName

std::string D3PD::ObjFillerTool::m_blockName
private

Property: the name of this block.

Definition at line 123 of file ObjFillerTool.h.

◆ m_getter

ToolHandle<IObjGetterTool> D3PD::ObjFillerTool::m_getter
private

Property: The object getter tool.

Definition at line 114 of file ObjFillerTool.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::ObjFillerTool::m_objectName
private

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

Definition at line 126 of file ObjFillerTool.h.

◆ m_prefix

std::string D3PD::ObjFillerTool::m_prefix
private

Property: Variable prefix for this block.

Definition at line 120 of file ObjFillerTool.h.

◆ m_saveMetadata

bool D3PD::ObjFillerTool::m_saveMetadata
private

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

Definition at line 132 of file ObjFillerTool.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::ObjFillerTool::m_tree
private

Pointer to the ID3PD object used.

Definition at line 135 of file ObjFillerTool.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:
D3PD::ObjectMetadata::variables
const std::set< Variable > & variables() const
Function for accessing all the variables of the D3PDObject.
Definition: ObjectMetadata.cxx:577
D3PD::ObjectMetadata::addDimensionedVariable
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)
The object doesn't support dimensioned variables at the moment, like most of the D3PDMaker code doesn...
Definition: ObjectMetadata.cxx:157
yodamerge_tmp.dim
dim
Definition: yodamerge_tmp.py:239
D3PD::ID3PD::addMetadata
virtual StatusCode addMetadata(const std::string &key, const void *obj, const std::type_info &ti)=0
Add a new piece of metadata to the tuple.
D3PD::AddVariable::configureD3PD
StatusCode configureD3PD(IAddVariable *tree)
Configure the parent tree.
Definition: AddVariable.cxx:61
D3PD::AddVariable::AddVariable
AddVariable(const std::string &prefix, const std::string &blockName=s_emptyString)
Constructor.
Definition: AddVariable.cxx:29
D3PD::AddVariable::m_suffix
const std::string & m_suffix
Reference to the variable suffix.
Definition: AddVariable.h:137
initialize
void initialize()
Definition: run_EoverP.cxx:894
tree
TChain * tree
Definition: tile_monitor.h:30
D3PD::ObjectMetadata::setName
void setName(const std::string &name)
Set the name of the D3PDObject that this object describes.
Definition: ObjectMetadata.cxx:175
D3PD::AddVariable::m_prefix
const std::string & m_prefix
Reference to the variable prefix.
Definition: AddVariable.h:134
D3PD::ObjectMetadata::setPrefix
void setPrefix(const std::string &prefix)
Set the prefix given to variables in this D3PDObject.
Definition: ObjectMetadata.cxx:224
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
D3PD::ObjFillerTool::m_objectName
std::string m_objectName
Property: the name of the D3PDObject that created this tool.
Definition: ObjFillerTool.h:126
D3PD::AddVariable::m_tree
IAddVariable * m_tree
Reference to the block name.
Definition: AddVariable.h:143
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
D3PD::AddVariable::m_metadata
ObjectMetadata m_metadata
Metadata about the variables created by this object.
Definition: AddVariable.h:129
lumiFormat.i
int i
Definition: lumiFormat.py:85
test_pyathena.parent
parent
Definition: test_pyathena.py:15
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::ObjFillerTool::m_allowMissing
bool m_allowMissing
Property: If true, the input object is allowed to be missing.
Definition: ObjFillerTool.h:129
D3PD::ObjectMetadata::toString
std::string toString() const
Function "serializing" the stored information into a string.
Definition: ObjectMetadata.cxx:249
D3PD::ObjFillerTool::m_prefix
std::string m_prefix
Property: Variable prefix for this block.
Definition: ObjFillerTool.h:120
D3PD::ObjFillerTool::configureD3PD
virtual StatusCode configureD3PD(IAddVariable *tree)
Configure the tool.
Definition: ObjFillerTool.cxx:84
D3PD::ObjectMetadata::setContainer
void setContainer(bool container)
Set whether the D3PDObject describes a container or not.
Definition: ObjectMetadata.cxx:235
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
D3PD::ObjectMetadata::addVariable
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.
Definition: ObjectMetadata.cxx:109
D3PD::ObjFillerTool::m_getter
ToolHandle< IObjGetterTool > m_getter
Property: The object getter tool.
Definition: ObjFillerTool.h:114
D3PD::ObjFillerTool::m_tree
ID3PD * m_tree
Pointer to the ID3PD object used.
Definition: ObjFillerTool.h:135
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::ObjFillerTool::m_saveMetadata
bool m_saveMetadata
Property: If true, the metadata about the variables is saved.
Definition: ObjFillerTool.h:132
D3PD::ObjFillerTool::isContainerFiller
virtual bool isContainerFiller() const
Find out if the filler handles containers or single objects.
Definition: ObjFillerTool.cxx:156
D3PD::IAddVariable::addVariable
StatusCode addVariable(const std::string &name, T *&ptr, const std::string &docstring="")
Add a variable to the tuple.
D3PD::ObjFillerTool::m_blockName
std::string m_blockName
Property: the name of this block.
Definition: ObjFillerTool.h:123
D3PD::IAddVariable::addDimensionedVariable
StatusCode addDimensionedVariable(const std::string &name, T *&ptr, const std::string &dim, const std::string &docstring="")
Add a variable to the tuple.
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
python.PyAthena.obj
obj
Definition: PyAthena.py:132
D3PD::ObjFillerTool::m_blockFillers
ToolHandleArray< IBlockFillerTool > m_blockFillers
Property: The list of block filler tools.
Definition: ObjFillerTool.h:117
D3PD::ObjFillerTool::book
virtual StatusCode book()
Declare tuple variables.
Definition: ObjFillerTool.cxx:105
ServiceHandle< IIncidentSvc >