Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4Hdf5FileManager.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 Hdf5 file output operations.
28
29// Author: Ivana Hrivnacova, 20/07/2017 ([email protected])
30
31#ifndef G4Hdf5FileManager_h
32#define G4Hdf5FileManager_h 1
33
34#include "G4VTFileManager.hh"
35#include "globals.hh"
36
37#include "tools/hdf5/ntuple" // for hid_t
38
39#include <memory>
40#include <tuple>
41
42using G4Hdf5File = std::tuple<hid_t, hid_t, hid_t>;
44
45class G4Hdf5FileManager : public G4VTFileManager<G4Hdf5File>
46{
47 public:
48 explicit G4Hdf5FileManager(const G4AnalysisManagerState& state);
50
54
55 // Methods to manipulate output files
56 virtual G4bool OpenFile(const G4String& fileName) final;
57
58 virtual G4String GetFileType() const final { return "hdf5"; }
59
60 // Specific methods for files per objects
62 G4bool CloseNtupleFile(Hdf5NtupleDescription* ntupleDescription);
63
64 // Set methods
65 void SetBasketSize(unsigned int basketSize);
66
67 // Get methods
68 hid_t GetHistoDirectory() const;
69 hid_t GetNtupleDirectory() const;
70 unsigned int GetBasketSize() const;
71
72 protected:
73 // // Methods derived from templated base class
74 virtual std::shared_ptr<G4Hdf5File> CreateFileImpl(const G4String& fileName) final;
75 virtual G4bool WriteFileImpl(std::shared_ptr<G4Hdf5File> file) final;
76 virtual G4bool CloseFileImpl(std::shared_ptr<G4Hdf5File> file) final;
77
78 private:
79 hid_t CreateDirectory(hid_t& file, const G4String& directoryName,
80 const G4String& objectType);
81 G4String GetNtupleFileName(Hdf5NtupleDescription* ntupleDescription);
82
83 // constants
84 static const G4String fgkDefaultDirectoryName;
85
86 // data members
87 unsigned int fBasketSize;
88};
89
90// inline functions
91
92//_____________________________________________________________________________
93inline void G4Hdf5FileManager::SetBasketSize(unsigned int basketSize)
94{ fBasketSize = basketSize; }
95
96//_____________________________________________________________________________
97inline unsigned int G4Hdf5FileManager::GetBasketSize() const
98{ return fBasketSize; }
99
100#endif
std::tuple< hid_t, hid_t, hid_t > G4Hdf5File
bool G4bool
Definition: G4Types.hh:86
G4String GetNtupleFileName(const G4String &ntupleName) const
virtual G4bool CloseFileImpl(std::shared_ptr< G4Hdf5File > file) final
void SetBasketSize(unsigned int basketSize)
virtual G4String GetFileType() const final
hid_t GetNtupleDirectory() const
virtual G4bool OpenFile(const G4String &fileName) final
G4bool CreateNtupleFile(Hdf5NtupleDescription *ntupleDescription)
virtual std::shared_ptr< G4Hdf5File > CreateFileImpl(const G4String &fileName) final
hid_t GetHistoDirectory() const
G4bool CloseNtupleFile(Hdf5NtupleDescription *ntupleDescription)
virtual G4bool WriteFileImpl(std::shared_ptr< G4Hdf5File > file) final
unsigned int GetBasketSize() const
virtual G4bool WriteFile(const G4String &fileName) final
virtual G4bool CloseFile(const G4String &fileName) final