47 fCreateH2Cmd(nullptr),
51 fSetH2TitleCmd(nullptr),
52 fSetH2XAxisCmd(nullptr),
53 fSetH2YAxisCmd(nullptr),
57 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(
"h2");
59 fDirectory = fHelper->CreateHnDirectory();
64 fSetH2XCmd = fHelper->CreateSetBinsCommand(
"x",
this);
65 fSetH2YCmd = fHelper->CreateSetBinsCommand(
"y",
this);
67 fSetH2TitleCmd = fHelper->CreateSetTitleCommand(
this);
68 fSetH2XAxisCmd = fHelper->CreateSetAxisCommand(
"x",
this);
69 fSetH2YAxisCmd = fHelper->CreateSetAxisCommand(
"y",
this);
70 fSetH2ZAxisCmd = fHelper->CreateSetAxisCommand(
"z",
this);
71 fSetH2XAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"x",
this);
72 fSetH2YAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"y",
this);
73 fSetH2ZAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"z",
this);
85void G4H2Messenger::CreateH2Cmd()
88 h2Name->SetGuidance(
"Histogram name (label)");
91 h2Title->SetGuidance(
"Histogram title");
94 h2xNbins0->SetGuidance(
"Number of x-bins (default = 100)");
95 h2xNbins0->SetGuidance(
"Can be reset with /analysis/h2/set command");
96 h2xNbins0->SetDefaultValue(100);
99 h2xValMin0->SetGuidance(
"Minimum x-value, expressed in unit (default = 0.)");
100 h2xValMin0->SetGuidance(
"Can be reset with /analysis/h2/set command");
101 h2xValMin0->SetDefaultValue(0.);
104 h2xValMax0->SetGuidance(
"Maximum x-value, expressed in unit (default = 1.)");
105 h2xValMax0->SetGuidance(
"Can be reset with /analysis/h2/set command");
106 h2xValMax0->SetDefaultValue(1.);
108 auto h2xValUnit0 =
new G4UIparameter(
"xvalUnit0",
's',
true);
109 h2xValUnit0->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
110 h2xValUnit0->SetDefaultValue(
"none");
113 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).";
114 h2xValFcn0->SetGuidance(fcnxGuidance);
115 h2xValFcn0->SetParameterCandidates(
"log log10 exp none");
116 h2xValFcn0->SetDefaultValue(
"none");
118 auto h2xValBinScheme0 =
new G4UIparameter(
"xvalBinScheme0",
's',
true);
119 G4String xbinSchemeGuidance =
"The binning scheme (linear, log).";
120 h2xValBinScheme0->SetParameterCandidates(
"linear log");
121 h2xValBinScheme0->SetGuidance(xbinSchemeGuidance);
122 h2xValBinScheme0->SetDefaultValue(
"linear");
125 h2yNbins0->SetGuidance(
"Number of y-bins (default = 100)");
126 h2yNbins0->SetGuidance(
"Can be reset with /analysis/h2/set command");
127 h2yNbins0->SetDefaultValue(100);
130 h2yValMin0->SetGuidance(
"Minimum y-value, expressed in unit (default = 0.)");
131 h2yValMin0->SetGuidance(
"Can be reset with /analysis/h2/set command");
132 h2yValMin0->SetDefaultValue(0.);
135 h2yValMax0->SetGuidance(
"Maximum y-value, expressed in unit (default = 1.)");
136 h2yValMax0->SetGuidance(
"Can be reset with /analysis/h2/set command");
137 h2yValMax0->SetDefaultValue(1.);
139 auto h2yValUnit0 =
new G4UIparameter(
"yvalUnit0",
's',
true);
140 h2yValUnit0->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
141 h2yValUnit0->SetDefaultValue(
"none");
144 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).";
145 h2yValFcn0->SetGuidance(fcnyGuidance);
146 h2yValFcn0->SetParameterCandidates(
"log log10 exp none");
147 h2yValFcn0->SetDefaultValue(
"none");
149 auto h2yValBinScheme0 =
new G4UIparameter(
"yvalBinScheme0",
's',
true);
150 G4String ybinSchemeGuidance =
"The binning scheme (linear, log).";
151 h2yValBinScheme0->SetParameterCandidates(
"linear log");
152 h2yValBinScheme0->SetGuidance(ybinSchemeGuidance);
153 h2yValBinScheme0->SetDefaultValue(
"linear");
155 fCreateH2Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h2/create",
this);
156 fCreateH2Cmd->SetGuidance(
"Create 2D histogram");
157 fCreateH2Cmd->SetParameter(h2Name);
158 fCreateH2Cmd->SetParameter(h2Title);
159 fCreateH2Cmd->SetParameter(h2xNbins0);
160 fCreateH2Cmd->SetParameter(h2xValMin0);
161 fCreateH2Cmd->SetParameter(h2xValMax0);
162 fCreateH2Cmd->SetParameter(h2xValUnit0);
163 fCreateH2Cmd->SetParameter(h2xValFcn0);
164 fCreateH2Cmd->SetParameter(h2xValBinScheme0);
165 fCreateH2Cmd->SetParameter(h2yNbins0);
166 fCreateH2Cmd->SetParameter(h2yValMin0);
167 fCreateH2Cmd->SetParameter(h2yValMax0);
168 fCreateH2Cmd->SetParameter(h2yValUnit0);
169 fCreateH2Cmd->SetParameter(h2yValFcn0);
170 fCreateH2Cmd->SetParameter(h2yValBinScheme0);
176void G4H2Messenger::SetH2Cmd()
179 h2Id->SetGuidance(
"Histogram id");
180 h2Id->SetParameterRange(
"id>=0");
183 h2xNbins->SetGuidance(
"Number of x-bins");
186 h2xValMin->SetGuidance(
"Minimum x-value, expressed in unit");
189 h2xValMax->SetGuidance(
"Maximum x-value, expressed in unit");
192 h2xValUnit->SetGuidance(
"The unit applied to filled x-values and xvalMin, xvalMax");
193 h2xValUnit->SetDefaultValue(
"none");
196 h2xValFcn->SetParameterCandidates(
"log log10 exp none");
197 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).";
198 h2xValFcn->SetGuidance(fcnxGuidance);
199 h2xValFcn->SetDefaultValue(
"none");
201 auto h2xValBinScheme =
new G4UIparameter(
"xvalBinScheme",
's',
true);
202 G4String xbinSchemeGuidance =
"The binning scheme (linear, log).";
203 h2xValBinScheme->SetParameterCandidates(
"linear log");
204 h2xValBinScheme->SetGuidance(xbinSchemeGuidance);
205 h2xValBinScheme->SetDefaultValue(
"linear");
208 h2yNbins->SetGuidance(
"Number of y-bins");
211 h2yValMin->SetGuidance(
"Minimum y-value, expressed in unit");
214 h2yValMax->SetGuidance(
"Maximum y-value, expressed in unit");
217 h2yValUnit->SetGuidance(
"The unit applied to filled y-values and yvalMin, yvalMax");
218 h2yValUnit->SetDefaultValue(
"none");
221 h2yValFcn->SetParameterCandidates(
"log log10 exp none");
222 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).";
223 h2yValFcn->SetGuidance(fcnyGuidance);
224 h2yValFcn->SetDefaultValue(
"none");
226 auto h2yValBinScheme =
new G4UIparameter(
"yvalBinScheme",
's',
true);
227 G4String ybinSchemeGuidance =
"The binning scheme (linear, log).";
228 h2yValBinScheme->SetParameterCandidates(
"linear log");
229 h2yValBinScheme->SetGuidance(ybinSchemeGuidance);
230 h2yValBinScheme->SetDefaultValue(
"linear");
232 fSetH2Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h2/set",
this);
233 fSetH2Cmd->SetGuidance(
"Set parameters for the 2D histogram of given id:");
234 fSetH2Cmd->SetGuidance(
" nxbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
235 fSetH2Cmd->SetGuidance(
" nybins; yvalMin; yvalMax; yunit; yfunction; ybinScheme");
236 fSetH2Cmd->SetParameter(h2Id);
237 fSetH2Cmd->SetParameter(h2xNbins);
238 fSetH2Cmd->SetParameter(h2xValMin);
239 fSetH2Cmd->SetParameter(h2xValMax);
240 fSetH2Cmd->SetParameter(h2xValUnit);
241 fSetH2Cmd->SetParameter(h2xValFcn);
242 fSetH2Cmd->SetParameter(h2xValBinScheme);
243 fSetH2Cmd->SetParameter(h2yNbins);
244 fSetH2Cmd->SetParameter(h2yValMin);
245 fSetH2Cmd->SetParameter(h2yValMax);
246 fSetH2Cmd->SetParameter(h2yValUnit);
247 fSetH2Cmd->SetParameter(h2yValFcn);
248 fSetH2Cmd->SetParameter(h2yValBinScheme);
261 std::vector<G4String> parameters;
266 fHelper->WarnAboutParameters(command, parameters.size());
270 if ( command == fCreateH2Cmd.get() ) {
272 auto name = parameters[counter++];
273 auto title = parameters[counter++];
275 fHelper->GetBinData(xdata, parameters, counter);
278 fHelper->GetBinData(ydata, parameters, counter);
287 else if ( command == fSetH2Cmd.get() ) {
291 fHelper->GetBinData(xdata, parameters, counter);
294 fHelper->GetBinData(ydata, parameters, counter);
303 else if ( command == fSetH2XCmd.get() ) {
307 fHelper->GetBinData(fXData, parameters, counter);
309 else if ( command == fSetH2YCmd.get() ) {
313 if ( fXId == -1 || fXId !=
id ) {
314 fHelper->WarnAboutSetCommands();
319 fHelper->GetBinData(ydata, parameters, counter);
329 else if ( command == fSetH2TitleCmd.get() ) {
332 auto title = parameters[counter++];
335 else if ( command == fSetH2XAxisCmd.get() ) {
338 auto xaxis = parameters[counter++];
341 else if ( command == fSetH2YAxisCmd.get() ) {
344 auto yaxis = parameters[counter++];
347 else if ( command == fSetH2ZAxisCmd.get() ) {
350 auto zaxis = parameters[counter++];
353 else if ( command == fSetH2XAxisLogCmd.get() ) {
359 else if ( command == fSetH2YAxisLogCmd.get() ) {
365 else if ( command == fSetH2ZAxisLogCmd.get() ) {
G4H2Messenger(G4VAnalysisManager *manager)
virtual void SetNewValue(G4UIcommand *command, G4String value) final
std::size_t GetParameterEntries() const
static G4int ConvertToInt(const char *st)
static G4bool ConvertToBool(const char *st)
G4bool SetH2XAxisIsLog(G4int id, G4bool isLog)
G4bool SetH2Title(G4int id, const G4String &title)
G4bool SetH2YAxisIsLog(G4int id, G4bool isLog)
G4bool SetH2XAxisTitle(G4int id, const G4String &title)
G4bool SetH2YAxisTitle(G4int id, const G4String &title)
G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool SetH2ZAxisIsLog(G4int id, G4bool isLog)
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4double GetUnitValue(const G4String &unit)