Geant4  10.02.p03
G4AnalysisMessengerHelper Class Reference

#include <G4AnalysisMessengerHelper.hh>

Collaboration diagram for G4AnalysisMessengerHelper:

Classes

struct  BinData
 
struct  ValueData
 

Public Member Functions

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

Private Member Functions

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

Private Attributes

G4String fHnType
 

Friends

class G4HnMessenger
 

Detailed Description

Definition at line 45 of file G4AnalysisMessengerHelper.hh.

Constructor & Destructor Documentation

◆ G4AnalysisMessengerHelper()

G4AnalysisMessengerHelper::G4AnalysisMessengerHelper ( const G4String hnType)
explicit

Definition at line 79 of file G4AnalysisMessengerHelper.cc.

80  : fHnType(hnType)
81 {}

◆ ~G4AnalysisMessengerHelper()

G4AnalysisMessengerHelper::~G4AnalysisMessengerHelper ( )

Definition at line 84 of file G4AnalysisMessengerHelper.cc.

85 {}

Member Function Documentation

◆ CreateHnDirectory()

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

Definition at line 134 of file G4AnalysisMessengerHelper.cc.

135 {
136  std::unique_ptr<G4UIdirectory> directory(new G4UIdirectory(Update("/analysis/HNTYPE_/")));
137  directory->SetGuidance(Update("NDIM_D LOBJECT control"));
138  return directory;
139 }
G4String Update(const G4String &str, const G4String &axis="") const
Here is the call graph for this function:

◆ CreateSetAxisCommand()

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

Definition at line 259 of file G4AnalysisMessengerHelper.cc.

261 {
262  auto parId = new G4UIparameter("id", 'i', false);
263  parId->SetGuidance(Update("OBJECT id"));
264  parId->SetParameterRange("id>=0");
265 
266  auto parAxis = new G4UIparameter("axis", 's', true);
267  parAxis->SetGuidance(Update("Histogram AXIS-axis title", axis));
268  parAxis->SetDefaultValue("none");
269 
270  std::unique_ptr<G4UIcommand> command(
271  new G4UIcommand(Update("/analysis/HNTYPE_/setUAXISaxis", axis), messenger));
272  command->SetGuidance(Update("Set AXIS-axis title for the NDIM_D LOBJECT of given id", axis));
273  command->SetParameter(parId);
274  command->SetParameter(parAxis);
275  command->AvailableForStates(G4State_PreInit, G4State_Idle);
276 
277  return command;
278 }
G4String Update(const G4String &str, const G4String &axis="") const
Here is the call graph for this function:

◆ CreateSetBinsCommand()

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

Definition at line 166 of file G4AnalysisMessengerHelper.cc.

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

◆ CreateSetTitleCommand()

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

Definition at line 143 of file G4AnalysisMessengerHelper.cc.

144 {
145  auto parId = new G4UIparameter("id", 'i', false);
146  parId->SetGuidance(Update("OBJECT id"));
147  parId->SetParameterRange("id>=0");
148 
149  auto parTitle = new G4UIparameter("title", 's', true);
150  parTitle->SetGuidance(Update("OBJECT title"));
151  parTitle->SetDefaultValue("none");
152 
153  std::unique_ptr<G4UIcommand> command(
154  new G4UIcommand(Update("/analysis/HNTYPE_/setTitle"), messenger));
155  command->SetGuidance(Update("Set title for the NDIM_D LOBJECT of given id"));
156  command->SetParameter(parId);
157  command->SetParameter(parTitle);
158  command->AvailableForStates(G4State_PreInit, G4State_Idle);
159 
160  return command;
161 }
G4String Update(const G4String &str, const G4String &axis="") const
Here is the call graph for this function:

◆ CreateSetValuesCommand()

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

Definition at line 222 of file G4AnalysisMessengerHelper.cc.

224 {
225  auto parId = new G4UIparameter("id", 'i', false);
226  parId->SetGuidance(Update("OBJECT id"));
227  parId->SetParameterRange("id>=0");
228 
229  auto parValMin = new G4UIparameter("valMin", 'd', false);
230  parValMin->SetGuidance(Update("Minimum AXIS-value expressed in unit", axis));
231 
232  auto parValMax = new G4UIparameter("valMax", 'd', false);
233  parValMax->SetGuidance(Update("Maximum AXIS-value expressed in unit", axis));
234 
235  auto parValUnit = new G4UIparameter("valUnit", 's', true);
236  parValUnit->SetGuidance("The unit applied to filled values and valMin, valMax");
237  parValUnit->SetDefaultValue("none");
238 
239  auto parValFcn = new G4UIparameter("valFcn", 's', true);
240  parValFcn->SetParameterCandidates("log log10 exp none");
241  G4String fcnGuidance = "The function applied to filled values (log, log10, exp, none).\n";
242  fcnGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
243  fcnGuidance += "but none value should be used instead.";
244  parValFcn->SetGuidance(fcnGuidance);
245  parValFcn->SetDefaultValue("none");
246 
247  std::unique_ptr<G4UIcommand> command(
248  new G4UIcommand(Update("/analysis/HNTYPE_/setUAXIS", axis), messenger));
249  command->SetGuidance(Update("Set parameters for the NDIM_D LOBJECT of #id:"));
250  command->SetGuidance(
251  Update(" AXISvalMin; AXISvalMax; AXISunit; AXISfunction", axis));
252  command->AvailableForStates(G4State_PreInit, G4State_Idle);
253 
254  return command;
255 }
G4String Update(const G4String &str, const G4String &axis="") const
Here is the call graph for this function:

◆ GetBinData()

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

Definition at line 281 of file G4AnalysisMessengerHelper.cc.

284 {
285  data.fNbins = G4UIcommand::ConvertToInt(parameters[counter++]);
286  data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
287  data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
288  data.fSunit = parameters[counter++];
289  data.fSfcn = parameters[counter++];
290  data.fSbinScheme = parameters[counter++];
291 }
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:443
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
Here is the call graph for this function:

◆ GetValueData()

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

Definition at line 294 of file G4AnalysisMessengerHelper.cc.

297 {
298  data.fVmin = G4UIcommand::ConvertToDouble(parameters[counter++]);
299  data.fVmax = G4UIcommand::ConvertToDouble(parameters[counter++]); ;
300  data.fSunit = parameters[counter++];
301  data.fSfcn = parameters[counter++];
302 }
static G4double ConvertToDouble(const char *st)
Definition: G4UIcommand.cc:443
Here is the call graph for this function:

◆ Update()

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

Definition at line 92 of file G4AnalysisMessengerHelper.cc.

93 {
94  G4String newStr(str);
95 
96  // Hn, Pn
97  G4String upperHnType(str);
98  upperHnType.toUpper();
99  Replace(newStr, "UHNTYPE_", upperHnType);
100 
101  // hn, pn
102  Replace(newStr, "HNTYPE_", fHnType);
103 
104  // n = 1,2,3
105  G4String second = fHnType.substr(1,1);
106  Replace(newStr, "NDIM_", second);
107 
108  // histogram, profile
109  G4String lowerObjectType(ObjectType(fHnType));
110  lowerObjectType.toLower();
111  Replace(newStr, "LOBJECT", lowerObjectType);
112 
113  // Histogram, Profile
114  Replace(newStr, "OBJECT", ObjectType(fHnType));
115 
116  // X, Y, Z
117  G4String upperAxis(axis);
118  upperAxis.toUpper();
119  Replace(newStr, "UAXIS", upperAxis);
120 
121  // x, y, z
122  Replace(newStr, "AXIS", axis);
123 
124  // return result
125  return newStr;
126 }
static const double second
Definition: G4SIunits.hh:156
Here is the call graph for this function:
Here is the caller graph for this function:

◆ WarnAboutParameters()

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

Definition at line 305 of file G4AnalysisMessengerHelper.cc.

307 {
308  G4ExceptionDescription description;
309  description
310  << "Got wrong number of \"" << command->GetCommandName()
311  << "\" parameters: " << nofParameters
312  << " instead of " << command->GetParameterEntries()
313  << " expected" << G4endl;
314  G4String methodName(Update("G4UHNTYPE_Messenger::SetNewValue"));
315  G4Exception(methodName,
316  "Analysis_W013", JustWarning, description);
317 }
const G4String & GetCommandName() const
Definition: G4UIcommand.hh:141
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String Update(const G4String &str, const G4String &axis="") const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

◆ WarnAboutSetCommands()

void G4AnalysisMessengerHelper::WarnAboutSetCommands ( ) const

Definition at line 320 of file G4AnalysisMessengerHelper.cc.

321 {
322  G4ExceptionDescription description;
323  description
324  << "Command setX, setY, setZ must be called sucessively in this order. " << G4endl
325  << "Command was ignored." << G4endl;
326  G4String methodName(Update("G4UHNTYPE_Messenger::SetNewValue"));
327  G4Exception(methodName,
328  "Analysis_W013", JustWarning, description);
329 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4String Update(const G4String &str, const G4String &axis="") const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

Friends And Related Function Documentation

◆ G4HnMessenger

friend class G4HnMessenger
friend

Definition at line 79 of file G4AnalysisMessengerHelper.hh.

Member Data Documentation

◆ fHnType

G4String G4AnalysisMessengerHelper::fHnType
private

Definition at line 112 of file G4AnalysisMessengerHelper.hh.


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