Geant4-11
Data Structures | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends
G4AnalysisMessengerHelper Class Reference

#include <G4AnalysisMessengerHelper.hh>

Data Structures

struct  BinData
 
struct  ValueData
 

Public Member Functions

std::unique_ptr< G4UIcommandCreateGetCommand (G4UImessenger *messenger) const
 
std::unique_ptr< G4UIdirectoryCreateHnDirectory () const
 
std::unique_ptr< G4UIcommandCreateSetAxisCommand (const G4String &axis, G4UImessenger *messenger) const
 
std::unique_ptr< G4UIcommandCreateSetAxisLogCommand (const G4String &axis, G4UImessenger *messenger) const
 
std::unique_ptr< G4UIcommandCreateSetBinsCommand (const G4String &axis, G4UImessenger *messenger) const
 
std::unique_ptr< G4UIcommandCreateSetTitleCommand (G4UImessenger *messenger) const
 
std::unique_ptr< G4UIcommandCreateSetValuesCommand (const G4String &axis, G4UImessenger *messenger) const
 
 G4AnalysisMessengerHelper ()=delete
 
 G4AnalysisMessengerHelper (const G4String &hnType)
 
void GetBinData (BinData &data, std::vector< G4String > &parameters, G4int &counter) const
 
void GetValueData (ValueData &data, std::vector< G4String > &parameters, G4int &counter) const
 
void SetHnType (const G4String &hnType)
 
void WarnAboutParameters (G4UIcommand *command, G4int nofParameters) const
 
void WarnAboutSetCommands () const
 
 ~G4AnalysisMessengerHelper ()=default
 

Private Member Functions

G4String Update (const G4String &str, const G4String &axis="") const
 

Private Attributes

G4String fHnType
 

Static Private Attributes

static constexpr std::string_view fkClass { "G4AnalysisMessengerHelper" }
 

Friends

class G4HnMessenger
 

Detailed Description

Definition at line 45 of file G4AnalysisMessengerHelper.hh.

Constructor & Destructor Documentation

◆ G4AnalysisMessengerHelper() [1/2]

G4AnalysisMessengerHelper::G4AnalysisMessengerHelper ( const G4String hnType)
explicit

Definition at line 78 of file G4AnalysisMessengerHelper.cc.

79 : fHnType(hnType)
80{}

◆ G4AnalysisMessengerHelper() [2/2]

G4AnalysisMessengerHelper::G4AnalysisMessengerHelper ( )
delete

◆ ~G4AnalysisMessengerHelper()

G4AnalysisMessengerHelper::~G4AnalysisMessengerHelper ( )
default

Member Function Documentation

◆ CreateGetCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateGetCommand ( G4UImessenger messenger) const

Definition at line 135 of file G4AnalysisMessengerHelper.cc.

136{
137 auto parId = new G4UIparameter("id", 'i', false);
138 parId->SetGuidance(Update("OBJECT id"));
139 parId->SetParameterRange("id>=0");
140
141 std::unique_ptr<G4UIcommand> command(
142 new G4UIcommand(Update("/analysis/HNTYPE_/get"), messenger));
143 command->SetGuidance(Update("Get the address of the NDIM_D LOBJECT of given id"));
144 command->SetParameter(parId);
145 command->AvailableForStates(G4State_Idle, G4State_GeomClosed, G4State_EventProc);
146
147 return command;
148}
@ G4State_EventProc
@ G4State_Idle
@ G4State_GeomClosed
G4String Update(const G4String &str, const G4String &axis="") const

References G4State_EventProc, G4State_GeomClosed, G4State_Idle, and Update().

Referenced by G4ToolsAnalysisMessenger::G4ToolsAnalysisMessenger().

◆ CreateHnDirectory()

std::unique_ptr< G4UIdirectory > G4AnalysisMessengerHelper::CreateHnDirectory ( ) const

Definition at line 126 of file G4AnalysisMessengerHelper.cc.

127{
128 std::unique_ptr<G4UIdirectory> directory(new G4UIdirectory(Update("/analysis/HNTYPE_/")));
129 directory->SetGuidance(Update("NDIM_D LOBJECT control"));
130 return directory;
131}

References Update().

◆ CreateSetAxisCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateSetAxisCommand ( const G4String axis,
G4UImessenger messenger 
) const

Definition at line 274 of file G4AnalysisMessengerHelper.cc.

276{
277 auto parId = new G4UIparameter("id", 'i', false);
278 parId->SetGuidance(Update("OBJECT id"));
279 parId->SetParameterRange("id>=0");
280
281 auto parAxis = new G4UIparameter("axis", 's', false);
282 parAxis->SetGuidance(Update("Histogram AXIS-axis title", axis));
283
284 std::unique_ptr<G4UIcommand> command(
285 new G4UIcommand(Update("/analysis/HNTYPE_/setUAXISaxis", axis), messenger));
286 command->SetGuidance(Update("Set AXIS-axis title for the NDIM_D LOBJECT of given id", axis));
287 command->SetParameter(parId);
288 command->SetParameter(parAxis);
289 command->AvailableForStates(G4State_PreInit, G4State_Idle);
290
291 return command;
292}
@ G4State_PreInit

References G4State_Idle, G4State_PreInit, and Update().

◆ CreateSetAxisLogCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateSetAxisLogCommand ( const G4String axis,
G4UImessenger messenger 
) const

Definition at line 296 of file G4AnalysisMessengerHelper.cc.

298{
299 auto parId = new G4UIparameter("id", 'i', false);
300 parId->SetGuidance(Update("OBJECT id"));
301 parId->SetParameterRange("id>=0");
302
303 auto parAxisLog = new G4UIparameter("axis", 'b', false);
304 parAxisLog->SetGuidance(Update("Histogram AXIS-axis log scale", axis));
305
306 std::unique_ptr<G4UIcommand> command(
307 new G4UIcommand(Update("/analysis/HNTYPE_/setUAXISaxisLog", axis), messenger));
308 command->SetGuidance(
309 Update("Activate AXIS-axis log scale for plotting of the NDIM_D LOBJECT of given id", axis));
310 command->SetParameter(parId);
311 command->SetParameter(parAxisLog);
312 command->AvailableForStates(G4State_PreInit, G4State_Idle);
313
314 return command;
315}

References G4State_Idle, G4State_PreInit, and Update().

◆ CreateSetBinsCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateSetBinsCommand ( const G4String axis,
G4UImessenger messenger 
) const

Definition at line 175 of file G4AnalysisMessengerHelper.cc.

177{
178 auto parId = new G4UIparameter("id", 'i', false);
179 parId->SetGuidance(Update( "OBJECT id"));
180 parId->SetParameterRange("id>=0");
181
182 auto parNbins = new G4UIparameter("nbins", 'i', false);
183 parNbins->SetGuidance("Number of bins");
184
185 auto parValMin = new G4UIparameter("valMin", 'd', false);
186 parValMin->SetGuidance("Minimum value, expressed in unit");
187
188 auto parValMax = new G4UIparameter("valMax", 'd', false);
189 parValMax->SetGuidance("Maximum value, expressed in unit");
190
191 auto parValUnit = new G4UIparameter("valUnit", 's', true);
192 parValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
193 parValUnit->SetDefaultValue("none");
194
195 auto parValFcn = new G4UIparameter("valFcn", 's', true);
196 parValFcn->SetParameterCandidates("log log10 exp none");
197 G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
198 fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
199 fcnGuidance += "but none value should be used instead.";
200 parValFcn->SetGuidance(fcnGuidance);
201 parValFcn->SetDefaultValue("none");
202
203 auto parValBinScheme = new G4UIparameter("valBinScheme", 's', true);
204 parValBinScheme->SetParameterCandidates("linear log");
205 G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
206 binSchemeGuidance
207 += "Note that the unit and fcn parameters cannot be omitted in this case,\n";
208 binSchemeGuidance += "but none value should be used instead.";
209 parValBinScheme->SetGuidance(binSchemeGuidance);
210 parValBinScheme->SetDefaultValue("linear");
211
212 auto commandName = Update("/analysis/HNTYPE_/setUAXIS", axis);
213 std::unique_ptr<G4UIcommand> command(
214 new G4UIcommand(Update("/analysis/HNTYPE_/setUAXIS", axis), messenger));
215 command->SetGuidance(Update("Set parameters for the NDIM_D LOBJECT of given id:"));
216 command->SetGuidance(
217 Update(" nAXISbins; AXISvalMin; AXISvalMax; AXISunit; AXISfunction; AXISbinScheme", axis));
218 command->SetParameter(parId);
219 command->SetParameter(parNbins);
220 command->SetParameter(parValMin);
221 command->SetParameter(parValMax);
222 command->SetParameter(parValUnit);
223 command->SetParameter(parValFcn);
224 command->SetParameter(parValBinScheme);
225 command->AvailableForStates(G4State_PreInit, G4State_Idle);
226
227 return command;
228}

References G4State_Idle, G4State_PreInit, and Update().

◆ CreateSetTitleCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateSetTitleCommand ( G4UImessenger messenger) const

Definition at line 152 of file G4AnalysisMessengerHelper.cc.

153{
154 auto parId = new G4UIparameter("id", 'i', false);
155 parId->SetGuidance(Update("OBJECT id"));
156 parId->SetParameterRange("id>=0");
157
158 auto parTitle = new G4UIparameter("title", 's', true);
159 parTitle->SetGuidance(Update("OBJECT title"));
160 parTitle->SetDefaultValue("none");
161
162 std::unique_ptr<G4UIcommand> command(
163 new G4UIcommand(Update("/analysis/HNTYPE_/setTitle"), messenger));
164 command->SetGuidance(Update("Set title for the NDIM_D LOBJECT of given id"));
165 command->SetParameter(parId);
166 command->SetParameter(parTitle);
167 command->AvailableForStates(G4State_PreInit, G4State_Idle);
168
169 return command;
170}

References G4State_Idle, G4State_PreInit, and Update().

◆ CreateSetValuesCommand()

std::unique_ptr< G4UIcommand > G4AnalysisMessengerHelper::CreateSetValuesCommand ( const G4String axis,
G4UImessenger messenger 
) const

Definition at line 232 of file G4AnalysisMessengerHelper.cc.

234{
235 auto parId = new G4UIparameter("id", 'i', false);
236 parId->SetGuidance(Update("OBJECT id"));
237 parId->SetParameterRange("id>=0");
238
239 auto parValMin = new G4UIparameter("valMin", 'd', false);
240 parValMin->SetGuidance(Update("Minimum AXIS-value expressed in unit", axis));
241
242 auto parValMax = new G4UIparameter("valMax", 'd', false);
243 parValMax->SetGuidance(Update("Maximum AXIS-value expressed in unit", axis));
244
245 auto parValUnit = new G4UIparameter("valUnit", 's', true);
246 parValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
247 parValUnit->SetDefaultValue("none");
248
249 auto parValFcn = new G4UIparameter("valFcn", 's', true);
250 parValFcn->SetParameterCandidates("log log10 exp none");
251 G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
252 fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
253 fcnGuidance += "but none value should be used instead.";
254 parValFcn->SetGuidance(fcnGuidance);
255 parValFcn->SetDefaultValue("none");
256
257 std::unique_ptr<G4UIcommand> command(
258 new G4UIcommand(Update("/analysis/HNTYPE_/setUAXIS", axis), messenger));
259 command->SetGuidance(Update("Set parameters for the NDIM_D LOBJECT of #id:"));
260 command->SetGuidance(
261 Update(" AXISvalMin; AXISvalMax; AXISunit; AXISfunction", axis));
262 command->SetParameter(parId);
263 command->SetParameter(parValMin);
264 command->SetParameter(parValMax);
265 command->SetParameter(parValUnit);
266 command->SetParameter(parValFcn);
267 command->AvailableForStates(G4State_PreInit, G4State_Idle);
268
269 return command;
270}

References G4State_Idle, G4State_PreInit, and Update().

◆ GetBinData()

void G4AnalysisMessengerHelper::GetBinData ( BinData data,
std::vector< G4String > &  parameters,
G4int counter 
) const

Definition at line 318 of file G4AnalysisMessengerHelper.cc.

321{
322 data.fNbins = G4UIcommand::ConvertToInt(parameters[counter++]);
323 data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
324 data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
325 data.fSunit = parameters[counter++];
326 data.fSfcn = parameters[counter++];
327 data.fSbinScheme = parameters[counter++];
328}
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:557
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:575

References G4UIcommand::ConvertToDouble(), G4UIcommand::ConvertToInt(), G4AnalysisMessengerHelper::BinData::fNbins, G4AnalysisMessengerHelper::BinData::fSbinScheme, G4AnalysisMessengerHelper::BinData::fSfcn, G4AnalysisMessengerHelper::BinData::fSunit, G4AnalysisMessengerHelper::BinData::fVmax, and G4AnalysisMessengerHelper::BinData::fVmin.

◆ GetValueData()

void G4AnalysisMessengerHelper::GetValueData ( ValueData data,
std::vector< G4String > &  parameters,
G4int counter 
) const

Definition at line 331 of file G4AnalysisMessengerHelper.cc.

334{
335 data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
336 data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
337 data.fSunit = parameters[counter++];
338 data.fSfcn = parameters[counter++];
339}

References G4UIcommand::ConvertToDouble(), G4AnalysisMessengerHelper::ValueData::fSfcn, G4AnalysisMessengerHelper::ValueData::fSunit, G4AnalysisMessengerHelper::ValueData::fVmax, and G4AnalysisMessengerHelper::ValueData::fVmin.

◆ SetHnType()

void G4AnalysisMessengerHelper::SetHnType ( const G4String hnType)
inline

Definition at line 119 of file G4AnalysisMessengerHelper.hh.

120{ fHnType = hnType; }

References fHnType.

Referenced by G4ToolsAnalysisMessenger::G4ToolsAnalysisMessenger().

◆ Update()

G4String G4AnalysisMessengerHelper::Update ( const G4String str,
const G4String axis = "" 
) const
private

Definition at line 87 of file G4AnalysisMessengerHelper.cc.

88{
89 G4String newStr(str);
90
91 // Hn, Pn
92 G4String upperHnType = G4StrUtil::to_upper_copy(str);
93 Replace(newStr, "UHNTYPE_", upperHnType);
94
95 // hn, pn
96 Replace(newStr, "HNTYPE_", fHnType);
97
98 // n = 1,2,3
99 G4String second = fHnType.substr(1,1);
100 Replace(newStr, "NDIM_", second);
101
102 // histogram, profile
104 Replace(newStr, "LOBJECT", lowerObjectType);
105
106 // Histogram, Profile
107 Replace(newStr, "OBJECT", ObjectType(fHnType));
108
109 // X, Y, Z
110 G4String upperAxis = G4StrUtil::to_upper_copy(axis);
111 Replace(newStr, "UAXIS", upperAxis);
112
113 // x, y, z
114 Replace(newStr, "AXIS", axis);
115
116 // return result
117 return newStr;
118}
static constexpr double second
Definition: G4SIunits.hh:137
G4String to_lower_copy(G4String str)
Return lowercased copy of string.
G4String to_upper_copy(G4String str)
Return uppercase copy of string.
void Replace(std::string &str, const std::string &from, const std::string &to)

References fHnType, anonymous_namespace{G4AnalysisMessengerHelper.cc}::ObjectType(), anonymous_namespace{G4AnalysisMessengerHelper.cc}::Replace(), second, G4StrUtil::to_lower_copy(), and G4StrUtil::to_upper_copy().

Referenced by CreateGetCommand(), CreateHnDirectory(), CreateSetAxisCommand(), CreateSetAxisLogCommand(), CreateSetBinsCommand(), CreateSetTitleCommand(), and CreateSetValuesCommand().

◆ WarnAboutParameters()

void G4AnalysisMessengerHelper::WarnAboutParameters ( G4UIcommand command,
G4int  nofParameters 
) const

Definition at line 342 of file G4AnalysisMessengerHelper.cc.

344{
345 Warn(
346 "Got wrong number of \"" + command->GetCommandName() +
347 "\" parameters: " + to_string(nofParameters) +
348 " instead of " + to_string(command->GetParameterEntries()) + " expected",
349 fkClass, "WarnAboutParameters");
350}
static constexpr std::string_view fkClass
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:137
void Warn(const G4String &message, const std::string_view inClass, const std::string_view inFunction)

References fkClass, G4UIcommand::GetCommandName(), G4UIcommand::GetParameterEntries(), and G4Analysis::Warn().

◆ WarnAboutSetCommands()

void G4AnalysisMessengerHelper::WarnAboutSetCommands ( ) const

Definition at line 353 of file G4AnalysisMessengerHelper.cc.

354{
355 Warn(
356 "Command setX, setY, setZ must be called successively in this order.\n"
357 "Command was ignored.",
358 fkClass, "WarnAboutSetCommands");
359}

References fkClass, and G4Analysis::Warn().

Friends And Related Function Documentation

◆ G4HnMessenger

friend class G4HnMessenger
friend

Definition at line 69 of file G4AnalysisMessengerHelper.hh.

Field Documentation

◆ fHnType

G4String G4AnalysisMessengerHelper::fHnType
private

Definition at line 114 of file G4AnalysisMessengerHelper.hh.

Referenced by SetHnType(), and Update().

◆ fkClass

constexpr std::string_view G4AnalysisMessengerHelper::fkClass { "G4AnalysisMessengerHelper" }
staticconstexprprivate

Definition at line 111 of file G4AnalysisMessengerHelper.hh.

Referenced by WarnAboutParameters(), and WarnAboutSetCommands().


The documentation for this class was generated from the following files: