Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VFileManager.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, 18/06/2013 ([email protected])
28
29#include "G4VFileManager.hh"
32
33#include "G4Threading.hh"
34
35//_____________________________________________________________________________
37 : G4BaseFileManager(state),
38 fHistoDirectoryName(""),
39 fNtupleDirectoryName(""),
40 fIsOpenFile(false),
41 fLockDirectoryNames(false),
42 fH1FileManager(nullptr),
43 fH2FileManager(nullptr),
44 fH3FileManager(nullptr),
45 fP1FileManager(nullptr),
46 fP2FileManager(nullptr)
47{}
48
49//_____________________________________________________________________________
51{}
52
53//
54// public methods
55//
56
57//_____________________________________________________________________________
59{
60 // Check extension
61 auto name = fileName;
62 auto extension = G4Analysis::GetExtension(fileName);
63 if ( extension.size() && GetFileType().size() && extension != GetFileType() ) {
64 // replace extension
65 name = G4Analysis::GetBaseName(fileName) + "." + GetFileType();
66 G4ExceptionDescription description;
67 description
68 << fileName << " file extension is not valid for "
69 << GetFileType() << " output." << G4endl
70 << name << " will be used.";
71 G4Exception("G4VFileManager::SetFileName()",
72 "Analysis_W012", JustWarning, description);
73 }
74
76}
77
78//_____________________________________________________________________________
80{
81 if ( fLockDirectoryNames ) {
82 G4ExceptionDescription description;
83 description
84 << "Cannot set Histo directory name as its value was already used.";
85 G4Exception("G4VFileManager::SetHistoDirectoryName()",
86 "Analysis_W012", JustWarning, description);
87 return false;
88 }
89
90 fHistoDirectoryName = dirName;
91 return true;
92}
93
94//_____________________________________________________________________________
96{
97 if ( fLockDirectoryNames ) {
98 G4ExceptionDescription description;
99 description
100 << "Cannot set Ntuple directory name as its value was already used.";
101 G4Exception("G4VFileManager::SetNtupleDirectoryName()",
102 "Analysis_W012", JustWarning, description);
103 return false;
104 }
105
106 fNtupleDirectoryName = dirName;
107 return true;
108}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.cc:35
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:40
bool G4bool
Definition: G4Types.hh:86
#define G4endl
Definition: G4ios.hh:57
virtual G4bool SetFileName(const G4String &fileName)
virtual G4String GetFileType() const
virtual ~G4VFileManager()
G4bool SetHistoDirectoryName(const G4String &dirName)
G4String fNtupleDirectoryName
G4VFileManager(const G4AnalysisManagerState &state)
G4bool fLockDirectoryNames
virtual G4bool SetFileName(const G4String &fileName) final
G4bool SetNtupleDirectoryName(const G4String &dirName)
G4String fHistoDirectoryName
G4String GetExtension(const G4String &fileName, const G4String &defaultExtension="")
G4String GetBaseName(const G4String &fileName)