Geant4-11
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
G4CsvFileManager Class Reference

#include <G4CsvFileManager.hh>

Inheritance diagram for G4CsvFileManager:
G4VTFileManager< std::ofstream > G4VFileManager G4TFileManager< std::ofstream > G4BaseFileManager

Public Member Functions

void AddFileName (const G4String &fileName)
 
virtual void Clear () final
 
void ClearData ()
 
virtual G4bool CloseFile (const G4String &fileName) final
 
virtual G4bool CloseFile (const G4String &fileName)=0
 
virtual G4bool CloseFiles () final
 
G4bool CloseNtupleFile (CsvNtupleDescription *ntupleDescription)
 
G4bool CloseTFile (const G4String &fileName)
 
virtual G4bool CreateFile (const G4String &fileName) final
 
G4bool CreateNtupleFile (CsvNtupleDescription *ntupleDescription)
 
std::shared_ptr< std::ofstream > CreateTFile (const G4String &fileName)
 
virtual G4bool DeleteEmptyFiles () final
 
 G4CsvFileManager ()=delete
 
 G4CsvFileManager (const G4AnalysisManagerState &state)
 
std::shared_ptr< std::ofstream > GetFile () const
 
G4String GetFileName () const
 
const std::vector< G4String > & GetFileNames () const
 
virtual G4String GetFileType () const final
 
G4String GetFullFileName (const G4String &baseFileName="", G4bool isPerThread=true) const
 
G4String GetHistoDirectoryName () const
 
template<typename HT >
std::shared_ptr< G4VTHnFileManager< HT > > GetHnFileManager () const
 
G4String GetHnFileName (const G4String &hnType, const G4String &hnName) const
 
G4String GetNtupleDirectoryName () const
 
G4String GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 
std::shared_ptr< std::ofstream > GetTFile (const G4String &fileName, G4bool warn=true) const
 
G4bool IsHistoDirectory () const
 
G4bool IsNtupleDirectory () const
 
G4bool IsOpenFile () const
 
void LockDirectoryNames ()
 
virtual G4bool OpenFile (const G4String &fileName) final
 
G4bool OpenFiles ()
 
virtual G4bool SetFileName (const G4String &fileName) final
 
virtual G4bool SetHistoDirectoryName (const G4String &dirName) final
 
virtual G4bool SetIsEmpty (const G4String &fileName, G4bool isEmpty) final
 
virtual G4bool SetNtupleDirectoryName (const G4String &dirName) final
 
void UnlockDirectoryNames ()
 
virtual G4bool WriteFile (const G4String &fileName) final
 
virtual G4bool WriteFile (const G4String &fileName)=0
 
virtual G4bool WriteFiles () final
 
G4bool WriteTFile (const G4String &fileName)
 
 ~G4CsvFileManager ()=default
 

Protected Member Functions

virtual G4bool CloseFileImpl (std::shared_ptr< std::ofstream > file) final
 
virtual std::shared_ptr< std::ofstream > CreateFileImpl (const G4String &fileName) final
 
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
virtual G4bool WriteFileImpl (std::shared_ptr< std::ofstream > file) final
 

Protected Attributes

std::shared_ptr< std::ofstream > fFile
 
G4String fFileName
 
std::vector< G4StringfFileNames
 
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 }
 
G4String fHistoDirectoryName
 
G4bool fIsOpenFile { false }
 
G4bool fLockDirectoryNames { false }
 
G4String fNtupleDirectoryName
 
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager { nullptr }
 
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager { nullptr }
 
const G4AnalysisManagerStatefState
 

Private Member Functions

G4bool CloseTFile (std::shared_ptr< std::ofstream > file, const G4String &fileName)
 
G4bool DeleteEmptyFile (const G4String &fileName)
 
void FileNotFoundWarning (const G4String &fileName, std::string_view functionName) const
 
G4TFileInformation< std::ofstream > * GetFileInfoInFunction (const G4String &fileName, std::string_view functionName, G4bool warn=true) const
 
std::shared_ptr< std::ofstream > GetFileInFunction (const G4String &fileName, std::string_view functionName, G4bool warn=true) const
 
G4String GetNtupleFileName (CsvNtupleDescription *ntupleDescription)
 
G4bool WriteTFile (std::shared_ptr< std::ofstream > file, const G4String &fileName)
 

Private Attributes

const G4AnalysisManagerStatefAMState
 
std::map< G4String, G4TFileInformation< std::ofstream > * > fFileMap
 
G4bool fIsHistoDirectory { false }
 
G4bool fIsNtupleDirectory { false }
 

Static Private Attributes

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

Detailed Description

Definition at line 45 of file G4CsvFileManager.hh.

Constructor & Destructor Documentation

◆ G4CsvFileManager() [1/2]

G4CsvFileManager::G4CsvFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 39 of file G4CsvFileManager.cc.

40 : G4VTFileManager(state)
41{
42 // Create helpers defined in the base class
43 fH1FileManager = std::make_shared<G4CsvHnFileManager<histo::h1d>>(this);
44 fH2FileManager = std::make_shared<G4CsvHnFileManager<histo::h2d>>(this);
45 fH3FileManager = std::make_shared<G4CsvHnFileManager<histo::h3d>>(this);
46 fP1FileManager = std::make_shared<G4CsvHnFileManager<histo::p1d>>(this);
47 fP2FileManager = std::make_shared<G4CsvHnFileManager<histo::p2d>>(this);
48}
std::shared_ptr< G4VTHnFileManager< tools::histo::h3d > > fH3FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::h1d > > fH1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::h2d > > fH2FileManager
G4VTFileManager(const G4AnalysisManagerState &state)

References G4VFileManager::fH1FileManager, G4VFileManager::fH2FileManager, G4VFileManager::fH3FileManager, G4VFileManager::fP1FileManager, and G4VFileManager::fP2FileManager.

◆ G4CsvFileManager() [2/2]

G4CsvFileManager::G4CsvFileManager ( )
delete

◆ ~G4CsvFileManager()

G4CsvFileManager::~G4CsvFileManager ( )
default

Member Function Documentation

◆ AddFileName()

void G4BaseFileManager::AddFileName ( const G4String fileName)
inherited

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
const char * name(G4int ptype)

References G4BaseFileManager::fFileNames, and G4InuclParticleNames::name().

◆ Clear()

void G4VTFileManager< std::ofstream >::Clear
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 65 of file G4VTFileManager.hh.

◆ ClearData()

void G4TFileManager< std::ofstream >::ClearData ( )
inherited

◆ CloseFile() [1/2]

G4bool G4VTFileManager< std::ofstream >::CloseFile ( const G4String fileName)
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 56 of file G4VTFileManager.hh.

96{
97 return G4TFileManager<FT>::CloseTFile(fileName);
98}
G4bool CloseTFile(const G4String &fileName)

◆ CloseFile() [2/2]

virtual G4bool G4VFileManager::CloseFile ( const G4String fileName)
virtualinherited

Implements G4VFileManager.

◆ CloseFileImpl()

G4bool G4CsvFileManager::CloseFileImpl ( std::shared_ptr< std::ofstream >  file)
finalprotectedvirtual

Implements G4TFileManager< std::ofstream >.

Definition at line 98 of file G4CsvFileManager.cc.

99{
100 if ( ! file ) return false;
101
102 // close file
103 file->close();
104
105 return true;
106}

References geant4_check_module_cycles::file.

◆ CloseFiles()

G4bool G4VTFileManager< std::ofstream >::CloseFiles
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 61 of file G4VTFileManager.hh.

120{
121 auto result = G4TFileManager<FT>::CloseFiles();
122
123 fIsOpenFile = false;
124 fFile.reset();
125
126 return result;
127}
G4bool CloseFiles()
std::shared_ptr< std::ofstream > fFile

◆ CloseNtupleFile()

G4bool G4CsvFileManager::CloseNtupleFile ( CsvNtupleDescription ntupleDescription)

Definition at line 184 of file G4CsvFileManager.cc.

186{
187 // Do nothing if there is no file
188 if ( ! ntupleDescription->fFile ) return true;
189
190 auto result = true;
191
192 auto ntupleFileName = GetNtupleFileName(ntupleDescription);
193
194 Message(kVL4, "close", "ntuple file", ntupleFileName);
195
196 // close file
197 result &= CloseTFile(ntupleFileName);
198 // Notify not empty file
199 result &= SetIsEmpty(ntupleFileName, ! ntupleDescription->fHasFill);
200
201 // Reset file info in ntuple description
202 ntupleDescription->fFile.reset();
203
204 Message(kVL2, "close", "ntuple file", ntupleFileName);
205
206 return result;
207}
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
G4String GetNtupleFileName(CsvNtupleDescription *ntupleDescription)
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
constexpr G4int kVL2
constexpr G4int kVL4
std::shared_ptr< FT > fFile

References G4TFileManager< std::ofstream >::CloseTFile(), G4TNtupleDescription< NT, FT >::fFile, G4TNtupleDescription< NT, FT >::fHasFill, GetNtupleFileName(), G4Analysis::kVL2, G4Analysis::kVL4, G4BaseFileManager::Message(), and G4VTFileManager< std::ofstream >::SetIsEmpty().

◆ CloseTFile() [1/2]

G4bool G4TFileManager< std::ofstream >::CloseTFile ( const G4String fileName)
inherited

◆ CloseTFile() [2/2]

G4bool G4TFileManager< std::ofstream >::CloseTFile ( std::shared_ptr< std::ofstream >  file,
const G4String fileName 
)
privateinherited

◆ CreateFile()

G4bool G4VTFileManager< std::ofstream >::CreateFile ( const G4String fileName)
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 54 of file G4VTFileManager.hh.

80{
81 return (G4TFileManager<FT>::CreateTFile(fileName) != nullptr);
82}

◆ CreateFileImpl()

std::shared_ptr< std::ofstream > G4CsvFileManager::CreateFileImpl ( const G4String fileName)
finalprotectedvirtual

Implements G4TFileManager< std::ofstream >.

Definition at line 79 of file G4CsvFileManager.cc.

80{
81 std::shared_ptr<std::ofstream> file = std::make_shared<std::ofstream>(fileName);
82 if ( file->fail() ) {
83 Warn("Cannot create file " + fileName, fkClass, "CreateFileImpl");
84 return nullptr;
85 }
86
87 return file;
88}
static constexpr std::string_view fkClass
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

References geant4_check_module_cycles::file, fkClass, and G4Analysis::Warn().

◆ CreateNtupleFile()

G4bool G4CsvFileManager::CreateNtupleFile ( CsvNtupleDescription ntupleDescription)

Definition at line 154 of file G4CsvFileManager.cc.

156{
157 // get ntuple file name per object (if defined)
158 auto ntupleFileName = GetNtupleFileName(ntupleDescription);
159
160 Message(kVL4, "create", "ntuple file", ntupleFileName);
161
162 // update file name if it is already in use
163 while ( GetTFile(ntupleFileName, false) ) {
164 // the file is already in use
165 auto oldName = ntupleDescription->fFileName;
166 auto newName = GetBaseName(oldName) + "_bis." + GetExtension(oldName);
167 ntupleDescription->fFileName = newName;
168
169 Warn("Ntuple filename " + oldName + " is already in use.\n" +
170 "It will be replaced with : " + newName,
171 fkClass, "CreateNtupleFile");
172
173 ntupleFileName = GetNtupleFileName(ntupleDescription);
174 }
175
176 ntupleDescription->fFile = CreateTFile(ntupleFileName);
177
178 Message(kVL2, "create", "ntuple file", ntupleFileName);
179
180 return (ntupleDescription->fFile != nullptr);
181}
std::shared_ptr< std::ofstream > GetTFile(const G4String &fileName, G4bool warn=true) const
std::shared_ptr< std::ofstream > CreateTFile(const G4String &fileName)
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetBaseName(const G4String &fileName)

References G4TFileManager< std::ofstream >::CreateTFile(), G4TNtupleDescription< NT, FT >::fFile, G4TNtupleDescription< NT, FT >::fFileName, fkClass, G4Analysis::GetBaseName(), G4Analysis::GetExtension(), GetNtupleFileName(), G4TFileManager< std::ofstream >::GetTFile(), G4Analysis::kVL2, G4Analysis::kVL4, G4BaseFileManager::Message(), and G4Analysis::Warn().

◆ CreateTFile()

std::shared_ptr< std::ofstream > G4TFileManager< std::ofstream >::CreateTFile ( const G4String fileName)
inherited

◆ DeleteEmptyFile()

G4bool G4TFileManager< std::ofstream >::DeleteEmptyFile ( const G4String fileName)
privateinherited

◆ DeleteEmptyFiles()

G4bool G4VTFileManager< std::ofstream >::DeleteEmptyFiles
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 62 of file G4VTFileManager.hh.

133{
135}
G4bool DeleteEmptyFiles()

◆ FileNotFoundWarning()

void G4TFileManager< std::ofstream >::FileNotFoundWarning ( const G4String fileName,
std::string_view  functionName 
) const
privateinherited

◆ GetFile()

std::shared_ptr< std::ofstream > G4VTFileManager< std::ofstream >::GetFile
inlineinherited

Definition at line 68 of file G4VTFileManager.hh.

149{
150 return fFile;
151}

◆ GetFileInfoInFunction()

G4TFileInformation< std::ofstream > * G4TFileManager< std::ofstream >::GetFileInfoInFunction ( const G4String fileName,
std::string_view  functionName,
G4bool  warn = true 
) const
privateinherited

◆ GetFileInFunction()

std::shared_ptr< std::ofstream > G4TFileManager< std::ofstream >::GetFileInFunction ( const G4String fileName,
std::string_view  functionName,
G4bool  warn = true 
) const
privateinherited

◆ GetFileName()

G4String G4BaseFileManager::GetFileName ( ) const
inlineinherited

Definition at line 105 of file G4BaseFileManager.hh.

105 {
106 return fFileName;
107}

References G4BaseFileManager::fFileName.

◆ GetFileNames()

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

Definition at line 109 of file G4BaseFileManager.hh.

109 {
110 return fFileNames;
111}

References G4BaseFileManager::fFileNames.

Referenced by G4GenericFileManager::OpenFiles().

◆ GetFileType()

virtual G4String G4CsvFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 62 of file G4CsvFileManager.hh.

62{ return "csv"; }

Referenced by GetNtupleFileName().

◆ GetFullFileName()

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

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() ) {
83 name.append(".");
84 name.append(extension);
85 }
86
87 return name;
88}
virtual G4String GetFileType() const
const G4AnalysisManagerState & fState
G4int G4GetThreadId()
Definition: G4Threading.cc:122

References G4BaseFileManager::fFileName, G4Analysis::GetBaseName(), and G4InuclParticleNames::name().

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

◆ GetHistoDirectoryName()

G4String G4VFileManager::GetHistoDirectoryName ( ) const
inlineinherited

Definition at line 120 of file G4VFileManager.hh.

121{ return fHistoDirectoryName; }
G4String fHistoDirectoryName

References G4VFileManager::fHistoDirectoryName.

Referenced by G4GenericFileManager::CreateFileManager().

◆ GetHnFileManager()

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

◆ GetHnFileName()

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

Definition at line 91 of file G4BaseFileManager.cc.

93{
94 return G4Analysis::GetHnFileName(fFileName, GetFileType(), hnType, hnName);
95}
G4String GetHnFileName(const G4String &fileName, const G4String &fileType, const G4String &hnType, const G4String &hnName)

References G4BaseFileManager::fFileName, G4BaseFileManager::GetFileType(), and G4Analysis::GetHnFileName().

◆ GetNtupleDirectoryName()

G4String G4VFileManager::GetNtupleDirectoryName ( ) const
inlineinherited

◆ GetNtupleFileName() [1/3]

G4String G4BaseFileManager::GetNtupleFileName ( const G4String ntupleName) const

Definition at line 71 of file G4BaseFileManager.cc.

99{
101}
virtual G4String GetFileType() const final
G4String GetNtupleFileName(const G4String &fileName, const G4String &fileType, const G4String &ntupleName)

References G4Threading::G4GetThreadId(), and G4InuclParticleNames::name().

◆ GetNtupleFileName() [2/3]

G4String G4CsvFileManager::GetNtupleFileName ( CsvNtupleDescription ntupleDescription)
private

Definition at line 55 of file G4CsvFileManager.cc.

56{
57 // get ntuple file name
58 auto ntupleFileName = ntupleDescription->fFileName;
59 if ( ntupleFileName.size() ) {
60 // update filename per object per thread
61 ntupleFileName = GetTnFileName(ntupleFileName, GetFileType());
62 } else {
63 // compose ntuple file name from the default file name
64 ntupleFileName = GetNtupleFileName(ntupleDescription->fNtupleBooking.name());
65 }
66
67 if ( IsNtupleDirectory() ) {
68 ntupleFileName = "./" + GetNtupleDirectoryName() + "/" + ntupleFileName;
69 }
70
71 return ntupleFileName;
72}
G4bool IsNtupleDirectory() const
G4String GetNtupleDirectoryName() const
G4String GetTnFileName(const G4String &fileName, const G4String &fileType)
tools::ntuple_booking fNtupleBooking

References G4TNtupleDescription< NT, FT >::fFileName, G4TNtupleDescription< NT, FT >::fNtupleBooking, GetFileType(), G4VFileManager::GetNtupleDirectoryName(), GetNtupleFileName(), G4Analysis::GetTnFileName(), and IsNtupleDirectory().

Referenced by CloseNtupleFile(), CreateNtupleFile(), and GetNtupleFileName().

◆ GetNtupleFileName() [3/3]

G4String G4BaseFileManager::GetNtupleFileName ( G4int  ntupleFileNumber) const

Definition at line 77 of file G4BaseFileManager.cc.

105{
106 return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleFileNumber);
107}

◆ GetPlotFileName()

G4String G4BaseFileManager::GetPlotFileName ( ) const
inherited

Definition at line 110 of file G4BaseFileManager.cc.

111{
113}
G4String GetPlotFileName(const G4String &fileName)

References G4BaseFileManager::fFileName, and G4Analysis::GetPlotFileName().

◆ GetTFile()

std::shared_ptr< std::ofstream > G4TFileManager< std::ofstream >::GetTFile ( const G4String fileName,
G4bool  warn = true 
) const
inherited

◆ IsHistoDirectory()

G4bool G4CsvFileManager::IsHistoDirectory ( ) const
inline

Definition at line 91 of file G4CsvFileManager.hh.

92{ return fIsHistoDirectory; }

References fIsHistoDirectory.

◆ IsNtupleDirectory()

G4bool G4CsvFileManager::IsNtupleDirectory ( ) const
inline

Definition at line 94 of file G4CsvFileManager.hh.

95{ return fIsNtupleDirectory; }

References fIsNtupleDirectory.

Referenced by GetNtupleFileName().

◆ IsOpenFile()

G4bool G4VFileManager::IsOpenFile ( ) const
inlineinherited

Definition at line 117 of file G4VFileManager.hh.

118{ return fIsOpenFile; }

References G4VFileManager::fIsOpenFile.

◆ LockDirectoryNames()

void G4VFileManager::LockDirectoryNames ( )
inlineinherited

◆ Message()

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

◆ OpenFile()

G4bool G4CsvFileManager::OpenFile ( const G4String fileName)
finalvirtual

Implements G4VFileManager.

Definition at line 113 of file G4CsvFileManager.cc.

114{
115 // Keep file name
116 fFileName = fileName;
117
118 fIsOpenFile = true;
119
120 return true;
121}

References G4BaseFileManager::fFileName, and G4VFileManager::fIsOpenFile.

◆ OpenFiles()

G4bool G4TFileManager< std::ofstream >::OpenFiles ( )
inherited

◆ SetFileName()

G4bool G4VFileManager::SetFileName ( const G4String fileName)
finalvirtualinherited

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() && GetFileType().size() && 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)
static constexpr std::string_view fkClass

References G4VFileManager::fkClass, G4Analysis::GetBaseName(), G4Analysis::GetExtension(), G4BaseFileManager::GetFileType(), G4InuclParticleNames::name(), G4BaseFileManager::SetFileName(), and G4Analysis::Warn().

Referenced by G4GenericFileManager::OpenFile().

◆ SetHistoDirectoryName()

G4bool G4CsvFileManager::SetHistoDirectoryName ( const G4String dirName)
finalvirtual

Reimplemented from G4VFileManager.

Definition at line 124 of file G4CsvFileManager.cc.

125{
126 // A directory is taken into account only if it exists in file system
127 if ( G4fs::is_directory(dirName.data()) ) {
129 return fIsHistoDirectory;
130 }
131
132 G4Analysis::Warn("Directory " + dirName + " does not exists.\n"
133 "Histograms will be written in the current directory.",
134 fkClass, "SetHistoDirectoryName");
135 return false;
136}
virtual G4bool SetHistoDirectoryName(const G4String &dirName)

References fIsHistoDirectory, fkClass, G4VFileManager::SetHistoDirectoryName(), and G4Analysis::Warn().

◆ SetIsEmpty()

G4bool G4VTFileManager< std::ofstream >::SetIsEmpty ( const G4String fileName,
G4bool  isEmpty 
)
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 57 of file G4VTFileManager.hh.

104{
105 return G4TFileManager<FT>::SetIsEmpty(fileName, isEmpty);
106}
G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty)

◆ SetNtupleDirectoryName()

G4bool G4CsvFileManager::SetNtupleDirectoryName ( const G4String dirName)
finalvirtual

Reimplemented from G4VFileManager.

Definition at line 139 of file G4CsvFileManager.cc.

140{
141 // A directory is taken into account only if it exists in file system
142 if ( G4fs::is_directory(dirName.data()) ) {
144 return fIsNtupleDirectory;
145 }
146
147 G4Analysis::Warn("Directory " + dirName + " does not exists.\n"
148 "Ntuples will be written in the current directory.",
149 fkClass, "SetNtupleDirectoryName");
150 return false;
151}
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)

References fIsNtupleDirectory, fkClass, G4VFileManager::SetNtupleDirectoryName(), and G4Analysis::Warn().

◆ UnlockDirectoryNames()

void G4VFileManager::UnlockDirectoryNames ( )
inlineinherited

Definition at line 114 of file G4VFileManager.hh.

115{ fLockDirectoryNames = false; }

References G4VFileManager::fLockDirectoryNames.

Referenced by G4GenericFileManager::Clear().

◆ WriteFile() [1/2]

G4bool G4VTFileManager< std::ofstream >::WriteFile ( const G4String fileName)
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 55 of file G4VTFileManager.hh.

88{
89 return G4TFileManager<FT>::WriteTFile(fileName);
90}
G4bool WriteTFile(const G4String &fileName)

◆ WriteFile() [2/2]

virtual G4bool G4VFileManager::WriteFile ( const G4String fileName)
virtualinherited

Implements G4VFileManager.

◆ WriteFileImpl()

G4bool G4CsvFileManager::WriteFileImpl ( std::shared_ptr< std::ofstream >  file)
finalprotectedvirtual

Implements G4TFileManager< std::ofstream >.

Definition at line 91 of file G4CsvFileManager.cc.

92{
93 // Nothing to be done here
94 return true;
95}

◆ WriteFiles()

G4bool G4VTFileManager< std::ofstream >::WriteFiles
inlinefinalvirtualinherited

Implements G4VFileManager.

Definition at line 60 of file G4VTFileManager.hh.

112{
114}
G4bool WriteFiles()

◆ WriteTFile() [1/2]

G4bool G4TFileManager< std::ofstream >::WriteTFile ( const G4String fileName)
inherited

◆ WriteTFile() [2/2]

G4bool G4TFileManager< std::ofstream >::WriteTFile ( std::shared_ptr< std::ofstream >  file,
const G4String fileName 
)
privateinherited

Field Documentation

◆ fAMState

const G4AnalysisManagerState& G4TFileManager< std::ofstream >::fAMState
privateinherited

Definition at line 87 of file G4TFileManager.hh.

◆ fFile

std::shared_ptr<std::ofstream > G4VTFileManager< std::ofstream >::fFile
protectedinherited

Definition at line 73 of file G4VTFileManager.hh.

◆ fFileMap

std::map<G4String, G4TFileInformation<std::ofstream >*> G4TFileManager< std::ofstream >::fFileMap
privateinherited

Definition at line 88 of file G4TFileManager.hh.

◆ fFileName

G4String G4BaseFileManager::fFileName
protectedinherited

◆ fFileNames

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

◆ fH1FileManager

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

◆ fH2FileManager

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

◆ fH3FileManager

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

◆ fHistoDirectoryName

G4String G4VFileManager::fHistoDirectoryName
protectedinherited

◆ fIsHistoDirectory

G4bool G4CsvFileManager::fIsHistoDirectory { false }
private

Definition at line 85 of file G4CsvFileManager.hh.

Referenced by IsHistoDirectory(), and SetHistoDirectoryName().

◆ fIsNtupleDirectory

G4bool G4CsvFileManager::fIsNtupleDirectory { false }
private

Definition at line 86 of file G4CsvFileManager.hh.

Referenced by IsNtupleDirectory(), and SetNtupleDirectoryName().

◆ fIsOpenFile

G4bool G4VFileManager::fIsOpenFile { false }
protectedinherited

◆ fkClass

constexpr std::string_view G4CsvFileManager::fkClass { "G4CsvFileManager" }
staticconstexprprivate

◆ fLockDirectoryNames

G4bool G4VFileManager::fLockDirectoryNames { false }
protectedinherited

◆ fNtupleDirectoryName

G4String G4VFileManager::fNtupleDirectoryName
protectedinherited

◆ fP1FileManager

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

◆ fP2FileManager

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

◆ fState

const G4AnalysisManagerState& G4BaseFileManager::fState
protectedinherited

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