Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include <memory>
|
||||
|
||||
class G4Hdf5FileManager;
|
||||
class G4Hdf5NtupleManager;
|
||||
class G4Hdf5NtupleFileManager;
|
||||
|
||||
class G4Hdf5AnalysisManager : public G4ToolsAnalysisManager
|
||||
{
|
||||
@@ -81,12 +81,10 @@ class G4Hdf5AnalysisManager : public G4ToolsAnalysisManager
|
||||
template <typename T>
|
||||
G4bool WriteHn(const std::vector<T*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector,
|
||||
const G4String& directoryName,
|
||||
const G4String& hnType);
|
||||
template <typename T>
|
||||
G4bool WritePn(const std::vector<T*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector,
|
||||
const G4String& directoryName,
|
||||
const G4String& hnType);
|
||||
G4bool WriteDirectory();
|
||||
G4bool WriteH1();
|
||||
@@ -97,7 +95,7 @@ class G4Hdf5AnalysisManager : public G4ToolsAnalysisManager
|
||||
G4bool Reset();
|
||||
|
||||
// data members
|
||||
G4Hdf5NtupleManager* fNtupleManager;
|
||||
std::shared_ptr<G4Hdf5NtupleFileManager> fNtupleFileManager;
|
||||
std::shared_ptr<G4Hdf5FileManager> fFileManager;
|
||||
};
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4Hdf5NtupleFileManager.hh"
|
||||
#include "G4Hdf5NtupleManager.hh"
|
||||
#include "G4Hdf5FileManager.hh"
|
||||
|
||||
@@ -36,9 +37,12 @@ template <typename T>
|
||||
inline
|
||||
G4bool G4Hdf5AnalysisManager::WriteHn(const std::vector<T*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector,
|
||||
const G4String& /*directoryName*/,
|
||||
const G4String& hnType)
|
||||
{
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
// Do nothing if there is no directory
|
||||
if ( directory < 0 ) return false;
|
||||
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
auto info = hnVector[i];
|
||||
auto activation = info->GetActivation();
|
||||
@@ -50,9 +54,6 @@ G4bool G4Hdf5AnalysisManager::WriteHn(const std::vector<T*>& htVector,
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", hnType, name);
|
||||
#endif
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
// Do nothing if there is no directory
|
||||
if ( directory < 0 ) return false;
|
||||
|
||||
G4bool result
|
||||
= tools::hdf5::write_histo(G4cout, directory, name, *ht);
|
||||
@@ -63,7 +64,7 @@ G4bool G4Hdf5AnalysisManager::WriteHn(const std::vector<T*>& htVector,
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
fFileManager->LockHistoDirectoryName();
|
||||
fFileManager->LockDirectoryNames();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -74,9 +75,12 @@ template <typename T>
|
||||
inline
|
||||
G4bool G4Hdf5AnalysisManager::WritePn(const std::vector<T*>& htVector,
|
||||
const std::vector<G4HnInformation*>& hnVector,
|
||||
const G4String& /*directoryName*/,
|
||||
const G4String& hnType)
|
||||
{
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
// Do nothing if there is no directory
|
||||
if ( directory < 0 ) return false;
|
||||
|
||||
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
||||
auto info = hnVector[i];
|
||||
auto activation = info->GetActivation();
|
||||
@@ -88,9 +92,6 @@ G4bool G4Hdf5AnalysisManager::WritePn(const std::vector<T*>& htVector,
|
||||
if ( fState.GetVerboseL3() )
|
||||
fState.GetVerboseL3()->Message("write", hnType, name);
|
||||
#endif
|
||||
auto directory = fFileManager->GetHistoDirectory();
|
||||
// Do nothing if there is no directory
|
||||
if ( directory < 0 ) return false;
|
||||
|
||||
G4bool result
|
||||
= tools::hdf5::write_profile(G4cout, directory, name, *ht);
|
||||
@@ -101,7 +102,7 @@ G4bool G4Hdf5AnalysisManager::WritePn(const std::vector<T*>& htVector,
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
fFileManager->LockHistoDirectoryName();
|
||||
fFileManager->LockDirectoryNames();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -118,28 +119,28 @@ G4bool G4Hdf5AnalysisManager::IsOpenFileImpl() const
|
||||
inline
|
||||
tools::hdf5::ntuple* G4Hdf5AnalysisManager::GetNtuple() const
|
||||
{
|
||||
return fNtupleManager->GetNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->GetNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::hdf5::ntuple* G4Hdf5AnalysisManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
return fNtupleManager->GetNtuple(ntupleId);
|
||||
return fNtupleFileManager->GetNtupleManager()->GetNtuple(ntupleId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::hdf5::ntuple*>::iterator G4Hdf5AnalysisManager::BeginNtuple()
|
||||
{
|
||||
return fNtupleManager->BeginNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->BeginNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::hdf5::ntuple*>::iterator G4Hdf5AnalysisManager::EndNtuple()
|
||||
{
|
||||
return fNtupleManager->EndNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->EndNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -147,7 +148,7 @@ inline
|
||||
std::vector<tools::hdf5::ntuple*>::const_iterator
|
||||
G4Hdf5AnalysisManager::BeginConstNtuple() const
|
||||
{
|
||||
return fNtupleManager->BeginConstNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->BeginConstNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -155,5 +156,5 @@ inline
|
||||
std::vector<tools::hdf5::ntuple*>::const_iterator
|
||||
G4Hdf5AnalysisManager::EndConstNtuple() const
|
||||
{
|
||||
return fNtupleManager->EndConstNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->EndConstNtuple();
|
||||
}
|
||||
|
||||
@@ -31,75 +31,69 @@
|
||||
#ifndef G4Hdf5FileManager_h
|
||||
#define G4Hdf5FileManager_h 1
|
||||
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4TNtupleDescription.hh"
|
||||
#include "G4VTFileManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/hdf5/ntuple"
|
||||
#include "tools/hdf5/ntuple" // for hid_t
|
||||
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
#include <tuple>
|
||||
|
||||
class G4AnalysisManagerState;
|
||||
using G4Hdf5File = std::tuple<hid_t, hid_t, hid_t>;
|
||||
using Hdf5NtupleDescription = G4TNtupleDescription<tools::hdf5::ntuple, G4Hdf5File>;
|
||||
|
||||
class G4Hdf5FileManager : public G4VFileManager
|
||||
class G4Hdf5FileManager : public G4VTFileManager<G4Hdf5File>
|
||||
{
|
||||
public:
|
||||
explicit G4Hdf5FileManager(const G4AnalysisManagerState& state);
|
||||
~G4Hdf5FileManager();
|
||||
|
||||
// Type aliases
|
||||
using NtupleType = tools::hdf5::ntuple;
|
||||
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
|
||||
using G4BaseFileManager::GetNtupleFileName;
|
||||
using G4VTFileManager<G4Hdf5File>::WriteFile;
|
||||
using G4VTFileManager<G4Hdf5File>::CloseFile;
|
||||
|
||||
// Methods to manipulate output files
|
||||
virtual G4bool OpenFile(const G4String& fileName) final;
|
||||
virtual G4bool WriteFile() final;
|
||||
virtual G4bool CloseFile() final;
|
||||
|
||||
G4bool WriteHistoDirectory();
|
||||
G4bool WriteNtupleDirectory();
|
||||
void CloseAfterHnWrite();
|
||||
virtual G4String GetFileType() const final { return "hdf5"; }
|
||||
|
||||
// Specific methods for files per objects
|
||||
G4bool CreateNtupleFile(Hdf5NtupleDescription* ntupleDescription);
|
||||
G4bool CloseNtupleFile(Hdf5NtupleDescription* ntupleDescription);
|
||||
|
||||
// Set methods
|
||||
void SetBasketSize(unsigned int basketSize);
|
||||
|
||||
// Get methods
|
||||
hid_t GetFile() const;
|
||||
hid_t GetHistoDirectory() const;
|
||||
hid_t GetNtupleDirectory() const;
|
||||
unsigned int GetBasketSize() const;
|
||||
|
||||
private:
|
||||
G4bool CreateDirectory(const G4String& directoryType,
|
||||
const G4String& directoryName, hid_t& directory);
|
||||
G4bool WriteDirectory(const G4String& directoryType,
|
||||
const G4String& directoryName, hid_t& directory);
|
||||
protected:
|
||||
// // Methods derived from templated base class
|
||||
virtual std::shared_ptr<G4Hdf5File> CreateFileImpl(const G4String& fileName) final;
|
||||
virtual G4bool WriteFileImpl(std::shared_ptr<G4Hdf5File> file) final;
|
||||
virtual G4bool CloseFileImpl(std::shared_ptr<G4Hdf5File> file) final;
|
||||
|
||||
private:
|
||||
hid_t CreateDirectory(hid_t& file, const G4String& directoryName,
|
||||
const G4String& objectType);
|
||||
G4String GetNtupleFileName(Hdf5NtupleDescription* ntupleDescription);
|
||||
|
||||
// constants
|
||||
static const G4String fgkDefaultDirectoryName;
|
||||
|
||||
// data members
|
||||
hid_t fFile;
|
||||
hid_t fHistoDirectory;
|
||||
hid_t fNtupleDirectory;
|
||||
unsigned int fBasketSize;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void G4Hdf5FileManager::SetBasketSize(unsigned int basketSize)
|
||||
//_____________________________________________________________________________
|
||||
inline void G4Hdf5FileManager::SetBasketSize(unsigned int basketSize)
|
||||
{ fBasketSize = basketSize; }
|
||||
|
||||
inline hid_t G4Hdf5FileManager::GetFile() const
|
||||
{ return fFile; }
|
||||
|
||||
inline hid_t G4Hdf5FileManager::GetHistoDirectory() const
|
||||
{ return fHistoDirectory; }
|
||||
|
||||
inline hid_t G4Hdf5FileManager::GetNtupleDirectory() const
|
||||
{ return fNtupleDirectory; }
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline unsigned int G4Hdf5FileManager::GetBasketSize() const
|
||||
{ return fBasketSize; }
|
||||
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// The manager for histogram/profile Hfd5 file output.
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4Hdf5HnFileManager_h
|
||||
#define G4Hdf5HnFileManager_h 1
|
||||
|
||||
#include "G4VTHnFileManager.hh"
|
||||
|
||||
#include "tools/hdf5/ntuple" // for hid_t
|
||||
|
||||
class G4Hdf5FileManager;
|
||||
|
||||
template <typename HT>
|
||||
class G4Hdf5HnFileManager : public G4VTHnFileManager<HT>
|
||||
{
|
||||
public:
|
||||
G4Hdf5HnFileManager(G4Hdf5FileManager* fileManger)
|
||||
: G4VTHnFileManager<HT>(), fFileManager(fileManger) {}
|
||||
virtual ~G4Hdf5HnFileManager() {}
|
||||
|
||||
// Methods for writing objects
|
||||
// Write to a new file (the file is closed after write)
|
||||
virtual G4bool WriteExtra(HT* ht, const G4String& htName, const G4String& fileName) final;
|
||||
// Write to the default file (handled with OpenFile()/CloseFile methods)
|
||||
virtual G4bool Write(HT* ht, const G4String& htName, G4String& fileName) final;
|
||||
|
||||
private:
|
||||
// Methods
|
||||
G4bool WriteImpl(hid_t hdirectory, HT* ht, const G4String& htName);
|
||||
// Data members
|
||||
G4Hdf5FileManager* fFileManager;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
#include "G4Hdf5HnFileManager.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,140 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "tools/hdf5/header"
|
||||
#include "tools/hdf5/h2file"
|
||||
#include "tools/histo/h1d"
|
||||
#include "tools/histo/h2d"
|
||||
#include "tools/histo/h3d"
|
||||
#include "tools/histo/p1d"
|
||||
#include "tools/histo/p2d"
|
||||
|
||||
#include "tools/hdf5/h2file"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
inline
|
||||
G4bool G4Hdf5HnFileManager<tools::histo::p1d>::WriteImpl(
|
||||
hid_t hdirectory, tools::histo::p1d* ht, const G4String& htName)
|
||||
{
|
||||
return tools::hdf5::write_profile(G4cout, hdirectory, htName, *ht);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <>
|
||||
inline
|
||||
G4bool G4Hdf5HnFileManager<tools::histo::p2d>::WriteImpl(
|
||||
hid_t hdirectory, tools::histo::p2d* ht, const G4String& htName)
|
||||
{
|
||||
return tools::hdf5::write_profile(G4cout, hdirectory, htName, *ht);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4Hdf5HnFileManager<HT>::WriteImpl(
|
||||
hid_t hdirectory, HT* ht, const G4String& htName)
|
||||
{
|
||||
return tools::hdf5::write_histo(G4cout, hdirectory, htName, *ht);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4Hdf5HnFileManager<HT>::WriteExtra(
|
||||
HT* ht, const G4String& htName, const G4String& fileName)
|
||||
{
|
||||
// create a new file
|
||||
// create new file
|
||||
hid_t hfile = ::H5Fcreate(fileName, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
|
||||
|
||||
// Do nothing if there is no file
|
||||
// (te error should be handled by caller)
|
||||
if ( hfile < 0 ) {
|
||||
G4cerr << "::H5Fcreate failed " << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// create a header with general infos :
|
||||
if(!tools::hdf5::write_header(hfile)) {
|
||||
G4cerr << "tools::hdf5::write_header() failed." << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create directories
|
||||
hid_t hdirectory = tools_H5Gcreate(hfile, "histograms", 0);
|
||||
if ( hdirectory < 0 ) {
|
||||
G4cerr << "tools_H5Gcreate failed " << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = tools::hdf5::write_atb(hdirectory, "type", "directory");
|
||||
if ( ! result) {
|
||||
G4cerr << "tools::hdf5::write_atb failed " << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
result = WriteImpl(hdirectory, ht, htName);
|
||||
if ( ! result) {
|
||||
G4cerr << "Writing HT failed" << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
// close file
|
||||
::H5Gclose(hdirectory);
|
||||
::H5Gclose(hfile);
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
inline
|
||||
G4bool G4Hdf5HnFileManager<HT>::Write(
|
||||
HT* ht, const G4String& htName, G4String& fileName)
|
||||
{
|
||||
if (fileName.empty()) {
|
||||
// should not happen
|
||||
G4cerr << "!!! Hdf5 file name not defined." << G4endl;
|
||||
G4cerr << "!!! Write " << htName << " failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto hdirectory = std::get<1>(*fFileManager->GetTFile(fileName));
|
||||
if ( hdirectory < 0 ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Failed to get Hdf5 file " << fileName << " histo directory.";
|
||||
G4Exception("G4Hdf5HnFileManager<HT>::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto result = WriteImpl(hdirectory, ht, htName);
|
||||
fFileManager->LockDirectoryNames();
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for ntuple Hdf5 file output.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4Hdf5NtupleFileManager_h
|
||||
#define G4Hdf5NtupleFileManager_h 1
|
||||
|
||||
#include "G4VNtupleFileManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4Hdf5FileManager;
|
||||
class G4Hdf5NtupleManager;
|
||||
class G4VNtupleManager;
|
||||
class G4NtupleBookingManager;
|
||||
|
||||
class G4Hdf5NtupleFileManager : public G4VNtupleFileManager
|
||||
{
|
||||
friend class G4Hdf5AnalysisManager;
|
||||
|
||||
public:
|
||||
explicit G4Hdf5NtupleFileManager(const G4AnalysisManagerState& state);
|
||||
~G4Hdf5NtupleFileManager();
|
||||
|
||||
virtual std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
|
||||
|
||||
// Methods to be performed at file management
|
||||
virtual G4bool ActionAtOpenFile(const G4String& fileName) override;
|
||||
virtual G4bool ActionAtWrite() override;
|
||||
virtual G4bool ActionAtCloseFile(G4bool reset) override;
|
||||
virtual G4bool Reset() override;
|
||||
|
||||
void SetFileManager(std::shared_ptr<G4Hdf5FileManager> fileManager);
|
||||
|
||||
std::shared_ptr<G4Hdf5NtupleManager> GetNtupleManager() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
G4bool CloseNtupleFiles();
|
||||
|
||||
// data members
|
||||
std::shared_ptr<G4Hdf5FileManager> fFileManager;
|
||||
std::shared_ptr<G4Hdf5NtupleManager> fNtupleManager;
|
||||
};
|
||||
|
||||
inline void G4Hdf5NtupleFileManager::SetFileManager(
|
||||
std::shared_ptr<G4Hdf5FileManager> fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline std::shared_ptr<G4Hdf5NtupleManager> G4Hdf5NtupleFileManager::GetNtupleManager() const
|
||||
{ return fNtupleManager; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -41,46 +41,45 @@
|
||||
|
||||
class G4Hdf5FileManager;
|
||||
|
||||
// Types alias
|
||||
using G4Hdf5File = std::tuple<hid_t, hid_t, hid_t>;
|
||||
using Hdf5NtupleDescription = G4TNtupleDescription<tools::hdf5::ntuple, G4Hdf5File>;
|
||||
|
||||
// template specialization used by this class defined below
|
||||
|
||||
template <>
|
||||
template <>
|
||||
G4bool G4TNtupleManager<tools::hdf5::ntuple>::FillNtupleTColumn(
|
||||
G4bool G4TNtupleManager<tools::hdf5::ntuple, G4Hdf5File>::FillNtupleTColumn(
|
||||
G4int ntupleId, G4int columnId, const std::string& value);
|
||||
|
||||
|
||||
class G4Hdf5NtupleManager : public G4TNtupleManager<tools::hdf5::ntuple>
|
||||
class G4Hdf5NtupleManager : public G4TNtupleManager<tools::hdf5::ntuple,
|
||||
G4Hdf5File>
|
||||
{
|
||||
friend class G4Hdf5AnalysisManager;
|
||||
friend class G4Hdf5NtupleFileManager;
|
||||
|
||||
public:
|
||||
explicit G4Hdf5NtupleManager(const G4AnalysisManagerState& state);
|
||||
~G4Hdf5NtupleManager();
|
||||
|
||||
private:
|
||||
// Types alias
|
||||
using NtupleType = tools::hdf5::ntuple;
|
||||
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
|
||||
|
||||
// Set methods
|
||||
void SetFileManager(std::shared_ptr<G4Hdf5FileManager> fileManager);
|
||||
|
||||
// Access to ntuple vector (needed for Write())
|
||||
const std::vector<NtupleDescriptionType*>& GetNtupleDescriptionVector() const;
|
||||
const std::vector<Hdf5NtupleDescription*>& GetNtupleDescriptionVector() const;
|
||||
|
||||
// Utility function
|
||||
void CreateTNtuple(NtupleDescriptionType* ntupleDescription, G4bool warn);
|
||||
void CreateTNtuple(Hdf5NtupleDescription* ntupleDescription, G4bool warn);
|
||||
|
||||
// Methods from the templated base class
|
||||
//
|
||||
virtual void CreateTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription,
|
||||
const G4String& name, const G4String& title) final;
|
||||
virtual void CreateTNtupleFromBooking(
|
||||
NtupleDescriptionType* ntupleDescription) final;
|
||||
Hdf5NtupleDescription* ntupleDescription) final;
|
||||
|
||||
virtual void FinishTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription,
|
||||
Hdf5NtupleDescription* ntupleDescription,
|
||||
G4bool fromBooking) final;
|
||||
|
||||
// data members
|
||||
@@ -94,13 +93,13 @@ inline void
|
||||
G4Hdf5NtupleManager::SetFileManager(std::shared_ptr<G4Hdf5FileManager> fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline const std::vector<G4TNtupleDescription<tools::hdf5::ntuple>*>&
|
||||
inline const std::vector<Hdf5NtupleDescription*>&
|
||||
G4Hdf5NtupleManager::GetNtupleDescriptionVector() const
|
||||
{ return fNtupleDescriptionVector; }
|
||||
|
||||
template <>
|
||||
template <>
|
||||
inline G4bool G4TNtupleManager<tools::hdf5::ntuple>::FillNtupleTColumn(
|
||||
inline G4bool G4TNtupleManager<tools::hdf5::ntuple, G4Hdf5File>::FillNtupleTColumn(
|
||||
G4int ntupleId, G4int columnId, const std::string& value)
|
||||
{
|
||||
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
|
||||
@@ -150,4 +149,3 @@ inline G4bool G4TNtupleManager<tools::hdf5::ntuple>::FillNtupleTColumn(
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@ class G4Hdf5RFileManager : public G4BaseFileManager
|
||||
explicit G4Hdf5RFileManager(const G4AnalysisManagerState& state);
|
||||
virtual ~G4Hdf5RFileManager();
|
||||
|
||||
virtual G4String GetFileType() const final { return "hdf5"; }
|
||||
|
||||
// Get methods
|
||||
hid_t GetRFile(const G4String& fileName, G4bool isPerThread) const;
|
||||
hid_t GetHistoRDirectory(const G4String& fileName, const G4String& dirName,
|
||||
|
||||
Reference in New Issue
Block a user