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

#include <G4CsvRFileManager.hh>

+ Inheritance diagram for G4CsvRFileManager:

Public Member Functions

 G4CsvRFileManager (const G4AnalysisManagerState &state)
 
 ~G4CsvRFileManager ()
 
virtual G4String GetFileType () const final
 
virtual G4bool OpenRFile (const G4String &fileName)
 
std::ifstream * 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 42 of file G4CsvRFileManager.hh.

Constructor & Destructor Documentation

◆ G4CsvRFileManager()

G4CsvRFileManager::G4CsvRFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 33 of file G4CsvRFileManager.cc.

34 : G4BaseFileManager(state),
35 fRFiles()
36{
37}

◆ ~G4CsvRFileManager()

G4CsvRFileManager::~G4CsvRFileManager ( )

Definition at line 40 of file G4CsvRFileManager.cc.

41{
42 for (G4int i=0; i<G4int(fRFiles.size()); ++i) {
43 delete fRFiles[i];
44 }
45}
int G4int
Definition: G4Types.hh:85

Member Function Documentation

◆ GetFileType()

virtual G4String G4CsvRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 48 of file G4CsvRFileManager.hh.

48{ return "csv"; }

◆ GetRFile()

std::ifstream * G4CsvRFileManager::GetRFile ( const G4String fileName) const

Definition at line 90 of file G4CsvRFileManager.cc.

91{
92 std::map<G4String, std::ifstream*>::const_iterator it
93 = fRFiles.find(fileName);
94 if ( it != fRFiles.end() )
95 return it->second;
96 else {
97 return nullptr;
98 }
99}

Referenced by G4CsvAnalysisReader::ReadNtupleImpl().

◆ OpenRFile()

G4bool G4CsvRFileManager::OpenRFile ( const G4String fileName)
virtual

Definition at line 52 of file G4CsvRFileManager.cc.

53{
54#ifdef G4VERBOSE
55 if ( fState.GetVerboseL4() )
56 fState.GetVerboseL4()->Message("open", "read analysis file", fileName);
57#endif
58
59 // create new file
60 std::ifstream* newFile = new std::ifstream(fileName);
61 if ( ! newFile->is_open() ) {
62 G4ExceptionDescription description;
63 description << " " << "Cannot open file " << fileName;
64 G4Exception("G4CsvAnalysisReader::OpenRFile()",
65 "Analysis_WR001", JustWarning, description);
66 return false;
67 }
68
69 // add file in a map and delete the previous file if it exists
70 std::map<G4String, std::ifstream*>::iterator it
71 = fRFiles.find(fileName);
72 if ( it != fRFiles.end() ) {
73 delete it->second;
74 it->second = newFile;
75 }
76 else {
77 fRFiles[fileName] = newFile;
78 }
79
80#ifdef G4VERBOSE
81 if ( fState.GetVerboseL1() )
83 ->Message("open", "read analysis file", fileName);
84#endif
85
86 return true;
87}
@ 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
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

Referenced by G4CsvAnalysisReader::ReadNtupleImpl().


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