Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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
27// Author: Ivana Hrivnacova, 10/09/2014 ([email protected])
28
29#include "G4BaseFileManager.hh"
31
32#include "G4Threading.hh"
33
34//_____________________________________________________________________________
36 : fState(state),
37 fFileName(""),
38 fFileNames()
39{
40}
41
42//_____________________________________________________________________________
44{
45}
46
47//
48// public methods
49//
50
51//_____________________________________________________________________________
53{
54 // G4cout << "registering " << fileName << " in manager of " << GetFileType() << G4endl;
55
56 // Do nothing in file name is already present
57 for ( auto name : fFileNames ) {
58 if ( name == fileName ) return;
59 }
60
61 fFileNames.push_back(fileName);
62}
63
64//_____________________________________________________________________________
66{
67 G4String fileType = fState.GetType();
68 fileType.toLower();
69 return fileType;
71
72//_____________________________________________________________________________
74 G4bool isPerThread) const
75{
76 G4String fileName(baseFileName);
77 if ( fileName == "" ) fileName = fFileName;
78
79 // Take out file extension
80 auto name = G4Analysis::GetBaseName(fileName);
81
82 // Add thread Id to a file name if MT processing
83 if ( isPerThread && ! fState.GetIsMaster() ) {
84 std::ostringstream os;
86 name.append("_t");
87 name.append(os.str());
88 }
89
90 // Add (back if it was present or is defined) file extension
91 auto extension = G4Analysis::GetExtension(fileName, GetFileType());
92 if ( extension.size() ) {
93 name.append(".");
94 name.append(extension);
95 }
96
97 return name;
98}
99
100//_____________________________________________________________________________
102 const G4String& hnName) const
103{
104 return G4Analysis::GetHnFileName(fFileName, GetFileType(), hnType, hnName);
105}
106
107//_____________________________________________________________________________
109{
111}
112
113//_____________________________________________________________________________
115{
116 return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleFileNumber);
117}
118
119//_____________________________________________________________________________
121{
123}
124
125
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
std::vector< G4String > fFileNames
G4String GetFullFileName(const G4String &baseFileName="", G4bool isPerThread=true) const
G4String GetPlotFileName() const
G4BaseFileManager(const G4AnalysisManagerState &state)
virtual G4String GetFileType() const
G4String GetHnFileName(const G4String &hnType, const G4String &hnName) const
const G4AnalysisManagerState & fState
G4String GetNtupleFileName(const G4String &ntupleName) const
virtual ~G4BaseFileManager()
void AddFileName(const G4String &fileName)
void toLower()
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetPlotFileName(const G4String &fileName)
G4String GetHnFileName(const G4String &fileName, const G4String &fileType, const G4String &hnType, const G4String &hnName)
G4String GetBaseName(const G4String &fileName)
G4String GetNtupleFileName(const G4String &fileName, const G4String &fileType, const G4String &ntupleName)
const char * name(G4int ptype)
G4int G4GetThreadId()
Definition: G4Threading.cc:122