Import Geant4 10.7.0 source tree
This commit is contained in:
@@ -39,10 +39,10 @@ G4AnalysisManagerState::G4AnalysisManagerState(
|
||||
fIsActivation(false),
|
||||
fVerboseLevel(0),
|
||||
fCompressionLevel(1),
|
||||
fVerboseL1(type,1),
|
||||
fVerboseL2(type,2),
|
||||
fVerboseL3(type,3),
|
||||
fVerboseL4(type,4),
|
||||
fVerboseL1(1),
|
||||
fVerboseL2(2),
|
||||
fVerboseL3(3),
|
||||
fVerboseL4(4),
|
||||
fpVerboseL1(0),
|
||||
fpVerboseL2(0),
|
||||
fpVerboseL3(0),
|
||||
@@ -62,34 +62,33 @@ void G4AnalysisManagerState::SetVerboseLevel(G4int verboseLevel)
|
||||
fVerboseLevel = verboseLevel;
|
||||
|
||||
if ( verboseLevel == 0 ) {
|
||||
fpVerboseL1 = 0;
|
||||
fpVerboseL2 = 0;
|
||||
fpVerboseL3 = 0;
|
||||
fpVerboseL4 = 0;
|
||||
fpVerboseL1 = nullptr;
|
||||
fpVerboseL2 = nullptr;
|
||||
fpVerboseL3 = nullptr;
|
||||
fpVerboseL4 = nullptr;
|
||||
}
|
||||
else if ( verboseLevel == 1 ) {
|
||||
fpVerboseL1 = &fVerboseL1;
|
||||
fpVerboseL2 = 0;
|
||||
fpVerboseL3 = 0;
|
||||
fpVerboseL4 = 0;
|
||||
fpVerboseL2 = nullptr;
|
||||
fpVerboseL3 = nullptr;
|
||||
fpVerboseL4 = nullptr;
|
||||
}
|
||||
else if ( verboseLevel == 2 ) {
|
||||
fpVerboseL1 = &fVerboseL1;
|
||||
fpVerboseL2 = &fVerboseL2;
|
||||
fpVerboseL3 = 0;
|
||||
fpVerboseL4 = 0;
|
||||
fpVerboseL3 = nullptr;
|
||||
fpVerboseL4 = nullptr;
|
||||
}
|
||||
else if ( verboseLevel == 3 ) {
|
||||
fpVerboseL1 = &fVerboseL1;
|
||||
fpVerboseL2 = &fVerboseL2;
|
||||
fpVerboseL3 = &fVerboseL3;
|
||||
fpVerboseL4 = 0;
|
||||
fpVerboseL4 = nullptr;
|
||||
}
|
||||
else {
|
||||
else if ( verboseLevel > 3 ) {
|
||||
fpVerboseL1 = &fVerboseL1;
|
||||
fpVerboseL2 = &fVerboseL2;
|
||||
fpVerboseL3 = &fVerboseL3;
|
||||
fpVerboseL4 = &fVerboseL4;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -115,9 +115,9 @@ void G4AnalysisMessenger::SetH2HnManager(G4HnManager& h2HnManager)
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4AnalysisMessenger::SetH3HnManager(G4HnManager& h2HnManager)
|
||||
void G4AnalysisMessenger::SetH3HnManager(G4HnManager& h3HnManager)
|
||||
{
|
||||
fH2HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h2HnManager);
|
||||
fH3HnMessenger = G4Analysis::make_unique<G4HnMessenger>(h3HnManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
|
||||
@@ -348,7 +348,7 @@ void G4AnalysisMessengerHelper::WarnAboutSetCommands() const
|
||||
{
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Command setX, setY, setZ must be called sucessively in this order. " << G4endl
|
||||
<< "Command setX, setY, setZ must be called successively in this order. " << G4endl
|
||||
<< "Command was ignored." << G4endl;
|
||||
G4String methodName(Update("G4UHNTYPE_Messenger::SetNewValue"));
|
||||
G4Exception(methodName,
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "G4BinScheme.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4String.hh"
|
||||
#include "G4Threading.hh"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -190,9 +191,7 @@ void Tokenize(const G4String& line, std::vector<G4String>& tokens)
|
||||
//_____________________________________________________________________________
|
||||
G4AnalysisOutput GetOutput(const G4String& outputName, G4bool warn) {
|
||||
if ( outputName == "csv" ) { return G4AnalysisOutput::kCsv; }
|
||||
#ifdef TOOLS_USE_HDF5
|
||||
else if ( outputName == "hdf5" ) { return G4AnalysisOutput::kHdf5; }
|
||||
#endif
|
||||
else if ( outputName == "root" ) { return G4AnalysisOutput::kRoot; }
|
||||
else if ( outputName == "xml" ) { return G4AnalysisOutput::kXml; }
|
||||
else if ( outputName == "none" ) { return G4AnalysisOutput::kNone; }
|
||||
@@ -202,7 +201,7 @@ G4AnalysisOutput GetOutput(const G4String& outputName, G4bool warn) {
|
||||
description
|
||||
<< " \"" << outputName << "\" output type is not supported." << G4endl;
|
||||
G4Exception("G4Analysis::GetOutputType",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
"Analysis_W051", JustWarning, description);
|
||||
}
|
||||
return G4AnalysisOutput::kNone;
|
||||
}
|
||||
@@ -214,11 +213,9 @@ G4String GetOutputName(G4AnalysisOutput output) {
|
||||
case G4AnalysisOutput::kCsv:
|
||||
return "csv";
|
||||
break;
|
||||
#ifdef TOOLS_USE_HDF5
|
||||
case G4AnalysisOutput::kHdf5:
|
||||
return "hdf5";
|
||||
break;
|
||||
#endif
|
||||
case G4AnalysisOutput::kRoot:
|
||||
return "root";
|
||||
break;
|
||||
@@ -235,8 +232,171 @@ G4String GetOutputName(G4AnalysisOutput output) {
|
||||
<< " \"" << static_cast<int>(output) << "\" is not handled." << G4endl
|
||||
<< " " << "none type will be used.";
|
||||
G4Exception("G4Analysis::GetOutputName",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
"Analysis_W051", JustWarning, description);
|
||||
return "none";
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetBaseName(const G4String& fileName)
|
||||
{
|
||||
// Get file base name (without dot)
|
||||
|
||||
G4String name = fileName;
|
||||
if ( name.rfind(".") != std::string::npos ) {
|
||||
name = name.substr(0, name.rfind("."));
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetExtension(const G4String& fileName,
|
||||
const G4String& defaultExtension)
|
||||
{
|
||||
// Get file base extension (without dot)
|
||||
// If fileName is provided without extension, return defaultExtension
|
||||
|
||||
G4String extension;
|
||||
if ( fileName.rfind(".") != std::string::npos ) {
|
||||
extension = fileName.substr(fileName.rfind(".") + 1);
|
||||
}
|
||||
if ( ! extension.size() ) {
|
||||
extension = defaultExtension;
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetHnFileName(
|
||||
const G4String& fileName,
|
||||
const G4String& fileType,
|
||||
const G4String& hnType,
|
||||
const G4String& hnName)
|
||||
{
|
||||
// Compose and return the histogram or profile specific file name:
|
||||
// - add _hn_hnName suffix to the file base name
|
||||
// - add file extension if not present
|
||||
|
||||
auto name = GetBaseName(fileName);
|
||||
|
||||
// Add _hnType_hnName
|
||||
name.append("_");
|
||||
name.append(hnType);
|
||||
name.append("_");
|
||||
name.append(hnName);
|
||||
|
||||
// Add file extension
|
||||
auto extension = GetExtension(fileName, fileType);
|
||||
if ( extension.size() ) {
|
||||
name.append(".");
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetNtupleFileName(
|
||||
const G4String& fileName,
|
||||
const G4String& fileType,
|
||||
const G4String& ntupleName)
|
||||
{
|
||||
// Compose and return the ntuple specific file name:
|
||||
// - add _nt_ntupleName suffix to the file base name
|
||||
// - add _tN suffix if called on thread worker
|
||||
// - add file extension if not present
|
||||
|
||||
auto name = GetBaseName(fileName);
|
||||
|
||||
// Add ntupleName
|
||||
name.append("_nt_");
|
||||
name.append(ntupleName);
|
||||
|
||||
// Add thread Id to a file name if MT processing
|
||||
if ( ! G4Threading::IsMasterThread() ) {
|
||||
std::ostringstream os;
|
||||
os << G4Threading::G4GetThreadId();
|
||||
name.append("_t");
|
||||
name.append(os.str());
|
||||
}
|
||||
|
||||
// Add file extension
|
||||
auto extension = GetExtension(fileName, fileType);
|
||||
if ( extension.size() ) {
|
||||
name.append(".");
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetNtupleFileName(
|
||||
const G4String& fileName,
|
||||
const G4String& fileType,
|
||||
G4int ntupleFileNumber)
|
||||
{
|
||||
// Compose and return the ntuple specific file name:
|
||||
// - add _mFN suffix to the file base name where FN = ntupleFileNumber
|
||||
// - add file extension if not present
|
||||
|
||||
auto name = GetBaseName(fileName);
|
||||
|
||||
// Add _M followed by ntupleFileNumber
|
||||
std::ostringstream os;
|
||||
os << ntupleFileNumber;
|
||||
name.append("_m");
|
||||
name.append(os.str());
|
||||
|
||||
// Add file extension
|
||||
auto extension = GetExtension(fileName, fileType);
|
||||
if ( extension.size() ) {
|
||||
name.append(".");
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetTnFileName(
|
||||
const G4String& fileName,
|
||||
const G4String& fileType)
|
||||
{
|
||||
// Update file base name with the thread suffix:
|
||||
// - add _tN suffix if called on thread worker
|
||||
// - add file extension if not present
|
||||
|
||||
auto name = GetBaseName(fileName);
|
||||
|
||||
// Add thread Id to a file name if MT processing
|
||||
if ( ! G4Threading::IsMasterThread() ) {
|
||||
std::ostringstream os;
|
||||
os << G4Threading::G4GetThreadId();
|
||||
name.append("_t");
|
||||
name.append(os.str());
|
||||
}
|
||||
|
||||
// Add file extension
|
||||
auto extension = GetExtension(fileName, fileType);
|
||||
if ( extension.size() ) {
|
||||
name.append(".");
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String GetPlotFileName(const G4String& fileName)
|
||||
{
|
||||
// Generate plot file name for an output file name
|
||||
|
||||
auto name = GetBaseName(fileName);
|
||||
|
||||
// Add .ps extension
|
||||
name.append(".ps");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -32,9 +32,8 @@
|
||||
#include <iostream>
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4AnalysisVerbose::G4AnalysisVerbose(const G4String& type, G4int verboseLevel)
|
||||
: fType(type),
|
||||
fToBeDoneText(),
|
||||
G4AnalysisVerbose::G4AnalysisVerbose(G4int verboseLevel)
|
||||
: fToBeDoneText(),
|
||||
fDoneText(),
|
||||
fFailureText()
|
||||
{
|
||||
@@ -64,17 +63,17 @@ void G4AnalysisVerbose::Message(const G4String& action,
|
||||
<< fToBeDoneText
|
||||
<< action
|
||||
<< " "
|
||||
<< fType
|
||||
<< " "
|
||||
<< object
|
||||
<< object;
|
||||
if ( objectName.size() ) {
|
||||
G4cout
|
||||
<< " : "
|
||||
<< objectName
|
||||
<< " ";
|
||||
<< objectName;
|
||||
}
|
||||
|
||||
if ( success )
|
||||
G4cout << fDoneText;
|
||||
G4cout << " " << fDoneText;
|
||||
else
|
||||
G4cout << fFailureText;
|
||||
G4cout << " " << fFailureText;
|
||||
|
||||
G4cout << G4endl;
|
||||
}
|
||||
@@ -89,9 +88,7 @@ void G4AnalysisVerbose::Message(const G4String& action,
|
||||
<< fToBeDoneText
|
||||
<< action
|
||||
<< " "
|
||||
<< fType
|
||||
<< " "
|
||||
<< object
|
||||
<< object
|
||||
<< " : "
|
||||
<< description.str()
|
||||
<< " ";
|
||||
@@ -103,4 +100,3 @@ void G4AnalysisVerbose::Message(const G4String& action,
|
||||
|
||||
G4cout << G4endl;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,13 +27,15 @@
|
||||
// Author: Ivana Hrivnacova, 10/09/2014 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4BaseFileManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
#include "G4Threading.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4BaseFileManager::G4BaseFileManager(const G4AnalysisManagerState& state)
|
||||
: fState(state),
|
||||
fFileName("")
|
||||
fFileName(""),
|
||||
fFileNames()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -42,132 +44,21 @@ G4BaseFileManager::~G4BaseFileManager()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::TakeOffExtension(G4String& name) const
|
||||
{
|
||||
G4String extension;
|
||||
if ( name.rfind(".") != std::string::npos ) {
|
||||
extension = name.substr(name.rfind("."));
|
||||
name = name.substr(0, name.rfind("."));
|
||||
}
|
||||
else {
|
||||
extension = ".";
|
||||
extension.append(GetFileType());
|
||||
}
|
||||
return extension;
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetFullFileName(const G4String& baseFileName,
|
||||
G4bool isPerThread) const
|
||||
{
|
||||
G4String name(baseFileName);
|
||||
if ( name == "" ) name = fFileName;
|
||||
|
||||
// Take out file extension
|
||||
G4String extension = TakeOffExtension(name);
|
||||
|
||||
// Add thread Id to a file name if MT processing
|
||||
if ( isPerThread && ! fState.GetIsMaster() ) {
|
||||
std::ostringstream os;
|
||||
os << G4Threading::G4GetThreadId();
|
||||
name.append("_t");
|
||||
name.append(os.str());
|
||||
}
|
||||
|
||||
// Add (back if it was present) file extension
|
||||
name.append(extension);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetNtupleFileName(const G4String& ntupleName) const
|
||||
{
|
||||
G4String name(fFileName);
|
||||
|
||||
// Take out file extension
|
||||
auto extension = TakeOffExtension(name);
|
||||
|
||||
// Add ntupleName
|
||||
name.append("_nt_");
|
||||
name.append(ntupleName);
|
||||
|
||||
// Add thread Id to a file name if MT processing
|
||||
if ( ! fState.GetIsMaster() ) {
|
||||
std::ostringstream os;
|
||||
os << G4Threading::G4GetThreadId();
|
||||
name.append("_t");
|
||||
name.append(os.str());
|
||||
}
|
||||
|
||||
// Add (back if it was present) file extension
|
||||
name.append(extension);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetNtupleFileName(G4int ntupleFileNumber) const
|
||||
{
|
||||
G4String name(fFileName);
|
||||
|
||||
// Take out file extension
|
||||
auto extension = TakeOffExtension(name);
|
||||
|
||||
// Add _M followed by ntupleFileNumber
|
||||
std::ostringstream os;
|
||||
os << ntupleFileNumber;
|
||||
name.append("_m");
|
||||
name.append(os.str());
|
||||
|
||||
// Add (back if it was present) file extension
|
||||
name.append(extension);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetHnFileName(const G4String& hnType,
|
||||
const G4String& hnName) const
|
||||
void G4BaseFileManager::AddFileName(const G4String& fileName)
|
||||
{
|
||||
G4String name(fFileName);
|
||||
// G4cout << "registering " << fileName << " in manager of " << GetFileType() << G4endl;
|
||||
|
||||
// Take out file extension
|
||||
auto extension = TakeOffExtension(name);
|
||||
|
||||
// Add _hnType_hnName
|
||||
name.append("_");
|
||||
name.append(hnType);
|
||||
name.append("_");
|
||||
name.append(hnName);
|
||||
// Do nothing in file name is already present
|
||||
for ( auto name : fFileNames ) {
|
||||
if ( name == fileName ) return;
|
||||
}
|
||||
|
||||
// Add (back if it was present) file extension
|
||||
name.append(extension);
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetPlotFileName() const
|
||||
{
|
||||
G4String name(fFileName);
|
||||
|
||||
// Take out file extension
|
||||
auto extension = TakeOffExtension(name);
|
||||
|
||||
// Add .ps extension
|
||||
name.append(".ps");
|
||||
|
||||
return name;
|
||||
fFileNames.push_back(fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -176,6 +67,59 @@ G4String G4BaseFileManager::GetFileType() const
|
||||
G4String fileType = fState.GetType();
|
||||
fileType.toLower();
|
||||
return fileType;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetFullFileName(const G4String& baseFileName,
|
||||
G4bool isPerThread) const
|
||||
{
|
||||
G4String fileName(baseFileName);
|
||||
if ( fileName == "" ) fileName = fFileName;
|
||||
|
||||
// Take out file extension
|
||||
auto name = G4Analysis::GetBaseName(fileName);
|
||||
|
||||
// Add thread Id to a file name if MT processing
|
||||
if ( isPerThread && ! fState.GetIsMaster() ) {
|
||||
std::ostringstream os;
|
||||
os << G4Threading::G4GetThreadId();
|
||||
name.append("_t");
|
||||
name.append(os.str());
|
||||
}
|
||||
|
||||
// Add (back if it was present or is defined) file extension
|
||||
auto extension = G4Analysis::GetExtension(fileName, GetFileType());
|
||||
if ( extension.size() ) {
|
||||
name.append(".");
|
||||
name.append(extension);
|
||||
}
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetHnFileName(const G4String& hnType,
|
||||
const G4String& hnName) const
|
||||
{
|
||||
return G4Analysis::GetHnFileName(fFileName, GetFileType(), hnType, hnName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetNtupleFileName(const G4String& ntupleName) const
|
||||
{
|
||||
return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetNtupleFileName(G4int ntupleFileNumber) const
|
||||
{
|
||||
return G4Analysis::GetNtupleFileName(fFileName, GetFileType(), ntupleFileNumber);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4BaseFileManager::GetPlotFileName() const
|
||||
{
|
||||
return G4Analysis::GetPlotFileName(fFileName);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@
|
||||
//_____________________________________________________________________________
|
||||
G4BaseNtupleManager::G4BaseNtupleManager(const G4AnalysisManagerState& state)
|
||||
: G4VNtupleManager(state),
|
||||
fFirstNtupleColumnId(0),
|
||||
fLockFirstNtupleColumnId(false)
|
||||
fFirstNtupleColumnId(0)
|
||||
// fLockFirstNtupleColumnId(false)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -40,53 +40,6 @@ G4BaseNtupleManager::~G4BaseNtupleManager()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4BaseNtupleManager::GetCurrentNtupleId() const
|
||||
{
|
||||
return GetNofNtupleBookings() + fFirstId - 1;
|
||||
}
|
||||
|
||||
//
|
||||
// protected methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4BaseNtupleManager::CreateNtupleIColumn(const G4String& name,
|
||||
std::vector<int>* vector)
|
||||
{
|
||||
return CreateNtupleIColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4BaseNtupleManager::CreateNtupleFColumn(const G4String& name,
|
||||
std::vector<float>* vector)
|
||||
{
|
||||
return CreateNtupleFColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4BaseNtupleManager::CreateNtupleDColumn(const G4String& name,
|
||||
std::vector<double>* vector)
|
||||
{
|
||||
return CreateNtupleDColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4BaseNtupleManager::CreateNtupleSColumn(const G4String& name)
|
||||
{
|
||||
return CreateNtupleSColumn(GetCurrentNtupleId(), name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4BaseNtupleManager::FinishNtuple()
|
||||
{
|
||||
return FinishNtuple(GetCurrentNtupleId());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4BaseNtupleManager::FillNtupleIColumn(G4int id, G4int value)
|
||||
{
|
||||
@@ -118,18 +71,8 @@ G4bool G4BaseNtupleManager::AddNtupleRow()
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4BaseNtupleManager::SetFirstNtupleColumnId(G4int firstId)
|
||||
{
|
||||
if ( fLockFirstNtupleColumnId ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set FirstNtupleColumnId as its value was already used.";
|
||||
G4Exception("G4BaseNtupleManager::SetFirstNtupleColumnId()",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fFirstNtupleColumnId = firstId;
|
||||
G4bool G4BaseNtupleManager::SetFirstNtupleColumnId(G4int firstId)
|
||||
{
|
||||
fFirstNtupleColumnId = firstId;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
// Author: Ivana Hrivnacova, 18/06/2013 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4HnManager.hh"
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
using namespace G4Analysis;
|
||||
@@ -39,15 +40,78 @@ G4HnManager::G4HnManager(const G4String& hnType,
|
||||
fNofActiveObjects(0),
|
||||
fNofAsciiObjects(0),
|
||||
fNofPlottingObjects(0),
|
||||
fHnVector()
|
||||
fNofFileNameObjects(0),
|
||||
fHnVector(),
|
||||
fFileManager(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4HnManager::~G4HnManager()
|
||||
{
|
||||
for ( auto hnInformation : fHnVector ) {
|
||||
delete hnInformation;
|
||||
for ( auto info : fHnVector ) {
|
||||
delete info;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// private methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetActivation(G4HnInformation* info, G4bool activation)
|
||||
{
|
||||
// Set activation to a given object
|
||||
|
||||
// Do nothing if activation does not change
|
||||
if ( info->GetActivation() == activation ) return;
|
||||
|
||||
// Change activation and account it in fNofActiveObjects
|
||||
info->SetActivation(activation);
|
||||
if ( activation )
|
||||
fNofActiveObjects++;
|
||||
else
|
||||
fNofActiveObjects--;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetPlotting(G4HnInformation* info, G4bool plotting)
|
||||
{
|
||||
// Do nothing if ascii does not change
|
||||
if ( info->GetPlotting() == plotting ) return;
|
||||
|
||||
// Change Plotting and account it in fNofPlottingObjects
|
||||
info->SetPlotting(plotting);
|
||||
if ( plotting )
|
||||
fNofPlottingObjects++;
|
||||
else
|
||||
fNofPlottingObjects--;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetFileName(G4HnInformation* info, const G4String& fileName)
|
||||
{
|
||||
// Do nothing if file name does not change
|
||||
if ( info->GetFileName() == fileName ) return;
|
||||
|
||||
// Save the info and account a new file name if file manager
|
||||
info->SetFileName(fileName);
|
||||
if (fFileManager) {
|
||||
fFileManager->AddFileName(fileName);
|
||||
} else {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Failed to set fileName " << fileName << " for object " << info->GetName() << G4endl
|
||||
<< "File manager is not set.";
|
||||
G4Exception("G4HnManager::SetFileName",
|
||||
"Analysis_W012", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
|
||||
if ( fileName != "" ) {
|
||||
fNofFileNameObjects++;
|
||||
} else {
|
||||
fNofFileNameObjects--;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,11 +122,11 @@ G4HnManager::~G4HnManager()
|
||||
//_____________________________________________________________________________
|
||||
G4HnInformation* G4HnManager::AddHnInformation(const G4String& name, G4int nofDimensions)
|
||||
{
|
||||
auto hnInformation = new G4HnInformation(name, nofDimensions);
|
||||
fHnVector.push_back(hnInformation);
|
||||
auto info = new G4HnInformation(name, nofDimensions);
|
||||
fHnVector.push_back(info);
|
||||
++fNofActiveObjects;
|
||||
|
||||
return hnInformation;
|
||||
return info;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -92,11 +156,11 @@ G4HnDimensionInformation* G4HnManager::GetHnDimensionInformation(G4int id,
|
||||
G4int dimension,
|
||||
G4String functionName, G4bool warn) const
|
||||
{
|
||||
auto hnInformation = GetHnInformation(id, functionName, warn);
|
||||
if ( ! hnInformation ) return nullptr;
|
||||
auto info = GetHnInformation(id, functionName, warn);
|
||||
if ( ! info ) return nullptr;
|
||||
|
||||
return hnInformation->GetHnDimensionInformation(dimension);
|
||||
}
|
||||
return info->GetHnDimensionInformation(dimension);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4HnManager::IsActive() const
|
||||
@@ -116,6 +180,12 @@ G4bool G4HnManager::IsPlotting() const
|
||||
return ( fNofPlottingObjects > 0 );
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4HnManager::IsFileName() const
|
||||
{
|
||||
return ( fNofFileNameObjects > 0 );
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetActivation(G4int id, G4bool activation)
|
||||
{
|
||||
@@ -125,15 +195,7 @@ void G4HnManager::SetActivation(G4int id, G4bool activation)
|
||||
|
||||
if ( ! info ) return;
|
||||
|
||||
// Do nothing if activation does not change
|
||||
if ( info->GetActivation() == activation ) return;
|
||||
|
||||
// Change activation and account it in fNofActiveObjects
|
||||
info->SetActivation(activation);
|
||||
if ( activation )
|
||||
fNofActiveObjects++;
|
||||
else
|
||||
fNofActiveObjects--;
|
||||
SetActivation(info, activation);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -146,18 +208,9 @@ void G4HnManager::SetActivation(G4bool activation)
|
||||
// G4HnInformation* info = *it;
|
||||
|
||||
for ( auto info : fHnVector ) {
|
||||
|
||||
// Do nothing if activation does not change
|
||||
if ( info->GetActivation() == activation ) continue;
|
||||
|
||||
// Change activation and account it in fNofActiveObjects
|
||||
info->SetActivation(activation);
|
||||
if ( activation )
|
||||
fNofActiveObjects++;
|
||||
else
|
||||
fNofActiveObjects--;
|
||||
}
|
||||
}
|
||||
SetActivation(info, activation);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetAscii(G4int id, G4bool ascii)
|
||||
@@ -184,16 +237,8 @@ void G4HnManager::SetPlotting(G4int id, G4bool plotting)
|
||||
|
||||
if ( ! info ) return;
|
||||
|
||||
// Do nothing if ascii does not change
|
||||
if ( info->GetPlotting() == plotting ) return;
|
||||
|
||||
// Change Plotting and account it in fNofPlottingObjects
|
||||
info->SetPlotting(plotting);
|
||||
if ( plotting )
|
||||
fNofPlottingObjects++;
|
||||
else
|
||||
fNofPlottingObjects--;
|
||||
}
|
||||
SetPlotting(info, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetPlotting(G4bool plotting)
|
||||
@@ -201,17 +246,28 @@ void G4HnManager::SetPlotting(G4bool plotting)
|
||||
// Set plotting to all objects of the given type
|
||||
|
||||
for ( auto info : fHnVector ) {
|
||||
SetPlotting(info, plotting);
|
||||
}
|
||||
}
|
||||
|
||||
// Do nothing if plotting does not change
|
||||
if ( info->GetPlotting() == plotting ) continue;
|
||||
|
||||
// Change plotting and account it in fNofActiveObjects
|
||||
info->SetPlotting(plotting);
|
||||
if ( plotting )
|
||||
fNofPlottingObjects++;
|
||||
else
|
||||
fNofPlottingObjects--;
|
||||
}
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetFileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
auto info = GetHnInformation(id, "SetFileName");
|
||||
|
||||
if ( ! info ) return;
|
||||
|
||||
SetFileName(info, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnManager::SetFileName(const G4String& fileName)
|
||||
{
|
||||
// Set plotting to all objects of the given type
|
||||
|
||||
for ( auto info : fHnVector ) {
|
||||
SetFileName(info, fileName);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -345,4 +401,14 @@ G4bool G4HnManager::GetPlotting(G4int id) const
|
||||
if ( ! info ) return false;
|
||||
|
||||
return info->GetPlotting();
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4HnManager::GetFileName(G4int id) const
|
||||
{
|
||||
auto info = GetHnInformation(id, "GetFileName");
|
||||
|
||||
if ( ! info ) return "";
|
||||
|
||||
return info->GetFileName();
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
@@ -48,7 +49,9 @@ G4HnMessenger::G4HnMessenger(G4HnManager& manager)
|
||||
fSetHnActivationCmd(nullptr),
|
||||
fSetHnActivationAllCmd(nullptr),
|
||||
fSetHnPlottingCmd(nullptr),
|
||||
fSetHnPlottingAllCmd(nullptr)
|
||||
fSetHnPlottingAllCmd(nullptr),
|
||||
fSetHnFileNameCmd(nullptr),
|
||||
fSetHnFileNameAllCmd(nullptr)
|
||||
{
|
||||
G4String hnType = fManager.GetHnType();
|
||||
hnType.toLower();
|
||||
@@ -59,6 +62,8 @@ G4HnMessenger::G4HnMessenger(G4HnManager& manager)
|
||||
SetHnActivationToAllCmd();
|
||||
SetHnPlottingCmd();
|
||||
SetHnPlottingToAllCmd();
|
||||
SetHnFileNameCmd();
|
||||
SetHnFileNameToAllCmd();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -142,6 +147,36 @@ void G4HnMessenger::SetHnPlottingToAllCmd()
|
||||
fSetHnPlottingAllCmd->SetParameterName("Plotting",false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnMessenger::SetHnFileNameCmd()
|
||||
{
|
||||
auto hnId = new G4UIparameter("id", 'i', false);
|
||||
hnId->SetGuidance(fHelper->Update("OBJECT id"));
|
||||
hnId->SetParameterRange("id>=0");
|
||||
|
||||
auto hnFileName = new G4UIparameter("hnFileName", 's', true);
|
||||
hnFileName->SetGuidance(fHelper->Update("OBJECT output file name"));
|
||||
hnFileName->SetDefaultValue("none");
|
||||
|
||||
fSetHnFileNameCmd
|
||||
= G4Analysis::make_unique<G4UIcommand>(fHelper->Update("/analysis/HNTYPE_/setFileName"), this);
|
||||
fSetHnFileNameCmd->SetGuidance(
|
||||
fHelper->Update("Set the NDIM_D LOBJECT of given id output file name"));
|
||||
fSetHnFileNameCmd->SetParameter(hnId);
|
||||
fSetHnFileNameCmd->SetParameter(hnFileName);
|
||||
fSetHnFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4HnMessenger::SetHnFileNameToAllCmd()
|
||||
{
|
||||
fSetHnFileNameAllCmd
|
||||
= G4Analysis::make_unique<G4UIcmdWithAString>(fHelper->Update("/analysis/HNTYPE_/setFileNameToAll"), this);
|
||||
fSetHnFileNameAllCmd->SetGuidance(
|
||||
fHelper->Update("Set output file name for all NDIM_D LOBJECTs"));
|
||||
fSetHnFileNameAllCmd->SetParameterName("FileName",false);
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
@@ -149,11 +184,11 @@ void G4HnMessenger::SetHnPlottingToAllCmd()
|
||||
//_____________________________________________________________________________
|
||||
void G4HnMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
{
|
||||
if ( command == fSetHnAsciiCmd.get() ) {
|
||||
if ( command == fSetHnAsciiCmd.get() ) {
|
||||
auto id = fSetHnAsciiCmd->GetNewIntValue(newValues);
|
||||
fManager.SetAscii(id, true);
|
||||
}
|
||||
else if ( command == fSetHnActivationCmd.get() ) {
|
||||
fManager.SetAscii(id, true);
|
||||
}
|
||||
else if ( command == fSetHnActivationCmd.get() ) {
|
||||
// tokenize parameters in a vector
|
||||
std::vector<G4String> parameters;
|
||||
G4Analysis::Tokenize(newValues, parameters);
|
||||
@@ -162,18 +197,18 @@ void G4HnMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
auto counter = 0;
|
||||
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
|
||||
auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
|
||||
fManager.SetActivation(id, activation);
|
||||
fManager.SetActivation(id, activation);
|
||||
}
|
||||
else {
|
||||
// Should never happen but let's check anyway for consistency
|
||||
fHelper->WarnAboutParameters(command, parameters.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( command == fSetHnActivationAllCmd.get() ) {
|
||||
else if ( command == fSetHnActivationAllCmd.get() ) {
|
||||
auto activation = fSetHnActivationAllCmd->GetNewBoolValue(newValues);
|
||||
fManager.SetActivation(activation);
|
||||
}
|
||||
else if ( command == fSetHnPlottingCmd.get() ) {
|
||||
}
|
||||
else if ( command == fSetHnPlottingCmd.get() ) {
|
||||
// tokenize parameters in a vector
|
||||
std::vector<G4String> parameters;
|
||||
G4Analysis::Tokenize(newValues, parameters);
|
||||
@@ -182,15 +217,35 @@ void G4HnMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
auto counter = 0;
|
||||
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
|
||||
auto activation = G4UIcommand::ConvertToBool(parameters[counter++]);
|
||||
fManager.SetPlotting(id, activation);
|
||||
fManager.SetPlotting(id, activation);
|
||||
}
|
||||
else {
|
||||
// Should never happen but let's check anyway for consistency
|
||||
fHelper->WarnAboutParameters(command, parameters.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( command == fSetHnPlottingAllCmd.get() ) {
|
||||
auto activation = fSetHnPlottingAllCmd->GetNewBoolValue(newValues);
|
||||
fManager.SetPlotting(activation);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( command == fSetHnFileNameCmd.get() ) {
|
||||
// tokenize parameters in a vector
|
||||
std::vector<G4String> parameters;
|
||||
G4Analysis::Tokenize(newValues, parameters);
|
||||
// check consistency
|
||||
if ( parameters.size() == command->GetParameterEntries() ) {
|
||||
auto counter = 0;
|
||||
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
|
||||
auto fileName = parameters[counter++];
|
||||
fManager.SetFileName(id, fileName);
|
||||
}
|
||||
else {
|
||||
// Should never happen but let's check anyway for consistency
|
||||
fHelper->WarnAboutParameters(command, parameters.size());
|
||||
}
|
||||
}
|
||||
else if ( command == fSetHnFileNameAllCmd.get() ) {
|
||||
auto fileName = newValues;
|
||||
fManager.SetFileName(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,332 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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, 01/09/2020 (ivana@ipno.in2p3.fr)
|
||||
|
||||
#include "G4NtupleBookingManager.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
//
|
||||
// private template functions
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleBookingManager::G4NtupleBookingManager(
|
||||
const G4AnalysisManagerState& state)
|
||||
: G4BaseAnalysisManager(state),
|
||||
fNtupleBookingVector(),
|
||||
fFileType(),
|
||||
fFirstNtupleColumnId(0),
|
||||
fLockFirstNtupleColumnId(false)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleBookingManager::~G4NtupleBookingManager()
|
||||
{
|
||||
for ( auto ntupleBooking : fNtupleBookingVector ) {
|
||||
delete ntupleBooking;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleBooking*
|
||||
G4NtupleBookingManager::GetNtupleBookingInFunction(
|
||||
G4int id, G4String functionName, G4bool warn) const
|
||||
{
|
||||
auto index = id - fFirstId;
|
||||
if ( index < 0 || index >= G4int(fNtupleBookingVector.size()) ) {
|
||||
if ( warn) {
|
||||
G4String inFunction = "G4NtupleBookingManager::";
|
||||
inFunction += functionName;
|
||||
G4ExceptionDescription description;
|
||||
description << " " << "ntuple booking " << id << " does not exist.";
|
||||
G4Exception(inFunction, "Analysis_W011", JustWarning, description);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return fNtupleBookingVector[index];
|
||||
}
|
||||
|
||||
//
|
||||
// protected functions
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4NtupleBookingManager::IsEmpty() const
|
||||
{
|
||||
return ! fNtupleBookingVector.size();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtuple(
|
||||
const G4String& name, const G4String& title)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL4() )
|
||||
fState.GetVerboseL4()->Message("create", "ntuple booking", name);
|
||||
#endif
|
||||
|
||||
// Create ntuple description
|
||||
auto index = fNtupleBookingVector.size();
|
||||
auto ntupleBooking = new G4NtupleBooking();
|
||||
fNtupleBookingVector.push_back(ntupleBooking);
|
||||
|
||||
// Save name & title in ntuple booking
|
||||
ntupleBooking->fNtupleBooking.set_name(name);
|
||||
ntupleBooking->fNtupleBooking.set_title(title);
|
||||
|
||||
// Create ntuple
|
||||
fLockFirstId = true;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if ( fState.GetVerboseL2() ) {
|
||||
G4ExceptionDescription description;
|
||||
description << name << " ntupleId " << index + fFirstId;
|
||||
fState.GetVerboseL2()->Message("create", "ntuple booking", description);
|
||||
}
|
||||
#endif
|
||||
|
||||
return G4int(index + fFirstId);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleIColumn(const G4String& name,
|
||||
std::vector<int>* vector)
|
||||
{
|
||||
return CreateNtupleIColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleFColumn(const G4String& name,
|
||||
std::vector<float>* vector)
|
||||
{
|
||||
return CreateNtupleFColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleDColumn(const G4String& name,
|
||||
std::vector<double>* vector)
|
||||
{
|
||||
return CreateNtupleDColumn(GetCurrentNtupleId(), name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleSColumn(const G4String& name)
|
||||
{
|
||||
return CreateNtupleSColumn(GetCurrentNtupleId(), name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleBooking* G4NtupleBookingManager::FinishNtuple()
|
||||
{
|
||||
return FinishNtuple(GetCurrentNtupleId());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleIColumn(
|
||||
G4int ntupleId, const G4String& name, std::vector<int>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<int>(ntupleId, name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleFColumn(
|
||||
G4int ntupleId, const G4String& name, std::vector<float>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<float>(ntupleId, name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleDColumn(
|
||||
G4int ntupleId, const G4String& name, std::vector<double>* vector)
|
||||
{
|
||||
return CreateNtupleTColumn<double>(ntupleId, name, vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4int G4NtupleBookingManager::CreateNtupleSColumn(
|
||||
G4int ntupleId, const G4String& name)
|
||||
{
|
||||
return CreateNtupleTColumn<std::string>(ntupleId, name, nullptr);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleBooking* G4NtupleBookingManager::FinishNtuple(
|
||||
G4int ntupleId)
|
||||
{
|
||||
// Nothing to be done for booking,
|
||||
return GetNtupleBookingInFunction(ntupleId, "FinishNtuple");
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4NtupleBookingManager::SetFirstNtupleColumnId(G4int firstId)
|
||||
{
|
||||
if ( fLockFirstNtupleColumnId ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set FirstNtupleColumnId as its value was already used.";
|
||||
G4Exception("G4BaseNtupleManager::SetFirstNtupleColumnId()",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
|
||||
fFirstNtupleColumnId = firstId;
|
||||
return true;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleBookingManager::SetActivation(
|
||||
G4bool activation)
|
||||
{
|
||||
for ( auto ntupleBooking : fNtupleBookingVector ) {
|
||||
ntupleBooking->fActivation = activation;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleBookingManager::SetActivation(
|
||||
G4int ntupleId, G4bool activation)
|
||||
{
|
||||
auto ntupleBooking
|
||||
= GetNtupleBookingInFunction(ntupleId, "SetActivation");
|
||||
if ( ! ntupleBooking ) return;
|
||||
|
||||
ntupleBooking->fActivation = activation;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4NtupleBookingManager::GetActivation(
|
||||
G4int ntupleId) const
|
||||
{
|
||||
auto ntupleBooking
|
||||
= GetNtupleBookingInFunction(ntupleId, "GetActivation");
|
||||
if ( ! ntupleBooking ) return false;
|
||||
|
||||
return ntupleBooking->fActivation;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleBookingManager::SetFileName(
|
||||
const G4String& fileName)
|
||||
{
|
||||
for ( auto ntupleBooking : fNtupleBookingVector ) {
|
||||
ntupleBooking->fFileName = fileName;
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleBookingManager::SetFileName(
|
||||
G4int ntupleId, const G4String& fileName)
|
||||
{
|
||||
auto ntupleBooking
|
||||
= GetNtupleBookingInFunction(ntupleId, "SetFileName");
|
||||
if ( ! ntupleBooking ) return;
|
||||
|
||||
// Do nothing if file name does not change
|
||||
if ( ntupleBooking->fFileName == fileName ) return;
|
||||
|
||||
auto ntupleFileName = fileName;
|
||||
auto extension = GetExtension(fileName);
|
||||
if ( extension.size() ) {
|
||||
// Check if valid extension (if present)
|
||||
auto output = G4Analysis::GetOutput(extension);
|
||||
if ( output == G4AnalysisOutput::kNone ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "The file extension " << extension << "is not supported.";
|
||||
G4Exception("G4NtupleBookingManager::SetFileName",
|
||||
"Analysis_W051", JustWarning, description);
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( fFileType.size() ) {
|
||||
//add extension if missing and file type is defined
|
||||
ntupleFileName = fileName + "." + fFileType;
|
||||
}
|
||||
}
|
||||
|
||||
// Save the fileName in booking
|
||||
// If extension is still missing (possible with generic manager),
|
||||
// it will be completed with the default one at OpenFile
|
||||
ntupleBooking->fFileName = ntupleFileName;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4String G4NtupleBookingManager::GetFileName(
|
||||
G4int ntupleId) const
|
||||
{
|
||||
auto ntupleBooking
|
||||
= GetNtupleBookingInFunction(ntupleId, "GetFileName");
|
||||
if ( ! ntupleBooking ) return "";
|
||||
|
||||
return ntupleBooking->fFileName;
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleBookingManager::SetFileType(const G4String& fileType)
|
||||
{
|
||||
// do nothing if file type is defined and is same
|
||||
if ( fFileType == fileType ) return;
|
||||
|
||||
// save the type
|
||||
fFileType = fileType;
|
||||
|
||||
// Give warning and redefine file extension in bookings
|
||||
// with file name of different fileTypes
|
||||
for ( auto ntupleBooking : fNtupleBookingVector ) {
|
||||
|
||||
if ( ! (ntupleBooking->fFileName).size() ) continue;
|
||||
|
||||
auto extension = GetExtension(ntupleBooking->fFileName);
|
||||
if ( fFileType == extension ) continue;
|
||||
|
||||
// multiple file types are not suported
|
||||
auto baseFileName = GetBaseName(ntupleBooking->fFileName);
|
||||
auto ntupleFileName = baseFileName + "." + fFileType;
|
||||
if ( extension.size()) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Writing ntuples in files of different output types "
|
||||
<< fFileType << ", " << extension << " is not supported." << G4endl
|
||||
<< "Ntuple " << ntupleBooking->fNtupleBooking.name()
|
||||
<< " will be written in " << ntupleFileName;
|
||||
G4Exception("G4NtupleBookingManager::SetFileType",
|
||||
"Analysis_W051", JustWarning, description);
|
||||
}
|
||||
|
||||
// Save the info in ntuple description
|
||||
ntupleBooking->fFileName = ntupleFileName;
|
||||
}
|
||||
}
|
||||
@@ -33,23 +33,44 @@
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
using namespace G4Analysis;
|
||||
|
||||
namespace {
|
||||
|
||||
void WrongParametersException(
|
||||
const G4String& commandName, std::size_t got, std::size_t expected)
|
||||
{
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Got wrong number of \"" << commandName
|
||||
<< "\" parameters: " << got << " instead of " << expected
|
||||
<< " expected" << G4endl;
|
||||
G4Exception("G4NtupleMessenger::SetNewValue",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4NtupleMessenger::G4NtupleMessenger(G4VAnalysisManager* manager)
|
||||
: G4UImessenger(),
|
||||
fManager(manager),
|
||||
fSetActivationCmd(nullptr),
|
||||
fSetActivationAllCmd(nullptr)
|
||||
fSetActivationAllCmd(nullptr),
|
||||
fSetFileNameCmd(nullptr),
|
||||
fSetFileNameAllCmd(nullptr)
|
||||
{
|
||||
fNtupleDir = G4Analysis::make_unique<G4UIdirectory>("/analysis/ntuple/");
|
||||
fNtupleDir->SetGuidance("ntuple control");
|
||||
|
||||
SetActivationCmd();
|
||||
SetActivationToAllCmd();
|
||||
SetFileNameCmd();
|
||||
SetFileNameToAllCmd();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -91,6 +112,36 @@ void G4NtupleMessenger::SetActivationToAllCmd()
|
||||
fSetActivationAllCmd->SetParameterName("AllNtupleActivation",false);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleMessenger::SetFileNameCmd()
|
||||
{
|
||||
auto ntupleId = new G4UIparameter("NtupleId", 'i', false);
|
||||
ntupleId->SetGuidance("Ntuple id");
|
||||
ntupleId->SetParameterRange("NtupleId>=0");
|
||||
|
||||
auto ntupleFileName = new G4UIparameter("NtupleFileName", 's', true);
|
||||
ntupleFileName->SetGuidance("Ntuple file name");
|
||||
ntupleFileName->SetDefaultValue("none");
|
||||
|
||||
fSetFileNameCmd = G4Analysis::make_unique<G4UIcommand>("/analysis/ntuple/setFileName", this);
|
||||
G4String guidance("Set file name for the ntuple of given id");
|
||||
|
||||
fSetFileNameCmd->SetGuidance(guidance);
|
||||
fSetFileNameCmd->SetParameter(ntupleId);
|
||||
fSetFileNameCmd->SetParameter(ntupleFileName);
|
||||
fSetFileNameCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4NtupleMessenger::SetFileNameToAllCmd()
|
||||
{
|
||||
fSetFileNameAllCmd
|
||||
= G4Analysis::make_unique<G4UIcmdWithAString>("/analysis/ntuple/setFileNameToAll", this);
|
||||
G4String guidance("Set file name to all ntuples");
|
||||
fSetFileNameAllCmd->SetGuidance(guidance);
|
||||
fSetFileNameAllCmd->SetParameterName("AllNtupleFileName",false);
|
||||
}
|
||||
|
||||
//
|
||||
// public methods
|
||||
//
|
||||
@@ -111,18 +162,33 @@ void G4NtupleMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
|
||||
}
|
||||
else {
|
||||
// Should never happen but let's check anyway for consistency
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Got wrong number of \"" << command->GetCommandName()
|
||||
<< "\" parameters: " << parameters.size()
|
||||
<< " instead of " << command->GetParameterEntries()
|
||||
<< " expected" << G4endl;
|
||||
G4Exception("G4NtupleMessenger::SetNewValue",
|
||||
"Analysis_W013", JustWarning, description);
|
||||
WrongParametersException(command->GetCommandName(),
|
||||
parameters.size(),command->GetParameterEntries());
|
||||
}
|
||||
}
|
||||
else if ( command == fSetActivationAllCmd.get() ) {
|
||||
auto activation = fSetActivationAllCmd->GetNewBoolValue(newValues);
|
||||
fManager->SetNtupleActivation(activation);
|
||||
}
|
||||
}
|
||||
else if ( command == fSetFileNameCmd.get() ) {
|
||||
// tokenize parameters in a vector
|
||||
std::vector<G4String> parameters;
|
||||
G4Analysis::Tokenize(newValues, parameters);
|
||||
// check consistency
|
||||
if ( parameters.size() == command->GetParameterEntries() ) {
|
||||
auto counter = 0;
|
||||
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
|
||||
auto fileName = parameters[counter++];
|
||||
fManager->SetNtupleFileName(id, fileName);
|
||||
}
|
||||
else {
|
||||
// Should never happen but let's check anyway for consistency
|
||||
WrongParametersException(command->GetCommandName(),
|
||||
parameters.size(),command->GetParameterEntries());
|
||||
}
|
||||
}
|
||||
else if ( command == fSetFileNameAllCmd.get() ) {
|
||||
auto fileName = newValues;
|
||||
fManager->SetNtupleFileName(fileName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,7 @@ G4P1Messenger::G4P1Messenger(G4VAnalysisManager* manager)
|
||||
fSetP1TitleCmd(nullptr),
|
||||
fSetP1XAxisCmd(nullptr),
|
||||
fSetP1YAxisCmd(nullptr),
|
||||
fXId(-1),
|
||||
fXData()
|
||||
{
|
||||
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p1");
|
||||
|
||||
@@ -51,7 +51,11 @@ G4P2Messenger::G4P2Messenger(G4VAnalysisManager* manager)
|
||||
fSetP2ZCmd(nullptr),
|
||||
fSetP2TitleCmd(nullptr),
|
||||
fSetP2XAxisCmd(nullptr),
|
||||
fSetP2YAxisCmd(nullptr)
|
||||
fSetP2YAxisCmd(nullptr),
|
||||
fXId(-1),
|
||||
fYId(-1),
|
||||
fXData(),
|
||||
fYData()
|
||||
{
|
||||
fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p2");
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#if defined(TOOLS_USE_FREETYPE)
|
||||
#include <tools/sg/text_freetype>
|
||||
#include <tools/xml/xml_style>
|
||||
#include <tools/xml/wrap_viewplot_style>
|
||||
#include <tools/xml/wrap_viewplot_fonts_google_style>
|
||||
//inlib/xml/viewplot.style file embeded in an inline function.
|
||||
|
||||
namespace {
|
||||
@@ -127,7 +127,7 @@ void regions_style(tools::sg::plots& a_plots,float a_plotter_scale = 1) {
|
||||
bool load_embeded_styles(tools::xml::styles& a_styles) {
|
||||
std::string ss;
|
||||
unsigned int linen;
|
||||
const char** lines = viewplot_style(linen);
|
||||
const char** lines = viewplot_fonts_google_style(linen);
|
||||
for(unsigned int index=0;index<linen;index++) {
|
||||
std::string s = lines[index];
|
||||
tools::replace(s,"@@double_quote@@","\"");
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "G4VP2Manager.hh"
|
||||
#include "G4VNtupleManager.hh"
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4NtupleBookingManager.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
@@ -44,6 +45,7 @@ using namespace G4Analysis;
|
||||
|
||||
namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void NtupleMergingWarning(const G4String& functionName,
|
||||
const G4String& outputType)
|
||||
{
|
||||
@@ -62,6 +64,8 @@ G4VAnalysisManager::G4VAnalysisManager(const G4String& type, G4bool isMaster)
|
||||
: fState(type, isMaster),
|
||||
fVFileManager(nullptr),
|
||||
fPlotManager(nullptr),
|
||||
fNtupleBookingManager(nullptr),
|
||||
fVNtupleManager(nullptr),
|
||||
fMessenger(G4Analysis::make_unique<G4AnalysisMessenger>(this)),
|
||||
fH1HnManager(nullptr),
|
||||
fH2HnManager(nullptr),
|
||||
@@ -72,16 +76,15 @@ G4VAnalysisManager::G4VAnalysisManager(const G4String& type, G4bool isMaster)
|
||||
fVH2Manager(nullptr),
|
||||
fVH3Manager(nullptr),
|
||||
fVP1Manager(nullptr),
|
||||
fVP2Manager(nullptr),
|
||||
fVNtupleManager(nullptr)
|
||||
fVP2Manager(nullptr)
|
||||
{
|
||||
//fMessenger = G4Analysis::make_unique<G4AnalysisMessenger>(this);
|
||||
fNtupleBookingManager = std::make_shared<G4NtupleBookingManager>(fState);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4VAnalysisManager::~G4VAnalysisManager()
|
||||
{
|
||||
delete fVNtupleManager;
|
||||
// delete fVNtupleManager;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -94,7 +97,8 @@ void G4VAnalysisManager::SetH1Manager(G4VH1Manager* h1Manager)
|
||||
fVH1Manager.reset(h1Manager);
|
||||
fH1HnManager = h1Manager->GetHnManager();
|
||||
fMessenger->SetH1HnManager(*fH1HnManager);
|
||||
}
|
||||
if (fVFileManager != nullptr ) fH1HnManager->SetFileManager(fVFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH2Manager(G4VH2Manager* h2Manager)
|
||||
@@ -102,7 +106,8 @@ void G4VAnalysisManager::SetH2Manager(G4VH2Manager* h2Manager)
|
||||
fVH2Manager.reset(h2Manager);
|
||||
fH2HnManager = h2Manager->GetHnManager();
|
||||
fMessenger->SetH2HnManager(*fH2HnManager);
|
||||
}
|
||||
if (fVFileManager != nullptr ) fH2HnManager->SetFileManager(fVFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH3Manager(G4VH3Manager* h3Manager)
|
||||
@@ -110,7 +115,8 @@ void G4VAnalysisManager::SetH3Manager(G4VH3Manager* h3Manager)
|
||||
fVH3Manager.reset(h3Manager);
|
||||
fH3HnManager = h3Manager->GetHnManager();
|
||||
fMessenger->SetH3HnManager(*fH3HnManager);
|
||||
}
|
||||
if (fVFileManager != nullptr ) fH3HnManager->SetFileManager(fVFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP1Manager(G4VP1Manager* p1Manager)
|
||||
@@ -118,7 +124,8 @@ void G4VAnalysisManager::SetP1Manager(G4VP1Manager* p1Manager)
|
||||
fVP1Manager.reset(p1Manager);
|
||||
fP1HnManager = p1Manager->GetHnManager();
|
||||
fMessenger->SetP1HnManager(*fP1HnManager);
|
||||
}
|
||||
if (fVFileManager != nullptr ) fP1HnManager->SetFileManager(fVFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP2Manager(G4VP2Manager* p2Manager)
|
||||
@@ -126,19 +133,27 @@ void G4VAnalysisManager::SetP2Manager(G4VP2Manager* p2Manager)
|
||||
fVP2Manager.reset(p2Manager);
|
||||
fP2HnManager = p2Manager->GetHnManager();
|
||||
fMessenger->SetP2HnManager(*fP2HnManager);
|
||||
}
|
||||
if (fVFileManager != nullptr ) fP2HnManager->SetFileManager(fVFileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetNtupleManager(G4VNtupleManager* ntupleManager)
|
||||
void G4VAnalysisManager::SetNtupleManager(std::shared_ptr<G4VNtupleManager> ntupleManager)
|
||||
{
|
||||
// fVNtupleManager.reset(ntupleManager);
|
||||
fVNtupleManager = ntupleManager;
|
||||
}
|
||||
fVNtupleManager->SetFirstId(fNtupleBookingManager->GetFirstId());
|
||||
fVNtupleManager->SetFirstNtupleColumnId(fNtupleBookingManager->GetFirstNtupleColumnId());
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetFileManager(std::shared_ptr<G4VFileManager> fileManager)
|
||||
{
|
||||
fVFileManager = fileManager;
|
||||
|
||||
if ( fH1HnManager != nullptr ) fH1HnManager->SetFileManager(fileManager);
|
||||
if ( fH2HnManager != nullptr ) fH2HnManager->SetFileManager(fileManager);
|
||||
if ( fH3HnManager != nullptr ) fH3HnManager->SetFileManager(fileManager);
|
||||
if ( fP1HnManager != nullptr ) fP1HnManager->SetFileManager(fileManager);
|
||||
if ( fP2HnManager != nullptr ) fP2HnManager->SetFileManager(fileManager);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -218,7 +233,7 @@ G4bool G4VAnalysisManager::OpenFile(const G4String& fileName)
|
||||
return false;
|
||||
}
|
||||
return OpenFileImpl(fVFileManager->GetFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -753,7 +768,7 @@ G4int G4VAnalysisManager::CreateNtuple(const G4String& name,
|
||||
{
|
||||
if ( ! CheckName(name, "Ntuple") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtuple(name, title);
|
||||
return fNtupleBookingManager->CreateNtuple(name, title);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -761,7 +776,7 @@ G4int G4VAnalysisManager::CreateNtupleIColumn(const G4String& name)
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleIColumn(name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleIColumn(name, 0);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -769,7 +784,7 @@ G4int G4VAnalysisManager::CreateNtupleFColumn(const G4String& name)
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleFColumn(name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleFColumn(name, 0);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -777,7 +792,7 @@ G4int G4VAnalysisManager::CreateNtupleDColumn(const G4String& name)
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleDColumn(name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleDColumn(name, 0);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -785,7 +800,7 @@ G4int G4VAnalysisManager::CreateNtupleSColumn(const G4String& name)
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleSColumn(name);
|
||||
return fNtupleBookingManager->CreateNtupleSColumn(name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -794,7 +809,7 @@ G4int G4VAnalysisManager::CreateNtupleIColumn(const G4String& name,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleIColumn(name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleIColumn(name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -803,7 +818,7 @@ G4int G4VAnalysisManager::CreateNtupleFColumn(const G4String& name,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleFColumn(name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleFColumn(name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -812,13 +827,17 @@ G4int G4VAnalysisManager::CreateNtupleDColumn(const G4String& name,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleDColumn(name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleDColumn(name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::FinishNtuple()
|
||||
{
|
||||
return fVNtupleManager->FinishNtuple();
|
||||
auto ntupleBooking = fNtupleBookingManager->FinishNtuple();
|
||||
|
||||
if ( fVNtupleManager ) {
|
||||
fVNtupleManager->CreateNtuple(ntupleBooking);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -865,7 +884,7 @@ G4int G4VAnalysisManager::CreateNtupleIColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleIColumn(ntupleId, name, 0);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -874,7 +893,7 @@ G4int G4VAnalysisManager::CreateNtupleFColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleFColumn(ntupleId, name, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -884,7 +903,7 @@ G4int G4VAnalysisManager::CreateNtupleDColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, 0);
|
||||
return fNtupleBookingManager->CreateNtupleDColumn(ntupleId, name, 0);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -893,7 +912,7 @@ G4int G4VAnalysisManager::CreateNtupleSColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleSColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleSColumn(ntupleId, name);
|
||||
return fNtupleBookingManager->CreateNtupleSColumn(ntupleId, name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -903,7 +922,7 @@ G4int G4VAnalysisManager::CreateNtupleIColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleIColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleIColumn(ntupleId, name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleIColumn(ntupleId, name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -913,7 +932,7 @@ G4int G4VAnalysisManager::CreateNtupleFColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleFColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleFColumn(ntupleId, name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleFColumn(ntupleId, name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -923,13 +942,17 @@ G4int G4VAnalysisManager::CreateNtupleDColumn(G4int ntupleId,
|
||||
{
|
||||
if ( ! CheckName(name, "NtupleDColumn") ) return kInvalidId;
|
||||
|
||||
return fVNtupleManager->CreateNtupleDColumn(ntupleId, name, &vector);
|
||||
return fNtupleBookingManager->CreateNtupleDColumn(ntupleId, name, &vector);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::FinishNtuple(G4int ntupleId)
|
||||
{
|
||||
return fVNtupleManager->FinishNtuple(ntupleId);
|
||||
auto ntupleBooking = fNtupleBookingManager->FinishNtuple(ntupleId);
|
||||
|
||||
if ( fVNtupleManager ) {
|
||||
fVNtupleManager->CreateNtuple(ntupleBooking);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -996,13 +1019,33 @@ G4bool G4VAnalysisManager::SetFirstP2Id(G4int firstId)
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4VAnalysisManager::SetFirstNtupleId(G4int firstId)
|
||||
{
|
||||
return fVNtupleManager->SetFirstId(firstId);
|
||||
auto finalResult = true;
|
||||
|
||||
auto result = fNtupleBookingManager->SetFirstId(firstId);
|
||||
finalResult = finalResult && result;
|
||||
|
||||
if ( fVNtupleManager ) {
|
||||
result = fVNtupleManager->SetFirstId(firstId);
|
||||
finalResult = finalResult && result;
|
||||
}
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4VAnalysisManager::SetFirstNtupleColumnId(G4int firstId)
|
||||
{
|
||||
return fVNtupleManager->SetFirstNtupleColumnId(firstId);
|
||||
auto finalResult = true;
|
||||
|
||||
auto result = fNtupleBookingManager->SetFirstNtupleColumnId(firstId);
|
||||
finalResult = finalResult && result;
|
||||
|
||||
if ( fVNtupleManager ) {
|
||||
result = fVNtupleManager->SetFirstNtupleColumnId(firstId);
|
||||
finalResult = finalResult && result;
|
||||
}
|
||||
|
||||
return finalResult;
|
||||
}
|
||||
|
||||
// Fill methods in .icc
|
||||
@@ -1098,7 +1141,7 @@ G4int G4VAnalysisManager::GetFirstNtupleId() const
|
||||
{
|
||||
// Return first Ntuple id
|
||||
|
||||
return fVNtupleManager->GetFirstId();
|
||||
return fNtupleBookingManager->GetFirstId();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -1106,7 +1149,7 @@ G4int G4VAnalysisManager::GetFirstNtupleColumnId() const
|
||||
{
|
||||
// Return first Ntuple column id
|
||||
|
||||
return fVNtupleManager->GetFirstNtupleColumnId();
|
||||
return fNtupleBookingManager->GetFirstNtupleColumnId();
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -1175,6 +1218,12 @@ void G4VAnalysisManager::SetH1Plotting(G4int id, G4bool plotting)
|
||||
fH1HnManager->SetPlotting(id, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH1FileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
fH1HnManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH2Activation(G4int id, G4bool activation)
|
||||
{
|
||||
@@ -1203,6 +1252,12 @@ void G4VAnalysisManager::SetH2Plotting(G4int id, G4bool plotting)
|
||||
fH2HnManager->SetPlotting(id, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH2FileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
fH2HnManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH3Activation(G4int id, G4bool activation)
|
||||
{
|
||||
@@ -1231,6 +1286,12 @@ void G4VAnalysisManager::SetH3Plotting(G4int id, G4bool plotting)
|
||||
fH3HnManager->SetPlotting(id, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetH3FileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
fH3HnManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP1Activation(G4int id, G4bool activation)
|
||||
{
|
||||
@@ -1259,6 +1320,12 @@ void G4VAnalysisManager::SetP1Plotting(G4int id, G4bool plotting)
|
||||
fP1HnManager->SetPlotting(id, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP1FileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
fP1HnManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP2Activation(G4int id, G4bool activation)
|
||||
{
|
||||
@@ -1287,21 +1354,49 @@ void G4VAnalysisManager::SetP2Plotting(G4int id, G4bool plotting)
|
||||
fP2HnManager->SetPlotting(id, plotting);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetP2FileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
fP2HnManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetNtupleActivation(G4int id, G4bool activation)
|
||||
{
|
||||
// Set activation to a given P2 object
|
||||
// Set activation to a given ntuple object
|
||||
|
||||
fVNtupleManager->SetActivation(id, activation);
|
||||
}
|
||||
fNtupleBookingManager->SetActivation(id, activation);
|
||||
if ( fVNtupleManager ) {
|
||||
fVNtupleManager->SetActivation(id, activation);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetNtupleActivation(G4bool activation)
|
||||
{
|
||||
// Set activation to all ntuple objects
|
||||
|
||||
fNtupleBookingManager->SetActivation(activation);
|
||||
if ( fVNtupleManager ) {
|
||||
fVNtupleManager->SetActivation(activation);
|
||||
}
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetNtupleFileName(G4int id, const G4String& fileName)
|
||||
{
|
||||
// Set activation to a given P2 object
|
||||
|
||||
fNtupleBookingManager->SetFileName(id, fileName);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VAnalysisManager::SetNtupleFileName(const G4String& fileName)
|
||||
{
|
||||
// Set activation to all P2 objects
|
||||
|
||||
fVNtupleManager->SetActivation(activation);
|
||||
}
|
||||
fNtupleBookingManager->SetFileName(fileName);
|
||||
}
|
||||
|
||||
// Access methods in .icc
|
||||
|
||||
|
||||
@@ -28,18 +28,22 @@
|
||||
|
||||
#include "G4VFileManager.hh"
|
||||
#include "G4AnalysisManagerState.hh"
|
||||
#include "G4AnalysisUtilities.hh"
|
||||
|
||||
#include "G4Threading.hh"
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4VFileManager::G4VFileManager(const G4AnalysisManagerState& state)
|
||||
: G4BaseFileManager(state),
|
||||
fIsOpenFile(false),
|
||||
fHistoDirectoryName(""),
|
||||
fNtupleDirectoryName(""),
|
||||
fLockFileName(false),
|
||||
fLockHistoDirectoryName(false),
|
||||
fLockNtupleDirectoryName(false)
|
||||
fIsOpenFile(false),
|
||||
fLockDirectoryNames(false),
|
||||
fH1FileManager(nullptr),
|
||||
fH2FileManager(nullptr),
|
||||
fH3FileManager(nullptr),
|
||||
fP1FileManager(nullptr),
|
||||
fP2FileManager(nullptr)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
@@ -53,22 +57,28 @@ G4VFileManager::~G4VFileManager()
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4VFileManager::SetFileName(const G4String& fileName)
|
||||
{
|
||||
if ( fLockFileName ) {
|
||||
// Check extension
|
||||
auto name = fileName;
|
||||
auto extension = G4Analysis::GetExtension(fileName);
|
||||
if ( extension.size() && GetFileType().size() && extension != GetFileType() ) {
|
||||
// replace extension
|
||||
name = G4Analysis::GetBaseName(fileName) + "." + GetFileType();
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set File name as its value was already used.";
|
||||
<< fileName << " file extension is not valid for "
|
||||
<< GetFileType() << " output." << G4endl
|
||||
<< name << " will be used.";
|
||||
G4Exception("G4VFileManager::SetFileName()",
|
||||
"Analysis_W012", JustWarning, description);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return G4BaseFileManager::SetFileName(fileName);
|
||||
}
|
||||
return G4BaseFileManager::SetFileName(name);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4VFileManager::SetHistoDirectoryName(const G4String& dirName)
|
||||
{
|
||||
if ( fLockHistoDirectoryName ) {
|
||||
if ( fLockDirectoryNames ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set Histo directory name as its value was already used.";
|
||||
@@ -84,7 +94,7 @@ G4bool G4VFileManager::SetHistoDirectoryName(const G4String& dirName)
|
||||
//_____________________________________________________________________________
|
||||
G4bool G4VFileManager::SetNtupleDirectoryName(const G4String& dirName)
|
||||
{
|
||||
if ( fLockNtupleDirectoryName ) {
|
||||
if ( fLockDirectoryNames ) {
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< "Cannot set Ntuple directory name as its value was already used.";
|
||||
@@ -95,4 +105,4 @@ G4bool G4VFileManager::SetNtupleDirectoryName(const G4String& dirName)
|
||||
|
||||
fNtupleDirectoryName = dirName;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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 "G4VNtupleFileManager.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace {
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void NtupleMergingWarning(const G4String& functionName,
|
||||
const G4String& outputType)
|
||||
{
|
||||
G4ExceptionDescription description;
|
||||
description
|
||||
<< " " << "Ntuple merging is not available with "
|
||||
<< outputType << " output." << G4endl
|
||||
<< " " << "Setting is ignored.";
|
||||
G4Exception(functionName, "Analysis_W041", JustWarning, description);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4VNtupleFileManager::G4VNtupleFileManager(const G4AnalysisManagerState& state,
|
||||
const G4String& fileType)
|
||||
: fState(state),
|
||||
fFileType(fileType),
|
||||
fBookingManager(nullptr)
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
G4VNtupleFileManager::~G4VNtupleFileManager()
|
||||
{}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VNtupleFileManager::SetNtupleMerging(G4bool /*mergeNtuples*/,
|
||||
G4int /*nofReducedNtupleFiles*/)
|
||||
{
|
||||
// The function is overridden in the managers which supports ntuple merging
|
||||
// Here we give just a warning that the feature is not available.
|
||||
|
||||
NtupleMergingWarning("G4VNtupleFileManager::SetNtupleMerging", fFileType);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VNtupleFileManager::SetNtupleRowWise(G4bool /*rowWise*/,
|
||||
G4bool /*rowMode*/)
|
||||
{
|
||||
// The function is overridden in the managers which supports ntuple merging
|
||||
// Here we give just a warning that the feature is not available.
|
||||
|
||||
NtupleMergingWarning("G4VNtupleFileManager::SetNtupleRowWise", fFileType);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VNtupleFileManager::SetBasketSize(unsigned int /*basketSize*/)
|
||||
{
|
||||
// The function is overridden in the managers which supports ntuple merging
|
||||
// Here we give just a warning that the feature is not available.
|
||||
|
||||
NtupleMergingWarning("G4VNtupleFileManager::SetBasketSize", fFileType);
|
||||
}
|
||||
|
||||
//_____________________________________________________________________________
|
||||
void G4VNtupleFileManager::SetBasketEntries(unsigned int /*basketEntries*/)
|
||||
{
|
||||
// The function is overridden in the managers which supports ntuple merging
|
||||
// Here we give just a warning that the feature is not available.
|
||||
|
||||
NtupleMergingWarning("G4VNtupleFileManager::SetBasketEntries", fFileType);
|
||||
}
|
||||
Reference in New Issue
Block a user