44void WrongParametersException(
45 const G4String& commandName, std::size_t got, std::size_t expected)
49 <<
"Got wrong number of \"" << commandName
50 <<
"\" parameters: " << got <<
" instead of " << expected
62 fSetActivationCmd(nullptr),
63 fSetActivationAllCmd(nullptr),
64 fSetFileNameCmd(nullptr),
65 fSetFileNameAllCmd(nullptr)
67 fNtupleDir = G4Analysis::make_unique<G4UIdirectory>(
"/analysis/ntuple/");
68 fNtupleDir->SetGuidance(
"ntuple control");
71 SetActivationToAllCmd();
73 SetFileNameToAllCmd();
86void G4NtupleMessenger::SetActivationCmd()
89 ntupleId->SetGuidance(
"Ntuple id");
90 ntupleId->SetParameterRange(
"NtupleId>=0");
92 auto ntupleActivation =
new G4UIparameter(
"NtupleActivation",
's',
true);
93 ntupleActivation->SetGuidance(
"Ntuple activation");
94 ntupleActivation->SetDefaultValue(
"none");
96 fSetActivationCmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/ntuple/setActivation",
this);
97 G4String guidance(
"Set activation for the ntuple of given id");
99 fSetActivationCmd->SetGuidance(guidance);
100 fSetActivationCmd->SetParameter(ntupleId);
101 fSetActivationCmd->SetParameter(ntupleActivation);
106void G4NtupleMessenger::SetActivationToAllCmd()
109 = G4Analysis::make_unique<G4UIcmdWithABool>(
"/analysis/ntuple/setActivationToAll",
this);
110 G4String guidance(
"Set activation to all ntuples");
111 fSetActivationAllCmd->SetGuidance(guidance);
112 fSetActivationAllCmd->SetParameterName(
"AllNtupleActivation",
false);
116void G4NtupleMessenger::SetFileNameCmd()
119 ntupleId->SetGuidance(
"Ntuple id");
120 ntupleId->SetParameterRange(
"NtupleId>=0");
122 auto ntupleFileName =
new G4UIparameter(
"NtupleFileName",
's',
true);
123 ntupleFileName->SetGuidance(
"Ntuple file name");
124 ntupleFileName->SetDefaultValue(
"none");
126 fSetFileNameCmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/ntuple/setFileName",
this);
127 G4String guidance(
"Set file name for the ntuple of given id");
129 fSetFileNameCmd->SetGuidance(guidance);
130 fSetFileNameCmd->SetParameter(ntupleId);
131 fSetFileNameCmd->SetParameter(ntupleFileName);
136void G4NtupleMessenger::SetFileNameToAllCmd()
139 = G4Analysis::make_unique<G4UIcmdWithAString>(
"/analysis/ntuple/setFileNameToAll",
this);
140 G4String guidance(
"Set file name to all ntuples");
141 fSetFileNameAllCmd->SetGuidance(guidance);
142 fSetFileNameAllCmd->SetParameterName(
"AllNtupleFileName",
false);
152 if ( command == fSetActivationCmd.get() ) {
154 std::vector<G4String> parameters;
169 else if ( command == fSetActivationAllCmd.get() ) {
170 auto activation = fSetActivationAllCmd->GetNewBoolValue(newValues);
173 else if ( command == fSetFileNameCmd.get() ) {
175 std::vector<G4String> parameters;
181 auto fileName = parameters[counter++];
190 else if ( command == fSetFileNameAllCmd.get() ) {
191 auto fileName = newValues;
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
virtual void SetNewValue(G4UIcommand *command, G4String value) final
G4NtupleMessenger(G4VAnalysisManager *manager)
virtual ~G4NtupleMessenger()
std::size_t GetParameterEntries() const
static G4int ConvertToInt(const char *st)
static G4bool ConvertToBool(const char *st)
const G4String & GetCommandName() const
void SetNtupleFileName(const G4String &fileName)
void SetNtupleActivation(G4bool activation)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)