40 using namespace G4Analysis;
48 fCreateP1Cmd(nullptr),
50 fSetP1TitleCmd(nullptr),
51 fSetP1XAxisCmd(nullptr),
52 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);
79 void G4P1Messenger::CreateP1Cmd()
82 p1Name->SetGuidance(
"Profile name (label)");
85 p1Title->SetGuidance(
"Profile title");
88 p1xNbins0->SetGuidance(
"Number of x-bins (default = 100)");
89 p1xNbins0->SetGuidance(
"Can be reset with /analysis/p1/set command");
90 p1xNbins0->SetDefaultValue(100);
93 p1xValMin0->SetGuidance(
"Minimum x-value, expressed in unit (default = 0.)");
94 p1xValMin0->SetGuidance(
"Can be reset with /analysis/p1/set command");
95 p1xValMin0->SetDefaultValue(0.);
98 p1xValMax0->SetGuidance(
"Maximum x-value, expressed in unit (default = 1.)");
99 p1xValMax0->SetGuidance(
"Can be reset with /analysis/p1/set command");
100 p1xValMax0->SetDefaultValue(1.);
102 auto p1xValUnit0 =
new G4UIparameter(
"xvalUnit0",
's',
true);
103 p1xValUnit0->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
104 p1xValUnit0->SetDefaultValue(
"none");
107 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).\n";
108 fcnxGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
109 fcnxGuidance +=
"but none value should be used insted.";
110 p1xValFcn0->SetGuidance(fcnxGuidance);
111 p1xValFcn0->SetParameterCandidates(
"log log10 exp none");
112 p1xValFcn0->SetDefaultValue(
"none");
114 auto p1xValBinScheme0 =
new G4UIparameter(
"xvalBinScheme0",
's',
true);
115 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
116 p1xValBinScheme0->SetParameterCandidates(
"linear log");
118 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
119 binSchemeGuidance +=
"but none value should be used insted.";
120 p1xValBinScheme0->SetGuidance(binSchemeGuidance);
121 p1xValBinScheme0->SetDefaultValue(
"linear");
124 p1yValMin0->SetGuidance(
"Minimum y-value, expressed in unit (default = 0.)");
125 p1yValMin0->SetGuidance(
"Can be reset with /analysis/p1/set command");
126 p1yValMin0->SetDefaultValue(0.);
129 p1yValMax0->SetGuidance(
"Maximum y-value, expressed in unit (default = 1.)");
130 p1yValMax0->SetGuidance(
"Can be reset with /analysis/p1/set command");
131 p1yValMax0->SetDefaultValue(1.);
133 auto p1yValUnit0 =
new G4UIparameter(
"yvalUnit0",
's',
true);
134 p1yValUnit0->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
135 p1yValUnit0->SetDefaultValue(
"none");
138 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).\n";
139 fcnyGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
140 fcnyGuidance +=
"but none value should be used insted.";
141 p1yValFcn0->SetGuidance(fcnyGuidance);
142 p1yValFcn0->SetParameterCandidates(
"log log10 exp none");
143 p1yValFcn0->SetDefaultValue(
"none");
145 fCreateP1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/p1/create",
this);
146 fCreateP1Cmd->SetGuidance(
"Create 1D profile");
147 fCreateP1Cmd->SetParameter(p1Name);
148 fCreateP1Cmd->SetParameter(p1Title);
149 fCreateP1Cmd->SetParameter(p1xNbins0);
150 fCreateP1Cmd->SetParameter(p1xValMin0);
151 fCreateP1Cmd->SetParameter(p1xValMax0);
152 fCreateP1Cmd->SetParameter(p1xValUnit0);
153 fCreateP1Cmd->SetParameter(p1xValFcn0);
154 fCreateP1Cmd->SetParameter(p1xValBinScheme0);
155 fCreateP1Cmd->SetParameter(p1yValMin0);
156 fCreateP1Cmd->SetParameter(p1yValMax0);
157 fCreateP1Cmd->SetParameter(p1yValUnit0);
158 fCreateP1Cmd->SetParameter(p1yValFcn0);
164 void G4P1Messenger::SetP1Cmd()
167 p1Id->SetGuidance(
"Profile id");
168 p1Id->SetParameterRange(
"id>=0");
171 p1xNbins->SetGuidance(
"Number of x-bins");
174 p1xValMin->SetGuidance(
"Minimum x-value, expressed in unit");
177 p1xValMax->SetGuidance(
"Maximum x-value, expressed in unit");
180 p1xValUnit->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
181 p1xValUnit->SetDefaultValue(
"none");
184 p1xValFcn->SetParameterCandidates(
"log log10 exp none");
185 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).\n";
186 fcnxGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
187 fcnxGuidance +=
"but none value should be used insted.";
188 p1xValFcn->SetGuidance(fcnxGuidance);
189 p1xValFcn->SetDefaultValue(
"none");
191 auto p1xValBinScheme =
new G4UIparameter(
"xvalBinScheme",
's',
true);
192 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
193 p1xValBinScheme->SetParameterCandidates(
"linear log");
195 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
196 binSchemeGuidance +=
"but none value should be used insted.";
197 p1xValBinScheme->SetGuidance(binSchemeGuidance);
198 p1xValBinScheme->SetDefaultValue(
"linear");
201 p1yValMin->SetGuidance(
"Minimum y-value, expressed in unit");
204 p1yValMax->SetGuidance(
"Maximum y-value, expressed in unit");
207 p1yValUnit->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
208 p1yValUnit->SetDefaultValue(
"none");
211 p1yValFcn->SetParameterCandidates(
"log log10 exp none");
212 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).\n";
213 fcnyGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
214 fcnyGuidance +=
"but none value should be used insted.";
215 p1yValFcn->SetGuidance(fcnyGuidance);
216 p1yValFcn->SetDefaultValue(
"none");
218 fSetP1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/p1/set",
this);
219 fSetP1Cmd->SetGuidance(
"Set parameters for the 1D profile of given id:");
220 fSetP1Cmd->SetGuidance(
" nbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
221 fSetP1Cmd->SetGuidance(
" yvalMin; yvalMax; yunit; yfunction");
222 fSetP1Cmd->SetParameter(p1Id);
223 fSetP1Cmd->SetParameter(p1xNbins);
224 fSetP1Cmd->SetParameter(p1xValMin);
225 fSetP1Cmd->SetParameter(p1xValMax);
226 fSetP1Cmd->SetParameter(p1xValUnit);
227 fSetP1Cmd->SetParameter(p1xValFcn);
228 fSetP1Cmd->SetParameter(p1xValBinScheme);
229 fSetP1Cmd->SetParameter(p1yValMin);
230 fSetP1Cmd->SetParameter(p1yValMax);
231 fSetP1Cmd->SetParameter(p1yValUnit);
232 fSetP1Cmd->SetParameter(p1yValFcn);
244 std::vector<G4String> parameters;
249 fHelper->WarnAboutParameters(command, parameters.size());
253 if ( command == fCreateP1Cmd.get() ) {
255 auto name = parameters[counter++];
256 auto title = parameters[counter++];
258 fHelper->GetBinData(xdata, parameters, counter);
261 fHelper->GetValueData(ydata, parameters, counter);
270 else if ( command == fSetP1Cmd.get() ) {
274 fHelper->GetBinData(xdata, parameters, counter);
277 fHelper->GetValueData(ydata, parameters, counter);
286 else if ( command == fSetP1XCmd.get() ) {
290 fHelper->GetBinData(fXData, parameters, counter);
294 fManager->
SetP1(fXId,
298 fXData.
fSfcn,
"none",
301 else if ( command == fSetP1YCmd.get() ) {
305 if ( fXId == -1 || fXId !=
id ) {
306 fHelper->WarnAboutSetCommands();
311 fHelper->GetValueData(ydata, parameters, counter);
321 else if ( command == fSetP1TitleCmd.get() ) {
324 auto title = parameters[counter++];
327 else if ( command == fSetP1XAxisCmd.get() ) {
330 auto xaxis = parameters[counter++];
333 else if ( command == fSetP1YAxisCmd.get() ) {
336 auto yaxis = parameters[counter++];
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 SetP1YAxisTitle(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")
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
G4bool SetP1XAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4bool SetP1Title(G4int id, const G4String &title)
virtual void SetNewValue(G4UIcommand *command, G4String value) final
G4int GetParameterEntries() const
G4P1Messenger(G4VAnalysisManager *manager)