Import Geant4 10.4.0 source tree
This commit is contained in:
@@ -35,7 +35,6 @@
|
||||
#include "G4P1ToolsManager.hh"
|
||||
#include "G4P2ToolsManager.hh"
|
||||
#include "G4XmlRNtupleManager.hh"
|
||||
#include "G4XmlRNtupleDescription.hh"
|
||||
#include "G4AnalysisVerbose.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
#include "G4Threading.hh"
|
||||
@@ -167,6 +166,7 @@ G4bool G4XmlAnalysisReader::Reset()
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -192,6 +192,7 @@ G4int G4XmlAnalysisReader::ReadH1Impl(const G4String& h1Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -217,6 +218,7 @@ G4int G4XmlAnalysisReader::ReadH2Impl(const G4String& h2Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -242,6 +244,7 @@ G4int G4XmlAnalysisReader::ReadH3Impl(const G4String& h3Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -267,6 +270,7 @@ G4int G4XmlAnalysisReader::ReadP1Impl(const G4String& p1Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool /*isUserFileName*/)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -292,6 +296,7 @@ G4int G4XmlAnalysisReader::ReadP2Impl(const G4String& p2Name,
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
const G4String& fileName,
|
||||
const G4String& /*dirName*/,
|
||||
G4bool isUserFileName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
@@ -313,7 +318,7 @@ G4int G4XmlAnalysisReader::ReadNtupleImpl(const G4String& ntupleName,
|
||||
if ( ! handler ) return kInvalidId;
|
||||
|
||||
auto rntuple = static_cast<tools::aida::ntuple*>(handler->object());
|
||||
auto id = fNtupleManager->SetNtuple(new G4XmlRNtupleDescription(rntuple));
|
||||
auto id = fNtupleManager->SetNtuple(new G4TRNtupleDescription<tools::aida::ntuple>(rntuple));
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() )
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
// Author: Ivana Hrivnacova, 25/07/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4XmlRNtupleManager.hh"
|
||||
#include "G4XmlRNtupleDescription.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
|
||||
//
|
||||
@@ -60,278 +59,23 @@ bool to_vector(base_ntu& a_ntu,std::vector<T>& a_vec) {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4XmlRNtupleManager::G4XmlRNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4VRNtupleManager(state),
|
||||
fNtupleVector()
|
||||
{
|
||||
}
|
||||
: G4TRNtupleManager<tools::aida::ntuple>(state)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4XmlRNtupleManager::~G4XmlRNtupleManager()
|
||||
{
|
||||
std::vector<G4XmlRNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
delete (*it);
|
||||
}
|
||||
}
|
||||
{}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4XmlRNtupleDescription* G4XmlRNtupleManager::GetNtupleInFunction(G4int id,
|
||||
G4String functionName, G4bool warn) const
|
||||
{
|
||||
G4int index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4XmlRNtupleManager::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_WR011", JustWarning, description);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fNtupleVector[index];
|
||||
}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::IsEmpty() const
|
||||
{
|
||||
return ! fNtupleVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::Reset()
|
||||
{
|
||||
// Reset ntuples
|
||||
|
||||
std::vector<G4XmlRNtupleDescription*>::iterator it;
|
||||
for (it = fNtupleVector.begin(); it != fNtupleVector.end(); it++ ) {
|
||||
// ntuple is deleted automatically when file is closed
|
||||
// delete (*it)->fNtuple;
|
||||
(*it)->fNtuple=0;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::aida::ntuple* G4XmlRNtupleManager::GetNtuple() const
|
||||
{
|
||||
return GetNtuple(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
tools::aida::ntuple* G4XmlRNtupleManager::GetNtuple(G4int ntupleId) const
|
||||
{
|
||||
G4XmlRNtupleDescription* rntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetRNtuple");
|
||||
|
||||
if ( ! rntupleDescription ) return nullptr;
|
||||
|
||||
return rntupleDescription->fNtuple;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4XmlRNtupleManager::SetNtuple(G4XmlRNtupleDescription* rntupleDescription)
|
||||
{
|
||||
G4int id = fNtupleVector.size() + fFirstId;
|
||||
|
||||
fNtupleVector.push_back(rntupleDescription);
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleIColumn(const G4String& columnName,
|
||||
G4int& value)
|
||||
{
|
||||
return SetNtupleIColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleFColumn(const G4String& columnName,
|
||||
G4float& value)
|
||||
{
|
||||
return SetNtupleFColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleDColumn(const G4String& columnName,
|
||||
G4double& value)
|
||||
{
|
||||
return SetNtupleDColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleSColumn(const G4String& columnName,
|
||||
G4String& value)
|
||||
{
|
||||
return SetNtupleSColumn(fFirstId, columnName, value);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleIColumn(const G4String& columnName,
|
||||
std::vector<G4int>& vector)
|
||||
{
|
||||
return SetNtupleIColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleFColumn(const G4String& columnName,
|
||||
std::vector<G4float>& vector)
|
||||
{
|
||||
return SetNtupleFColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleDColumn(const G4String& columnName,
|
||||
std::vector<G4double>& vector)
|
||||
{
|
||||
return SetNtupleDColumn(fFirstId, columnName, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleIColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4int& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple I column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleIColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* 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
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleFColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4float& value)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple F column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleFColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple F colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4double& value)
|
||||
{
|
||||
// Add protection if ntuple is initialized
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple D column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleDColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple D colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleSColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
G4String& value)
|
||||
{
|
||||
// Add protection if ntuple is initialized
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL4()->Message("set", "ntuple S column", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleSColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, value);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId << " " << columnName;
|
||||
fState.GetVerboseL2()->Message("set", "ntuple S colum", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::SetNtupleIColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4int>& vector)
|
||||
{
|
||||
// Add protection if ntuple is initialized
|
||||
// Override base class default implementation
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
@@ -341,18 +85,17 @@ G4bool G4XmlRNtupleManager::SetNtupleIColumn(G4int ntupleId,
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleIColumn");
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetNtupleIColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
// not supported
|
||||
//tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
//ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
auto subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
ntupleDescription->fIVectorBindingMap[subNtuple] = &vector;
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, *subNtuple);
|
||||
ntupleBinding->add_column_cid(columnName, *subNtuple);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
@@ -370,7 +113,7 @@ G4bool G4XmlRNtupleManager::SetNtupleFColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4float>& vector)
|
||||
{
|
||||
// Add protection if ntuple is initialized
|
||||
// Override base class default implementation
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
@@ -380,18 +123,17 @@ G4bool G4XmlRNtupleManager::SetNtupleFColumn(G4int ntupleId,
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleFColumn");
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetNtupleFColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
// not supported
|
||||
//tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
//ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
auto subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
ntupleDescription->fFVectorBindingMap[subNtuple] = &vector;
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, *subNtuple);
|
||||
ntupleBinding->add_column_cid(columnName, *subNtuple);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
@@ -409,7 +151,7 @@ G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
const G4String& columnName,
|
||||
std::vector<G4double>& vector)
|
||||
{
|
||||
// Add protection if ntuple is initialized
|
||||
// Override base class default implementation
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
@@ -419,18 +161,17 @@ G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "SetNtupleDColumn");
|
||||
auto ntupleDescription = GetNtupleDescriptionInFunction(ntupleId, "SetNtupleDColumn");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
// not supported
|
||||
//tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
//ntupleBinding->add_column(columnName, vector);
|
||||
|
||||
tools::aida::ntuple* subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
auto subNtuple = new tools::aida::ntuple(G4cout, columnName);
|
||||
ntupleDescription->fDVectorBindingMap[subNtuple] = &vector;
|
||||
tools::ntuple_binding* ntupleBinding = ntupleDescription->fNtupleBinding;
|
||||
ntupleBinding->add_column(columnName, *subNtuple);
|
||||
ntupleBinding->add_column_cid(columnName, *subNtuple);
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
@@ -444,27 +185,10 @@ G4bool G4XmlRNtupleManager::SetNtupleDColumn(G4int ntupleId,
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::GetNtupleRow()
|
||||
{
|
||||
return GetNtupleRow(fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4XmlRNtupleManager::GetNtupleRow(G4int ntupleId)
|
||||
G4bool G4XmlRNtupleManager::GetTNtupleRow(
|
||||
G4TRNtupleDescription<tools::aida::ntuple>* ntupleDescription)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL4()->Message("get", "ntuple row", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
G4XmlRNtupleDescription* ntupleDescription
|
||||
= GetNtupleInFunction(ntupleId, "GetNtupleRow");
|
||||
if ( ! ntupleDescription ) return false;
|
||||
|
||||
tools::aida::ntuple* ntuple = ntupleDescription->fNtuple;
|
||||
auto ntuple = ntupleDescription->fNtuple;
|
||||
|
||||
G4bool isInitialized = ntupleDescription->fIsInitialized;
|
||||
if ( ! isInitialized ) {
|
||||
@@ -513,13 +237,5 @@ G4bool G4XmlRNtupleManager::GetNtupleRow(G4int ntupleId)
|
||||
}}
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << " ntupleId " << ntupleId;
|
||||
fState.GetVerboseL2()->Message("get", "ntuple row", description, true);
|
||||
}
|
||||
#endif
|
||||
|
||||
return next;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user