Import Geant4 11.0.0 source tree
This commit is contained in:
committed by
Ben Morgan
parent
6399a014b6
commit
80e2389dd8
@@ -29,267 +29,245 @@
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
using std::to_string;
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4TRNtupleManager<TNTUPLE>::G4TRNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4BaseRNtupleManager(state),
|
||||
fNtupleDescriptionVector()
|
||||
template <typename NT>
|
||||
G4TRNtupleManager<NT>::G4TRNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4BaseRNtupleManager(state)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4TRNtupleManager<TNTUPLE>::~G4TRNtupleManager()
|
||||
{
|
||||
template <typename NT>
|
||||
G4TRNtupleManager<NT>::~G4TRNtupleManager()
|
||||
{
|
||||
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
|
||||
delete ntupleDescription;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4TRNtupleDescription<TNTUPLE>*
|
||||
G4TRNtupleManager<TNTUPLE>::GetNtupleDescriptionInFunction(
|
||||
G4int id, G4String functionName, G4bool warn) const
|
||||
{
|
||||
template <typename NT>
|
||||
G4TRNtupleDescription<NT>*
|
||||
G4TRNtupleManager<NT>::GetNtupleDescriptionInFunction(
|
||||
G4int id, std::string_view functionName, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleDescriptionVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4TRNtupleManager<TNTUPLE>::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_WR011", JustWarning, description);
|
||||
G4Analysis::Warn("ntuple " + to_string(id) + " does not exist.",
|
||||
fkClass, functionName);
|
||||
}
|
||||
return nullptr;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
return fNtupleDescriptionVector[index];
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
template <typename T>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleTColumn(
|
||||
template <typename NT>
|
||||
template <typename T>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleTColumn(
|
||||
G4int ntupleId, const G4String& columnName, T& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
Message(G4Analysis::kVL4, "set", "ntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) + " " + columnName);
|
||||
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetNtupleTColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
auto ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple I colum", description, true);
|
||||
}
|
||||
#endif
|
||||
Message(G4Analysis::kVL2, "set", "ntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) + " " + columnName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
template <typename T>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleTColumn(
|
||||
template <typename NT>
|
||||
template <typename T>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleTColumn(
|
||||
G4int ntupleId, const G4String& columnName, std::vector<T>& vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
Message(G4Analysis::kVL4, "set", "ntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) + " " + columnName);
|
||||
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetNtupleTColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
auto ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple T colum", description, true);
|
||||
}
|
||||
#endif
|
||||
Message(G4Analysis::kVL2, "set", "ntuple T column",
|
||||
" ntupleId " + to_string(ntupleId) + " " + columnName);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool G4TRNtupleManager<TNTUPLE>::IsEmpty() const
|
||||
template <typename NT>
|
||||
G4bool G4TRNtupleManager<NT>::IsEmpty() const
|
||||
{
|
||||
return ! fNtupleDescriptionVector.size();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool G4TRNtupleManager<TNTUPLE>::Reset()
|
||||
template <typename NT>
|
||||
G4bool G4TRNtupleManager<NT>::Reset()
|
||||
{
|
||||
// Reset ntuples
|
||||
|
||||
for ( auto ntupleDescription : fNtupleDescriptionVector ) {
|
||||
ntupleDescription->fNtuple=0;
|
||||
}
|
||||
|
||||
delete ntupleDescription->fNtuple;
|
||||
ntupleDescription->fNtuple=nullptr;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
TNTUPLE*
|
||||
G4TRNtupleManager<TNTUPLE>::GetNtuple() const
|
||||
template <typename NT>
|
||||
NT*
|
||||
G4TRNtupleManager<NT>::GetNtuple() const
|
||||
{
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
TNTUPLE*
|
||||
G4TRNtupleManager<TNTUPLE>::GetNtuple(
|
||||
template <typename NT>
|
||||
NT*
|
||||
G4TRNtupleManager<NT>::GetNtuple(
|
||||
G4int ntupleId) const
|
||||
{
|
||||
auto rntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "GetNtuple");
|
||||
|
||||
if ( ! rntupleDescription ) return nullptr;
|
||||
if ( ! rntupleDescription ) return nullptr;
|
||||
|
||||
return rntupleDescription->fNtuple;
|
||||
}
|
||||
return rntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4int G4TRNtupleManager<TNTUPLE>::SetNtuple(
|
||||
G4TRNtupleDescription<TNTUPLE>* rntupleDescription)
|
||||
template <typename NT>
|
||||
G4int G4TRNtupleManager<NT>::SetNtuple(
|
||||
G4TRNtupleDescription<NT>* rntupleDescription)
|
||||
{
|
||||
G4int id = fNtupleDescriptionVector.size() + fFirstId;
|
||||
|
||||
fNtupleDescriptionVector.push_back(rntupleDescription);
|
||||
|
||||
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleIColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleIColumn(
|
||||
G4int ntupleId, const G4String& columnName, G4int& value)
|
||||
{
|
||||
return SetNtupleTColumn<int>(ntupleId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleFColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleFColumn(
|
||||
G4int ntupleId, const G4String& columnName, G4float& value)
|
||||
{
|
||||
{
|
||||
return SetNtupleTColumn<float>(ntupleId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleDColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleDColumn(
|
||||
G4int ntupleId, const G4String& columnName, G4double& value)
|
||||
{
|
||||
{
|
||||
return SetNtupleTColumn<double>(ntupleId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleIColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleIColumn(
|
||||
G4int ntupleId, const G4String& columnName, std::vector<G4int>& vector)
|
||||
{
|
||||
return SetNtupleTColumn<int>(ntupleId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleFColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleFColumn(
|
||||
G4int ntupleId, const G4String& columnName, std::vector<G4float>& vector)
|
||||
{
|
||||
return SetNtupleTColumn<float>(ntupleId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleDColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleDColumn(
|
||||
G4int ntupleId, const G4String& columnName, std::vector<G4double>& vector)
|
||||
{
|
||||
return SetNtupleTColumn<double>(ntupleId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool
|
||||
G4TRNtupleManager<TNTUPLE>::SetNtupleSColumn(
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleSColumn(
|
||||
G4int ntupleId, const G4String& columnName, G4String& value)
|
||||
{
|
||||
{
|
||||
return SetNtupleTColumn<std::string>(ntupleId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4bool G4TRNtupleManager<TNTUPLE>::GetNtupleRow(G4int ntupleId)
|
||||
template <typename NT>
|
||||
G4bool
|
||||
G4TRNtupleManager<NT>::SetNtupleSColumn(
|
||||
G4int ntupleId, const G4String& columnName, std::vector<std::string>& vector)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("get", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
return SetNtupleTColumn<std::string>(ntupleId, columnName, vector);
|
||||
}
|
||||
|
||||
auto ntupleDescription
|
||||
//_____________________________________________________________________________
|
||||
template <typename NT>
|
||||
G4bool G4TRNtupleManager<NT>::GetNtupleRow(G4int ntupleId)
|
||||
{
|
||||
Message(G4Analysis::kVL4, "get", "ntuple row",
|
||||
"ntupleId " + to_string(ntupleId));
|
||||
|
||||
auto ntupleDescription
|
||||
= GetNtupleDescriptionInFunction(ntupleId, "GetNtupleRow");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
auto next = GetTNtupleRow(ntupleDescription);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("get", "ntuple row", description, true);
|
||||
}
|
||||
#endif
|
||||
Message(G4Analysis::kVL2, "get", "ntuple row",
|
||||
"ntupleId " + to_string(ntupleId));
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
|
||||
//_____________________________________________________________________________
|
||||
template <typename TNTUPLE>
|
||||
G4int
|
||||
G4TRNtupleManager<TNTUPLE>::GetNofNtuples() const
|
||||
{
|
||||
return G4int(fNtupleDescriptionVector.size());
|
||||
template <typename NT>
|
||||
G4int
|
||||
G4TRNtupleManager<NT>::GetNofNtuples() const
|
||||
{
|
||||
return G4int(fNtupleDescriptionVector.size());
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user