Geant4 11.1.1
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
 
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 Member Functions

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

Protected Attributes

const G4AnalysisManagerStatefState
 
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

◆ GetFileName()

G4String G4BaseFileManager::GetFileName ( ) const
inline

Definition at line 122 of file G4BaseFileManager.hh.

122 {
123 return fFileName;
124}

◆ GetFileNames()

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

Definition at line 126 of file G4BaseFileManager.hh.

126 {
127 return fFileNames;
128}

Referenced by G4GenericFileManager::OpenFiles().

◆ GetFileType()

G4String G4BaseFileManager::GetFileType ( ) const
virtual

◆ 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()
Definition: G4Threading.cc:122

Referenced by G4XmlRFileManager::GetRFile(), G4Hdf5RFileManager::GetRFile(), G4RootRFileManager::GetRFile(), G4Hdf5FileManager::OpenFile(), G4RootFileManager::OpenFile(), G4XmlFileManager::OpenFile(), G4XmlRFileManager::OpenRFile(), and G4RootRFileManager::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 118 of file G4BaseFileManager.hh.

118 {
119 return false;
120}

Referenced by GetHnFileName(), 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 130 of file G4BaseFileManager.hh.

133{
134 fState.Message(level, action, objectType, objectName, success);
135}
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(), G4XmlRFileManager::OpenRFile(), G4RootRFileManager::OpenRFile(), and G4GenericFileManager::WriteFiles().

◆ SetFileName()

G4bool G4BaseFileManager::SetFileName ( const G4String fileName)
inlinevirtual

Reimplemented in G4VFileManager.

Definition at line 112 of file G4BaseFileManager.hh.

112 {
113 // CHECK if still needed in this base class
114 fFileName = fileName;
115 return true;
116}

Referenced by G4VFileManager::SetFileName().

Member Data Documentation

◆ fFileName

◆ fFileNames

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

Definition at line 109 of file G4BaseFileManager.hh.

Referenced by AddFileName(), and GetFileNames().

◆ fState


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