291 lines
9.3 KiB
Plaintext
291 lines
9.3 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. *
|
|
// ********************************************************************
|
|
//
|
|
|
|
#include "G4HnInformation.hh"
|
|
|
|
#include "G4THnToolsManager.hh"
|
|
|
|
//_____________________________________________________________________________
|
|
template <typename HT>
|
|
inline
|
|
G4bool G4ToolsAnalysisManager::WriteT(
|
|
const std::vector<std::pair<HT*, G4HnInformation*>>& hnVector)
|
|
{
|
|
auto result = true;
|
|
|
|
for ( auto& [ht, info] : hnVector) {
|
|
auto activation = info->GetActivation();
|
|
|
|
// skip writing if activation is enabled and H1 is inactivated
|
|
// or if histogram was deleted
|
|
if ( ( fState.GetIsActivation() && ( ! activation ) ) ||
|
|
( info->GetDeleted() ) ) continue;
|
|
|
|
auto name = info->GetName();
|
|
auto fileName = info->GetFileName();
|
|
auto fileManager = GetFileManager(fileName);
|
|
|
|
// skip writing if cannot get file manager (wrong file extension)
|
|
if ( ! fileManager ) {
|
|
G4Analysis::Warn(
|
|
"Cannot get file manager for file " + fileName + ".\n" +
|
|
"Writing " + G4Analysis::GetHnType<HT>() + " " + name + " will be skipped.",
|
|
fkClass, "WriteT");
|
|
continue;
|
|
}
|
|
|
|
auto fileKind = " in file ";
|
|
if ( fileName != "" ) {
|
|
fileKind = " in extra file ";
|
|
} else {
|
|
fileName = fileManager->GetFullFileName();
|
|
}
|
|
|
|
// update name with a cycle number
|
|
if (! fileManager->HasCycles() && fState.GetCycle() > 0) {
|
|
name += "_v" + std::to_string(fState.GetCycle());
|
|
}
|
|
|
|
Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
|
|
name + fileKind + fileName);
|
|
|
|
if ( ! fileManager->template GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
|
|
G4Analysis::Warn(
|
|
"Writing " + G4Analysis::GetHnType<HT>() + " " + name +
|
|
" to file " + fileName + " failed.",
|
|
fkClass, "WriteT");
|
|
result = false;
|
|
}
|
|
|
|
if (result) {
|
|
// notify that file has a written object
|
|
fileManager->SetIsEmpty(fileName, false);
|
|
}
|
|
|
|
Message(G4Analysis::kVL3, "write", G4Analysis::GetHnType<HT>(),
|
|
name + " in the " + fileKind + " file " + fileName);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
G4bool G4ToolsAnalysisManager::IsOpenFileImpl() const
|
|
{
|
|
return fVFileManager->IsOpenFile();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH1Manager->GetT(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH2Manager->GetT(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH3Manager->GetT(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fP1Manager->GetT(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fP2Manager->GetT(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
|
|
{
|
|
return fH1Manager->BeginT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
|
|
{
|
|
return fH1Manager->EndT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH1() const
|
|
{
|
|
return fH1Manager->BeginConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH1() const
|
|
{
|
|
return fH1Manager->EndConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
|
|
{
|
|
return fH2Manager->BeginT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
|
|
{
|
|
return fH2Manager->EndT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH2() const
|
|
{
|
|
return fH2Manager->BeginConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH2() const
|
|
{
|
|
return fH2Manager->EndConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
|
|
{
|
|
return fH3Manager->BeginT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
|
|
{
|
|
return fH3Manager->EndT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH3() const
|
|
{
|
|
return fH3Manager->BeginConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH3() const
|
|
{
|
|
return fH3Manager->EndConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
|
|
{
|
|
return fP1Manager->BeginT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
|
|
{
|
|
return fP1Manager->EndT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstP1() const
|
|
{
|
|
return fP1Manager->BeginConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstP1() const
|
|
{
|
|
return fP1Manager->EndConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
|
|
{
|
|
return fP2Manager->BeginT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
|
|
{
|
|
return fP2Manager->EndT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstP2() const
|
|
{
|
|
return fP2Manager->BeginConstT();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstP2() const
|
|
{
|
|
return fP2Manager->EndConstT();
|
|
}
|