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

Object filler tool for a collection of objects, saved as vectors. More...

#include <VectorFillerTool.h>

Inheritance diagram for D3PD::VectorFillerTool:
Collaboration diagram for D3PD::VectorFillerTool:

Public Member Functions

 VectorFillerTool (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...
 

Private Attributes

ToolHandle< ICollectionGetterToolm_getter
 Property: The collection getter tool. 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...
 

Detailed Description

Object filler tool for a collection of objects, saved as vectors.

This is an object filler tool for a collection of objects. The object variables are saved as vectors. I.e., if a block books a variable of type ‘int’, the variable we actually create is of type ‘vector<int>’. An additional variable giving the object count is added automatically (can be controlled via the NrowName property).

This tool has the following properties:

Getter - ICollectionGetterTool instance. AllowMissing - If true, then it is not considered an error for the requested input object to be missing.

and the following inherited from VectorFillerToolBase:

BlockFillers - List of IBlockFillerTool instances. Prefix - Prefix to add to variable names for this block. NrowName - Name of the variable for the count of rows. Omitted if empty. Default: ‘n’. NobjName - Name of the variable for the count of objects. (May be less than the number of rows if AGAIN is used.) Omitted if empty (default). ObjIndexName - Name of the variable for the object index. Omitted if empty (default).

For each event, we call the getter to retrieve the collection. We then loop over the objects in the collection. For each object, we set the variable pointers to point to the proper locations within the vectors. Then we loop over all block filler tools, passing the object to each.

Definition at line 68 of file VectorFillerTool.h.

Constructor & Destructor Documentation

◆ VectorFillerTool()

D3PD::VectorFillerTool::VectorFillerTool ( 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 VectorFillerTool.cxx.

33  : base_class (type, name, parent),
34  m_getter (this),
35  m_tree (0)
36 {
37  declareProperty ("Getter", m_getter,
38  "The ICollectionGetterTool instance.");
39  declareProperty ("ObjectName", m_objectName = "",
40  "Name of the D3PDObject that created this filler.");
41  declareProperty ("AllowMissing", m_allowMissing = false,
42  "If true, then it is not considered an error for the "
43  "requested input object to be missing.");
44  declareProperty ("SaveMetadata", m_saveMetadata = false,
45  "Set to true to get metadata into the output D3PD "
46  "about the variables created by this tool");
47 }

Member Function Documentation

◆ book()

StatusCode D3PD::VectorFillerTool::book ( )
virtual

Declare tuple variables.

This is called at the start of the first event.

Definition at line 94 of file VectorFillerTool.cxx.

95 {
96  // Be sure aux variables are defined.
97  CHECK( m_getter->reset (m_allowMissing) );
98 
99  // Configure the metadata object correctly:
100  m_metadata.setName( m_objectName );
101  m_metadata.setPrefix( m_prefix );
102  m_metadata.setContainer( isContainerFiller() );
103 
104  CHECK( doBook() );
105 
106  return StatusCode::SUCCESS;
107 }

◆ configureD3PD()

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

Configure the tool.

Parameters
treeThe parent D3PD tree.

This is called during initialization.

Definition at line 78 of file VectorFillerTool.cxx.

79 {
80  CHECK( doConfigure (tree, *m_getter) );
81 
82  // Try to cast the received object into an ID3PD one:
83  m_tree = dynamic_cast< ID3PD* >( tree );
84 
85  return StatusCode::SUCCESS;
86 }

◆ fill()

StatusCode D3PD::VectorFillerTool::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 119 of file VectorFillerTool.cxx.

120 {
121  CHECK( m_getter->reset (m_allowMissing) );
122  size_t sz = m_getter->sizeHint (m_allowMissing);
123 
124  CHECK( doFill (*m_getter, sz) );
125 
126  return StatusCode::SUCCESS;
127 }

◆ handle()

void D3PD::VectorFillerTool::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 150 of file VectorFillerTool.cxx.

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

◆ initialize()

StatusCode D3PD::VectorFillerTool::initialize ( )
virtual

Standard Gaudi initialize method.

Definition at line 54 of file VectorFillerTool.cxx.

55 {
57 
58  // Make sure the block fillers are initialized before the getter,
59  // so that it's more likely for the DataVector info to be available.
60  CHECK( m_getter.retrieve() );
61 
62  // Listen to the EndEvtLoop incident:
63  ServiceHandle< IIncidentSvc > p_incSvc( "IncidentSvc", name() );
64  CHECK( p_incSvc.retrieve() );
65  p_incSvc->addListener( this, "EndEvtLoop" );
66 
67  return StatusCode::SUCCESS;
68 }

◆ isContainerFiller()

bool D3PD::VectorFillerTool::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 136 of file VectorFillerTool.cxx.

137 {
138  return true;
139 }

Member Data Documentation

◆ m_allowMissing

bool D3PD::VectorFillerTool::m_allowMissing
private

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

Definition at line 141 of file VectorFillerTool.h.

◆ m_getter

ToolHandle<ICollectionGetterTool> D3PD::VectorFillerTool::m_getter
private

Property: The collection getter tool.

Definition at line 135 of file VectorFillerTool.h.

◆ m_objectName

std::string D3PD::VectorFillerTool::m_objectName
private

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

Definition at line 138 of file VectorFillerTool.h.

◆ m_saveMetadata

bool D3PD::VectorFillerTool::m_saveMetadata
private

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

Definition at line 144 of file VectorFillerTool.h.

◆ m_tree

ID3PD* D3PD::VectorFillerTool::m_tree
private

Pointer to the ID3PD object used.

Definition at line 147 of file VectorFillerTool.h.


The documentation for this class was generated from the following files:
fitman.sz
sz
Definition: fitman.py:527
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.
tree
TChain * tree
Definition: tile_monitor.h:30
python.checkMetadata.metadata
metadata
Definition: checkMetadata.py:175
Monitored::detail::doFill
void doFill(H *hist, W weight, size_t i, const M &m1, const Ms &... m)
Perform (arbitrary dimension) histogram fill with weight.
Definition: HistogramFillerUtils.h:164
D3PD::VectorFillerToolBase::initialize
virtual StatusCode initialize()
Standard Gaudi initialize method.
Definition: VectorFillerToolBase.cxx:88
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::VectorFillerTool::isContainerFiller
virtual bool isContainerFiller() const
Find out if the filler handles containers or single objects.
Definition: VectorFillerTool.cxx:136
D3PD::VectorFillerTool::m_allowMissing
bool m_allowMissing
Property: If true, the input object is allowed to be missing.
Definition: VectorFillerTool.h:141
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
REPORT_MESSAGE
#define REPORT_MESSAGE(LVL)
Report a message.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:365
D3PD::VectorFillerTool::m_objectName
std::string m_objectName
Property: the name of the D3PDObject that created this tool.
Definition: VectorFillerTool.h:138
D3PD::VectorFillerTool::m_tree
ID3PD * m_tree
Pointer to the ID3PD object used.
Definition: VectorFillerTool.h:147
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
D3PD::VectorFillerTool::m_saveMetadata
bool m_saveMetadata
Property: If true, the metadata about the variables is saved.
Definition: VectorFillerTool.h:144
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
ATLAS_THREAD_SAFE
#define ATLAS_THREAD_SAFE
Definition: checker_macros.h:211
D3PD::VectorFillerTool::m_getter
ToolHandle< ICollectionGetterTool > m_getter
Property: The collection getter tool.
Definition: VectorFillerTool.h:135
ServiceHandle< IIncidentSvc >