Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -40,7 +40,7 @@
|
||||
#include <memory>
|
||||
|
||||
class G4XmlFileManager;
|
||||
class G4XmlNtupleManager;
|
||||
class G4XmlNtupleFileManager;
|
||||
|
||||
class G4XmlAnalysisManager : public G4ToolsAnalysisManager
|
||||
{
|
||||
@@ -90,8 +90,8 @@ class G4XmlAnalysisManager : public G4ToolsAnalysisManager
|
||||
G4bool Reset();
|
||||
|
||||
// data members
|
||||
G4XmlNtupleManager* fNtupleManager;
|
||||
std::shared_ptr<G4XmlFileManager> fFileManager;
|
||||
std::shared_ptr<G4XmlNtupleFileManager> fNtupleFileManager;
|
||||
};
|
||||
|
||||
#include "G4XmlAnalysisManager.icc"
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
#include "G4XmlNtupleFileManager.hh"
|
||||
#include "G4XmlNtupleManager.hh"
|
||||
#include "G4XmlFileManager.hh"
|
||||
|
||||
@@ -50,7 +51,7 @@ G4bool G4XmlAnalysisManager::WriteT(const std::vector<T*>& htVector,
|
||||
#endif
|
||||
G4String path = "/";
|
||||
path.append(directoryName);
|
||||
std::shared_ptr<std::ofstream> hnFile = fFileManager->GetHnFile();
|
||||
std::shared_ptr<std::ofstream> hnFile = fFileManager->GetFile();
|
||||
// Do nothing if there is no file
|
||||
if ( ! hnFile.get() ) return false;
|
||||
|
||||
@@ -63,7 +64,7 @@ G4bool G4XmlAnalysisManager::WriteT(const std::vector<T*>& htVector,
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
fFileManager->LockHistoDirectoryName();
|
||||
fFileManager->LockDirectoryNames();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -80,28 +81,28 @@ G4bool G4XmlAnalysisManager::IsOpenFileImpl() const
|
||||
inline
|
||||
tools::waxml::ntuple* G4XmlAnalysisManager::GetNtuple() const
|
||||
{
|
||||
return fNtupleManager->GetNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->GetNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
tools::waxml::ntuple* G4XmlAnalysisManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
return fNtupleManager->GetNtuple(ntupleId);
|
||||
return fNtupleFileManager->GetNtupleManager()->GetNtuple(ntupleId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::waxml::ntuple*>::iterator G4XmlAnalysisManager::BeginNtuple()
|
||||
{
|
||||
return fNtupleManager->BeginNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->BeginNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
inline
|
||||
std::vector<tools::waxml::ntuple*>::iterator G4XmlAnalysisManager::EndNtuple()
|
||||
{
|
||||
return fNtupleManager->EndNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->EndNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -109,7 +110,7 @@ inline
|
||||
std::vector<tools::waxml::ntuple*>::const_iterator
|
||||
G4XmlAnalysisManager::BeginConstNtuple() const
|
||||
{
|
||||
return fNtupleManager->BeginConstNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->BeginConstNtuple();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -117,5 +118,5 @@ inline
|
||||
std::vector<tools::waxml::ntuple*>::const_iterator
|
||||
G4XmlAnalysisManager::EndConstNtuple() const
|
||||
{
|
||||
return fNtupleManager->EndConstNtuple();
|
||||
return fNtupleFileManager->GetNtupleManager()->EndConstNtuple();
|
||||
}
|
||||
|
||||
@@ -31,8 +31,9 @@
|
||||
#ifndef G4XmlFileManager_h
|
||||
#define G4XmlFileManager_h 1
|
||||
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4VTFileManager.hh"
|
||||
#include "G4TNtupleDescription.hh"
|
||||
#include "G4TFileManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/waxml/ntuple"
|
||||
@@ -40,40 +41,39 @@
|
||||
#include <fstream>
|
||||
#include <memory>
|
||||
|
||||
// Type aliases
|
||||
using XmlNtupleDescription = G4TNtupleDescription<tools::waxml::ntuple, std::ofstream>;
|
||||
|
||||
class G4AnalysisManagerState;
|
||||
|
||||
class G4XmlFileManager : public G4VFileManager
|
||||
class G4XmlFileManager : public G4VTFileManager<std::ofstream>
|
||||
{
|
||||
public:
|
||||
explicit G4XmlFileManager(const G4AnalysisManagerState& state);
|
||||
~G4XmlFileManager();
|
||||
|
||||
// Type aliases
|
||||
using NtupleType = tools::waxml::ntuple;
|
||||
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
|
||||
using G4BaseFileManager::GetNtupleFileName;
|
||||
using G4VTFileManager<std::ofstream>::WriteFile;
|
||||
using G4VTFileManager<std::ofstream>::CloseFile;
|
||||
|
||||
// Methods to manipulate output files
|
||||
virtual G4bool OpenFile(const G4String& fileName) final;
|
||||
virtual G4bool WriteFile() final;
|
||||
virtual G4bool CloseFile() final;
|
||||
|
||||
virtual G4String GetFileType() const final { return "xml"; }
|
||||
|
||||
// Specific methods for files per objects
|
||||
G4bool CreateHnFile();
|
||||
G4bool CloseHnFile();
|
||||
G4bool CreateNtupleFile(NtupleDescriptionType* ntupleDescription);
|
||||
G4bool CloseNtupleFile(NtupleDescriptionType* ntupleDescription);
|
||||
|
||||
// Get methods
|
||||
std::shared_ptr<std::ofstream> GetHnFile() const;
|
||||
G4bool CreateNtupleFile(XmlNtupleDescription* ntupleDescription);
|
||||
G4bool CloseNtupleFile(XmlNtupleDescription* ntupleDescription);
|
||||
|
||||
protected:
|
||||
// Methods derived from templated base class
|
||||
virtual std::shared_ptr<std::ofstream> CreateFileImpl(const G4String& fileName) final;
|
||||
virtual G4bool WriteFileImpl(std::shared_ptr<std::ofstream> file) final;
|
||||
virtual G4bool CloseFileImpl(std::shared_ptr<std::ofstream> file) final;
|
||||
|
||||
private:
|
||||
// data members
|
||||
std::shared_ptr<std::ofstream> fHnFile;
|
||||
// utility method
|
||||
G4String GetNtupleFileName(XmlNtupleDescription* ntupleDescription);
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline std::shared_ptr<std::ofstream> G4XmlFileManager::GetHnFile() const
|
||||
{ return fHnFile; }
|
||||
|
||||
#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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// The manager histogram/profile Xml file output.
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4XmlHnFileManager_h
|
||||
#define G4XmlHnFileManager_h 1
|
||||
|
||||
#include "G4VTHnFileManager.hh"
|
||||
|
||||
class G4XmlFileManager;
|
||||
|
||||
template <typename HT>
|
||||
class G4XmlHnFileManager : public G4VTHnFileManager<HT>
|
||||
{
|
||||
public:
|
||||
G4XmlHnFileManager(G4XmlFileManager* fileManger)
|
||||
: G4VTHnFileManager<HT>(), fFileManager(fileManger) {}
|
||||
virtual ~G4XmlHnFileManager() {}
|
||||
|
||||
// Methods for writing objects
|
||||
// Write to a new file (the file is closed after write)
|
||||
virtual G4bool WriteExtra(HT* ht, const G4String& htName, const G4String& fileName) final;
|
||||
// Write to the default file (handled with OpenFile()/CloseFile methods)
|
||||
virtual G4bool Write(HT* ht, const G4String& htName, G4String& fileName) final;
|
||||
|
||||
private:
|
||||
// Data members
|
||||
G4XmlFileManager* fFileManager;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
#include "G4XmlHnFileManager.icc"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "tools/waxml/histos"
|
||||
#include "tools/waxml/begend"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
G4bool G4XmlHnFileManager<HT>::WriteExtra(
|
||||
HT* ht, const G4String& htName, const G4String& fileName)
|
||||
{
|
||||
// create a new file
|
||||
std::ofstream hnFile(fileName);
|
||||
|
||||
// Do nothing if there is no file
|
||||
if ( ! hnFile.is_open() ) return false;
|
||||
|
||||
// Write file opening
|
||||
tools::waxml::begin(hnFile);
|
||||
|
||||
// no directory supported in this mode
|
||||
G4String path = "/";
|
||||
|
||||
// write histo
|
||||
auto result = tools::waxml::write(hnFile, *ht, path, htName);
|
||||
if ( ! result) {
|
||||
// TO DO: give an exception about failure
|
||||
return false;
|
||||
}
|
||||
|
||||
// close file
|
||||
tools::waxml::end(hnFile);
|
||||
hnFile.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename HT>
|
||||
G4bool G4XmlHnFileManager<HT>::Write(
|
||||
HT* ht, const G4String& htName, G4String& fileName)
|
||||
{
|
||||
if ( fileName.empty()) {
|
||||
// should not happen
|
||||
G4cerr << "!!! Xml file name not defined." << G4endl;
|
||||
G4cerr << "!!! Write " << htName << " failed." << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
auto hnFile = fFileManager->GetTFile(fileName);
|
||||
if ( hnFile == nullptr ) {
|
||||
// TO DO: give an exception,
|
||||
// this prototype can be used only with OpenFile() mode
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Failed to get Xml file " << fileName;
|
||||
G4Exception("G4XmlHnFileManager<HT>::Write()",
|
||||
"Analysis_W022", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
G4String path = "/";
|
||||
path.append(fFileManager->GetHistoDirectoryName());
|
||||
|
||||
auto result = tools::waxml::write(*hnFile, *ht, path, htName);
|
||||
fFileManager->LockDirectoryNames();
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
// Manager class for ntuple Xml file output.
|
||||
//
|
||||
// Author: Ivana Hrivnacova, 15/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#ifndef G4XmlNtupleFileManager_h
|
||||
#define G4XmlNtupleFileManager_h 1
|
||||
|
||||
#include "G4VNtupleFileManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include "tools/waxml/ntuple"
|
||||
|
||||
#include <memory>
|
||||
|
||||
class G4XmlFileManager;
|
||||
class G4XmlNtupleManager;
|
||||
|
||||
class G4XmlNtupleFileManager : public G4VNtupleFileManager
|
||||
{
|
||||
public:
|
||||
explicit G4XmlNtupleFileManager(const G4AnalysisManagerState& state);
|
||||
~G4XmlNtupleFileManager();
|
||||
|
||||
virtual std::shared_ptr<G4VNtupleManager> CreateNtupleManager() override;
|
||||
|
||||
// Methods to be performed at file management
|
||||
virtual G4bool ActionAtOpenFile(const G4String& fileName) override;
|
||||
virtual G4bool ActionAtWrite() override;
|
||||
virtual G4bool ActionAtCloseFile(G4bool reset) override;
|
||||
virtual G4bool Reset() override;
|
||||
|
||||
void SetFileManager(std::shared_ptr<G4XmlFileManager> fileManager);
|
||||
|
||||
std::shared_ptr<G4XmlNtupleManager> GetNtupleManager() const;
|
||||
|
||||
private:
|
||||
// methods
|
||||
G4bool CloseNtupleFiles();
|
||||
|
||||
// data members
|
||||
std::shared_ptr<G4XmlFileManager> fFileManager;
|
||||
std::shared_ptr<G4XmlNtupleManager> fNtupleManager;
|
||||
};
|
||||
|
||||
// inline functions
|
||||
|
||||
inline void G4XmlNtupleFileManager::SetFileManager(
|
||||
std::shared_ptr<G4XmlFileManager> fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline std::shared_ptr<G4XmlNtupleManager> G4XmlNtupleFileManager::GetNtupleManager() const
|
||||
{ return fNtupleManager; }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -39,40 +39,38 @@
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
// Types alias
|
||||
using XmlNtupleDescription = G4TNtupleDescription<tools::waxml::ntuple, std::ofstream>;
|
||||
|
||||
class G4XmlFileManager;
|
||||
|
||||
class G4XmlNtupleManager : public G4TNtupleManager<tools::waxml::ntuple>
|
||||
class G4XmlNtupleManager : public G4TNtupleManager<tools::waxml::ntuple,
|
||||
std::ofstream>
|
||||
{
|
||||
friend class G4XmlAnalysisManager;
|
||||
friend class G4XmlNtupleFileManager;
|
||||
|
||||
public:
|
||||
explicit G4XmlNtupleManager(const G4AnalysisManagerState& state);
|
||||
~G4XmlNtupleManager();
|
||||
|
||||
private:
|
||||
// Types alias
|
||||
using NtupleType = tools::waxml::ntuple;
|
||||
using NtupleDescriptionType = G4TNtupleDescription<NtupleType>;
|
||||
|
||||
// Functions specific to the output type
|
||||
//
|
||||
|
||||
|
||||
// Set methods
|
||||
void SetFileManager(std::shared_ptr<G4XmlFileManager> fileManager);
|
||||
|
||||
// Access to ntuple vector (needed for Write())
|
||||
const std::vector<NtupleDescriptionType*>& GetNtupleDescriptionVector() const;
|
||||
const std::vector<XmlNtupleDescription*>& 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;
|
||||
XmlNtupleDescription* ntupleDescription) final;
|
||||
|
||||
virtual void FinishTNtuple(
|
||||
NtupleDescriptionType* ntupleDescription,
|
||||
XmlNtupleDescription* ntupleDescription,
|
||||
G4bool fromBooking) final;
|
||||
|
||||
// data members
|
||||
@@ -86,7 +84,7 @@ inline void
|
||||
G4XmlNtupleManager::SetFileManager(std::shared_ptr<G4XmlFileManager> fileManager)
|
||||
{ fFileManager = fileManager; }
|
||||
|
||||
inline const std::vector<G4TNtupleDescription<tools::waxml::ntuple>*>&
|
||||
inline const std::vector<G4TNtupleDescription<tools::waxml::ntuple, std::ofstream>*>&
|
||||
G4XmlNtupleManager::GetNtupleDescriptionVector() const
|
||||
{ return fNtupleDescriptionVector; }
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ class G4XmlRFileManager : public G4BaseFileManager
|
||||
explicit G4XmlRFileManager(const G4AnalysisManagerState& state);
|
||||
~G4XmlRFileManager();
|
||||
|
||||
virtual G4String GetFileType() const final { return "xml"; }
|
||||
|
||||
// Methods to manipulate input files
|
||||
virtual G4bool OpenRFile(const G4String& fileName);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user