The Gaudi Framework  master (69a68366)
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 103 of file Writer.h.

Member Function Documentation

◆ file()

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

Definition at line 105 of file Writer.h.

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

◆ 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 107 of file Writer.h.

107 {
108 return Base::initialize().andThen( [this]() {
109 m_file = m_fileSvc->getFile( m_fileId );
110 if ( !m_file ) {
111 this->error() << "Failed to retrieve TFile." << endmsg;
112 return StatusCode::FAILURE;
113 }
114 return StatusCode::SUCCESS;
115 } );
116 }
Small class wrapping an algorithm and adding management of a Root File via the FileSvc.
Definition Writer.h:103
Gaudi::Property< std::string > m_fileId
Definition Writer.h:119
ServiceHandle< Gaudi::Interfaces::IFileSvc > m_fileSvc
Definition Writer.h:120

Member Data Documentation

◆ m_file

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

Definition at line 121 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 119 of file Writer.h.

119{ 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 120 of file Writer.h.

120{ this, "FileSvc", "FileSvc" };

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