ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4BaseFileManager.cc
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4BaseFileManager.cc
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
// Author: Ivana Hrivnacova, 10/09/2014 (ivana@ipno.in2p3.fr)
28
29
#include "
G4BaseFileManager.hh
"
30
31
#include "
G4Threading.hh
"
32
33
//_____________________________________________________________________________
34
G4BaseFileManager::G4BaseFileManager
(
const
G4AnalysisManagerState
& state)
35
: fState(state),
36
fFileName(
""
)
37
{
38
}
39
40
//_____________________________________________________________________________
41
G4BaseFileManager::~G4BaseFileManager
()
42
{
43
}
44
45
//
46
// private methods
47
//
48
49
//_____________________________________________________________________________
50
G4String
G4BaseFileManager::TakeOffExtension
(
G4String
&
name
)
const
51
{
52
G4String
extension;
53
if
( name.rfind(
"."
) != std::string::npos ) {
54
extension = name.substr(name.rfind(
"."
));
55
name = name.substr(0, name.rfind(
"."
));
56
}
57
else
{
58
extension =
"."
;
59
extension.
append
(
GetFileType
());
60
}
61
return
extension;
62
}
63
64
//
65
// public methods
66
//
67
68
//_____________________________________________________________________________
69
G4String
G4BaseFileManager::GetFullFileName
(
const
G4String
& baseFileName,
70
G4bool
isPerThread)
const
71
{
72
G4String
name
(baseFileName);
73
if
( name ==
""
) name =
fFileName
;
74
75
// Take out file extension
76
G4String
extension =
TakeOffExtension
(name);
77
78
// Add thread Id to a file name if MT processing
79
if
( isPerThread && !
fState
.
GetIsMaster
() ) {
80
std::ostringstream os;
81
os <<
G4Threading::G4GetThreadId
();
82
name.
append
(
"_t"
);
83
name.
append
(os.str());
84
}
85
86
// Add (back if it was present) file extension
87
name.
append
(extension);
88
89
return
name
;
90
}
91
92
//_____________________________________________________________________________
93
G4String
G4BaseFileManager::GetNtupleFileName
(
const
G4String
& ntupleName)
const
94
{
95
G4String
name
(
fFileName
);
96
97
// Take out file extension
98
auto
extension =
TakeOffExtension
(name);
99
100
// Add ntupleName
101
name.
append
(
"_nt_"
);
102
name.
append
(ntupleName);
103
104
// Add thread Id to a file name if MT processing
105
if
( !
fState
.
GetIsMaster
() ) {
106
std::ostringstream os;
107
os <<
G4Threading::G4GetThreadId
();
108
name.
append
(
"_t"
);
109
name.
append
(os.str());
110
}
111
112
// Add (back if it was present) file extension
113
name.
append
(extension);
114
115
return
name
;
116
}
117
118
//_____________________________________________________________________________
119
G4String
G4BaseFileManager::GetNtupleFileName
(
G4int
ntupleFileNumber)
const
120
{
121
G4String
name
(
fFileName
);
122
123
// Take out file extension
124
auto
extension =
TakeOffExtension
(name);
125
126
// Add _M followed by ntupleFileNumber
127
std::ostringstream os;
128
os << ntupleFileNumber;
129
name.
append
(
"_m"
);
130
name.
append
(os.str());
131
132
// Add (back if it was present) file extension
133
name.
append
(extension);
134
135
return
name
;
136
}
137
138
//_____________________________________________________________________________
139
G4String
G4BaseFileManager::GetHnFileName
(
const
G4String
& hnType,
140
const
G4String
& hnName)
const
141
{
142
G4String
name
(
fFileName
);
143
144
// Take out file extension
145
auto
extension =
TakeOffExtension
(name);
146
147
// Add _hnType_hnName
148
name.
append
(
"_"
);
149
name.
append
(hnType);
150
name.
append
(
"_"
);
151
name.
append
(hnName);
152
153
// Add (back if it was present) file extension
154
name.
append
(extension);
155
156
return
name
;
157
}
158
159
//_____________________________________________________________________________
160
G4String
G4BaseFileManager::GetPlotFileName
()
const
161
{
162
G4String
name
(
fFileName
);
163
164
// Take out file extension
165
auto
extension =
TakeOffExtension
(name);
166
167
// Add .ps extension
168
name.
append
(
".ps"
);
169
170
return
name
;
171
}
172
173
//_____________________________________________________________________________
174
G4String
G4BaseFileManager::GetFileType
()
const
175
{
176
G4String
fileType =
fState
.
GetType
();
177
fileType.
toLower
();
178
return
fileType;
179
}
180
181
geant4
tree
geant4-10.6-release
source
analysis
management
src
G4BaseFileManager.cc
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:11
using
1.8.2 with
ECCE GitHub integration