Import Geant4 10.4.0 source tree

This commit is contained in:
Gabriele Cosmo
2017-12-08 12:52:30 +01:00
parent 98e455a940
commit fc6af9e721
2166 changed files with 276760 additions and 100873 deletions
@@ -0,0 +1,108 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// The main manager for Hdf5 analysis.
// It delegates most of functions to the object specific managers.
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5AnalysisManager_h
#define G4Hdf5AnalysisManager_h 1
#include "G4ToolsAnalysisManager.hh"
#include "globals.hh"
#include "tools/hdf5/ntuple"
#include <memory>
class G4Hdf5FileManager;
class G4Hdf5NtupleManager;
class G4Hdf5AnalysisManager : public G4ToolsAnalysisManager
{
public:
explicit G4Hdf5AnalysisManager(G4bool isMaster = true);
~G4Hdf5AnalysisManager();
// static methods
static G4Hdf5AnalysisManager* Instance();
static G4bool IsInstance();
// Access methods
tools::hdf5::ntuple* GetNtuple() const;
tools::hdf5::ntuple* GetNtuple(G4int ntupleId) const;
// Iterators
std::vector<tools::hdf5::ntuple*>::iterator BeginNtuple();
std::vector<tools::hdf5::ntuple*>::iterator EndNtuple();
std::vector<tools::hdf5::ntuple*>::const_iterator BeginConstNtuple() const;
std::vector<tools::hdf5::ntuple*>::const_iterator EndConstNtuple() const;
protected:
// virtual methods from base class
virtual G4bool OpenFileImpl(const G4String& fileName) final;
virtual G4bool WriteImpl() final;
virtual G4bool CloseFileImpl() final;
virtual G4bool IsOpenFileImpl() const final;
private:
// constants
static constexpr unsigned int fgkDefaultBasketSize = 32000;
// static data members
static G4Hdf5AnalysisManager* fgMasterInstance;
static G4ThreadLocal G4Hdf5AnalysisManager* fgInstance;
// methods
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();
G4bool WriteH2();
G4bool WriteH3();
G4bool WriteP1();
G4bool WriteP2();
G4bool Reset();
// data members
G4Hdf5NtupleManager* fNtupleManager;
std::shared_ptr<G4Hdf5FileManager> fFileManager;
};
#include "G4Hdf5AnalysisManager.icc"
#endif
@@ -0,0 +1,160 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
//
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#include "G4Hdf5NtupleManager.hh"
#include "G4Hdf5FileManager.hh"
#include "tools/hdf5/h2file"
//_____________________________________________________________________________
template <typename T>
inline
G4bool G4Hdf5AnalysisManager::WriteHn(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector,
const G4String& /*directoryName*/,
const G4String& hnType)
{
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
auto info = hnVector[i];
auto activation = info->GetActivation();
auto name = info->GetName();
// skip writing if inactivated
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
auto ht = htVector[i];
#ifdef G4VERBOSE
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);
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "saving " << hnType << " " << name << " failed";
G4Exception("G4Hdf5AnalysisManager::Write()",
"Analysis_W022", JustWarning, description);
return false;
}
fFileManager->LockHistoDirectoryName();
}
return true;
}
//_____________________________________________________________________________
template <typename T>
inline
G4bool G4Hdf5AnalysisManager::WritePn(const std::vector<T*>& htVector,
const std::vector<G4HnInformation*>& hnVector,
const G4String& /*directoryName*/,
const G4String& hnType)
{
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
auto info = hnVector[i];
auto activation = info->GetActivation();
auto name = info->GetName();
// skip writing if inactivated
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
auto ht = htVector[i];
#ifdef G4VERBOSE
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);
if ( ! result ) {
G4ExceptionDescription description;
description << " " << "saving " << hnType << " " << name << " failed";
G4Exception("G4Hdf5AnalysisManager::Write()",
"Analysis_W022", JustWarning, description);
return false;
}
fFileManager->LockHistoDirectoryName();
}
return true;
}
//_____________________________________________________________________________
inline
G4bool G4Hdf5AnalysisManager::IsOpenFileImpl() const
{
return fFileManager->IsOpenFile();
}
//_____________________________________________________________________________
inline
tools::hdf5::ntuple* G4Hdf5AnalysisManager::GetNtuple() const
{
return fNtupleManager->GetNtuple();
}
//_____________________________________________________________________________
inline
tools::hdf5::ntuple* G4Hdf5AnalysisManager::GetNtuple(G4int ntupleId) const
{
return fNtupleManager->GetNtuple(ntupleId);
}
//_____________________________________________________________________________
inline
std::vector<tools::hdf5::ntuple*>::iterator G4Hdf5AnalysisManager::BeginNtuple()
{
return fNtupleManager->BeginNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hdf5::ntuple*>::iterator G4Hdf5AnalysisManager::EndNtuple()
{
return fNtupleManager->EndNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hdf5::ntuple*>::const_iterator
G4Hdf5AnalysisManager::BeginConstNtuple() const
{
return fNtupleManager->BeginConstNtuple();
}
//_____________________________________________________________________________
inline
std::vector<tools::hdf5::ntuple*>::const_iterator
G4Hdf5AnalysisManager::EndConstNtuple() const
{
return fNtupleManager->EndConstNtuple();
}
@@ -0,0 +1,106 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// The main manager for Hdf5 analysis reader.
// It delegates most of functions to the object specific managers.
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5AnalysisReader_h
#define G4Hdf5AnalysisReader_h 1
#include "G4ToolsAnalysisReader.hh"
#include "globals.hh"
#include "tools/histo/h1d"
#include "tools/histo/h2d"
#include "tools/histo/h3d"
#include "tools/histo/p1d"
#include "tools/histo/p2d"
#include "tools/hdf5/ntuple"
class G4Hdf5RFileManager;
class G4H1ToolsManager;
class G4H2ToolsManager;
class G4H3ToolsManager;
class G4P1ToolsManager;
class G4P2ToolsManager;
class G4Hdf5RNtupleManager;
class G4Hdf5AnalysisReader : public G4ToolsAnalysisReader
{
public:
explicit G4Hdf5AnalysisReader(G4bool isMaster = true);
virtual ~G4Hdf5AnalysisReader();
// static methods
static G4Hdf5AnalysisReader* Instance();
// Access methods
tools::hdf5::ntuple* GetNtuple() const;
tools::hdf5::ntuple* GetNtuple(G4int ntupleId) const;
using G4VAnalysisReader::GetNtuple;
protected:
// virtual methods from base class
virtual G4int ReadH1Impl(const G4String& h1Name, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
virtual G4int ReadH2Impl(const G4String& h2Name, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
virtual G4int ReadH3Impl(const G4String& h3Name, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
virtual G4int ReadP1Impl(const G4String& p1Name, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
virtual G4int ReadP2Impl(const G4String& p2Name, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
virtual G4int ReadNtupleImpl(const G4String& ntupleName, const G4String& fileName,
const G4String& dirName, G4bool isUserFileName) final;
private:
// static data members
static G4Hdf5AnalysisReader* fgMasterInstance;
static G4ThreadLocal G4Hdf5AnalysisReader* fgInstance;
// methods
//
template <typename T>
T* ReadHnImpl(const G4String& htName, const G4String& fileName,
const G4String& dirName);
template <typename T>
T* ReadPnImpl(const G4String& ptName, const G4String& fileName,
const G4String& dirName);
G4bool Reset();
// data members
G4Hdf5RNtupleManager* fNtupleManager;
G4Hdf5RFileManager* fFileManager;
};
#include "G4Hdf5AnalysisReader.icc"
#endif
@@ -0,0 +1,110 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
#include "G4Hdf5RFileManager.hh"
#include <tools/hdf5/h2file>
// //_____________________________________________________________________________
// inline
// tools::hdf5::ntuple* G4Hdf5AnalysisReader::GetNtuple() const
// {
// return fNtupleManager->GetNtuple();
// }
// //_____________________________________________________________________________
// inline
// tools::hdf5::ntuple* G4Hdf5AnalysisReader::GetNtuple(G4int ntupleId) const
// {
// return fNtupleManager->GetNtuple(ntupleId);
// }
//_____________________________________________________________________________
template <typename T>
T* G4Hdf5AnalysisReader::ReadHnImpl(
const G4String& htName, const G4String& fileName,
const G4String& dirName)
{
// Get directory
auto directory = fFileManager->GetHistoRDirectory(fileName, dirName, false);
if ( directory < 0 ) return nullptr;
// Read hn
T* ht;
auto result = tools::hdf5::read_histo(G4cout, directory, htName, ht);
if ( ! result ) return nullptr;
if ( ! ht ) {
G4ExceptionDescription description;
description
<< " "
<< "Streaming " << htName << " from file " << fileName << " failed.";
G4Exception("G4Hdf5AnalysisReader::ReadHnImpl",
"Analysis_WR011", JustWarning, description);
// when failure, directory and file should be closed
// ::H5Gclose(histos);
// ::H5Fclose(file);
return nullptr;
}
return ht;
}
//_____________________________________________________________________________
template <typename T>
T* G4Hdf5AnalysisReader::ReadPnImpl(
const G4String& ptName, const G4String& fileName,
const G4String& dirName)
{
// Get directory
auto directory = fFileManager->GetHistoRDirectory(fileName, dirName, false);
if ( directory < 0 ) return nullptr;
// Read hn
T* pt;
auto result = tools::hdf5::read_profile(G4cout, directory, ptName, pt);
if ( ! result ) return nullptr;
if ( ! pt ) {
G4ExceptionDescription description;
description
<< " "
<< "Streaming " << ptName << " from file " << fileName << " failed.";
G4Exception("G4Hdf5AnalysisReader::ReadPnImpl",
"Analysis_WR011", JustWarning, description);
// when failure, directory and file should be closed
// ::H5Gclose(histos);
// ::H5Fclose(file);
return nullptr;
}
return pt;
}
@@ -0,0 +1,107 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// The manager for Hdf5 file output operations.
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5FileManager_h
#define G4Hdf5FileManager_h 1
#include "G4VFileManager.hh"
#include "G4TNtupleDescription.hh"
#include "globals.hh"
#include "tools/hdf5/ntuple"
#include <fstream>
#include <memory>
class G4AnalysisManagerState;
class G4Hdf5FileManager : public G4VFileManager
{
public:
explicit G4Hdf5FileManager(const G4AnalysisManagerState& state);
~G4Hdf5FileManager();
// Type aliases
using NtupleType = tools::hdf5::ntuple;
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
// 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();
// 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);
// 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)
{ 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; }
#endif
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// Manager class for Hdf5 ntuples
//
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5NtupleManager_h
#define G4Hdf5NtupleManager_h 1
#include "G4TNtupleManager.hh"
#include "globals.hh"
#include "tools/hdf5/ntuple"
#include <vector>
#include <memory>
class G4Hdf5FileManager;
// template specialization used by this class defined below
template <>
template <>
G4bool G4TNtupleManager<tools::hdf5::ntuple>::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value);
class G4Hdf5NtupleManager : public G4TNtupleManager<tools::hdf5::ntuple>
{
friend class G4Hdf5AnalysisManager;
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;
// Methods from the templated base class
//
virtual void CreateTNtuple(
NtupleDescriptionType* ntupleDescription,
const G4String& name, const G4String& title) final;
virtual void CreateTNtupleFromBooking(
NtupleDescriptionType* ntupleDescription) final;
virtual void FinishTNtuple(
NtupleDescriptionType* ntupleDescription) final;
// data members
//
std::shared_ptr<G4Hdf5FileManager> fFileManager;
};
// inline functions
inline void
G4Hdf5NtupleManager::SetFileManager(std::shared_ptr<G4Hdf5FileManager> fileManager)
{ fFileManager = fileManager; }
inline const std::vector<G4TNtupleDescription<tools::hdf5::ntuple>*>&
G4Hdf5NtupleManager::GetNtupleDescriptionVector() const
{ return fNtupleDescriptionVector; }
template <>
template <>
inline G4bool G4TNtupleManager<tools::hdf5::ntuple>::FillNtupleTColumn(
G4int ntupleId, G4int columnId, const std::string& value)
{
if ( fState.GetIsActivation() && ( ! GetActivation(ntupleId) ) ) {
//G4cout << "Skipping FillNtupleIColumn for " << ntupleId << G4endl;
return false;
}
// get ntuple
auto ntuple = GetNtupleInFunction(ntupleId, "FillNtupleTColumn");
if ( ! ntuple ) return false;
// get generic column
auto index = columnId - fFirstNtupleColumnId;
if ( index < 0 || index >= G4int(ntuple->columns().size()) ) {
G4ExceptionDescription description;
description << " " << "ntupleId " << ntupleId
<< " columnId " << columnId << " does not exist.";
G4Exception("G4TNtupleManager::FillNtupleTColumn()",
"Analysis_W011", JustWarning, description);
return false;
}
auto icolumn = ntuple->columns()[index];
// get column and check its type
auto column = dynamic_cast<tools::hdf5::ntuple::column_string* >(icolumn);
if ( ! column ) {
G4ExceptionDescription description;
description << " Column type does not match: "
<< " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
G4Exception("G4TNtupleManager:FillNtupleTColumn",
"Analysis_W011", JustWarning, description);
return false;
}
column->fill(value);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() ) {
G4ExceptionDescription description;
description << " ntupleId " << ntupleId
<< " columnId " << columnId << " value " << value;
fState.GetVerboseL4()->Message("fill", "ntuple T column", description);
}
#endif
return true;
}
#endif
@@ -0,0 +1,70 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// The manager for Hdf5 file input operations.
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5RFileManager_h
#define G4Hdf5RFileManager_h 1
#include "G4BaseFileManager.hh"
#include "globals.hh"
#include "tools/hdf5/ntuple"
#include <map>
class G4Hdf5RFileManager : public G4BaseFileManager
{
public:
explicit G4Hdf5RFileManager(const G4AnalysisManagerState& state);
virtual ~G4Hdf5RFileManager();
// Get methods
hid_t GetRFile(const G4String& fileName, G4bool isPerThread) const;
hid_t GetHistoRDirectory(const G4String& fileName, const G4String& dirName,
G4bool isPerThread);
hid_t GetNtupleRDirectory(const G4String& fileName, const G4String& dirName,
G4bool isPerThread);
private:
// constants
static const G4String fgkDefaultDirectoryName;
// methods
hid_t OpenRFile(const G4String& fileName, G4bool isPerThread);
hid_t OpenDirectory(hid_t file, const G4String& directoryName);
hid_t GetRDirectory(const G4String& directoryType,
const G4String& fileName, const G4String& dirName,
G4bool isPerThread);
// data members
std::map<G4String, hid_t> fRFiles;
};
#endif
@@ -0,0 +1,61 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// Manager class for Hdf5 read ntuples.
// It implements functions specific to Hdf5 read ntuples.
//
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef G4Hdf5RNtupleManager_h
#define G4Hdf5RNtupleManager_h 1
#include "G4TRNtupleManager.hh"
#include "globals.hh"
#include "tools/hdf5/ntuple"
class G4Hdf5RNtupleManager : public G4TRNtupleManager<tools::hdf5::ntuple>
{
friend class G4Hdf5AnalysisReader;
protected:
explicit G4Hdf5RNtupleManager(const G4AnalysisManagerState& state);
virtual ~G4Hdf5RNtupleManager();
private:
// Methods from the templated base class
//
virtual G4bool GetTNtupleRow(G4TRNtupleDescription<tools::hdf5::ntuple>* ntupleDescription) final;
};
// // inline functions
// inline G4int G4Hdf5RNtupleManager::GetNofNtuples() const
// { return fNtupleVector.size(); }
#endif
+39
View File
@@ -0,0 +1,39 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef g4hdf5_h
#define g4hdf5_h
#include "g4hdf5_defs.hh"
using namespace G4Hdf5;
#endif
@@ -0,0 +1,86 @@
//
// ********************************************************************
// * 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. *
// ********************************************************************
//
// $Id$
// Author: Ivana Hrivnacova, 20/07/2017 (ivana@ipno.in2p3.fr)
#ifndef g4hdf5_defs_h
#define g4hdf5_defs_h
#include "tools/histo/h1d"
#include "tools/histo/h2d"
#include "tools/histo/h3d"
#include "tools/histo/p1d"
#include "tools/histo/p2d"
#include "tools/hdf5/ntuple"
#include "G4Hdf5AnalysisManager.hh"
#include "G4Hdf5AnalysisReader.hh"
namespace G4Hdf5 {
// H1 types
using G4AnaH1 = tools::histo::h1d; // keep for backward compatibility
using G4H1 = tools::histo::h1d;
using G4H1Iterator = std::vector<tools::histo::h1d*>::iterator;
using G4H1ConstIterator = std::vector<tools::histo::h1d*>::const_iterator;
// H2 types
using G4AnaH2 = tools::histo::h2d; // keep for backward compatibility
using G4H2 = tools::histo::h2d;
using G4H2Iterator = std::vector<tools::histo::h2d*>::iterator;
using G4H2ConstIterator = std::vector<tools::histo::h2d*>::const_iterator;
// H3 types
using G4H3 = tools::histo::h3d;
using G4H3Iterator = std::vector<tools::histo::h3d*>::iterator;
using G4H3ConstIterator = std::vector<tools::histo::h3d*>::const_iterator;
// P1 types
using G4P1 = tools::histo::p1d;
using G4P1Iterator = std::vector<tools::histo::p1d*>::iterator;
using G4P1ConstIterator = std::vector<tools::histo::p1d*>::const_iterator;
// P2 types
using G4P2 = tools::histo::p2d;
using G4P2Iterator = std::vector<tools::histo::p2d*>::iterator;
using G4P2ConstIterator = std::vector<tools::histo::p2d*>::const_iterator;
// Ntuple types
using G4Ntuple = tools::hdf5::ntuple;
using G4NtupleIterator = std::vector<tools::hdf5::ntuple*>::iterator;
using G4NtupleConstIterator = std::vector<tools::hdf5::ntuple*>::const_iterator;
// RNtuple types
using G4RNtuple = tools::hdf5::ntuple;
// Managers
using G4AnalysisManager = G4Hdf5AnalysisManager;
using G4AnalysisReader = G4Hdf5AnalysisReader;
}
#endif