Geant4 10.7.0
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)
 
virtual ~G4VFileManager ()
 
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 WriteFiles ()=0
 
virtual G4bool CloseFiles ()=0
 
virtual G4bool DeleteEmptyFiles ()=0
 
virtual G4bool SetFileName (const G4String &fileName) final
 
G4bool SetHistoDirectoryName (const G4String &dirName)
 
G4bool SetNtupleDirectoryName (const G4String &dirName)
 
void LockDirectoryNames ()
 
G4bool IsOpenFile () const
 
G4String GetHistoDirectoryName () const
 
G4String GetNtupleDirectoryName () const
 
template<typename HT >
std::shared_ptr< G4VTHnFileManager< HT > > GetHnFileManager () const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseFileManager ()
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () 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 GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 

Protected Attributes

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

Detailed Description

Definition at line 48 of file G4VFileManager.hh.

Constructor & Destructor Documentation

◆ G4VFileManager()

G4VFileManager::G4VFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 36 of file G4VFileManager.cc.

37 : G4BaseFileManager(state),
40 fIsOpenFile(false),
41 fLockDirectoryNames(false),
42 fH1FileManager(nullptr),
43 fH2FileManager(nullptr),
44 fH3FileManager(nullptr),
45 fP1FileManager(nullptr),
46 fP2FileManager(nullptr)
47{}
std::shared_ptr< G4VTHnFileManager< tools::histo::h3d > > fH3FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::h1d > > fH1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager
G4String fNtupleDirectoryName
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager
G4bool fLockDirectoryNames
std::shared_ptr< G4VTHnFileManager< tools::histo::h2d > > fH2FileManager
G4String fHistoDirectoryName

◆ ~G4VFileManager()

G4VFileManager::~G4VFileManager ( )
virtual

Definition at line 50 of file G4VFileManager.cc.

51{}

Member Function Documentation

◆ CloseFile()

◆ CloseFiles()

◆ CreateFile()

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

◆ DeleteEmptyFiles()

◆ GetHistoDirectoryName()

G4String G4VFileManager::GetHistoDirectoryName ( ) const
inline

Definition at line 106 of file G4VFileManager.hh.

107{ return fHistoDirectoryName; }

◆ GetHnFileManager()

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

◆ GetNtupleDirectoryName()

G4String G4VFileManager::GetNtupleDirectoryName ( ) const
inline

Definition at line 109 of file G4VFileManager.hh.

110{ return fNtupleDirectoryName; }

◆ IsOpenFile()

G4bool G4VFileManager::IsOpenFile ( ) const
inline

Definition at line 103 of file G4VFileManager.hh.

104{ return fIsOpenFile; }

◆ LockDirectoryNames()

void G4VFileManager::LockDirectoryNames ( )
inline

Definition at line 100 of file G4VFileManager.hh.

101{ fLockDirectoryNames = true; }

◆ OpenFile()

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

◆ SetFileName()

G4bool G4VFileManager::SetFileName ( const G4String fileName)
finalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 58 of file G4VFileManager.cc.

59{
60 // Check extension
61 auto name = fileName;
62 auto extension = G4Analysis::GetExtension(fileName);
63 if ( extension.size() && GetFileType().size() && extension != GetFileType() ) {
64 // replace extension
65 name = G4Analysis::GetBaseName(fileName) + "." + GetFileType();
66 G4ExceptionDescription description;
67 description
68 << fileName << " file extension is not valid for "
69 << GetFileType() << " output." << G4endl
70 << name << " will be used.";
71 G4Exception("G4VFileManager::SetFileName()",
72 "Analysis_W012", JustWarning, description);
73 }
74
76}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
#define G4endl
Definition: G4ios.hh:57
virtual G4bool SetFileName(const G4String &fileName)
virtual G4String GetFileType() const
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetBaseName(const G4String &fileName)
const char * name(G4int ptype)

Referenced by G4GenericFileManager::OpenFile().

◆ SetHistoDirectoryName()

G4bool G4VFileManager::SetHistoDirectoryName ( const G4String dirName)

Definition at line 79 of file G4VFileManager.cc.

80{
81 if ( fLockDirectoryNames ) {
82 G4ExceptionDescription description;
83 description
84 << "Cannot set Histo directory name as its value was already used.";
85 G4Exception("G4VFileManager::SetHistoDirectoryName()",
86 "Analysis_W012", JustWarning, description);
87 return false;
88 }
89
90 fHistoDirectoryName = dirName;
91 return true;
92}

◆ SetIsEmpty()

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

◆ SetNtupleDirectoryName()

G4bool G4VFileManager::SetNtupleDirectoryName ( const G4String dirName)

Definition at line 95 of file G4VFileManager.cc.

96{
97 if ( fLockDirectoryNames ) {
98 G4ExceptionDescription description;
99 description
100 << "Cannot set Ntuple directory name as its value was already used.";
101 G4Exception("G4VFileManager::SetNtupleDirectoryName()",
102 "Analysis_W012", JustWarning, description);
103 return false;
104 }
105
106 fNtupleDirectoryName = dirName;
107 return true;
108}

◆ WriteFile()

◆ WriteFiles()

Member Data Documentation

◆ fH1FileManager

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

◆ fH2FileManager

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

◆ fH3FileManager

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

◆ fHistoDirectoryName

G4String G4VFileManager::fHistoDirectoryName
protected

◆ fIsOpenFile

◆ fLockDirectoryNames

◆ fNtupleDirectoryName

G4String G4VFileManager::fNtupleDirectoryName
protected

◆ fP1FileManager

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

◆ fP2FileManager

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

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