34#include "tools/waxml/begend"
44 fH1FileManager = std::make_shared<G4XmlHnFileManager<histo::h1d>>(
this);
45 fH2FileManager = std::make_shared<G4XmlHnFileManager<histo::h2d>>(
this);
46 fH3FileManager = std::make_shared<G4XmlHnFileManager<histo::h3d>>(
this);
47 fP1FileManager = std::make_shared<G4XmlHnFileManager<histo::p1d>>(
this);
48 fP2FileManager = std::make_shared<G4XmlHnFileManager<histo::p2d>>(
this);
59 auto ntupleFileName = ntupleDescription->
fFileName;
60 if ( ntupleFileName.size() ) {
67 return ntupleFileName;
77 std::shared_ptr<std::ofstream>
file = std::make_shared<std::ofstream>(fileName);
97 if ( !
file )
return false;
144 Message(
kVL4,
"create",
"ntuple file", ntupleFileName);
147 while (
GetTFile(ntupleFileName,
false) ) {
149 auto oldName = ntupleDescription->
fFileName;
153 Warn(
G4String(
"Ntuple filename ") + oldName +
" is already in use.\n" +
154 "It will be replaced with : " + newName,
162 Message(
kVL2,
"create",
"ntuple file", ntupleFileName);
164 return (ntupleDescription->
fFile !=
nullptr);
172 if ( ! ntupleDescription->
fFile )
return true;
178 Message(
kVL4,
"close",
"ntuple file", ntupleFileName);
186 ntupleDescription->
fFile.reset();
188 Message(
kVL2,
"close",
"ntuple file", ntupleFileName);
G4bool GetIsMaster() const
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
const G4AnalysisManagerState & fState
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)
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
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
std::shared_ptr< std::ofstream > fFile
static constexpr std::string_view fkClass
virtual G4bool OpenFile(const G4String &fileName) final
G4String GetNtupleFileName(XmlNtupleDescription *ntupleDescription)
virtual G4bool CloseFileImpl(std::shared_ptr< std::ofstream > file) final
G4XmlFileManager()=delete
virtual std::shared_ptr< std::ofstream > CreateFileImpl(const G4String &fileName) final
virtual G4bool WriteFileImpl(std::shared_ptr< std::ofstream > file) final
G4bool CloseNtupleFile(XmlNtupleDescription *ntupleDescription)
virtual G4String GetFileType() const final
G4bool CreateNtupleFile(XmlNtupleDescription *ntupleDescription)
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)
const char * name(G4int ptype)
tools::ntuple_booking fNtupleBooking
std::shared_ptr< FT > fFile