14 #include "G4UIcommand.hh"
15 #include "G4UIparameter.hh"
16 #include "G4UIdirectory.hh"
17 #include "G4UIcmdWithAString.hh"
18 #include "G4UIcmdWithABool.hh"
19 #include "G4UIcmdWithAnInteger.hh"
20 #include "G4UIcmdWithoutParameter.hh"
21 #include "G4UnitsTable.hh"
24 : pRA(dc), currentID(-1)
26 G4UIparameter* para =
nullptr;
28 anaDir =
new G4UIdirectory(
"/eAST/analysis/");
29 anaDir->SetGuidance(
"GORAD analysis commands");
31 verboseCmd =
new G4UIcmdWithAnInteger(
"/eAST/analysis/verbose",
this);
38 fileCmd =
new G4UIcmdWithAString(
"/eAST/analysis/file",
this);
39 fileCmd->SetGuidance(
"Define the output file name.");
40 fileCmd->SetParameterName(
"file",
false);
41 fileCmd->AvailableForStates(G4State_Idle);
43 listCmd =
new G4UIcmdWithoutParameter(
"/eAST/analysis/list",
this);
44 listCmd->SetGuidance(
"List defined histograms.");
45 listCmd->AvailableForStates(G4State_Idle);
47 openCmd =
new G4UIcmdWithAnInteger(
"/eAST/analysis/open",
this);
48 openCmd->SetGuidance(
"Open a histogram that has already been created and closed.");
49 openCmd->SetGuidance(
"\"create\" command opens a new histogram so you don't need to open it.");
50 openCmd->SetGuidance(
"This \"open\" command is required only for reopening a closed histogram.");
51 openCmd->SetParameterName(
"id",
false);
52 openCmd->AvailableForStates(G4State_Idle);
54 plotCmd =
new G4UIcmdWithAnInteger(
"/eAST/analysis/plot",
this);
55 plotCmd->SetGuidance(
"Create an additional postscript plot for specified histogram/profile.");
56 plotCmd->SetGuidance(
"Regardless of this command, histogram is dumped to the output file.");
57 plotCmd->SetGuidance(
"If id is not specified, currently open histogram/profile is plotted.");
58 plotCmd->SetGuidance(
"If id = -1, all currently defined histograms/profiles are plotted.");
59 plotCmd->SetParameterName(
"id",
true,
true);
60 plotCmd->AvailableForStates(G4State_Idle);
62 carryCmd =
new G4UIcmdWithABool(
"/eAST/analysis/carry",
this);
63 carryCmd->SetGuidance(
"Carry histograms over more than one runs.");
64 carryCmd->SetGuidance(
"Once this is set, histograms won't be output until /eAST/analysis/flush is explicitly issued.");
65 carryCmd->SetGuidance(
"This command has to be issued before starting the run to be carried over.");
66 carryCmd->SetParameterName(
"carry",
true);
68 carryCmd->AvailableForStates(G4State_Idle);
70 flushCmd =
new G4UIcmdWithoutParameter(
"/eAST/analysis/flush",
this);
71 flushCmd->SetGuidance(
"Make output. This command is necessary if /eAST/analysis/carry is set.");
72 flushCmd->AvailableForStates(G4State_Idle);
74 resetCmd =
new G4UIcmdWithoutParameter(
"/eAST/analysis/reset",
this);
75 resetCmd->SetGuidance(
"Reset histograms without making output.");
76 resetCmd->AvailableForStates(G4State_Idle);
78 oneDDir =
new G4UIdirectory(
"/eAST/analysis/1D/");
79 oneDDir->SetGuidance(
"1-dimentional histogram");
81 create1DCmd =
new G4UIcommand(
"/eAST/analysis/1D/create",
this);
82 create1DCmd->SetGuidance(
"Create a 1D histogram and fill it with event-by-event score.");
83 create1DCmd->SetGuidance(
"Scoring mesh (logical volume for real-world volume scoring) and");
84 create1DCmd->SetGuidance(
"primitive scorers must be defined prior to this command.");
85 para =
new G4UIparameter(
"meshName",
's',
false);
86 para->SetGuidance(
"Scoring mesh name. Logical volume name for real-world volume scoring.");
88 para =
new G4UIparameter(
"primName",
's',
false);
90 para =
new G4UIparameter(
"idx",
'i',
true);
91 para->SetGuidance(
"Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells.");
92 para->SetDefaultValue(-1);
93 para->SetParameterRange(
"idx>=-1");
98 create1DPlotPCmd->SetGuidance(
"Create a 1D energy spectrum histogram and fill it with each individual track that gets into the volume.");
99 create1DPlotPCmd->SetGuidance(
"Histogram is created for each physical volume separately.");
100 create1DPlotPCmd->SetGuidance(
"So, this command should not be used for Box or Cylinder mesh type due to memory consumption concern.");
101 create1DPlotPCmd->SetGuidance(
"Currently, this is supported only for some scorers.");
102 para =
new G4UIparameter(
"meshName",
's',
false);
103 para->SetGuidance(
"Scoring mesh name. Logical volume name for real-world volume scoring.");
105 para =
new G4UIparameter(
"primName",
's',
false);
106 para->SetGuidance(
"Scoring primitive name.");
110 config1DCmd =
new G4UIcommand(
"/eAST/analysis/1D/config",
this);
111 config1DCmd->SetGuidance(
"Set binning parameters of the current 1D histogram.");
112 config1DCmd->SetGuidance(
"<unit> is applied to <minVal> and <maxVal> as well as filled value.");
113 para =
new G4UIparameter(
"nBin",
'i',
false);
114 para->SetParameterRange(
"nBin>0");
116 para =
new G4UIparameter(
"minVal",
'd',
false);
118 para =
new G4UIparameter(
"maxVal",
'd',
false);
120 para =
new G4UIparameter(
"unit",
's',
true);
121 para->SetDefaultValue(
"none");
123 para =
new G4UIparameter(
"scale",
's',
true);
124 para->SetGuidance(
"Define the binning scale. (default: linear)");
125 para->SetParameterCandidates(
"linear log");
126 para->SetDefaultValue(
"linear");
128 para =
new G4UIparameter(
"logVal",
'b',
true);
129 para->SetDefaultValue(
false);
133 title1DCmd =
new G4UIcommand(
"/eAST/analysis/1D/title",
this);
134 title1DCmd->SetGuidance(
"Define histogram title");
135 para =
new G4UIparameter(
"title",
's',
false);
137 para =
new G4UIparameter(
"x_axis",
's',
false);
139 para =
new G4UIparameter(
"y_axis",
's',
false);
149 onePDir =
new G4UIdirectory(
"/eAST/analysis/1P/");
150 onePDir->SetGuidance(
"1-dimentional profile plot");
152 create1PCmd =
new G4UIcommand(
"/eAST/analysis/1P/create",
this);
153 create1PCmd->SetGuidance(
"Create a 1D profile plot and fill it with event-by-event score.");
154 create1PCmd->SetGuidance(
"Scoring mesh (logical volume for real-world volume scoring) and");
155 create1PCmd->SetGuidance(
"primitive scorers must be defined prior to this command.");
156 create1PCmd->SetGuidance(
"Copy number of the scoring cell is used as the x-axis value.");
157 para =
new G4UIparameter(
"meshName",
's',
false);
158 para->SetGuidance(
"Scoring mesh name. Logical volume name for real-world volume scoring.");
160 para =
new G4UIparameter(
"primName",
's',
false);
162 para =
new G4UIparameter(
"idx",
'i',
false);
163 para->SetGuidance(
"Maximum index (i.e. copy number) of the cell to be scored.");
164 para->SetParameterRange(
"idx>0");
168 set1PCmd =
new G4UIcommand(
"/eAST/analysis/1P/set",
this);
169 set1PCmd->SetGuidance(
"Set binning parameters of the current 1D profile plot.");
170 set1PCmd->SetGuidance(
"<unit> is applied to <minYVal> and <maxYVal> as well as filled value.");
171 para =
new G4UIparameter(
"minYVal",
'd',
false);
173 para =
new G4UIparameter(
"maxYVal",
'd',
false);
175 para =
new G4UIparameter(
"unit",
's',
true);
176 para->SetDefaultValue(
"none");
178 para =
new G4UIparameter(
"func-x",
's',
true);
179 para->SetGuidance(
"The function applied to the filled x-value (default: none).");
180 para->SetParameterCandidates(
"log log10 exp none");
181 para->SetDefaultValue(
"none");
183 para =
new G4UIparameter(
"func-y",
's',
true);
184 para->SetGuidance(
"The function applied to the filled y-value (default: none).");
185 para->SetParameterCandidates(
"log log10 exp none");
186 para->SetDefaultValue(
"none");
188 para =
new G4UIparameter(
"scale",
's',
true);
189 para->SetGuidance(
"Define the binning scale. (default: linear)");
190 para->SetParameterCandidates(
"linear log");
191 para->SetDefaultValue(
"linear");
193 set1PCmd->AvailableForStates(G4State_Idle);
195 title1PCmd =
new G4UIcommand(
"/eAST/analysis/1P/title",
this);
196 title1PCmd->SetGuidance(
"Define histogram title");
197 para =
new G4UIparameter(
"title",
's',
false);
199 para =
new G4UIparameter(
"x_axis",
's',
false);
201 para =
new G4UIparameter(
"y_axis",
's',
false);
205 ntupleDir =
new G4UIdirectory(
"/eAST/analysis/ntuple/");
206 onePDir->SetGuidance(
"Define an ntuple");
208 addColumnCmd =
new G4UIcommand(
"/eAST/analysis/ntuple/addColumn",
this);
209 addColumnCmd->SetGuidance(
"Define a column and fill it with event-by-event score.");
210 addColumnCmd->SetGuidance(
"Scoring mesh (logical volume for real-world volume scoring) and");
211 addColumnCmd->SetGuidance(
"primitive scorers must be defined prior to this command.");
212 para =
new G4UIparameter(
"meshName",
's',
false);
213 para->SetGuidance(
"Scoring mesh name. Logical volume name for real-world volume scoring.");
215 para =
new G4UIparameter(
"primName",
's',
false);
217 para =
new G4UIparameter(
"unit",
's',
true);
218 para->SetDefaultValue(
"none");
220 para =
new G4UIparameter(
"idx",
'i',
true);
221 para->SetGuidance(
"Index (i.e. copy number) of the cell to be scored. \"-1\" (defult) to score all cells.");
222 para->SetDefaultValue(-1);
223 para->SetParameterRange(
"idx>=-1");
256 #include "G4Tokenizer.hh"
268 auto id =
openCmd->GetNewIntValue(val);
275 G4ExceptionDescription ed;
276 ed <<
"<" <<
id <<
"> is not a valid histogram ID.";
277 cmd->CommandFailed(ed);
285 auto id =
plotCmd->GetNewIntValue(val);
293 G4ExceptionDescription ed;
294 ed <<
"Histogram/profile id <" <<
id <<
"> is not valid.";
295 cmd->CommandFailed(ed);
304 G4cout <<
"Not yet implemented. Sorry." << G4endl;
312 G4Tokenizer next(val);
313 G4String meshName = next();
314 G4String primName = next();
315 G4int idx = StoI(next());
319 G4ExceptionDescription ed;
320 ed <<
"1D histogram <" << val <<
"> cannot be created.";
321 cmd->CommandFailed(ed);
329 G4Tokenizer next(val);
330 G4String meshName = next();
331 G4String primName = next();
336 G4ExceptionDescription ed;
337 ed <<
"1D histogram <" << val <<
"> cannot be created.";
338 cmd->CommandFailed(ed);
346 G4Tokenizer next(val);
347 G4int nBin = StoI(next());
348 G4double minVal = StoD(next());
349 G4double maxVal = StoD(next());
350 G4String unit = next();
351 G4String schem = next();
352 G4bool logVal = StoB(next());
353 if(unit!=
"none" && !(G4UnitDefinition::IsUnitDefined(unit)))
355 G4ExceptionDescription ed;
356 ed <<
"Unknown unit <" << unit <<
">. Command failed.";
357 cmd->CommandFailed(ed);
365 G4Tokenizer next(val);
366 G4String
title = next();
367 G4String x_axis = next();
368 G4String y_axis = next();
377 G4ExceptionDescription ed;
378 ed <<
"This command is not available for this histogram.";
379 cmd->CommandFailed(ed);
388 G4Tokenizer next(val);
389 G4String meshName = next();
390 G4String primName = next();
391 G4int cn = StoI(next());
395 G4ExceptionDescription ed;
396 ed <<
"1D histogram <" << val <<
"> cannot be created.";
397 cmd->CommandFailed(ed);
405 G4Tokenizer next(val);
406 G4double minYVal = StoD(next());
407 G4double maxYVal = StoD(next());
408 G4String unit = next();
409 G4String funcX = next();
410 G4String funcY = next();
411 G4String schem = next();
412 if(unit!=
"none" && !(G4UnitDefinition::IsUnitDefined(unit)))
414 G4ExceptionDescription ed;
415 ed <<
"Unknown unit <" << unit <<
">. Command failed.";
416 cmd->CommandFailed(ed);
424 G4Tokenizer next(val);
425 G4String
title = next();
426 G4String x_axis = next();
427 G4String y_axis = next();
435 G4Tokenizer next(val);
436 G4String meshName = next();
437 G4String primName = next();
438 G4String unit = next();
439 G4int idx = StoI(next());
440 if(unit!=
"none" && !(G4UnitDefinition::IsUnitDefined(unit)))
442 G4ExceptionDescription ed;
443 ed <<
"Unknown unit <" << unit <<
">. Command failed.";
444 cmd->CommandFailed(ed);
451 G4ExceptionDescription ed;
452 ed <<
"Ntuple column <" << val <<
"> cannot be created.";
453 cmd->CommandFailed(ed);