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);
58 auto ntupleFileName = ntupleDescription->
GetFileName();
60 if (ntupleFileName.size() != 0u) {
66 ntupleFileName = GetNtupleFileName(ntupleDescription->
GetNtupleBooking().name(), cycle);
73 return ntupleFileName;
83 std::shared_ptr<std::ofstream> file = std::make_shared<std::ofstream>(fileName);
85 Warn(
"Cannot create file " + fileName, fkClass,
"CreateFileImpl");
102 if ( ! file )
return false;
129 if ( G4fs::is_directory(dirName.data()) ) {
131 return fIsHistoDirectory;
135 "Histograms will be written in the current directory.",
136 fkClass,
"SetHistoDirectoryName");
144 if ( G4fs::is_directory(dirName.data()) ) {
146 return fIsNtupleDirectory;
150 "Ntuples will be written in the current directory.",
151 fkClass,
"SetNtupleDirectoryName");
159 auto ntupleFileName = GetNtupleFileName(ntupleDescription);
169 auto ntupleFileName = GetNtupleFileName(ntupleDescription);
172 while (
GetTFile(ntupleFileName,
false) !=
nullptr ) {
174 auto oldName = ntupleFileName;
178 Warn(
"Ntuple filename " + oldName +
" is already in use.\n" +
179 "It will be replaced with : " + newName,
180 fkClass,
"CreateNtupleFile");
182 ntupleFileName = GetNtupleFileName(ntupleDescription);
188 return (ntupleDescription->
GetFile() !=
nullptr);
202 ntupleDescription->
GetFile().reset();
G4bool CreateNtupleFile(CsvNtupleDescription *ntupleDescription)
std::shared_ptr< std::ofstream > CreateFileImpl(const G4String &fileName) final
G4bool OpenFile(const G4String &fileName) final
G4bool SetHistoDirectoryName(const G4String &dirName) final
G4String GetFileType() const final
G4CsvFileManager()=delete
G4bool SetNtupleDirectoryName(const G4String &dirName) final
G4bool CloseFileImpl(std::shared_ptr< std::ofstream > file) final
G4bool IsNtupleDirectory() const
G4bool WriteFileImpl(std::shared_ptr< std::ofstream > file) final
G4bool CloseNtupleFile(CsvNtupleDescription *ntupleDescription)
G4bool NotifyNtupleFile(CsvNtupleDescription *ntupleDescription)
std::shared_ptr< std::ofstream > GetTFile(const G4String &fileName, G4bool warn=true) const
std::shared_ptr< std::ofstream > CreateTFile(const G4String &fileName)
void SetFile(std::shared_ptr< FT > file)
const tools::ntuple_booking & GetNtupleBooking() const
G4bool GetHasFill() const
void SetFileName(const G4String &fileName)
std::shared_ptr< FT > GetFile() const
G4String GetFileName() const
G4String GetNtupleDirectoryName() const
std::shared_ptr< G4VTHnFileManager< tools::histo::h3d > > fH3FileManager
virtual G4bool SetHistoDirectoryName(const G4String &dirName)
std::shared_ptr< G4VTHnFileManager< tools::histo::h1d > > fH1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p1d > > fP1FileManager
std::shared_ptr< G4VTHnFileManager< tools::histo::p2d > > fP2FileManager
virtual G4bool SetNtupleDirectoryName(const G4String &dirName)
std::shared_ptr< G4VTHnFileManager< tools::histo::h2d > > fH2FileManager
G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetTnFileName(const G4String &fileName, const G4String &fileType, G4int cycle=0)
G4String GetBaseName(const G4String &fileName)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)