47 using namespace G4Analysis;
55 fCreateH1Cmd(nullptr),
57 fSetH1TitleCmd(nullptr),
58 fSetH1XAxisCmd(nullptr),
59 fSetH1YAxisCmd(nullptr)
61 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>(
"h1");
63 fDirectory = fHelper->CreateHnDirectory();
68 fSetH1XCmd = fHelper->CreateSetBinsCommand(
"x",
this);
71 fSetH1TitleCmd = fHelper->CreateSetTitleCommand(
this);
72 fSetH1XAxisCmd = fHelper->CreateSetAxisCommand(
"x",
this);
73 fSetH1YAxisCmd = fHelper->CreateSetAxisCommand(
"y",
this);
85 void G4H1Messenger::CreateH1Cmd()
88 h1Name->SetGuidance(
"Histogram name (label)");
91 h1Title->SetGuidance(
"Histogram title");
94 h1Nbins0->SetGuidance(
"Number of bins (default = 100)");
95 h1Nbins0->SetGuidance(
"Can be reset with /analysis/h1/set command");
96 h1Nbins0->SetDefaultValue(100);
99 h1ValMin0->SetGuidance(
"Minimum value, expressed in unit (default = 0.)");
100 h1ValMin0->SetGuidance(
"Can be reset with /analysis/h1/set command");
101 h1ValMin0->SetDefaultValue(0.);
104 h1ValMax0->SetGuidance(
"Maximum value, expressed in unit (default = 1.)");
105 h1ValMax0->SetGuidance(
"Can be reset with /analysis/h1/set command");
106 h1ValMax0->SetDefaultValue(1.);
109 h1ValUnit0->SetGuidance(
"The unit applied to filled values and valMin0, valMax0");
110 h1ValUnit0->SetDefaultValue(
"none");
113 G4String fcnGuidance =
"The function applied to filled values (log, log10, exp).\n";
114 fcnGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
115 fcnGuidance +=
"but none value should be used instead.";
116 h1ValFcn0->SetGuidance(fcnGuidance);
117 h1ValFcn0->SetParameterCandidates(
"log log10 exp none");
118 h1ValFcn0->SetDefaultValue(
"none");
120 auto h1ValBinScheme0 =
new G4UIparameter(
"valBinScheme0",
's',
true);
121 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
122 h1ValBinScheme0->SetParameterCandidates(
"linear log");
124 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
125 binSchemeGuidance +=
"but none value should be used instead.";
126 h1ValBinScheme0->SetGuidance(binSchemeGuidance);
127 h1ValBinScheme0->SetDefaultValue(
"linear");
129 fCreateH1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h1/create",
this);
130 fCreateH1Cmd->SetGuidance(
"Create 1D histogram");
131 fCreateH1Cmd->SetParameter(h1Name);
132 fCreateH1Cmd->SetParameter(h1Title);
133 fCreateH1Cmd->SetParameter(h1Nbins0);
134 fCreateH1Cmd->SetParameter(h1ValMin0);
135 fCreateH1Cmd->SetParameter(h1ValMax0);
136 fCreateH1Cmd->SetParameter(h1ValUnit0);
137 fCreateH1Cmd->SetParameter(h1ValFcn0);
138 fCreateH1Cmd->SetParameter(h1ValBinScheme0);
144 void G4H1Messenger::SetH1Cmd()
147 h1Id->SetGuidance(
"Histogram id");
148 h1Id->SetParameterRange(
"id>=0");
151 h1Nbins->SetGuidance(
"Number of bins");
154 h1ValMin->SetGuidance(
"Minimum value, expressed in unit");
157 h1ValMax->SetGuidance(
"Maximum value, expressed in unit");
160 h1ValUnit->SetGuidance(
"The unit applied to filled values and valMin, valMax");
161 h1ValUnit->SetDefaultValue(
"none");
164 h1ValFcn->SetParameterCandidates(
"log log10 exp none");
165 G4String fcnGuidance =
"The function applied to filled values (log, log10, exp, none).\n";
166 fcnGuidance +=
"Note that the unit parameter cannot be omitted in this case,\n";
167 fcnGuidance +=
"but none value should be used instead.";
168 h1ValFcn->SetGuidance(fcnGuidance);
169 h1ValFcn->SetDefaultValue(
"none");
171 auto h1ValBinScheme =
new G4UIparameter(
"valBinScheme",
's',
true);
172 h1ValBinScheme->SetParameterCandidates(
"linear log");
173 G4String binSchemeGuidance =
"The binning scheme (linear, log).\n";
175 +=
"Note that the unit and fcn parameters cannot be omitted in this case,\n";
176 binSchemeGuidance +=
"but none value should be used instead.";
177 h1ValBinScheme->SetGuidance(binSchemeGuidance);
178 h1ValBinScheme->SetDefaultValue(
"linear");
180 fSetH1Cmd = G4Analysis::make_unique<G4UIcommand>(
"/analysis/h1/set",
this);
181 fSetH1Cmd->SetGuidance(
"Set parameters for the 1D histogram of given id:");
182 fSetH1Cmd->SetGuidance(
" nbins; valMin; valMax; unit; function; binScheme");
183 fSetH1Cmd->SetParameter(h1Id);
184 fSetH1Cmd->SetParameter(h1Nbins);
185 fSetH1Cmd->SetParameter(h1ValMin);
186 fSetH1Cmd->SetParameter(h1ValMax);
187 fSetH1Cmd->SetParameter(h1ValUnit);
188 fSetH1Cmd->SetParameter(h1ValFcn);
189 fSetH1Cmd->SetParameter(h1ValBinScheme);
201 std::vector<G4String> parameters;
206 fHelper->WarnAboutParameters(command, parameters.size());
210 if ( command == fCreateH1Cmd.get() ) {
212 auto name = parameters[counter++];
213 auto title = parameters[counter++];
215 fHelper->GetBinData(xdata, parameters, counter);
221 else if ( command == fSetH1Cmd.get() ) {
225 fHelper->GetBinData(xdata, parameters, counter);
231 else if ( command == fSetH1XCmd.get() ) {
235 fHelper->GetBinData(xdata, parameters, counter);
241 else if ( command == fSetH1TitleCmd.get() ) {
244 auto title = parameters[counter++];
247 else if ( command == fSetH1XAxisCmd.get() ) {
250 auto xaxis = parameters[counter++];
253 else if ( command == fSetH1YAxisCmd.get() ) {
256 auto yaxis = parameters[counter++];
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 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)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
virtual void SetNewValue(G4UIcommand *command, G4String value) final
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4H1Messenger(G4VAnalysisManager *manager)
G4bool SetH1Title(G4int id, const G4String &title)
G4int GetParameterEntries() const
G4bool SetH1XAxisTitle(G4int id, const G4String &title)