111 lines
4.0 KiB
Plaintext
111 lines
4.0 KiB
Plaintext
//
|
|
// ********************************************************************
|
|
// * 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;
|
|
}
|