ATLAS Offline Software
Loading...
Searching...
No Matches
VectorFillerTool.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
13#include "VectorFillerTool.h"
17#include "GaudiKernel/Incident.h"
18#include "GaudiKernel/IIncidentSvc.h"
19
20
21namespace D3PD {
22
23
31 const std::string& name,
32 const IInterface* parent)
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}
48
49
53StatusCode
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}
69
70
77StatusCode
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}
87
88
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}
108
109
118StatusCode
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}
128
129
137{
138 return true;
139}
140
141
150void VectorFillerTool::handle( const Incident& inc )
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}
168
169
170} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define REPORT_MESSAGE(LVL)
Report a message.
#define CHECK(...)
Evaluate an expression and check for errors.
Abstract interface for a D3PD tree.
static Double_t sz
Object filler tool for a collection of objects, saved as vectors.
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Common interface for adding a variable to a tuple.
Define an abstract interface for building a D3PD tree.
Definition ID3PD.h:37
virtual StatusCode initialize()
Standard Gaudi initialize method.
virtual StatusCode initialize()
Standard Gaudi initialize method.
bool m_allowMissing
Property: If true, the input object is allowed to be missing.
virtual StatusCode book()
Declare tuple variables.
VectorFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual void handle(const Incident &inc)
Handle end of run incidents to save the metadata at that point.
virtual bool isContainerFiller() const
Find out if the filler handles containers or single objects.
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.
virtual StatusCode fill()
Fill one object.
virtual StatusCode configureD3PD(IAddVariable *tree)
Configure the tool.
bool m_saveMetadata
Property: If true, the metadata about the variables is saved.
Block filler tool for noisy FEB information.
TChain * tree