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->
fFileName;
59 if ( ntupleFileName.size() ) {
71 return ntupleFileName;
81 std::shared_ptr<std::ofstream>
file = std::make_shared<std::ofstream>(fileName);
83 Warn(
"Cannot create file " + fileName,
fkClass,
"CreateFileImpl");
100 if ( !
file )
return false;
127 if ( G4fs::is_directory(dirName.data()) ) {
133 "Histograms will be written in the current directory.",
134 fkClass,
"SetHistoDirectoryName");
142 if ( G4fs::is_directory(dirName.data()) ) {
148 "Ntuples will be written in the current directory.",
149 fkClass,
"SetNtupleDirectoryName");
160 Message(
kVL4,
"create",
"ntuple file", ntupleFileName);
163 while (
GetTFile(ntupleFileName,
false) ) {
165 auto oldName = ntupleDescription->
fFileName;
169 Warn(
"Ntuple filename " + oldName +
" is already in use.\n" +
170 "It will be replaced with : " + newName,
178 Message(
kVL2,
"create",
"ntuple file", ntupleFileName);
180 return (ntupleDescription->
fFile !=
nullptr);
188 if ( ! ntupleDescription->
fFile )
return true;
194 Message(
kVL4,
"close",
"ntuple file", ntupleFileName);
202 ntupleDescription->
fFile.reset();
204 Message(
kVL2,
"close",
"ntuple file", ntupleFileName);
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
G4bool CreateNtupleFile(CsvNtupleDescription *ntupleDescription)
virtual std::shared_ptr< std::ofstream > CreateFileImpl(const G4String &fileName) final
virtual G4bool OpenFile(const G4String &fileName) final
G4bool fIsNtupleDirectory
virtual G4bool SetHistoDirectoryName(const G4String &dirName) final
G4CsvFileManager()=delete
virtual G4bool SetNtupleDirectoryName(const G4String &dirName) final
static constexpr std::string_view fkClass
virtual G4bool CloseFileImpl(std::shared_ptr< std::ofstream > file) final
G4bool IsNtupleDirectory() const
virtual G4bool WriteFileImpl(std::shared_ptr< std::ofstream > file) final
G4bool CloseNtupleFile(CsvNtupleDescription *ntupleDescription)
virtual G4String GetFileType() const final
G4String GetNtupleFileName(CsvNtupleDescription *ntupleDescription)
G4bool CloseTFile(const G4String &fileName)
std::shared_ptr< std::ofstream > GetTFile(const G4String &fileName, G4bool warn=true) const
std::shared_ptr< std::ofstream > CreateTFile(const G4String &fileName)
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
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetTnFileName(const G4String &fileName, const G4String &fileType)
G4String GetBaseName(const G4String &fileName)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)
tools::ntuple_booking fNtupleBooking
std::shared_ptr< FT > fFile