Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4CsvFileManager Class Reference

#include <G4CsvFileManager.hh>

Inheritance diagram for G4CsvFileManager:
Collaboration diagram for G4CsvFileManager:

Public Types

using NtupleType = tools::wcsv::ntuple
 
using NtupleDescriptionType = G4TNtupleDescription< NtupleType >
 

Public Member Functions

 G4CsvFileManager (const G4AnalysisManagerState &state)
 
 ~G4CsvFileManager ()
 
virtual G4bool OpenFile (const G4String &fileName) final
 
virtual G4bool WriteFile () final
 
virtual G4bool CloseFile () final
 
G4bool CreateNtupleFile (NtupleDescriptionType *ntupleDescription)
 
G4bool CloseNtupleFile (NtupleDescriptionType *ntupleDescription)
 
- Public Member Functions inherited from G4VFileManager
 G4VFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4VFileManager ()
 
virtual G4bool SetFileName (const G4String &fileName) final
 
void LockHistoDirectoryName ()
 
void LockNtupleDirectoryName ()
 
G4bool SetHistoDirectoryName (const G4String &dirName)
 
G4bool SetNtupleDirectoryName (const G4String &dirName)
 
G4bool IsOpenFile () const
 
G4String GetHistoDirectoryName () const
 
G4String GetNtupleDirectoryName () const
 
- Public Member Functions inherited from G4BaseFileManager
 G4BaseFileManager (const G4AnalysisManagerState &state)
 
virtual ~G4BaseFileManager ()
 
G4String GetFileName () const
 
G4String GetFullFileName (const G4String &baseFileName="", G4bool isPerThread=true) const
 
G4String GetHnFileName (const G4String &hnType, const G4String &hnName) const
 
G4String GetNtupleFileName (const G4String &ntupleName) const
 
G4String GetNtupleFileName (G4int ntupleFileNumber) const
 
G4String GetPlotFileName () const
 
G4String GetFileType () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4BaseFileManager
G4String TakeOffExtension (G4String &name) const
 
- Protected Attributes inherited from G4VFileManager
G4bool fIsOpenFile
 
G4String fHistoDirectoryName
 
G4String fNtupleDirectoryName
 
G4bool fLockFileName
 
G4bool fLockHistoDirectoryName
 
G4bool fLockNtupleDirectoryName
 
- Protected Attributes inherited from G4BaseFileManager
const G4AnalysisManagerStatefState
 
G4String fFileName
 

Detailed Description

Definition at line 41 of file G4CsvFileManager.hh.

Member Typedef Documentation

using G4CsvFileManager::NtupleType = tools::wcsv::ntuple

Definition at line 48 of file G4CsvFileManager.hh.

Constructor & Destructor Documentation

G4CsvFileManager::G4CsvFileManager ( const G4AnalysisManagerState state)
explicit

Definition at line 34 of file G4CsvFileManager.cc.

35  : G4VFileManager(state)
36 {}
G4VFileManager(const G4AnalysisManagerState &state)
G4CsvFileManager::~G4CsvFileManager ( )

Definition at line 39 of file G4CsvFileManager.cc.

40 {}

Member Function Documentation

G4bool G4CsvFileManager::CloseFile ( )
finalvirtual

Implements G4VFileManager.

Definition at line 67 of file G4CsvFileManager.cc.

68 {
69  fLockFileName = false;
70  fIsOpenFile = false;
71  return true;
72 }
G4bool G4CsvFileManager::CloseNtupleFile ( NtupleDescriptionType ntupleDescription)

Definition at line 108 of file G4CsvFileManager.cc.

110 {
111  // Do nothing if there is no file
112  if ( ! ntupleDescription->fFile ) return true;
113 
114  G4String ntupleName = ntupleDescription->fNtupleBooking.name();
115 
116 #ifdef G4VERBOSE
117  if ( fState.GetVerboseL4() )
119  ->Message("close", "file", GetNtupleFileName(ntupleName));
120 #endif
121 
122  // close file
123  ntupleDescription->fFile->close();
124 
125 #ifdef G4VERBOSE
126  if ( fState.GetVerboseL1() )
128  ->Message("close", "file", GetNtupleFileName(ntupleName));
129 #endif
130 
131  return true;
132 }
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
G4String GetNtupleFileName(const G4String &ntupleName) const
const G4AnalysisVerbose * GetVerboseL4() const
const G4AnalysisVerbose * GetVerboseL1() const

Here is the call graph for this function:

G4bool G4CsvFileManager::CreateNtupleFile ( NtupleDescriptionType ntupleDescription)

Definition at line 75 of file G4CsvFileManager.cc.

77 {
78  G4String ntupleName = ntupleDescription->fNtupleBooking.name();
79 
80 #ifdef G4VERBOSE
81  if ( fState.GetVerboseL4() )
83  ->Message("create", "file", GetNtupleFileName(ntupleName));
84 #endif
85 
86  auto ntupleFile = new std::ofstream(GetNtupleFileName(ntupleName));
87  if ( ntupleFile->fail() ) {
88  delete ntupleFile;
89  G4ExceptionDescription description;
90  description << " " << "Cannot open file "
91  << GetNtupleFileName(ntupleName);
92  G4Exception("G4CsvFileManager::CreateNtupleFile()",
93  "Analysis_W001", JustWarning, description);
94  return false;
95  }
96 
97 #ifdef G4VERBOSE
98  if ( fState.GetVerboseL1() )
100  ->Message("create", "file", GetNtupleFileName(ntupleName));
101 #endif
102 
103  ntupleDescription->fFile = ntupleFile;
104  return true;
105 }
void Message(const G4String &action, const G4String &object, const G4String &objectName, G4bool success=true) const
const G4AnalysisManagerState & fState
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String GetNtupleFileName(const G4String &ntupleName) const
const G4AnalysisVerbose * GetVerboseL4() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
const G4AnalysisVerbose * GetVerboseL1() const

Here is the call graph for this function:

G4bool G4CsvFileManager::OpenFile ( const G4String fileName)
finalvirtual

Implements G4VFileManager.

Definition at line 47 of file G4CsvFileManager.cc.

48 {
49  // Keep file name
50  fFileName = fileName;
51 
52  fLockFileName = true;
54  fIsOpenFile = true;
55 
56  return true;
57 }
G4bool fLockNtupleDirectoryName
G4bool G4CsvFileManager::WriteFile ( )
finalvirtual

Implements G4VFileManager.

Definition at line 60 of file G4CsvFileManager.cc.

61 {
62  // nothing to be done for Csv file
63  return true;
64 }

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