Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -67,6 +67,14 @@ G4AnalysisMessenger::G4AnalysisMessenger(G4VAnalysisManager* manager)
"list", "List all/activate analysis objects.", "OnlyIfActive", true);
fListCmd->SetDefaultValue(true);
fSetDefaultFileTypeCmd = CreateCommand<G4UIcmdWithAString>(
"setDefaultFileType", "Set default output file type", "DefaultFileType", false);
#ifdef TOOLS_USE_HDF5
fSetDefaultFileTypeCmd->SetCandidates("csv hdf5 root xml");
#else
fSetDefaultFileTypeCmd->SetCandidates("csv root xml");
#endif
fSetActivationCmd = CreateCommand<G4UIcmdWithABool>(
"setActivation",
"Set activation. \n"
@@ -150,6 +158,11 @@ void G4AnalysisMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
return;
}
if ( command == fSetDefaultFileTypeCmd.get() ) {
fManager->SetDefaultFileType(newValues);
return;
}
if ( command == fSetActivationCmd.get() ) {
fManager->SetActivation(fSetActivationCmd->GetNewBoolValue(newValues));
return;
@@ -56,7 +56,7 @@ void G4BaseFileManager::AddFileName(const G4String& fileName)
//_____________________________________________________________________________
G4String G4BaseFileManager::GetFileType() const
{
return G4StrUtil::to_lower_copy(fState.GetType());
return fState.GetFileType();
}
//_____________________________________________________________________________
+62 -9
View File
@@ -40,9 +40,7 @@ using std::to_string;
//_____________________________________________________________________________
G4HnManager::G4HnManager(G4String hnType, const G4AnalysisManagerState& state)
: G4BaseAnalysisManager(state), fHnType(std::move(hnType))
{
fMessenger = std::make_unique<G4HnMessenger>(*this);
}
{}
//_____________________________________________________________________________
G4HnManager::~G4HnManager()
@@ -96,10 +94,28 @@ void G4HnManager::SetFileName(G4HnInformation* info, const G4String& fileName)
// Do nothing if file name does not change
if ( info->GetFileName() == fileName ) return;
auto hnFileName = fileName;
auto extension = GetExtension(fileName);
if (extension.size() != 0u) {
// Check if valid extension (if present)
auto output = G4Analysis::GetOutput(extension);
if ( output == G4AnalysisOutput::kNone ) {
Warn("The file extension " + extension + " is not supported.",
fkClass, "SetFileName");
return;
}
}
else {
if (fDefaultFileType.size() != 0u) {
//add extension if missing and file type is defined
hnFileName = fileName + "." + fDefaultFileType;
}
}
// Save the info and account a new file name if file manager
info->SetFileName(fileName);
info->SetFileName(hnFileName);
if (fFileManager) {
fFileManager->AddFileName(fileName);
fFileManager->AddFileName(hnFileName);
} else {
Warn("Failed to set fileName " + fileName +
" for object " + info->GetName() + ".\nFile manager is not set.",
@@ -107,7 +123,7 @@ void G4HnManager::SetFileName(G4HnInformation* info, const G4String& fileName)
return;
}
if ( fileName != "" ) {
if ( hnFileName != "" ) {
fNofFileNameObjects++;
} else {
fNofFileNameObjects--;
@@ -119,13 +135,50 @@ void G4HnManager::SetFileName(G4HnInformation* info, const G4String& fileName)
//
//_____________________________________________________________________________
G4HnInformation* G4HnManager::AddHnInformation(const G4String& name, G4int nofDimensions)
void G4HnManager::CreateMessenger()
{
auto info = new G4HnInformation(name, nofDimensions);
fMessenger = std::make_unique<G4HnMessenger>(*this);
}
//_____________________________________________________________________________
void G4HnManager::AddHnInformation(G4HnInformation* info)
{
// Add new information
fHnVector.push_back(info);
++fNofActiveObjects;
}
return info;
//_____________________________________________________________________________
void G4HnManager::AddHnInformation(G4HnInformation* info, G4int index)
{
// Replace the information at 'index' position with new one.
// Update new information with the previous one settings if the
// previous histogram was deleted with 'keepSetting' set true.
auto previousInfo = fHnVector[index];
if (previousInfo->GetDeletedPair().second) {
info->Update(*previousInfo);
}
delete previousInfo;
fHnVector[index] = info;
if (info->GetActivation()) { ++fNofActiveObjects; }
if (info->GetAscii()) { ++fNofAsciiObjects; }
if (info->GetPlotting()) { ++fNofPlottingObjects; }
if (! info->GetFileName().empty()) { ++fNofFileNameObjects; }
}
//_____________________________________________________________________________
void G4HnManager::SetHnDeleted(G4HnInformation* info, G4bool keepSetting)
{
info->SetDeleted(true, keepSetting);
if (info->GetActivation()) { --fNofActiveObjects; }
if (info->GetAscii()) { --fNofAsciiObjects; }
if (info->GetPlotting()) { --fNofPlottingObjects; }
if (! info->GetFileName().empty()) { --fNofFileNameObjects; }
}
//_____________________________________________________________________________
@@ -28,16 +28,20 @@
#include "G4HnMessenger.hh"
#include "G4HnManager.hh"
#include "G4AnalysisUtilities.hh"
#include "G4UIcommand.hh"
#include "G4UIparameter.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithAString.hh"
using namespace G4Analysis;
//_____________________________________________________________________________
G4HnMessenger::G4HnMessenger(G4HnManager& manager)
: fManager(manager),
fHnType(manager.GetHnType())
fHnType(manager.GetHnType()),
fHnDimension(std::stoi(manager.GetHnType().substr(1,1)))
{
SetHnAsciiCmd();
SetHnActivationCmd();
@@ -46,6 +50,11 @@ G4HnMessenger::G4HnMessenger(G4HnManager& manager)
SetHnPlottingToAllCmd();
SetHnFileNameCmd();
SetHnFileNameToAllCmd();
auto maxDim = (fHnDimension < kMaxDim) ? fHnDimension + 1 : kMaxDim;
for (unsigned int idim = 0; idim < maxDim; ++idim) {
fSetAxisLogCmd.push_back(CreateSetAxisLogCommand(idim));
}
}
//_____________________________________________________________________________
@@ -154,6 +163,30 @@ void G4HnMessenger::SetHnFileNameToAllCmd()
fSetFileNameAllCmd->SetParameterName("FileName", false);
}
//_____________________________________________________________________________
std::unique_ptr<G4UIcommand>
G4HnMessenger::CreateSetAxisLogCommand(unsigned int idim)
{
G4String xyz{"XYZ"};
auto axis = xyz.substr(idim, 1);
G4String commandName = "set" + axis + "axisLog";
G4String guidance = "Activate " + axis + "-axis log scale for plotting of the ";
auto command = CreateCommand<G4UIcommand>(commandName, guidance);
command->AvailableForStates(G4State_PreInit, G4State_Idle);
// Add Id parameter
AddIdParameter(*command);
auto parAxisLog = new G4UIparameter("axis", 'b', false);
guidance = GetObjectType() + " " + axis + "-axis log scale";
parAxisLog->SetGuidance(guidance.c_str());
command->SetParameter(parAxisLog);
return command;
}
//
// public methods
//
@@ -213,4 +246,13 @@ void G4HnMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
fManager.SetFileName(id, parameters[counter++]);
return;
}
auto maxDim = (fHnDimension < kMaxDim) ? fHnDimension + 1 : kMaxDim;
for (unsigned int idim = 0; idim < maxDim; ++idim) {
if ( command == fSetAxisLogCmd[idim].get() ) {
auto axisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager.SetAxisIsLog(idim, id, axisLog);
return;
}
}
}
@@ -98,23 +98,37 @@ G4int G4NtupleBookingManager::CreateNtuple(
Message(kVL4, "create", "ntuple booking", name);
// Create ntuple description
auto index = fNtupleBookingVector.size();
auto ntupleBooking = new G4NtupleBooking();
fNtupleBookingVector.push_back(ntupleBooking);
G4int index = 0;
G4NtupleBooking* ntupleBooking = nullptr;
if (fFreeIds.empty()) {
index = (G4int)fNtupleBookingVector.size();
ntupleBooking = new G4NtupleBooking();
fNtupleBookingVector.push_back(ntupleBooking);
ntupleBooking->fNtupleId = G4int(index + fFirstId);
}
else {
// Get the first freed Id
index = *(fFreeIds.begin()) - GetFirstId();
ntupleBooking = fNtupleBookingVector[index];
ntupleBooking->fNtupleBooking = tools::ntuple_booking();
ntupleBooking->Reset();
// Remove the id from the set
fFreeIds.erase(fFreeIds.begin());
}
// Save name & title in ntuple booking
ntupleBooking->fNtupleBooking.set_name(name);
ntupleBooking->fNtupleBooking.set_title(title);
ntupleBooking->fNtupleId = G4int(index + fFirstId);
// Create ntuple
// Update related data
fLockFirstId = true;
fCurrentNtupleId = ntupleBooking->fNtupleId;
Message(kVL2, "create", "ntuple booking",
name + " ntupleId " + to_string(ntupleBooking->fNtupleId));
return ntupleBooking->fNtupleId;
return fCurrentNtupleId;
}
//_____________________________________________________________________________
@@ -298,6 +312,89 @@ void G4NtupleBookingManager::ClearData()
Message(G4Analysis::kVL2, "clear", "ntupleBookings");
}
//_____________________________________________________________________________
G4bool G4NtupleBookingManager::Delete(G4int id, G4bool keepSetting)
{
Message(kVL4, "delete", "ntuple booking ntupleId " + to_string(id));
auto ntupleBooking = GetNtupleBookingInFunction(id, "Delete", true);
if (ntupleBooking == nullptr) return false;
// Update ntuple booking
ntupleBooking->SetDeleted(true, keepSetting);
// Register freed Id
fFreeIds.insert(id);
Message(G4Analysis::kVL2, "delete", "ntuple booking ntupleId " + to_string(id));
return true;
}
//_____________________________________________________________________________
G4bool G4NtupleBookingManager::List(std::ostream& output, G4bool onlyIfActive)
{
// Save current output stream formatting
std::ios_base::fmtflags outputFlags(output.flags() );
// Define optimal field widths
size_t maxNameLength = 0;
size_t maxTitleLength = 0;
// size_t maxEntries = 0;
size_t nofActive = 0;
for (auto g4NtupleBooking : fNtupleBookingVector) {
const auto& ntupleBooking = g4NtupleBooking->fNtupleBooking;
if (ntupleBooking.name().length() > maxNameLength) {
maxNameLength = ntupleBooking.name().length();
}
if (ntupleBooking.title().length() > maxTitleLength) {
maxTitleLength = ntupleBooking.title().length();
}
// if (ntuple->entries() > maxEntries) {
// maxEntries = ntuple->entries();
// }
if (g4NtupleBooking->fActivation) {
++nofActive;
}
}
size_t maxIdWidth = std::to_string(fNtupleBookingVector.size() + GetFirstId()).length();
// update strings width for added double quotas
maxNameLength += 2;
maxTitleLength += 2;
// List general info
output << "Ntuple: " << nofActive << " active ";
if (! onlyIfActive) {
output << " of " << GetNofNtuples(true) << " defined ";
}
output << G4endl;
// List objects
G4int counter = 0;
for (auto g4NtupleBooking : fNtupleBookingVector) {
const auto& ntupleBooking = g4NtupleBooking->fNtupleBooking;
// skip inactivated objcets
if (fState.GetIsActivation() && onlyIfActive && (! g4NtupleBooking->fActivation)) continue;
// print selected info
output << " id: " << std::setw((G4int)maxIdWidth) << GetFirstId() + counter++
<< " name: \"" << std::setw((G4int)maxNameLength) << std::left << ntupleBooking.name() + "\""
<< " title: \"" << std::setw((G4int)maxTitleLength) << std::left << ntupleBooking.title() + "\"";
// << " entries: " << std::setw((G4int)maxEntriesWidth) << ntuple->entries();
if (! onlyIfActive) {
output << " active: " << std::boolalpha << g4NtupleBooking->fActivation;
}
output << G4endl;
}
// Restore the output stream formatting
output.flags(outputFlags);
return output.good();
}
//
// public methods
//
@@ -332,3 +429,24 @@ void G4NtupleBookingManager::SetFileType(const G4String& fileType)
ntupleBooking->fFileName = ntupleFileName;
}
}
//_____________________________________________________________________________
tools::ntuple_booking* G4NtupleBookingManager::GetNtuple(
G4bool warn, G4bool onlyIfActive) const
{
return GetNtuple(fFirstId, warn, onlyIfActive);
}
//_____________________________________________________________________________
tools::ntuple_booking* G4NtupleBookingManager::GetNtuple(
G4int ntupleId, G4bool warn, G4bool onlyIfActive) const
{
auto g4Booking = GetNtupleBookingInFunction(ntupleId, "GetNtuple", warn);
if (g4Booking == nullptr) return nullptr;
if ( ( g4Booking->GetDeleted() ) ||
( onlyIfActive && (! g4Booking->fActivation) ) ) return nullptr;
return &(g4Booking->fNtupleBooking);
}
@@ -34,6 +34,7 @@
#include "G4UIparameter.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithoutParameter.hh"
using namespace G4Analysis;
using std::to_string;
@@ -45,6 +46,10 @@ G4NtupleMessenger::G4NtupleMessenger(G4VAnalysisManager* manager)
fNtupleDir = std::make_unique<G4UIdirectory>("/analysis/ntuple/");
fNtupleDir->SetGuidance("ntuple control");
CreateCmd();
CreateColumnCmds();
FinishCmd();
DeleteCmd();
SetActivationCmd();
SetActivationToAllCmd();
SetFileNameCmd();
@@ -69,11 +74,65 @@ void G4NtupleMessenger::AddIdParameter(G4UIcommand& command)
command.SetParameter(ntupleId);
}
//_____________________________________________________________________________
void G4NtupleMessenger::CreateCmd()
{
fCreateCmd = CreateCommand<G4UIcommand>("create", "Create ntuple");
auto ntName = new G4UIparameter("name", 's', false);
ntName->SetGuidance("Ntuple name");
fCreateCmd->SetParameter(ntName);
auto ntTitle = new G4UIparameter("title", 's', false);
ntTitle->SetGuidance("Ntuple title");
fCreateCmd->SetParameter(ntTitle);
}
//_____________________________________________________________________________
void G4NtupleMessenger::CreateColumnCmds()
{
std::vector<char> colTypes = {'I', 'F', 'D', 'S'};
for (auto colType : colTypes ) {
G4String name = "createColumn";
G4String guidance = "Create ntuple column";
name.insert(6, 1, colType);
guidance.insert(7, 1, colType);
auto cmd = CreateCommand<G4UIcmdWithAString>(name, guidance);
fCreateColumnCmds[colType] = std::move(cmd);
}
}
//_____________________________________________________________________________
void G4NtupleMessenger::FinishCmd()
{
fFinishCmd = CreateCommand<G4UIcmdWithoutParameter>(
"finish", "Finish creating ntuple");
}
//_____________________________________________________________________________
void G4NtupleMessenger::DeleteCmd()
{
fDeleteCmd = CreateCommand<G4UIcommand>(
"delete", "Delete ntuple with given id");
// Add Id parameter
AddIdParameter(*fDeleteCmd);
auto parKeepSetting = new G4UIparameter("keepSetting", 'b', true);
G4String guidance =
"If set true, activation, file name, etc. options will be kept\n"
"and applied when a new object with the same id is created.";
parKeepSetting->SetGuidance(guidance.c_str());
parKeepSetting->SetDefaultValue("false");
fDeleteCmd->SetParameter(parKeepSetting);
}
//_____________________________________________________________________________
void G4NtupleMessenger::SetActivationCmd()
{
fSetActivationCmd = CreateCommand<G4UIcommand>(
"setActivation", "Set activation for the ntuple");
"setActivation", "Set activation for the ntuple with given id");
AddIdParameter(*fSetActivationCmd);
@@ -95,7 +154,7 @@ void G4NtupleMessenger::SetActivationToAllCmd()
void G4NtupleMessenger::SetFileNameCmd()
{
fSetFileNameCmd = CreateCommand<G4UIcommand>(
"setFileName", "Set file name for the ntuple");
"setFileName", "Set file name for the ntuple with given id");
AddIdParameter(*fSetFileNameCmd);
@@ -158,8 +217,54 @@ void G4NtupleMessenger::SetNewValue(G4UIcommand* command, G4String newValues)
}
auto counter = 0;
// commands without Id parameter
if ( command == fCreateCmd.get() ) {
auto name = parameters[counter++];
auto title = parameters[counter++];
fTmpNtupleId = fManager->CreateNtuple(name, title);
return;
}
for (const auto& [colType, checkCommand] : fCreateColumnCmds) {
if ( command == checkCommand.get() ) {
auto name = parameters[counter++];
switch (colType) {
case 'I':
fManager->CreateNtupleIColumn(fTmpNtupleId, name);
return;
case 'F':
fManager->CreateNtupleFColumn(fTmpNtupleId, name);
return;
case 'D':
fManager->CreateNtupleDColumn(fTmpNtupleId, name);
return;
case 'S':
fManager->CreateNtupleSColumn(fTmpNtupleId, name);
return;
default:
return;
}
}
}
if ( command == fFinishCmd.get() ) {
fManager->FinishNtuple(fTmpNtupleId);
fTmpNtupleId = G4Analysis::kInvalidId;
return;
}
// commands with Id parameter
auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
if ( command == fDeleteCmd.get() ) {
auto keepSetting = G4UIcommand::ConvertToBool(parameters[counter++]);
fManager->DeleteNtuple(id, keepSetting);
return;
}
if ( command == fSetActivationCmd.get() ) {
fManager->SetNtupleActivation(id, G4UIcommand::ConvertToBool(parameters[counter++]));
return;
@@ -28,7 +28,6 @@
#include "G4VAnalysisManager.hh"
#include "G4AnalysisMessenger.hh"
#include "G4AnalysisUtilities.hh"
#include "G4HnManager.hh"
#include "G4VNtupleManager.hh"
#include "G4VNtupleFileManager.hh"
@@ -175,12 +174,38 @@ G4bool G4VAnalysisManager::ResetFromUI()
// protected methods
//
//_____________________________________________________________________________
void G4VAnalysisManager::SetDefaultFileTypeImpl(const G4String& value)
{
if ( (! GetType().empty()) && (GetFileType() != value) ) {
// If not generic analysis manager (which does not define FileType)
// the file type cannot be different from the analysis manager type
Warn("Cannot set default file type " + value +
" different than the analysis manager type " + GetType(),
fkClass, "SetDefault");
return;
}
fH1HnManager->SetDefaultFileType(value);
fH2HnManager->SetDefaultFileType(value);
fH3HnManager->SetDefaultFileType(value);
fP1HnManager->SetDefaultFileType(value);
fP2HnManager->SetDefaultFileType(value);
}
//_____________________________________________________________________________
G4String G4VAnalysisManager::GetDefaultFileTypeImpl() const
{
return GetFileType();
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetH1Manager(G4VTBaseHnManager<kDim1>* h1Manager)
{
fVH1Manager.reset(h1Manager);
fH1HnManager = h1Manager->GetHnManager();
if (fVFileManager != nullptr ) fH1HnManager->SetFileManager(fVFileManager);
if (! GetFileType().empty() ) fH1HnManager->SetDefaultFileType(GetFileType());
}
//_____________________________________________________________________________
@@ -189,6 +214,7 @@ void G4VAnalysisManager::SetH2Manager(G4VTBaseHnManager<kDim2>* h2Manager)
fVH2Manager.reset(h2Manager);
fH2HnManager = h2Manager->GetHnManager();
if (fVFileManager != nullptr ) fH2HnManager->SetFileManager(fVFileManager);
if (! GetFileType().empty() ) fH2HnManager->SetDefaultFileType(GetFileType());
}
//_____________________________________________________________________________
@@ -197,6 +223,7 @@ void G4VAnalysisManager::SetH3Manager(G4VTBaseHnManager<kDim3>* h3Manager)
fVH3Manager.reset(h3Manager);
fH3HnManager = h3Manager->GetHnManager();
if (fVFileManager != nullptr ) fH3HnManager->SetFileManager(fVFileManager);
if (! GetFileType().empty() ) fH3HnManager->SetDefaultFileType(GetFileType());
}
//_____________________________________________________________________________
@@ -205,6 +232,7 @@ void G4VAnalysisManager::SetP1Manager(G4VTBaseHnManager<kDim2>* p1Manager)
fVP1Manager.reset(p1Manager);
fP1HnManager = p1Manager->GetHnManager();
if (fVFileManager != nullptr ) fP1HnManager->SetFileManager(fVFileManager);
if (! GetFileType().empty() ) fP1HnManager->SetDefaultFileType(GetFileType());
}
//_____________________________________________________________________________
@@ -213,6 +241,7 @@ void G4VAnalysisManager::SetP2Manager(G4VTBaseHnManager<kDim3>* p2Manager)
fVP2Manager.reset(p2Manager);
fP2HnManager = p2Manager->GetHnManager();
if (fVFileManager != nullptr ) fP2HnManager->SetFileManager(fVFileManager);
if (! GetFileType().empty() ) fP2HnManager->SetDefaultFileType(GetFileType());
}
//_____________________________________________________________________________
@@ -394,6 +423,18 @@ G4bool G4VAnalysisManager::IsOpenFile() const
return IsOpenFileImpl();
}
//_____________________________________________________________________________
void G4VAnalysisManager::SetDefaultFileType(const G4String& value)
{
SetDefaultFileTypeImpl(value);
}
//_____________________________________________________________________________
G4String G4VAnalysisManager::GetDefaultFileType() const
{
return GetDefaultFileTypeImpl();
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::SetFileName(const G4String& fileName)
{
@@ -415,7 +456,7 @@ G4bool G4VAnalysisManager::SetNtupleDirectoryName(const G4String& dirName)
//_____________________________________________________________________________
void G4VAnalysisManager::SetCompressionLevel(G4int level)
{
fState.SetCompressionLevel(level);
fVFileManager->SetCompressionLevel(level);
}
//_____________________________________________________________________________
@@ -439,7 +480,7 @@ G4String G4VAnalysisManager::GetNtupleDirectoryName() const
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetCompressionLevel() const
{
return fState.GetCompressionLevel();
return fVFileManager->GetCompressionLevel();
}
//_____________________________________________________________________________
@@ -1210,43 +1251,39 @@ G4int G4VAnalysisManager::GetFirstNtupleColumnId() const
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofH1s() const
G4int G4VAnalysisManager::GetNofH1s(G4bool onlyIfExist) const
{
return fH1HnManager->GetNofHns();
return fVH1Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofH2s() const
G4int G4VAnalysisManager::GetNofH2s(G4bool onlyIfExist) const
{
return fH2HnManager->GetNofHns();
return fVH2Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofH3s() const
G4int G4VAnalysisManager::GetNofH3s(G4bool onlyIfExist) const
{
return fH3HnManager->GetNofHns();
return fVH3Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofP1s() const
G4int G4VAnalysisManager::GetNofP1s(G4bool onlyIfExist) const
{
return fP1HnManager->GetNofHns();
return fVP1Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofP2s() const
G4int G4VAnalysisManager::GetNofP2s(G4bool onlyIfExist) const
{
return fP2HnManager->GetNofHns();
return fVP2Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisManager::GetNofNtuples() const
G4int G4VAnalysisManager::GetNofNtuples(G4bool onlyIfExist) const
{
if (fVNtupleManager != nullptr) {
return fVNtupleManager->GetNofNtuples();
}
return 0;
return fNtupleBookingManager->GetNofNtuples(onlyIfExist);
}
// GetH1Id(), GetH2Id in .icc
@@ -1284,10 +1321,7 @@ G4bool G4VAnalysisManager::ListP2(G4bool onlyIfActive) const
//_____________________________________________________________________________
G4bool G4VAnalysisManager::ListNtuple(G4bool onlyIfActive) const
{
if (fVNtupleManager != nullptr) {
return fVNtupleManager->List(G4cout, onlyIfActive);
}
return false;
return fNtupleBookingManager->List(G4cout, onlyIfActive);
}
//_____________________________________________________________________________
@@ -1512,6 +1546,48 @@ void G4VAnalysisManager::SetNtupleFileName(const G4String& fileName)
fNtupleBookingManager->SetFileName(fileName);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteH1(G4int id, G4bool keepSetting)
{
return fVH1Manager->Delete(id, keepSetting);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteH2(G4int id, G4bool keepSetting)
{
return fVH2Manager->Delete(id, keepSetting);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteH3(G4int id, G4bool keepSetting)
{
return fVH3Manager->Delete(id, keepSetting);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteP1(G4int id, G4bool keepSetting)
{
return fVP1Manager->Delete(id, keepSetting);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteP2(G4int id, G4bool keepSetting)
{
return fVP2Manager->Delete(id, keepSetting);
}
//_____________________________________________________________________________
G4bool G4VAnalysisManager::DeleteNtuple(G4int id, G4bool keepSetting)
{
auto result = fNtupleBookingManager->Delete(id, keepSetting);
if (fVNtupleManager != nullptr) {
result &= fVNtupleManager->Delete(id);
}
return result;
}
// Access methods in .icc
//_____________________________________________________________________________
@@ -48,31 +48,31 @@ G4VAnalysisReader::~G4VAnalysisReader() = default;
//
//_____________________________________________________________________________
void G4VAnalysisReader::SetH1Manager(G4VTBaseHnManager<1>* h1Manager)
void G4VAnalysisReader::SetH1Manager(G4VTBaseHnManager<kDim1>* h1Manager)
{
fVH1Manager.reset(h1Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetH2Manager(G4VTBaseHnManager<2>* h2Manager)
void G4VAnalysisReader::SetH2Manager(G4VTBaseHnManager<kDim2>* h2Manager)
{
fVH2Manager.reset(h2Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetH3Manager(G4VTBaseHnManager<3>* h3Manager)
void G4VAnalysisReader::SetH3Manager(G4VTBaseHnManager<kDim3>* h3Manager)
{
fVH3Manager.reset(h3Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetP1Manager(G4VTBaseHnManager<2>* p1Manager)
void G4VAnalysisReader::SetP1Manager(G4VTBaseHnManager<kDim2>* p1Manager)
{
fVP1Manager.reset(p1Manager);
}
//_____________________________________________________________________________
void G4VAnalysisReader::SetP2Manager(G4VTBaseHnManager<3>* p2Manager)
void G4VAnalysisReader::SetP2Manager(G4VTBaseHnManager<kDim3>* p2Manager)
{
fVP2Manager.reset(p2Manager);
}
@@ -396,33 +396,33 @@ G4bool G4VAnalysisReader::GetNtupleRow(G4int ntupleId)
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH1s() const
G4int G4VAnalysisReader::GetNofH1s(G4bool onlyIfExist) const
{
return fVH1Manager->GetHnManager()->GetNofHns();
return fVH1Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH2s() const
G4int G4VAnalysisReader::GetNofH2s(G4bool onlyIfExist) const
{
return fVH2Manager->GetHnManager()->GetNofHns();
return fVH2Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofH3s() const
G4int G4VAnalysisReader::GetNofH3s(G4bool onlyIfExist) const
{
return fVH3Manager->GetHnManager()->GetNofHns();
return fVH3Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofP1s() const
G4int G4VAnalysisReader::GetNofP1s(G4bool onlyIfExist) const
{
return fVP1Manager->GetHnManager()->GetNofHns();
return fVP1Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________
G4int G4VAnalysisReader::GetNofP2s() const
G4int G4VAnalysisReader::GetNofP2s(G4bool onlyIfExist) const
{
return fVP2Manager->GetHnManager()->GetNofHns();
return fVP2Manager->GetNofHns(onlyIfExist);
}
//_____________________________________________________________________________