45 fNtupleDir = std::make_unique<G4UIdirectory>(
"/analysis/ntuple/");
46 fNtupleDir->SetGuidance(
"ntuple control");
49 SetActivationToAllCmd();
51 SetFileNameToAllCmd();
63void G4NtupleMessenger::AddIdParameter(
G4UIcommand& command)
66 ntupleId->SetGuidance(
"Ntuple id");
67 ntupleId->SetParameterRange(
"NtupleId>=0");
73void G4NtupleMessenger::SetActivationCmd()
75 fSetActivationCmd = CreateCommand<G4UIcommand>(
76 "setActivation",
"Set activation for the ntuple");
78 AddIdParameter(*fSetActivationCmd);
80 auto ntupleActivation =
new G4UIparameter(
"NtupleActivation",
'b',
true);
81 ntupleActivation->SetGuidance(
"Ntuple activation");
82 ntupleActivation->SetDefaultValue(
true);
83 fSetActivationCmd->SetParameter(ntupleActivation);
87void G4NtupleMessenger::SetActivationToAllCmd()
89 fSetActivationAllCmd = CreateCommand<G4UIcmdWithABool>(
90 "setActivationToAll",
"Set activation to all ntuples");
91 fSetActivationAllCmd->SetParameterName(
"AllNtupleActivation",
false);
95void G4NtupleMessenger::SetFileNameCmd()
97 fSetFileNameCmd = CreateCommand<G4UIcommand>(
98 "setFileName",
"Set file name for the ntuple");
100 AddIdParameter(*fSetFileNameCmd);
102 auto ntupleFileName =
new G4UIparameter(
"NtupleFileName",
's',
false);
103 ntupleFileName->SetGuidance(
"Ntuple file name");
104 fSetFileNameCmd->SetParameter(ntupleFileName);
108void G4NtupleMessenger::SetFileNameToAllCmd()
110 fSetFileNameAllCmd = CreateCommand<G4UIcmdWithAString>(
111 "setFileNameToAll",
"Set file name to all ntuples");
112 fSetFileNameAllCmd->SetParameterName(
"AllNtupleFileName",
false);
116void G4NtupleMessenger::ListCmd()
118 fListCmd = CreateCommand<G4UIcommand>(
"list",
"List all/active ntuples");
121 auto parOnlyIfActive =
new G4UIparameter(
"onlyIfActive",
'b',
true);
122 parOnlyIfActive->SetGuidance(
"Option whether to list only active objects");
123 parOnlyIfActive->SetDefaultValue(
"true");
124 fListCmd->SetParameter(parOnlyIfActive);
136 if ( command == fSetActivationAllCmd.get() ) {
137 fManager->
SetActivation(fSetActivationAllCmd->GetNewBoolValue(newValues));
141 if ( command == fSetFileNameAllCmd.get() ) {
147 std::vector<G4String> parameters;
154 "\" parameters: " + std::to_string(parameters.size()) +
156 fkClass,
"WarnAboutParameters");
163 if ( command == fSetActivationCmd.get() ) {
168 if ( command == fSetFileNameCmd.get() ) {
173 if ( command == fListCmd.get() ) {
void SetNewValue(G4UIcommand *command, G4String value) final
~G4NtupleMessenger() override
G4NtupleMessenger()=delete
std::size_t GetParameterEntries() const
void SetParameter(G4UIparameter *const newParameter)
static G4int ConvertToInt(const char *st)
static G4bool ConvertToBool(const char *st)
const G4String & GetCommandName() const
G4bool ListNtuple(G4bool onlyIfActive=true) const
void SetNtupleFileName(const G4String &fileName)
void SetActivation(G4bool activation)
G4bool SetFileName(const G4String &fileName)
void SetNtupleActivation(G4bool activation)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)