Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VFileManager Class Referenceabstract

#include <G4VFileManager.hh>

+ Inheritance diagram for G4VFileManager:

Public Member Functions

 G4VFileManager (const G4AnalysisManagerState &state)
 
 G4VFileManager ()=delete
 
 ~G4VFileManager () override=default
 
virtual G4bool OpenFile (const G4String &fileName)=0
 
virtual G4bool CreateFile (const G4String &fileName)=0
 
virtual G4bool WriteFile (const G4String &fileName)=0
 
virtual G4bool CloseFile (const G4String &fileName)=0
 
virtual G4bool SetIsEmpty (const G4String &fileName, G4bool isEmpty)=0
 
virtual G4bool OpenFiles ()=0
 
virtual G4bool WriteFiles ()=0
 
virtual G4bool CloseFiles ()=0
 
virtual G4bool DeleteEmptyFiles ()=0
 
virtual void Clear ()=0
 
G4bool SetFileName (const G4String &fileName) final
 
virtual G4bool SetHistoDirectoryName (const G4String &dirName)
 
virtual G4bool SetNtupleDirectoryName (const G4String &dirName)
 
void LockDirectoryNames ()
 
void UnlockDirectoryNames ()
 
G4bool IsOpenFile () const
 
G4String GetHistoDirectoryName () const
 
G4String GetNtupleDirectoryName () const
 
G4int GetCycle () const
 
template<typename HT >
std::shared_ptr< G4VTHnFileManager< HT > > GetHnFileManager () const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
 G4BaseFileManager ()=delete
 
virtual ~G4BaseFileManager ()=default
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () const
 
virtual G4bool HasCycles () const
 
void AddFileName (const G4String &fileName)
 
G4String GetFileName () const
 
G4String GetFullFileName (const G4String &baseFileName="", G4bool isPerThread=true) const
 
const std::vector< G4String > & GetFileNames () const
 
G4String GetHnFileName (const G4String &hnType, const G4String &hnName) const
 
G4String GetHnFileName (const G4String &fileName, G4int cycle=0) const
 
G4String GetNtupleFileName (const G4String &ntupleName, G4int cycle=0) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber, G4int cycle=0) const
 
G4String GetPlotFileName () const
 

Protected Attributes

G4String fHistoDirectoryName
 
G4String fNtupleDirectoryName
 
G4bool fIsOpenFile { false }
 
G4bool fLockDirectoryNames { false }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::h1d > > fH1FileManager { nullptr }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::h2d > > fH2FileManager { nullptr }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::h3d > > fH3FileManager { nullptr }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager { nullptr }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager { nullptr }
 
- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4String fFileName
 
std::vector< G4StringfFileNames
 

Static Protected Attributes

static constexpr std::string_view fkClass { "G4VFileManager" }
 

Additional Inherited Members

- Protected Member Functions inherited from G4BaseFileManager
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 

Detailed Description

Definition at line 51 of file G4VFileManager.hh.

Constructor & Destructor Documentation

◆ G4VFileManager() [1/2]

G4VFileManager::G4VFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 36 of file G4VFileManager.cc.

37 : G4BaseFileManager(state)
38{}
G4BaseFileManager()=delete

◆ G4VFileManager() [2/2]

G4VFileManager::G4VFileManager ( )
delete

◆ ~G4VFileManager()

G4VFileManager::~G4VFileManager ( )
overridedefault

Member Function Documentation

◆ Clear()

◆ CloseFile()

◆ CloseFiles()

◆ CreateFile()

virtual G4bool G4VFileManager::CreateFile ( const G4String fileName)
pure virtual

◆ DeleteEmptyFiles()

◆ GetCycle()

G4int G4VFileManager::GetCycle ( ) const
inline

Definition at line 128 of file G4VFileManager.hh.

129{ return fState.GetCycle(); }
const G4AnalysisManagerState & fState

Referenced by G4GenericFileManager::OpenFiles().

◆ GetHistoDirectoryName()

G4String G4VFileManager::GetHistoDirectoryName ( ) const
inline

Definition at line 122 of file G4VFileManager.hh.

123{ return fHistoDirectoryName; }
G4String fHistoDirectoryName

◆ GetHnFileManager()

template<typename HT >
std::shared_ptr< G4VTHnFileManager< HT > > G4VFileManager::GetHnFileManager ( ) const

◆ GetNtupleDirectoryName()

G4String G4VFileManager::GetNtupleDirectoryName ( ) const
inline

Definition at line 125 of file G4VFileManager.hh.

126{ return fNtupleDirectoryName; }
G4String fNtupleDirectoryName

◆ IsOpenFile()

G4bool G4VFileManager::IsOpenFile ( ) const
inline

Definition at line 119 of file G4VFileManager.hh.

120{ return fIsOpenFile; }

◆ LockDirectoryNames()

void G4VFileManager::LockDirectoryNames ( )
inline

◆ OpenFile()

virtual G4bool G4VFileManager::OpenFile ( const G4String fileName)
pure virtual

◆ OpenFiles()

◆ SetFileName()

G4bool G4VFileManager::SetFileName ( const G4String fileName)
finalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 45 of file G4VFileManager.cc.

46{
47 // Check extension
48 auto name = fileName;
49 auto extension = G4Analysis::GetExtension(fileName);
50 if ((extension.size() != 0u) && (GetFileType().size() != 0u) && extension != GetFileType()) {
51 // replace extension
52 name = G4Analysis::GetBaseName(fileName) + "." + GetFileType();
53 Warn(fileName + " file extension is not valid for " + GetFileType() + " output.\n" +
54 name + " will be used.", fkClass, "SetFileName");
55 }
56
58}
virtual G4bool SetFileName(const G4String &fileName)
virtual G4String GetFileType() const
static constexpr std::string_view fkClass
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetBaseName(const G4String &fileName)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
const char * name(G4int ptype)

Referenced by G4GenericFileManager::OpenFile().

◆ SetHistoDirectoryName()

G4bool G4VFileManager::SetHistoDirectoryName ( const G4String dirName)
virtual

Reimplemented in G4CsvFileManager, and G4GenericFileManager.

Definition at line 61 of file G4VFileManager.cc.

62{
63 if ( fLockDirectoryNames ) {
64 Warn("Cannot set Histo directory name as its value was already used.",
65 fkClass, "SetHistoDirectoryName");
66 return false;
67 }
68
69 fHistoDirectoryName = dirName;
70 return true;
71}

Referenced by G4CsvFileManager::SetHistoDirectoryName(), and G4GenericFileManager::SetHistoDirectoryName().

◆ SetIsEmpty()

virtual G4bool G4VFileManager::SetIsEmpty ( const G4String fileName,
G4bool  isEmpty 
)
pure virtual

◆ SetNtupleDirectoryName()

G4bool G4VFileManager::SetNtupleDirectoryName ( const G4String dirName)
virtual

Reimplemented in G4CsvFileManager, and G4GenericFileManager.

Definition at line 74 of file G4VFileManager.cc.

75{
76 if ( fLockDirectoryNames ) {
77 Warn("Cannot set Ntuple directory name as its value was already used.",
78 fkClass, "SetNtupleDirectoryName");
79 return false;
80 }
81
82 fNtupleDirectoryName = dirName;
83 return true;
84}

Referenced by G4CsvFileManager::SetNtupleDirectoryName(), and G4GenericFileManager::SetNtupleDirectoryName().

◆ UnlockDirectoryNames()

void G4VFileManager::UnlockDirectoryNames ( )
inline

Definition at line 116 of file G4VFileManager.hh.

117{ fLockDirectoryNames = false; }

Referenced by G4GenericFileManager::Clear().

◆ WriteFile()

◆ WriteFiles()

Member Data Documentation

◆ fH1FileManager

std::shared_ptr<G4VTHnFileManager<tools::histo::h1d> > G4VFileManager::fH1FileManager { nullptr }
protected

◆ fH2FileManager

std::shared_ptr<G4VTHnFileManager<tools::histo::h2d> > G4VFileManager::fH2FileManager { nullptr }
protected

◆ fH3FileManager

std::shared_ptr<G4VTHnFileManager<tools::histo::h3d> > G4VFileManager::fH3FileManager { nullptr }
protected

◆ fHistoDirectoryName

G4String G4VFileManager::fHistoDirectoryName
protected

◆ fIsOpenFile

◆ fkClass

constexpr std::string_view G4VFileManager::fkClass { "G4VFileManager" }
staticconstexprprotected

Definition at line 95 of file G4VFileManager.hh.

Referenced by SetFileName(), SetHistoDirectoryName(), and SetNtupleDirectoryName().

◆ fLockDirectoryNames

G4bool G4VFileManager::fLockDirectoryNames { false }
protected

◆ fNtupleDirectoryName

G4String G4VFileManager::fNtupleDirectoryName
protected

◆ fP1FileManager

std::shared_ptr<G4VTHnFileManager<tools::histo::p1d> > G4VFileManager::fP1FileManager { nullptr }
protected

◆ fP2FileManager

std::shared_ptr<G4VTHnFileManager<tools::histo::p2d> > G4VFileManager::fP2FileManager { nullptr }
protected

The documentation for this class was generated from the following files: