Geant4 10.7.0
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 ()
 
virtual G4String GetFileType () const final
 
virtual G4bool OpenRFile (const G4String &fileName)
 
tools::raxml * GetRFile (const G4String &fileName) const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseFileManager ()
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () const
 
void AddFileName (const G4String &fileName)
 
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 GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 

Additional Inherited Members

- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4String fFileName
 
std::vector< G4StringfFileNames
 

Detailed Description

Definition at line 43 of file G4XmlRFileManager.hh.

Constructor & Destructor Documentation

◆ G4XmlRFileManager()

G4XmlRFileManager::G4XmlRFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 36 of file G4XmlRFileManager.cc.

37 : G4BaseFileManager(state),
38 fReadFactory(0),
39 fRFiles()
40{
41}

◆ ~G4XmlRFileManager()

G4XmlRFileManager::~G4XmlRFileManager ( )

Definition at line 44 of file G4XmlRFileManager.cc.

45{
46 for (G4int i=0; i<G4int(fRFiles.size()); ++i) {
47 delete fRFiles[i];
48 }
49 delete fReadFactory;
50}
int G4int
Definition: G4Types.hh:85

Member Function Documentation

◆ GetFileType()

virtual G4String G4XmlRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 49 of file G4XmlRFileManager.hh.

49{ return "xml"; }

◆ GetRFile()

tools::raxml * G4XmlRFileManager::GetRFile ( const G4String fileName) const

Definition at line 115 of file G4XmlRFileManager.cc.

116{
117 // Get full file name (add only extension)
118 G4bool isPerThread = false;
119 G4String name = GetFullFileName(fileName, isPerThread);
120
121 std::map<G4String, tools::raxml*>::const_iterator it
122 = fRFiles.find(name);
123 if ( it != fRFiles.end() )
124 return it->second;
125 else {
126 return nullptr;
127 }
128}
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 57 of file G4XmlRFileManager.cc.

58{
59 // Get full file name (add only extension)
60 G4bool isPerThread = false;
61 G4String name = GetFullFileName(fileName, isPerThread);
62
63#ifdef G4VERBOSE
64 if ( fState.GetVerboseL4() )
65 fState.GetVerboseL4()->Message("open", "read analysis file", name);
66#endif
67
68 G4bool verbose = false;
69
70 // create factory (if it does not yet exist)
71 if ( ! fReadFactory ) {
72 fReadFactory = new tools::xml::default_factory();
73 }
74
75 // create new file
76 tools::raxml* newFile
77 = new tools::raxml(*fReadFactory, G4cout, verbose);
78
79 // clear objects
80 // (this should not be needed when starting a new raxml)
81 std::vector<tools::raxml_out>& objs = newFile->objects();
82 objs.clear();
83
84 G4bool compressed = false;
85 if ( ! newFile->load_file(name, compressed) ) {
86 G4ExceptionDescription description;
87 description << " " << "Cannot open file " << name;
88 G4Exception("G4XmlRFileManager::OpenRFile()",
89 "Analysis_WR001", JustWarning, description);
90 delete newFile;
91 return false;
92 }
93
94 // add file in a map and delete the previous file if it exists
95 std::map<G4String, tools::raxml*>::iterator it
96 = fRFiles.find(name);
97 if ( it != fRFiles.end() ) {
98 delete it->second;
99 it->second = newFile;
100 }
101 else {
102 fRFiles[name] = newFile;
103 }
104
105#ifdef G4VERBOSE
106 if ( fState.GetVerboseL1() )
108 ->Message("open", "read analysis file", name);
109#endif
110
111 return true;
112}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
G4GLOB_DLL std::ostream G4cout
const G4AnalysisVerbose * GetVerboseL1() const
const G4AnalysisVerbose * GetVerboseL4() const
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState

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