Geant4 11.1.1
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 ()=delete
 
 ~G4CsvRFileManager () override
 
G4String GetFileType () const final
 
void CloseFiles () final
 
virtual G4bool OpenRFile (const G4String &fileName)
 
std::ifstream * GetRFile (const G4String &fileName) const
 
- Public Member Functions inherited from G4VRFileManager
 G4VRFileManager (const G4AnalysisManagerState &state)
 
 G4VRFileManager ()=delete
 
 ~G4VRFileManager () override=default
 
virtual void CloseFiles ()=0
 
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
 
virtual G4bool SetFileName (const G4String &fileName)
 
virtual G4String GetFileType () const
 
virtual G4bool HasCycles () 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 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
 
- 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
 
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 G4CsvRFileManager.hh.

Constructor & Destructor Documentation

◆ G4CsvRFileManager() [1/2]

G4CsvRFileManager::G4CsvRFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 38 of file G4CsvRFileManager.cc.

39 : G4VRFileManager(state)
40{
41 // Create helpers defined in the base class
42 fH1RFileManager = std::make_shared<G4CsvHnRFileManager<histo::h1d>>(this);
43 fH2RFileManager = std::make_shared<G4CsvHnRFileManager<histo::h2d>>(this);
44 fH3RFileManager = std::make_shared<G4CsvHnRFileManager<histo::h3d>>(this);
45 fP1RFileManager = std::make_shared<G4CsvHnRFileManager<histo::p1d>>(this);
46 fP2RFileManager = std::make_shared<G4CsvHnRFileManager<histo::p2d>>(this);
47}
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

◆ G4CsvRFileManager() [2/2]

G4CsvRFileManager::G4CsvRFileManager ( )
delete

◆ ~G4CsvRFileManager()

G4CsvRFileManager::~G4CsvRFileManager ( )
override

Definition at line 50 of file G4CsvRFileManager.cc.

51{
52 for ( auto& rfile : fRFiles ) {
53 delete rfile.second;
54 }
55}

Member Function Documentation

◆ CloseFiles()

void G4CsvRFileManager::CloseFiles ( )
inlinefinalvirtual

Implements G4VRFileManager.

Definition at line 53 of file G4CsvRFileManager.hh.

53{}

◆ GetFileType()

G4String G4CsvRFileManager::GetFileType ( ) const
inlinefinalvirtual

Reimplemented from G4BaseFileManager.

Definition at line 50 of file G4CsvRFileManager.hh.

50{ return "csv"; }

◆ GetRFile()

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

Definition at line 89 of file G4CsvRFileManager.cc.

90{
91 auto it = fRFiles.find(fileName);
92 if (it != fRFiles.end()) {
93 return it->second;
94 }
95 return nullptr;
96}

◆ OpenRFile()

G4bool G4CsvRFileManager::OpenRFile ( const G4String fileName)
virtual

Definition at line 62 of file G4CsvRFileManager.cc.

63{
64 Message(kVL4, "open", "read analysis file", fileName);
65
66 // create new file
67 auto newFile = new std::ifstream(fileName);
68 if ( ! newFile->is_open() ) {
69 Warn("Cannot open file " + fileName, fkClass, "OpenRFile");
70 return false;
71 }
72
73 // add file in a map and delete the previous file if it exists
74 auto it = fRFiles.find(fileName);
75 if ( it != fRFiles.end() ) {
76 delete it->second;
77 it->second = newFile;
78 }
79 else {
80 fRFiles[fileName] = newFile;
81 }
82
83 Message(kVL1, "open", "read analysis file", fileName);
84
85 return true;
86}
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: