Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4BaseFileManager.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26
27// Base class for analysis file managers.
28//
29// Author: Ivana Hrivnacova, 18/06/2013 ([email protected])
30
31#ifndef G4BaseFileManager_h
32#define G4BaseFileManager_h 1
33
35#include "globals.hh"
36
37#include <vector>
38
40{
41 public:
42 explicit G4BaseFileManager(const G4AnalysisManagerState& state);
44 virtual ~G4BaseFileManager() = default;
45
46 virtual G4bool SetFileName(const G4String& fileName);
47 // Set the base file name (without extension)
48 virtual G4String GetFileType() const;
49 // Return the manager type (starts with a lowercase letter)
50 virtual G4bool HasCycles() const;
51 // Return true when the output supports writing the same object in a file
52 // multiple times.
53 // The default implementation returns false.
54
55 void AddFileName(const G4String& fileName);
56 // For handling multiple files
57 // Save file name in a vector if not yet present
58
59 G4String GetFileName() const;
60 // Return the base file name (without extension)
61 G4String GetFullFileName(const G4String& baseFileName = "",
62 G4bool isPerThread = true) const;
63 // Compose and return the full file name:
64 // - add _tN suffix to the file base name if isPerThread
65 // - add file extension if not present and available in state
66 const std::vector<G4String>& GetFileNames() const;
67 // Return the file names vector
68
69 G4String GetHnFileName(const G4String& hnType,
70 const G4String& hnName) const;
71 // Compose and return the histogram or profile specific file name:
72 // - add _hn_hnName suffix to the file base name
73 // - add file extension if not present
74
75 G4String GetHnFileName(const G4String& fileName,
76 G4int cycle = 0) const;
77 // Update Hn file name:
78 // - add _vN suffix to the base namer if cycle > 0
79
80 G4String GetNtupleFileName(const G4String& ntupleName,
81 G4int cycle = 0) const;
82 // Compose and return the ntuple specific file name:
83 // - add _nt_ntupleName suffix to the file base name
84 // - add _vN suffix if cycle > 0
85 // - add _tN suffix if called on thread worker
86 // - add file extension if not present
87
88 G4String GetNtupleFileName(G4int ntupleFileNumber,
89 G4int cycle = 0) const;
90 // Compose and return the ntuple specific file name:
91 // - add _mN suffix to the file base name
92 // - add _vN suffix if cycle > 0
93 // - add file extension if not present
94
96 // Return the file name for batch plotting output
97
98 protected:
99 // Methods for verbose
100 void Message(G4int level,
101 const G4String& action,
102 const G4String& objectType,
103 const G4String& objectName = "",
104 G4bool success = true) const;
105
106 // Data members
108 G4String fFileName; // to be changed in fDefaultFileName
109 std::vector<G4String> fFileNames;
110};
111
113 // CHECK if still needed in this base class
114 fFileName = fileName;
115 return true;
116}
117
119 return false;
120}
121
123 return fFileName;
124}
125
126inline const std::vector<G4String>& G4BaseFileManager::GetFileNames() const {
127 return fFileNames;
128}
129
131 G4int level, const G4String& action, const G4String& objectType,
132 const G4String& objectName, G4bool success) const
133{
134 fState.Message(level, action, objectType, objectName, success);
135}
136
137#endif
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
virtual ~G4BaseFileManager()=default
std::vector< G4String > fFileNames
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
G4String GetPlotFileName() const
virtual G4bool SetFileName(const G4String &fileName)
const std::vector< G4String > & GetFileNames() const
virtual G4String GetFileType() const
G4String GetHnFileName(const G4String &hnType, const G4String &hnName) const
G4String GetFileName() const
virtual G4bool HasCycles() const
void Message(G4int level, const G4String &action, const G4String &objectType, const G4String &objectName="", G4bool success=true) const
const G4AnalysisManagerState & fState
G4BaseFileManager()=delete
G4String GetNtupleFileName(const G4String &ntupleName, G4int cycle=0) const
void AddFileName(const G4String &fileName)