Geant4
10.03
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
G4BaseFileManager.cc
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
// $Id: G4BaseFileManager.cc 70604 2013-06-03 11:27:06Z ihrivnac $
27
28
// Author: Ivana Hrivnacova, 10/09/2014 (ivana@ipno.in2p3.fr)
29
30
#include "
G4BaseFileManager.hh
"
31
32
#include "
G4Threading.hh
"
33
34
//_____________________________________________________________________________
35
G4BaseFileManager::G4BaseFileManager
(
const
G4AnalysisManagerState
& state)
36
: fState(state),
37
fFileName(
""
)
38
{
39
}
40
41
//_____________________________________________________________________________
42
G4BaseFileManager::~G4BaseFileManager
()
43
{
44
}
45
46
//
47
// private methods
48
//
49
50
//_____________________________________________________________________________
51
G4String
G4BaseFileManager::TakeOffExtension
(
G4String
&
name
)
const
52
{
53
G4String
extension;
54
if
( name.find(
"."
) != std::string::npos ) {
55
extension = name.substr(name.find(
"."
));
56
name = name.substr(0, name.find(
"."
));
57
}
58
else
{
59
extension =
"."
;
60
extension.
append
(
GetFileType
());
61
}
62
return
extension;
63
}
64
65
//
66
// public methods
67
//
68
69
//_____________________________________________________________________________
70
G4String
G4BaseFileManager::GetFullFileName
(
const
G4String
& baseFileName,
71
G4bool
isPerThread)
const
72
{
73
G4String
name
(baseFileName);
74
if
( name ==
""
) name =
fFileName
;
75
76
// Take out file extension
77
G4String
extension =
TakeOffExtension
(name);
78
79
// Add thread Id to a file name if MT processing
80
if
( isPerThread && !
fState
.
GetIsMaster
() ) {
81
std::ostringstream os;
82
os <<
G4Threading::G4GetThreadId
();
83
name.
append
(
"_t"
);
84
name.
append
(os.str());
85
}
86
87
// Add (back if it was present) file extension
88
name.
append
(extension);
89
90
return
name
;
91
}
92
93
//_____________________________________________________________________________
94
G4String
G4BaseFileManager::GetNtupleFileName
(
const
G4String
& ntupleName)
const
95
{
96
G4String
name
(
fFileName
);
97
98
// Take out file extension
99
auto
extension =
TakeOffExtension
(name);
100
101
// Add ntupleName
102
name.
append
(
"_nt_"
);
103
name.
append
(ntupleName);
104
105
// Add thread Id to a file name if MT processing
106
if
( !
fState
.
GetIsMaster
() ) {
107
std::ostringstream os;
108
os <<
G4Threading::G4GetThreadId
();
109
name.
append
(
"_t"
);
110
name.
append
(os.str());
111
}
112
113
// Add (back if it was present) file extension
114
name.
append
(extension);
115
116
return
name
;
117
}
118
119
//_____________________________________________________________________________
120
G4String
G4BaseFileManager::GetNtupleFileName
(
G4int
ntupleFileNumber)
const
121
{
122
G4String
name
(
fFileName
);
123
124
// Take out file extension
125
auto
extension =
TakeOffExtension
(name);
126
127
// Add _M followed by ntupleFileNumber
128
std::ostringstream os;
129
os << ntupleFileNumber;
130
name.
append
(
"_m"
);
131
name.
append
(os.str());
132
133
// Add (back if it was present) file extension
134
name.
append
(extension);
135
136
return
name
;
137
}
138
139
//_____________________________________________________________________________
140
G4String
G4BaseFileManager::GetHnFileName
(
const
G4String
& hnType,
141
const
G4String
& hnName)
const
142
{
143
G4String
name
(
fFileName
);
144
145
// Take out file extension
146
auto
extension =
TakeOffExtension
(name);
147
148
// Add _hnType_hnName
149
name.
append
(
"_"
);
150
name.
append
(hnType);
151
name.
append
(
"_"
);
152
name.
append
(hnName);
153
154
// Add (back if it was present) file extension
155
name.
append
(extension);
156
157
return
name
;
158
}
159
160
//_____________________________________________________________________________
161
G4String
G4BaseFileManager::GetPlotFileName
()
const
162
{
163
G4String
name
(
fFileName
);
164
165
// Take out file extension
166
auto
extension =
TakeOffExtension
(name);
167
168
// Add .ps extension
169
name.
append
(
".ps"
);
170
171
return
name
;
172
}
173
174
//_____________________________________________________________________________
175
G4String
G4BaseFileManager::GetFileType
()
const
176
{
177
G4String
fileType =
fState
.
GetType
();
178
fileType.
toLower
();
179
return
fileType;
180
}
181
182
G4BaseFileManager.hh
G4BaseFileManager::fState
const G4AnalysisManagerState & fState
Definition:
G4BaseFileManager.hh:86
G4BaseFileManager::GetNtupleFileName
G4String GetNtupleFileName(const G4String &ntupleName) const
Definition:
G4BaseFileManager.cc:94
G4BaseFileManager::GetPlotFileName
G4String GetPlotFileName() const
Definition:
G4BaseFileManager.cc:161
G4BaseFileManager::fFileName
G4String fFileName
Definition:
G4BaseFileManager.hh:87
G4InuclParticleNames::name
const char * name(G4int ptype)
Definition:
G4InuclParticleNames.hh:77
G4BaseFileManager::GetHnFileName
G4String GetHnFileName(const G4String &hnType, const G4String &hnName) const
Definition:
G4BaseFileManager.cc:140
G4int
int G4int
Definition:
G4Types.hh:78
G4AnalysisManagerState::GetType
G4String GetType() const
Definition:
G4AnalysisManagerState.hh:96
G4AnalysisManagerState
Definition:
G4AnalysisManagerState.hh:39
G4BaseFileManager::~G4BaseFileManager
virtual ~G4BaseFileManager()
Definition:
G4BaseFileManager.cc:42
G4BaseFileManager::GetFileType
G4String GetFileType() const
Definition:
G4BaseFileManager.cc:175
G4Threading.hh
G4bool
bool G4bool
Definition:
G4Types.hh:79
G4BaseFileManager::TakeOffExtension
G4String TakeOffExtension(G4String &name) const
Definition:
G4BaseFileManager.cc:51
G4BaseFileManager::G4BaseFileManager
G4BaseFileManager(const G4AnalysisManagerState &state)
Definition:
G4BaseFileManager.cc:35
G4String::toLower
void toLower()
G4String::append
G4String & append(const G4String &)
G4AnalysisManagerState::GetIsMaster
G4bool GetIsMaster() const
Definition:
G4AnalysisManagerState.hh:99
G4BaseFileManager::GetFullFileName
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
Definition:
G4BaseFileManager.cc:70
G4Threading::G4GetThreadId
G4int G4GetThreadId()
Definition:
G4Threading.cc:144
G4String
Definition:
G4String.hh:45
geant4.10.03
source
analysis
management
src
G4BaseFileManager.cc
Generated on Thu Feb 14 2002 02:28:01 for Geant4 by
1.8.8