281 lines
9.1 KiB
Plaintext
281 lines
9.1 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 "G4H1ToolsManager.hh"
|
|
#include "G4H2ToolsManager.hh"
|
|
#include "G4H3ToolsManager.hh"
|
|
#include "G4P1ToolsManager.hh"
|
|
#include "G4P2ToolsManager.hh"
|
|
|
|
//_____________________________________________________________________________
|
|
template <typename HT>
|
|
inline
|
|
G4bool G4ToolsAnalysisManager::WriteT(const std::vector<HT*>& htVector,
|
|
const std::vector<G4HnInformation*>& hnVector)
|
|
{
|
|
auto result = true;
|
|
|
|
for ( G4int i=0; i<G4int(htVector.size()); ++i ) {
|
|
auto info = hnVector[i];
|
|
auto activation = info->GetActivation();
|
|
// skip writing if activation is enabled and H1 is inactivated
|
|
if ( fState.GetIsActivation() && ( ! activation ) ) continue;
|
|
|
|
auto name = info->GetName();
|
|
auto ht = htVector[i];
|
|
|
|
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();
|
|
}
|
|
|
|
Message(G4Analysis::kVL4, "write", G4Analysis::GetHnType<HT>(),
|
|
name + fileKind + fileName);
|
|
|
|
if ( ! fileManager->GetHnFileManager<HT>()->Write(ht, name, fileName) ) {
|
|
G4Analysis::Warn(
|
|
"Writing " + G4Analysis::GetHnType<HT>() + " " + name +
|
|
" to file " + fileName + " failed.",
|
|
fkClass, "WriteT");
|
|
result = false;
|
|
}
|
|
|
|
// 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
|
|
tools::histo::h1d* G4ToolsAnalysisManager::GetH1(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH1Manager->GetH1(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::h2d* G4ToolsAnalysisManager::GetH2(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH2Manager->GetH2(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::h3d* G4ToolsAnalysisManager::GetH3(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fH3Manager->GetH3(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::p1d* G4ToolsAnalysisManager::GetP1(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fP1Manager->GetP1(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
tools::histo::p2d* G4ToolsAnalysisManager::GetP2(G4int id, G4bool warn,
|
|
G4bool onlyIfActive) const
|
|
{
|
|
return fP2Manager->GetP2(id, warn, onlyIfActive);
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::BeginH1()
|
|
{
|
|
return fH1Manager->BeginH1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::iterator G4ToolsAnalysisManager::EndH1()
|
|
{
|
|
return fH1Manager->EndH1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH1() const
|
|
{
|
|
return fH1Manager->BeginConstH1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h1d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH1() const
|
|
{
|
|
return fH1Manager->EndConstH1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::BeginH2()
|
|
{
|
|
return fH2Manager->BeginH2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::iterator G4ToolsAnalysisManager::EndH2()
|
|
{
|
|
return fH2Manager->EndH2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH2() const
|
|
{
|
|
return fH2Manager->BeginConstH2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h2d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH2() const
|
|
{
|
|
return fH2Manager->EndConstH2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::BeginH3()
|
|
{
|
|
return fH3Manager->BeginH3();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::iterator G4ToolsAnalysisManager::EndH3()
|
|
{
|
|
return fH3Manager->EndH3();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstH3() const
|
|
{
|
|
return fH3Manager->BeginConstH3();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::h3d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstH3() const
|
|
{
|
|
return fH3Manager->EndConstH3();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::BeginP1()
|
|
{
|
|
return fP1Manager->BeginP1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::iterator G4ToolsAnalysisManager::EndP1()
|
|
{
|
|
return fP1Manager->EndP1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstP1() const
|
|
{
|
|
return fP1Manager->BeginConstP1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p1d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstP1() const
|
|
{
|
|
return fP1Manager->EndConstP1();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::BeginP2()
|
|
{
|
|
return fP2Manager->BeginP2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::iterator G4ToolsAnalysisManager::EndP2()
|
|
{
|
|
return fP2Manager->EndP2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::const_iterator
|
|
G4ToolsAnalysisManager::BeginConstP2() const
|
|
{
|
|
return fP2Manager->BeginConstP2();
|
|
}
|
|
|
|
//_____________________________________________________________________________
|
|
inline
|
|
std::vector<tools::histo::p2d*>::const_iterator
|
|
G4ToolsAnalysisManager::EndConstP2() const
|
|
{
|
|
return fP2Manager->EndConstP2();
|
|
}
|
|
|