ATLAS Offline Software
Loading...
Searching...
No Matches
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.
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.

Private Attributes

ToolHandle< ICollectionGetterToolm_getter
 Property: The collection getter tool.
std::string m_objectName
 Property: the name of the D3PDObject that created this tool.
bool m_allowMissing
 Property: If true, the input object is allowed to be missing.
bool m_saveMetadata
 Property: If true, the metadata about the variables is saved.
ID3PDm_tree
 Pointer to the ID3PD object used.

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}
bool m_allowMissing
Property: If true, the input object is allowed to be missing.
ToolHandle< ICollectionGetterTool > m_getter
Property: The collection getter tool.
std::string m_objectName
Property: the name of the D3PDObject that created this tool.
ID3PD * m_tree
Pointer to the ID3PD object used.
bool m_saveMetadata
Property: If true, the metadata about the variables is saved.

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}
#define CHECK(...)
Evaluate an expression and check for errors.
virtual bool isContainerFiller() const
Find out if the filler handles containers or single objects.

◆ 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}
TChain * tree

◆ 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}
static Double_t sz

◆ 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}
#define REPORT_MESSAGE(LVL)
Report a message.
#define ATLAS_THREAD_SAFE

◆ 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}
virtual StatusCode initialize()
Standard Gaudi initialize method.

◆ 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: