54 fCreateH1Cmd(nullptr),
56 fSetH1TitleCmd(nullptr),
57 fSetH1XAxisCmd(nullptr),
58 fSetH1YAxisCmd(nullptr)
60 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(
"h1");
62 fDirectory = fHelper->CreateHnDirectory();
67 fSetH1XCmd = fHelper->CreateSetBinsCommand(
"x",
this);
70 fSetH1TitleCmd = fHelper->CreateSetTitleCommand(
this);
71 fSetH1XAxisCmd = fHelper->CreateSetAxisCommand(
"x",
this);
72 fSetH1YAxisCmd = fHelper->CreateSetAxisCommand(
"y",
this);
73 fSetH1XAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"x",
this);
74 fSetH1YAxisLogCmd = fHelper->CreateSetAxisLogCommand(
"y",
this);
86void G4H1Messenger::CreateH1Cmd()
89 h1Name->SetGuidance(
"Histogram name (label)");
92 h1Title->SetGuidance(
"Histogram title");
95 h1Nbins0->SetGuidance(
"Number of bins (default = 100)");
96 h1Nbins0->SetGuidance(
"Can be reset with /analysis/h1/set command");
97 h1Nbins0->SetDefaultValue(100);
100 h1ValMin0->SetGuidance(
"Minimum value, expressed in unit (default = 0.)");
101 h1ValMin0->SetGuidance(
"Can be reset with /analysis/h1/set command");
102 h1ValMin0->SetDefaultValue(0.);
105 h1ValMax0->SetGuidance(
"Maximum value, expressed in unit (default = 1.)");
106 h1ValMax0->SetGuidance(
"Can be reset with /analysis/h1/set command");
107 h1ValMax0->SetDefaultValue(1.);
110 h1ValUnit0->SetGuidance(
"The unit applied to filled values and valMin0, valMax0");
111 h1ValUnit0->SetDefaultValue(
"none");
114 G4String fcnGuidance =
"The function applied to filled values (log, log10, exp).\n";
115 fcnGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
116 fcnGuidance +=
"but none value should be used instead.";
117 h1ValFcn0->SetGuidance(fcnGuidance);
118 h1ValFcn0->SetParameterCandidates(
"log log10 exp none");
119 h1ValFcn0->SetDefaultValue(
"none");
121 auto h1ValBinScheme0 =
new G4UIparameter(
"valBinScheme0",
's',
true);
122 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
123 h1ValBinScheme0->SetParameterCandidates(
"linear log");
125 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
126 binSchemeGuidance +=
"but none value should be used instead.";
127 h1ValBinScheme0->SetGuidance(binSchemeGuidance);
128 h1ValBinScheme0->SetDefaultValue(
"linear");
130 fCreateH1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h1/create",
this);
131 fCreateH1Cmd->SetGuidance(
"Create 1D histogram");
132 fCreateH1Cmd->SetParameter(h1Name);
133 fCreateH1Cmd->SetParameter(h1Title);
134 fCreateH1Cmd->SetParameter(h1Nbins0);
135 fCreateH1Cmd->SetParameter(h1ValMin0);
136 fCreateH1Cmd->SetParameter(h1ValMax0);
137 fCreateH1Cmd->SetParameter(h1ValUnit0);
138 fCreateH1Cmd->SetParameter(h1ValFcn0);
139 fCreateH1Cmd->SetParameter(h1ValBinScheme0);
145void G4H1Messenger::SetH1Cmd()
148 h1Id->SetGuidance(
"Histogram id");
149 h1Id->SetParameterRange(
"id>=0");
152 h1Nbins->SetGuidance(
"Number of bins");
155 h1ValMin->SetGuidance(
"Minimum value, expressed in unit");
158 h1ValMax->SetGuidance(
"Maximum value, expressed in unit");
161 h1ValUnit->SetGuidance(
"The unit applied to filled values and valMin, valMax");
162 h1ValUnit->SetDefaultValue(
"none");
165 h1ValFcn->SetParameterCandidates(
"log log10 exp none");
166 G4String fcnGuidance =
"The function applied to filled values (log, log10, exp, none).\n";
167 fcnGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
168 fcnGuidance +=
"but none value should be used instead.";
169 h1ValFcn->SetGuidance(fcnGuidance);
170 h1ValFcn->SetDefaultValue(
"none");
172 auto h1ValBinScheme =
new G4UIparameter(
"valBinScheme",
's',
true);
173 h1ValBinScheme->SetParameterCandidates(
"linear log");
174 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
176 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
177 binSchemeGuidance +=
"but none value should be used instead.";
178 h1ValBinScheme->SetGuidance(binSchemeGuidance);
179 h1ValBinScheme->SetDefaultValue(
"linear");
181 fSetH1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h1/set",
this);
182 fSetH1Cmd->SetGuidance(
"Set parameters for the 1D histogram of given id:");
183 fSetH1Cmd->SetGuidance(
" nbins; valMin; valMax; unit; function; binScheme");
184 fSetH1Cmd->SetParameter(h1Id);
185 fSetH1Cmd->SetParameter(h1Nbins);
186 fSetH1Cmd->SetParameter(h1ValMin);
187 fSetH1Cmd->SetParameter(h1ValMax);
188 fSetH1Cmd->SetParameter(h1ValUnit);
189 fSetH1Cmd->SetParameter(h1ValFcn);
190 fSetH1Cmd->SetParameter(h1ValBinScheme);
202 std::vector<G4String> parameters;
207 fHelper->WarnAboutParameters(command, parameters.size());
211 if ( command == fCreateH1Cmd.get() ) {
213 auto name = parameters[counter++];
214 auto title = parameters[counter++];
216 fHelper->GetBinData(xdata, parameters, counter);
222 else if ( command == fSetH1Cmd.get() ) {
226 fHelper->GetBinData(xdata, parameters, counter);
232 else if ( command == fSetH1XCmd.get() ) {
236 fHelper->GetBinData(xdata, parameters, counter);
242 else if ( command == fSetH1TitleCmd.get() ) {
245 auto title = parameters[counter++];
248 else if ( command == fSetH1XAxisCmd.get() ) {
251 auto xaxis = parameters[counter++];
254 else if ( command == fSetH1YAxisCmd.get() ) {
257 auto yaxis = parameters[counter++];
260 else if ( command == fSetH1XAxisLogCmd.get() ) {
266 else if ( command == fSetH1YAxisLogCmd.get() ) {
G4H1Messenger(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)
G4int CreateH1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4bool SetH1YAxisIsLog(G4int id, G4bool isLog)
G4bool SetH1Title(G4int id, const G4String &title)
G4bool SetH1XAxisTitle(G4int id, const G4String &title)
G4bool SetH1XAxisIsLog(G4int id, G4bool isLog)
G4bool SetH1(G4int id, G4int nbins, G4double xmin, G4double xmax, const G4String &unitName="none", const G4String &fcnName="none", const G4String &binSchemeName="linear")
G4bool SetH1YAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4double GetUnitValue(const G4String &unit)