Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BaseFileManager Class Reference

#include <G4BaseFileManager.hh>

+ Inheritance diagram for G4BaseFileManager:

Public Member Functions

 G4BaseFileManager (const G4AnalysisManagerState &state)
 
 G4BaseFileManager ()=delete
 
virtual ~G4BaseFileManager ()=default
 
void SetCompressionLevel (G4int level)
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () const
 
virtual G4bool HasCycles () const
 
void AddFileName (const G4String &fileName)
 
G4int GetCompressionLevel () const
 
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 Member Functions

void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
void ClearData ()
 

Protected Attributes

const G4AnalysisManagerStatefState
 
G4int fCompressionLevel { 1 }
 
G4String fFileName
 
std::vector< G4StringfFileNames
 

Detailed Description

Definition at line 39 of file G4BaseFileManager.hh.

Constructor & Destructor Documentation

◆ G4BaseFileManager() [1/2]

G4BaseFileManager::G4BaseFileManager ( const G4AnalysisManagerState & state)
explicit

Definition at line 35 of file G4BaseFileManager.cc.

36 : fState(state)
37{}
const G4AnalysisManagerState & fState

◆ G4BaseFileManager() [2/2]

G4BaseFileManager::G4BaseFileManager ( )
delete

◆ ~G4BaseFileManager()

virtual G4BaseFileManager::~G4BaseFileManager ( )
virtualdefault

Member Function Documentation

◆ AddFileName()

void G4BaseFileManager::AddFileName ( const G4String & fileName)

Definition at line 44 of file G4BaseFileManager.cc.

45{
46 // G4cout << "registering " << fileName << " in manager of " << GetFileType() << G4endl;
47
48 // Do nothing in file name is already present
49 for ( const auto& name : fFileNames ) {
50 if ( name == fileName ) return;
51 }
52
53 fFileNames.push_back(fileName);
54}
std::vector< G4String > fFileNames

◆ ClearData()

void G4BaseFileManager::ClearData ( )
inlineprotected

Definition at line 151 of file G4BaseFileManager.hh.

151 {
152 fFileNames.clear();
153}

Referenced by G4VTFileManager< FT >::Clear(), and G4GenericFileManager::DeleteEmptyFiles().

◆ GetCompressionLevel()

G4int G4BaseFileManager::GetCompressionLevel ( ) const
inline

Definition at line 133 of file G4BaseFileManager.hh.

134{ return fCompressionLevel; }

Referenced by G4RootFileManager::CreateFileImpl().

◆ GetFileName()

G4String G4BaseFileManager::GetFileName ( ) const
inline

Definition at line 136 of file G4BaseFileManager.hh.

136 {
137 return fFileName;
138}

◆ GetFileNames()

const std::vector< G4String > & G4BaseFileManager::GetFileNames ( ) const
inline

Definition at line 140 of file G4BaseFileManager.hh.

140 {
141 return fFileNames;
142}

Referenced by G4GenericFileManager::OpenFiles().

◆ GetFileType()

◆ GetFullFileName()

G4String G4BaseFileManager::GetFullFileName ( const G4String & baseFileName = "",
G4bool isPerThread = true ) const

Definition at line 63 of file G4BaseFileManager.cc.

65{
66 G4String fileName(baseFileName);
67 if ( fileName == "" ) fileName = fFileName;
68
69 // Take out file extension
70 auto name = G4Analysis::GetBaseName(fileName);
71
72 // Add thread Id to a file name if MT processing
73 if ( isPerThread && ! fState.GetIsMaster() ) {
74 std::ostringstream os;
76 name.append("_t");
77 name.append(os.str());
78 }
79
80 // Add (back if it was present or is defined) file extension
81 auto extension = G4Analysis::GetExtension(fileName, GetFileType());
82 if (extension.size() != 0u) {
83 name.append(".");
84 name.append(extension);
85 }
86
87 return name;
88}
virtual G4String GetFileType() const
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetBaseName(const G4String &fileName)
const char * name(G4int ptype)
G4int G4GetThreadId()

Referenced by G4Hdf5RFileManager::GetRFile(), G4RootRFileManager::GetRFile(), G4XmlRFileManager::GetRFile(), G4Hdf5FileManager::OpenFile(), G4RootFileManager::OpenFile(), G4XmlFileManager::OpenFile(), G4RootRFileManager::OpenRFile(), and G4XmlRFileManager::OpenRFile().

◆ GetHnFileName() [1/2]

G4String G4BaseFileManager::GetHnFileName ( const G4String & fileName,
G4int cycle = 0 ) const

Definition at line 98 of file G4BaseFileManager.cc.

100{
101 // Do nothing if cycle is supported by the output type
102 if (HasCycles()) return fileName;
103
104 return G4Analysis::GetHnFileName(fileName, GetFileType(), cycle);
105}
virtual G4bool HasCycles() const
G4String GetHnFileName(const G4String &fileName, const G4String &fileType, const G4String &hnType, const G4String &hnName)

◆ GetHnFileName() [2/2]

G4String G4BaseFileManager::GetHnFileName ( const G4String & hnType,
const G4String & hnName ) const

Definition at line 91 of file G4BaseFileManager.cc.

93{
94 return G4Analysis::GetHnFileName(fFileName, GetFileType(), hnType, hnName);
95}

◆ GetNtupleFileName() [1/2]

G4String G4BaseFileManager::GetNtupleFileName ( const G4String & ntupleName,
G4int cycle = 0 ) const

Definition at line 108 of file G4BaseFileManager.cc.

110{
111 // Do not pass cycle if supported by the output type
112 auto cycleToPass = (HasCycles()) ? 0 : cycle;
113
114 return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleName, cycleToPass);
115}
G4String GetNtupleFileName(const G4String &fileName, const G4String &fileType, const G4String &ntupleName, G4int cycle=0)

◆ GetNtupleFileName() [2/2]

G4String G4BaseFileManager::GetNtupleFileName ( G4int ntupleFileNumber,
G4int cycle = 0 ) const

Definition at line 118 of file G4BaseFileManager.cc.

120{
121 // Do not pass cycle if supported by the output type
122 auto cycleToPass = (HasCycles()) ? 0 : cycle;
123
124 return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleFileNumber, cycleToPass);
125}

◆ GetPlotFileName()

G4String G4BaseFileManager::GetPlotFileName ( ) const

Definition at line 128 of file G4BaseFileManager.cc.

129{
131}
G4String GetPlotFileName(const G4String &fileName)

◆ HasCycles()

G4bool G4BaseFileManager::HasCycles ( ) const
inlinevirtual

Reimplemented in G4RootFileManager.

Definition at line 129 of file G4BaseFileManager.hh.

129 {
130 return false;
131}

Referenced by GetHnFileName(), GetNtupleFileName(), and GetNtupleFileName().

◆ Message()

void G4BaseFileManager::Message ( G4int level,
const G4String & action,
const G4String & objectType,
const G4String & objectName = "",
G4bool success = true ) const
inlineprotected

Definition at line 144 of file G4BaseFileManager.hh.

147{
148 fState.Message(level, action, objectType, objectName, success);
149}
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const

Referenced by G4GenericFileManager::CloseFiles(), G4GenericFileManager::DeleteEmptyFiles(), G4GenericFileManager::OpenFile(), G4GenericFileManager::OpenFiles(), G4CsvRFileManager::OpenRFile(), G4RootRFileManager::OpenRFile(), G4XmlRFileManager::OpenRFile(), and G4GenericFileManager::WriteFiles().

◆ SetCompressionLevel()

void G4BaseFileManager::SetCompressionLevel ( G4int level)
inline

Definition at line 120 of file G4BaseFileManager.hh.

121{ fCompressionLevel = level; }

◆ SetFileName()

G4bool G4BaseFileManager::SetFileName ( const G4String & fileName)
inlinevirtual

Reimplemented in G4VFileManager.

Definition at line 123 of file G4BaseFileManager.hh.

123 {
124 // CHECK if still needed in this base class
125 fFileName = fileName;
126 return true;
127}

Referenced by G4VFileManager::SetFileName().

Member Data Documentation

◆ fCompressionLevel

G4int G4BaseFileManager::fCompressionLevel { 1 }
protected

Definition at line 115 of file G4BaseFileManager.hh.

115{ 1 };

Referenced by GetCompressionLevel(), and SetCompressionLevel().

◆ fFileName

◆ fFileNames

std::vector<G4String> G4BaseFileManager::fFileNames
protected

Definition at line 117 of file G4BaseFileManager.hh.

Referenced by AddFileName(), ClearData(), and GetFileNames().

◆ fState


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