Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
+33 -37
View File
@@ -27,29 +27,38 @@
// Author: Ivana Hrivnacova, 10/09/2014 (ivana@ipno.in2p3.fr)
#include "G4XmlRFileManager.hh"
#include "G4XmlHnRFileManager.hh"
#include "G4AnalysisManagerState.hh"
#include "G4AnalysisUtilities.hh"
#include "tools/waxml/begend"
#include "tools/raxml"
using namespace G4Analysis;
using namespace tools;
//_____________________________________________________________________________
G4XmlRFileManager::G4XmlRFileManager(const G4AnalysisManagerState& state)
: G4BaseFileManager(state),
fReadFactory(0),
fRFiles()
: G4VRFileManager(state)
{
// Create helpers defined in the base class
fH1RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h1d>>(this);
fH2RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h2d>>(this);
fH3RFileManager = std::make_shared<G4XmlHnRFileManager<histo::h3d>>(this);
fP1RFileManager = std::make_shared<G4XmlHnRFileManager<histo::p1d>>(this);
fP2RFileManager = std::make_shared<G4XmlHnRFileManager<histo::p2d>>(this);
}
//_____________________________________________________________________________
G4XmlRFileManager::~G4XmlRFileManager()
{
for (G4int i=0; i<G4int(fRFiles.size()); ++i) {
delete fRFiles[i];
}
delete fReadFactory;
{
for ( auto& rfile : fRFiles ) {
delete rfile.second;
}
delete fReadFactory;
}
//
//
// public methods
//
@@ -60,69 +69,56 @@ G4bool G4XmlRFileManager::OpenRFile(const G4String& fileName)
G4bool isPerThread = false;
G4String name = GetFullFileName(fileName, isPerThread);
#ifdef G4VERBOSE
if ( fState.GetVerboseL4() )
fState.GetVerboseL4()->Message("open", "read analysis file", name);
#endif
Message(kVL4, "open", "read analysis file", name);
G4bool verbose = false;
// create factory (if it does not yet exist)
if ( ! fReadFactory ) {
fReadFactory = new tools::xml::default_factory();
}
}
// create new file
tools::raxml* newFile
= new tools::raxml(*fReadFactory, G4cout, verbose);
auto newFile = new tools::raxml(*fReadFactory, G4cout, verbose);
// clear objects
// clear objects
// (this should not be needed when starting a new raxml)
std::vector<tools::raxml_out>& objs = newFile->objects();
objs.clear();
G4bool compressed = false;
if ( ! newFile->load_file(name, compressed) ) {
G4ExceptionDescription description;
description << " " << "Cannot open file " << name;
G4Exception("G4XmlRFileManager::OpenRFile()",
"Analysis_WR001", JustWarning, description);
Warn(G4String( "Cannot open file ") + name, fkClass, "OpenRFile");
delete newFile;
return false;
}
// add file in a map and delete the previous file if it exists
std::map<G4String, tools::raxml*>::iterator it
= fRFiles.find(name);
if ( it != fRFiles.end() ) {
auto it = fRFiles.find(name);
if ( it != fRFiles.end() ) {
delete it->second;
it->second = newFile;
}
else {
fRFiles[name] = newFile;
}
}
#ifdef G4VERBOSE
if ( fState.GetVerboseL1() )
fState.GetVerboseL1()
->Message("open", "read analysis file", name);
#endif
Message(kVL1, "open", "read analysis file", name);
return true;
}
}
//_____________________________________________________________________________
tools::raxml* G4XmlRFileManager::GetRFile(const G4String& fileName) const
{
{
// Get full file name (add only extension)
G4bool isPerThread = false;
G4String name = GetFullFileName(fileName, isPerThread);
std::map<G4String, tools::raxml*>::const_iterator it
= fRFiles.find(name);
auto it = fRFiles.find(name);
if ( it != fRFiles.end() )
return it->second;
else {
return nullptr;
}
}
}