40 using namespace G4Analysis;
48 fCreateH2Cmd(nullptr),
52 fSetH2TitleCmd(nullptr),
53 fSetH2XAxisCmd(nullptr),
54 fSetH2YAxisCmd(nullptr),
58 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(
"h2");
60 fDirectory = fHelper->CreateHnDirectory();
65 fSetH2XCmd = fHelper->CreateSetBinsCommand(
"x",
this);
66 fSetH2YCmd = fHelper->CreateSetBinsCommand(
"y",
this);
68 fSetH2TitleCmd = fHelper->CreateSetTitleCommand(
this);
69 fSetH2XAxisCmd = fHelper->CreateSetAxisCommand(
"x",
this);
70 fSetH2YAxisCmd = fHelper->CreateSetAxisCommand(
"y",
this);
71 fSetH2ZAxisCmd = fHelper->CreateSetAxisCommand(
"z",
this);
83 void G4H2Messenger::CreateH2Cmd()
86 h2Name->SetGuidance(
"Histogram name (label)");
89 h2Title->SetGuidance(
"Histogram title");
92 h2xNbins0->SetGuidance(
"Number of x-bins (default = 100)");
93 h2xNbins0->SetGuidance(
"Can be reset with /analysis/h2/set command");
94 h2xNbins0->SetDefaultValue(100);
97 h2xValMin0->SetGuidance(
"Minimum x-value, expressed in unit (default = 0.)");
98 h2xValMin0->SetGuidance(
"Can be reset with /analysis/h2/set command");
99 h2xValMin0->SetDefaultValue(0.);
102 h2xValMax0->SetGuidance(
"Maximum x-value, expressed in unit (default = 1.)");
103 h2xValMax0->SetGuidance(
"Can be reset with /analysis/h2/set command");
104 h2xValMax0->SetDefaultValue(1.);
106 auto h2xValUnit0 =
new G4UIparameter(
"xvalUnit0",
's',
true);
107 h2xValUnit0->SetGuidance(
"The unit applied to filled x-values and xvalMin0, xvalMax0");
108 h2xValUnit0->SetDefaultValue(
"none");
111 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).";
112 h2xValFcn0->SetGuidance(fcnxGuidance);
113 h2xValFcn0->SetParameterCandidates(
"log log10 exp none");
114 h2xValFcn0->SetDefaultValue(
"none");
116 auto h2xValBinScheme0 =
new G4UIparameter(
"xvalBinScheme0",
's',
true);
117 G4String xbinSchemeGuidance =
"The binning scheme (linear, log).";
118 h2xValBinScheme0->SetParameterCandidates(
"linear log");
119 h2xValBinScheme0->SetGuidance(xbinSchemeGuidance);
120 h2xValBinScheme0->SetDefaultValue(
"linear");
123 h2yNbins0->SetGuidance(
"Number of y-bins (default = 100)");
124 h2yNbins0->SetGuidance(
"Can be reset with /analysis/h2/set command");
125 h2yNbins0->SetDefaultValue(100);
128 h2yValMin0->SetGuidance(
"Minimum y-value, expressed in unit (default = 0.)");
129 h2yValMin0->SetGuidance(
"Can be reset with /analysis/h2/set command");
130 h2yValMin0->SetDefaultValue(0.);
133 h2yValMax0->SetGuidance(
"Maximum y-value, expressed in unit (default = 1.)");
134 h2yValMax0->SetGuidance(
"Can be reset with /analysis/h2/set command");
135 h2yValMax0->SetDefaultValue(1.);
137 auto h2yValUnit0 =
new G4UIparameter(
"yvalUnit0",
's',
true);
138 h2yValUnit0->SetGuidance(
"The unit applied to filled y-values and yvalMin0, yvalMax0");
139 h2yValUnit0->SetDefaultValue(
"none");
142 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).";
143 h2yValFcn0->SetGuidance(fcnyGuidance);
144 h2yValFcn0->SetParameterCandidates(
"log log10 exp none");
145 h2yValFcn0->SetDefaultValue(
"none");
147 auto h2yValBinScheme0 =
new G4UIparameter(
"yvalBinScheme0",
's',
true);
148 G4String ybinSchemeGuidance =
"The binning scheme (linear, log).";
149 h2yValBinScheme0->SetParameterCandidates(
"linear log");
150 h2yValBinScheme0->SetGuidance(ybinSchemeGuidance);
151 h2yValBinScheme0->SetDefaultValue(
"linear");
153 fCreateH2Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h2/create",
this);
154 fCreateH2Cmd->SetGuidance(
"Create 2D histogram");
155 fCreateH2Cmd->SetParameter(h2Name);
156 fCreateH2Cmd->SetParameter(h2Title);
157 fCreateH2Cmd->SetParameter(h2xNbins0);
158 fCreateH2Cmd->SetParameter(h2xValMin0);
159 fCreateH2Cmd->SetParameter(h2xValMax0);
160 fCreateH2Cmd->SetParameter(h2xValUnit0);
161 fCreateH2Cmd->SetParameter(h2xValFcn0);
162 fCreateH2Cmd->SetParameter(h2xValBinScheme0);
163 fCreateH2Cmd->SetParameter(h2yNbins0);
164 fCreateH2Cmd->SetParameter(h2yValMin0);
165 fCreateH2Cmd->SetParameter(h2yValMax0);
166 fCreateH2Cmd->SetParameter(h2yValUnit0);
167 fCreateH2Cmd->SetParameter(h2yValFcn0);
168 fCreateH2Cmd->SetParameter(h2yValBinScheme0);
174 void G4H2Messenger::SetH2Cmd()
177 h2Id->SetGuidance(
"Histogram id");
178 h2Id->SetParameterRange(
"id>=0");
181 h2xNbins->SetGuidance(
"Number of x-bins");
184 h2xValMin->SetGuidance(
"Minimum x-value, expressed in unit");
187 h2xValMax->SetGuidance(
"Maximum x-value, expressed in unit");
190 h2xValUnit->SetGuidance(
"The unit applied to filled x-values and xvalMin, xvalMax");
191 h2xValUnit->SetDefaultValue(
"none");
194 h2xValFcn->SetParameterCandidates(
"log log10 exp none");
195 G4String fcnxGuidance =
"The function applied to filled x-values (log, log10, exp, none).";
196 h2xValFcn->SetGuidance(fcnxGuidance);
197 h2xValFcn->SetDefaultValue(
"none");
199 auto h2xValBinScheme =
new G4UIparameter(
"xvalBinScheme",
's',
true);
200 G4String xbinSchemeGuidance =
"The binning scheme (linear, log).";
201 h2xValBinScheme->SetParameterCandidates(
"linear log");
202 h2xValBinScheme->SetGuidance(xbinSchemeGuidance);
203 h2xValBinScheme->SetDefaultValue(
"linear");
206 h2yNbins->SetGuidance(
"Number of y-bins");
209 h2yValMin->SetGuidance(
"Minimum y-value, expressed in unit");
212 h2yValMax->SetGuidance(
"Maximum y-value, expressed in unit");
215 h2yValUnit->SetGuidance(
"The unit applied to filled y-values and yvalMin, yvalMax");
216 h2yValUnit->SetDefaultValue(
"none");
219 h2yValFcn->SetParameterCandidates(
"log log10 exp none");
220 G4String fcnyGuidance =
"The function applied to filled y-values (log, log10, exp, none).";
221 h2yValFcn->SetGuidance(fcnyGuidance);
222 h2yValFcn->SetDefaultValue(
"none");
224 auto h2yValBinScheme =
new G4UIparameter(
"yvalBinScheme",
's',
true);
225 G4String ybinSchemeGuidance =
"The binning scheme (linear, log).";
226 h2yValBinScheme->SetParameterCandidates(
"linear log");
227 h2yValBinScheme->SetGuidance(ybinSchemeGuidance);
228 h2yValBinScheme->SetDefaultValue(
"linear");
230 fSetH2Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h2/set",
this);
231 fSetH2Cmd->SetGuidance(
"Set parameters for the 2D histogram of given id:");
232 fSetH2Cmd->SetGuidance(
" nxbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
233 fSetH2Cmd->SetGuidance(
" nybins; yvalMin; yvalMax; yunit; yfunction; ybinScheme");
234 fSetH2Cmd->SetParameter(h2Id);
235 fSetH2Cmd->SetParameter(h2xNbins);
236 fSetH2Cmd->SetParameter(h2xValMin);
237 fSetH2Cmd->SetParameter(h2xValMax);
238 fSetH2Cmd->SetParameter(h2xValUnit);
239 fSetH2Cmd->SetParameter(h2xValFcn);
240 fSetH2Cmd->SetParameter(h2xValBinScheme);
241 fSetH2Cmd->SetParameter(h2yNbins);
242 fSetH2Cmd->SetParameter(h2yValMin);
243 fSetH2Cmd->SetParameter(h2yValMax);
244 fSetH2Cmd->SetParameter(h2yValUnit);
245 fSetH2Cmd->SetParameter(h2yValFcn);
246 fSetH2Cmd->SetParameter(h2yValBinScheme);
259 std::vector<G4String> parameters;
264 fHelper->WarnAboutParameters(command, parameters.size());
268 if ( command == fCreateH2Cmd.get() ) {
270 auto name = parameters[counter++];
271 auto title = parameters[counter++];
273 fHelper->GetBinData(xdata, parameters, counter);
276 fHelper->GetBinData(ydata, parameters, counter);
285 else if ( command == fSetH2Cmd.get() ) {
289 fHelper->GetBinData(xdata, parameters, counter);
292 fHelper->GetBinData(ydata, parameters, counter);
301 else if ( command == fSetH2XCmd.get() ) {
305 fHelper->GetBinData(fXData, parameters, counter);
307 else if ( command == fSetH2YCmd.get() ) {
311 if ( fXId == -1 || fXId !=
id ) {
312 fHelper->WarnAboutSetCommands();
317 fHelper->GetBinData(ydata, parameters, counter);
327 else if ( command == fSetH2TitleCmd.get() ) {
330 auto title = parameters[counter++];
333 else if ( command == fSetH2XAxisCmd.get() ) {
336 auto xaxis = parameters[counter++];
339 else if ( command == fSetH2YAxisCmd.get() ) {
342 auto yaxis = parameters[counter++];
345 else if ( command == fSetH2ZAxisCmd.get() ) {
348 auto zaxis = parameters[counter++];
G4bool SetH2YAxisTitle(G4int id, const G4String &title)
G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
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 SetH2Title(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4H2Messenger(G4VAnalysisManager *manager)
G4int GetParameterEntries() const
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 SetH2XAxisTitle(G4int id, const G4String &title)
virtual void SetNewValue(G4UIcommand *command, G4String value) final