13 #ifndef __PHTFileServer_H__
14 #define __PHTFileServer_H__
49 void open(
const std::string& filename,
const std::string& type =
"RECREATE" );
52 bool flush(
const std::string& filename );
55 bool cd(
const std::string& filename );
61 bool write(
const std::string& filename );
73 class SafeTFile:
public TFile
79 SafeTFile(
const std::string& filename,
const std::string& type=
"RECREATE" ):
80 TFile( filename.c_str(), type.c_str() ),
81 _filename( filename ),
86 virtual ~SafeTFile(
void );
93 const int& counter()
const
97 typedef std::map< std::string, SafeTFile* > TFileMap;
99 static TFileMap& file_map(
void )
105 std::string _filename;
111 static TFileMap _map;
virtual ~PHTFileServer()
destructor. All non close TFiles are closed, with a warning.
bool flush(const std::string &filename)
flush TFile matching filename
bool write(const std::string &filename)
if TFile is found in map and counter is 0, close the TFile, decrement counter otherwise ...
bool cd(const std::string &filename)
change to directory of TFile matching filename
void close(void)
close all TFiles
TFile clean handling. It allow independant classes to access the same TFile and write ntuple to it...
void open(const std::string &filename, const std::string &type="RECREATE")
open a SafeTFile. If filename is not found in the map, create a new TFile and append to the map; incr...