47 fCreateP1Cmd(nullptr),
49 fSetP1TitleCmd(nullptr),
50 fSetP1XAxisCmd(nullptr),
51 fSetP1YAxisCmd(nullptr),
55 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(
"p1");
57 fDirectory = fHelper->CreateHnDirectory();
62 fSetP1XCmd = fHelper->CreateSetBinsCommand(
"x",
this);
63 fSetP1YCmd = fHelper->CreateSetValuesCommand(
"y",
this);
65 fSetP1TitleCmd = fHelper->CreateSetTitleCommand(
this);
66 fSetP1XAxisCmd = fHelper->CreateSetAxisCommand(
"x",
this);
67 fSetP1YAxisCmd = fHelper->CreateSetAxisCommand(
"y",
this);
68 fSetP1XAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"x",
this);
69 fSetP1YAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"y",
this);
81void G4P1Messenger::CreateP1Cmd()
84 p1Name->SetGuidance(
"Profile name (label)");
87 p1Title->SetGuidance(
"Profile title");
90 p1xNbins0->SetGuidance(
"Number of x-bins (default = 100)");
91 p1xNbins0->SetGuidance(
"Can be reset with /analysis/p1/set command");
92 p1xNbins0->SetDefaultValue(100);
95 p1xValMin0->SetGuidance(
"Minimum x-value, expressed in unit (default = 0.)");
96 p1xValMin0->SetGuidance(
"Can be reset with /analysis/p1/set command");
97 p1xValMin0->SetDefaultValue(0.);
100 p1xValMax0->SetGuidance(
"Maximum x-value, expressed in unit (default = 1.)");
101 p1xValMax0->SetGuidance(
"Can be reset with /analysis/p1/set command");
102 p1xValMax0->SetDefaultValue(1.);
104 auto p1xValUnit0 =
new G4UIparameter(
"xvalUnit0",
's',
true);
105 p1xValUnit0->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
106 p1xValUnit0->SetDefaultValue(
"none");
109 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).\n";
110 fcnxGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
111 fcnxGuidance +=
"but none value should be used instead.";
112 p1xValFcn0->SetGuidance(fcnxGuidance);
113 p1xValFcn0->SetParameterCandidates(
"log log10 exp none");
114 p1xValFcn0->SetDefaultValue(
"none");
116 auto p1xValBinScheme0 =
new G4UIparameter(
"xvalBinScheme0",
's',
true);
117 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
118 p1xValBinScheme0->SetParameterCandidates(
"linear log");
120 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
121 binSchemeGuidance +=
"but none value should be used instead.";
122 p1xValBinScheme0->SetGuidance(binSchemeGuidance);
123 p1xValBinScheme0->SetDefaultValue(
"linear");
126 p1yValMin0->SetGuidance(
"Minimum y-value, expressed in unit (default = 0.)");
127 p1yValMin0->SetGuidance(
"Can be reset with /analysis/p1/set command");
128 p1yValMin0->SetDefaultValue(0.);
131 p1yValMax0->SetGuidance(
"Maximum y-value, expressed in unit (default = 1.)");
132 p1yValMax0->SetGuidance(
"Can be reset with /analysis/p1/set command");
133 p1yValMax0->SetDefaultValue(1.);
135 auto p1yValUnit0 =
new G4UIparameter(
"yvalUnit0",
's',
true);
136 p1yValUnit0->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
137 p1yValUnit0->SetDefaultValue(
"none");
140 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).\n";
141 fcnyGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
142 fcnyGuidance +=
"but none value should be used instead.";
143 p1yValFcn0->SetGuidance(fcnyGuidance);
144 p1yValFcn0->SetParameterCandidates(
"log log10 exp none");
145 p1yValFcn0->SetDefaultValue(
"none");
147 fCreateP1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/p1/create",
this);
148 fCreateP1Cmd->SetGuidance(
"Create 1D profile");
149 fCreateP1Cmd->SetParameter(p1Name);
150 fCreateP1Cmd->SetParameter(p1Title);
151 fCreateP1Cmd->SetParameter(p1xNbins0);
152 fCreateP1Cmd->SetParameter(p1xValMin0);
153 fCreateP1Cmd->SetParameter(p1xValMax0);
154 fCreateP1Cmd->SetParameter(p1xValUnit0);
155 fCreateP1Cmd->SetParameter(p1xValFcn0);
156 fCreateP1Cmd->SetParameter(p1xValBinScheme0);
157 fCreateP1Cmd->SetParameter(p1yValMin0);
158 fCreateP1Cmd->SetParameter(p1yValMax0);
159 fCreateP1Cmd->SetParameter(p1yValUnit0);
160 fCreateP1Cmd->SetParameter(p1yValFcn0);
166void G4P1Messenger::SetP1Cmd()
169 p1Id->SetGuidance(
"Profile id");
170 p1Id->SetParameterRange(
"id>=0");
173 p1xNbins->SetGuidance(
"Number of x-bins");
176 p1xValMin->SetGuidance(
"Minimum x-value, expressed in unit");
179 p1xValMax->SetGuidance(
"Maximum x-value, expressed in unit");
182 p1xValUnit->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
183 p1xValUnit->SetDefaultValue(
"none");
186 p1xValFcn->SetParameterCandidates(
"log log10 exp none");
187 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).\n";
188 fcnxGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
189 fcnxGuidance +=
"but none value should be used instead.";
190 p1xValFcn->SetGuidance(fcnxGuidance);
191 p1xValFcn->SetDefaultValue(
"none");
193 auto p1xValBinScheme =
new G4UIparameter(
"xvalBinScheme",
's',
true);
194 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
195 p1xValBinScheme->SetParameterCandidates(
"linear log");
197 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
198 binSchemeGuidance +=
"but none value should be used instead.";
199 p1xValBinScheme->SetGuidance(binSchemeGuidance);
200 p1xValBinScheme->SetDefaultValue(
"linear");
203 p1yValMin->SetGuidance(
"Minimum y-value, expressed in unit");
206 p1yValMax->SetGuidance(
"Maximum y-value, expressed in unit");
209 p1yValUnit->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
210 p1yValUnit->SetDefaultValue(
"none");
213 p1yValFcn->SetParameterCandidates(
"log log10 exp none");
214 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).\n";
215 fcnyGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
216 fcnyGuidance +=
"but none value should be used instead.";
217 p1yValFcn->SetGuidance(fcnyGuidance);
218 p1yValFcn->SetDefaultValue(
"none");
220 fSetP1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/p1/set",
this);
221 fSetP1Cmd->SetGuidance(
"Set parameters for the 1D profile of given id:");
222 fSetP1Cmd->SetGuidance(
" nbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
223 fSetP1Cmd->SetGuidance(
" yvalMin; yvalMax; yunit; yfunction");
224 fSetP1Cmd->SetParameter(p1Id);
225 fSetP1Cmd->SetParameter(p1xNbins);
226 fSetP1Cmd->SetParameter(p1xValMin);
227 fSetP1Cmd->SetParameter(p1xValMax);
228 fSetP1Cmd->SetParameter(p1xValUnit);
229 fSetP1Cmd->SetParameter(p1xValFcn);
230 fSetP1Cmd->SetParameter(p1xValBinScheme);
231 fSetP1Cmd->SetParameter(p1yValMin);
232 fSetP1Cmd->SetParameter(p1yValMax);
233 fSetP1Cmd->SetParameter(p1yValUnit);
234 fSetP1Cmd->SetParameter(p1yValFcn);
246 std::vector<G4String> parameters;
251 fHelper->WarnAboutParameters(command, parameters.size());
255 if ( command == fCreateP1Cmd.get() ) {
257 auto name = parameters[counter++];
258 auto title = parameters[counter++];
260 fHelper->GetBinData(xdata, parameters, counter);
263 fHelper->GetValueData(ydata, parameters, counter);
272 else if ( command == fSetP1Cmd.get() ) {
276 fHelper->GetBinData(xdata, parameters, counter);
279 fHelper->GetValueData(ydata, parameters, counter);
288 else if ( command == fSetP1XCmd.get() ) {
292 fHelper->GetBinData(fXData, parameters, counter);
296 fManager->
SetP1(fXId,
300 fXData.
fSfcn,
"none",
303 else if ( command == fSetP1YCmd.get() ) {
307 if ( fXId == -1 || fXId !=
id ) {
308 fHelper->WarnAboutSetCommands();
313 fHelper->GetValueData(ydata, parameters, counter);
323 else if ( command == fSetP1TitleCmd.get() ) {
326 auto title = parameters[counter++];
329 else if ( command == fSetP1XAxisCmd.get() ) {
332 auto xaxis = parameters[counter++];
335 else if ( command == fSetP1YAxisCmd.get() ) {
338 auto yaxis = parameters[counter++];
341 else if ( command == fSetP1XAxisLogCmd.get() ) {
347 else if ( command == fSetP1YAxisLogCmd.get() ) {
virtual void SetNewValue(G4UIcommand *command, G4String value) final
G4P1Messenger(G4VAnalysisManager *manager)
std::size_t GetParameterEntries() const
static G4int ConvertToInt(const char *st)
static G4bool ConvertToBool(const char *st)
G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4bool SetP1XAxisTitle(G4int id, const G4String &title)
G4bool SetP1(G4int id, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4bool SetP1YAxisIsLog(G4int id, G4bool isLog)
G4bool SetP1YAxisTitle(G4int id, const G4String &title)
G4bool SetP1XAxisIsLog(G4int id, G4bool isLog)
G4bool SetP1Title(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4double GetUnitValue(const G4String &unit)