Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4XmlRFileManager Class Reference

#include <G4XmlRFileManager.hh>

+ Inheritance diagram for G4XmlRFileManager:

Public Member Functions

 G4XmlRFileManager (const G4AnalysisManagerState &state)
 
 G4XmlRFileManager ()=delete
 
 ~G4XmlRFileManager () override
 
G4String GetFileType () const final
 
void CloseFiles () final
 
virtual G4bool OpenRFile (const G4String &fileName)
 
toolx::raxml * GetRFile (const G4String &fileName) const
 
template<typename HT >
tools::raxml_out * GetHandler (const G4String &fileName, const G4String &objectName, std::string_view inFunction)
 
- Public Member Functions inherited from G4VRFileManager
 G4VRFileManager (const G4AnalysisManagerState &state)
 
 G4VRFileManager ()=delete
 
 ~G4VRFileManager () override=default
 
template<typename HT >
std::shared_ptr< G4VTHnRFileManager< HT > > GetHnRFileManager () const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
 G4BaseFileManager ()=delete
 
virtual ~G4BaseFileManager ()=default
 
void SetCompressionLevel (G4int level)
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4bool HasCycles () const
 
void AddFileName (const G4String &fileName)
 
G4int GetCompressionLevel () const
 
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
 

Additional Inherited Members

- Protected Member Functions inherited from G4BaseFileManager
void Message (G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
 
void ClearData ()
 
- Protected Attributes inherited from G4VRFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h1d > > fH1RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::h2d > > fH2RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::h3d > > fH3RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::p1d > > fP1RFileManager { nullptr }
 
std::shared_ptr< G4VTHnRFileManager< tools::histo::p2d > > fP2RFileManager { nullptr }
 
- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4int fCompressionLevel { 1 }
 
G4String fFileName
 
std::vector< G4StringfFileNames
 
- Static Protected Attributes inherited from G4VRFileManager
static constexpr std::string_view fkClass { "G4VRFileManager" }
 

Detailed Description

Definition at line 43 of file G4XmlRFileManager.hh.

Constructor & Destructor Documentation

◆ G4XmlRFileManager() [1/2]

G4XmlRFileManager::G4XmlRFileManager ( const G4AnalysisManagerState & state)
explicit

Definition at line 40 of file G4XmlRFileManager.cc.

41 : G4VRFileManager(state)
42{
43 // Create helpers defined in the base class
44 fH1RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h1d>>(this);
45 fH2RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h2d>>(this);
46 fH3RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h3d>>(this);
47 fP1RFileManager = std::make_shared<G4XmlHnRFileManager<histo::p1d>>(this);
48 fP2RFileManager = std::make_shared<G4XmlHnRFileManager<histo::p2d>>(this);
49}
std::shared_ptr< G4VTHnRFileManager< tools::histo::h2d > > fH2RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::p2d > > fP2RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h3d > > fH3RFileManager
G4VRFileManager()=delete
std::shared_ptr< G4VTHnRFileManager< tools::histo::p1d > > fP1RFileManager
std::shared_ptr< G4VTHnRFileManager< tools::histo::h1d > > fH1RFileManager

◆ G4XmlRFileManager() [2/2]

G4XmlRFileManager::G4XmlRFileManager ( )
delete

◆ ~G4XmlRFileManager()

G4XmlRFileManager::~G4XmlRFileManager ( )
override

Definition at line 52 of file G4XmlRFileManager.cc.

53{
54 for ( auto& rfile : fRFiles ) {
55 delete rfile.second;
56 }
57
58 delete fReadFactory;
59}

Member Function Documentation

◆ CloseFiles()

void G4XmlRFileManager::CloseFiles ( )
inlinefinalvirtual

Implements G4VRFileManager.

Definition at line 53 of file G4XmlRFileManager.hh.

53{}

◆ GetFileType()

G4String G4XmlRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 50 of file G4XmlRFileManager.hh.

50{ return "xml"; }

◆ GetHandler()

template<typename HT >
tools::raxml_out * G4XmlRFileManager::GetHandler ( const G4String & fileName,
const G4String & objectName,
std::string_view inFunction )

◆ GetRFile()

toolx::raxml * G4XmlRFileManager::GetRFile ( const G4String & fileName) const

Definition at line 112 of file G4XmlRFileManager.cc.

113{
114 // Get full file name (add only extension)
115 G4bool isPerThread = false;
116 G4String name = GetFullFileName(fileName, isPerThread);
117
118 auto it = fRFiles.find(name);
119 if (it != fRFiles.end()) {
120 return it->second;
121 }
122 return nullptr;
123}
bool G4bool
Definition G4Types.hh:86
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
const char * name(G4int ptype)

◆ OpenRFile()

G4bool G4XmlRFileManager::OpenRFile ( const G4String & fileName)
virtual

Definition at line 66 of file G4XmlRFileManager.cc.

67{
68 // Get full file name (add only extension)
69 G4bool isPerThread = false;
70 G4String name = GetFullFileName(fileName, isPerThread);
71
72 Message(kVL4, "open", "read analysis file", name);
73
74 G4bool verbose = false;
75
76 // create factory (if it does not yet exist)
77 if (fReadFactory == nullptr) {
78 fReadFactory = new tools::xml::default_factory();
79 }
80
81 // create new file
82 auto newFile = new toolx::raxml(*fReadFactory, G4cout, verbose);
83
84 // clear objects
85 // (this should not be needed when starting a new raxml)
86 std::vector<tools::raxml_out>& objs = newFile->objects();
87 objs.clear();
88
89 G4bool compressed = false;
90 if ( ! newFile->load_file(name, compressed) ) {
91 Warn(G4String( "Cannot open file ") + name, fkClass, "OpenRFile");
92 delete newFile;
93 return false;
94 }
95
96 // add file in a map and delete the previous file if it exists
97 auto it = fRFiles.find(name);
98 if ( it != fRFiles.end() ) {
99 delete it->second;
100 it->second = newFile;
101 }
102 else {
103 fRFiles[name] = newFile;
104 }
105
106 Message(kVL1, "open", "read analysis file", name);
107
108 return true;
109}
G4GLOB_DLL std::ostream G4cout
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
constexpr G4int kVL1
constexpr G4int kVL4
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

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