The Gaudi Framework  master (34daa81a)
Loading...
Searching...
No Matches
Gaudi::NTuple::FileHolder< Base > Struct Template Reference

Small class wrapping an algorithm and adding management of a Root File via the FileSvc. More...

#include </builds/gaudi/Gaudi/GaudiUtils/include/Gaudi/NTuple/Writer.h>

Inheritance diagram for Gaudi::NTuple::FileHolder< Base >:
Collaboration diagram for Gaudi::NTuple::FileHolder< Base >:

Public Member Functions

TFile * file ()
 
virtual StatusCode initialize () override
 

Private Attributes

Gaudi::Property< std::string > m_fileId { this, "OutputFile", "NTuple", "Identifier for the TFile to write to." }
 
ServiceHandle< Gaudi::Interfaces::IFileSvcm_fileSvc { this, "FileSvc", "FileSvc" }
 
std::shared_ptr< TFile > m_file = nullptr
 

Detailed Description

template<typename Base>
struct Gaudi::NTuple::FileHolder< Base >

Small class wrapping an algorithm and adding management of a Root File via the FileSvc.

The file to be used is identified via Property OutputFile Can typically be used in conjunction with Wrapper to add support for NTuples in a given algorithm For simple cases (single NTuple), prefer to inherit directly from SimpleWriter or Writer (in case a single entry per event is required)

Definition at line 119 of file Writer.h.

Member Function Documentation

◆ file()

template<typename Base>
TFile * Gaudi::NTuple::FileHolder< Base >::file ( )
inline

Definition at line 121 of file Writer.h.

121{ return m_file.get(); }
std::shared_ptr< TFile > m_file
Definition Writer.h:137

◆ initialize()

template<typename Base>
virtual StatusCode Gaudi::NTuple::FileHolder< Base >::initialize ( )
inlineoverridevirtual

Reimplemented in Gaudi::NTuple::SimpleWriter< std::tuple< OUTPUTs... >(const INPUTs &...), Traits_ >.

Definition at line 123 of file Writer.h.

123 {
124 return Base::initialize().andThen( [this]() {
125 m_file = m_fileSvc->getFile( m_fileId );
126 if ( !m_file ) {
127 this->error() << "Failed to retrieve TFile." << endmsg;
128 return StatusCode::FAILURE;
129 }
130 return StatusCode::SUCCESS;
131 } );
132 }
Small class wrapping an algorithm and adding management of a Root File via the FileSvc.
Definition Writer.h:119
Gaudi::Property< std::string > m_fileId
Definition Writer.h:135
ServiceHandle< Gaudi::Interfaces::IFileSvc > m_fileSvc
Definition Writer.h:136

Member Data Documentation

◆ m_file

template<typename Base>
std::shared_ptr<TFile> Gaudi::NTuple::FileHolder< Base >::m_file = nullptr
private

Definition at line 137 of file Writer.h.

◆ m_fileId

template<typename Base>
Gaudi::Property<std::string> Gaudi::NTuple::FileHolder< Base >::m_fileId { this, "OutputFile", "NTuple", "Identifier for the TFile to write to." }
private

Definition at line 135 of file Writer.h.

135{ this, "OutputFile", "NTuple", "Identifier for the TFile to write to." };

◆ m_fileSvc

template<typename Base>
ServiceHandle<Gaudi::Interfaces::IFileSvc> Gaudi::NTuple::FileHolder< Base >::m_fileSvc { this, "FileSvc", "FileSvc" }
private

Definition at line 136 of file Writer.h.

136{ this, "FileSvc", "FileSvc" };

The documentation for this struct was generated from the following file: