Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4GenericFileManager.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// The manager for Root output file operations.
28
29// Author: Ivana Hrivnacova, 18/06/2013 ([email protected])
30
31#ifndef G4GenericFileManager_h
32#define G4GenericFileManager_h 1
33
34#include "G4VFileManager.hh"
36#include "globals.hh"
37
38#include <vector>
39#include <memory>
40
41class G4HnInformation;
43
45#ifdef TOOLS_USE_HDF5
47#endif
50
52{
53 public:
54 explicit G4GenericFileManager(const G4AnalysisManagerState& state);
55 virtual ~G4GenericFileManager();
56
57 // Method to manipulate a default file
58 virtual G4bool OpenFile(const G4String& fileName) final;
59
60 // Methods applied to all registered files
61 virtual G4bool OpenFiles() final;
62 virtual G4bool WriteFiles() final;
63 virtual G4bool CloseFiles() final;
64 virtual G4bool DeleteEmptyFiles() final;
65
66 // Methods applied to file per name
67 virtual G4bool CreateFile(const G4String& fileName) final;
68 virtual G4bool WriteFile(const G4String& fileName) final;
69 virtual G4bool CloseFile(const G4String& fileName) final;
70 virtual G4bool SetIsEmpty(const G4String& fileName, G4bool isEmpty) final;
71
72 virtual G4String GetFileType() const final { return ""; }
73
74 // set default output type (backward compatibility)
75 // this type will be used for file names without extension
76 void SetDefaultFileType(const G4String& value);
78
79 template <typename T>
80 G4bool WriteT(const std::vector<T*>& htVector,
81 const std::vector<G4HnInformation*>& hnVector);
82
83 template <typename T>
84 G4bool WriteTExtra(const G4String& fileName, T* ht, const G4String& htName);
85
86 // methods
87 std::shared_ptr<G4VNtupleFileManager> CreateNtupleFileManager(G4AnalysisOutput output);
88
89 private:
90 // methods
91 void CreateFileManager(G4AnalysisOutput output);
92 std::shared_ptr<G4VFileManager> GetFileManager(G4AnalysisOutput output) const;
93 std::shared_ptr<G4VFileManager> GetFileManager(const G4String& fileName);
94
95 // constants
96 static const G4String fgkDefaultFileType;
97
98 // data members
99 G4String fDefaultFileType;
100 std::shared_ptr<G4VFileManager> fDefaultFileManager;
101 std::vector<std::shared_ptr<G4VFileManager>> fFileManagers;
102
103 std::shared_ptr<G4CsvFileManager> fCsvFileManager;
104#ifdef TOOLS_USE_HDF5
105 std::shared_ptr<G4Hdf5FileManager> fHdf5FileManager;
106#endif
107 std::shared_ptr<G4RootFileManager> fRootFileManager;
108 std::shared_ptr<G4XmlFileManager> fXmlFileManager;
109 G4bool fHdf5Warn;
110};
111
112#include "G4GenericFileManager.icc"
113
114#endif
115
G4AnalysisOutput
bool G4bool
Definition: G4Types.hh:86
virtual G4bool SetIsEmpty(const G4String &fileName, G4bool isEmpty) final
G4bool WriteTExtra(const G4String &fileName, T *ht, const G4String &htName)
virtual G4bool WriteFiles() final
virtual G4bool CreateFile(const G4String &fileName) final
std::shared_ptr< G4VNtupleFileManager > CreateNtupleFileManager(G4AnalysisOutput output)
G4bool WriteT(const std::vector< T * > &htVector, const std::vector< G4HnInformation * > &hnVector)
virtual G4bool OpenFiles() final
virtual G4bool CloseFile(const G4String &fileName) final
virtual G4String GetFileType() const final
virtual G4bool OpenFile(const G4String &fileName) final
void SetDefaultFileType(const G4String &value)
virtual G4bool WriteFile(const G4String &fileName) final
G4String GetDefaultFileType() const
virtual G4bool CloseFiles() final
virtual G4bool DeleteEmptyFiles() final