Geant4  10.02.p03
G4P1Messenger Class Reference

#include <G4P1Messenger.hh>

Inheritance diagram for G4P1Messenger:
Collaboration diagram for G4P1Messenger:

Public Member Functions

 G4P1Messenger (G4VAnalysisManager *manager)
 
virtual ~G4P1Messenger ()
 
virtual void SetNewValue (G4UIcommand *command, G4String value) final
 
- Public Member Functions inherited from G4UImessenger
 G4UImessenger ()
 
 G4UImessenger (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
virtual ~G4UImessenger ()
 
virtual G4String GetCurrentValue (G4UIcommand *command)
 
G4bool operator== (const G4UImessenger &messenger) const
 
G4bool CommandsShouldBeInMaster () const
 

Private Member Functions

void CreateP1Cmd ()
 
void SetP1Cmd ()
 

Private Attributes

G4VAnalysisManagerfManager
 Associated class. More...
 
std::unique_ptr< G4AnalysisMessengerHelperfHelper
 
std::unique_ptr< G4UIdirectoryfDirectory
 
std::unique_ptr< G4UIcommandfCreateP1Cmd
 
std::unique_ptr< G4UIcommandfSetP1Cmd
 
std::unique_ptr< G4UIcommandfSetP1XCmd
 
std::unique_ptr< G4UIcommandfSetP1YCmd
 
std::unique_ptr< G4UIcommandfSetP1TitleCmd
 
std::unique_ptr< G4UIcommandfSetP1XAxisCmd
 
std::unique_ptr< G4UIcommandfSetP1YAxisCmd
 
G4int fXId
 
G4AnalysisMessengerHelper::BinData fXData
 

Additional Inherited Members

- Protected Member Functions inherited from G4UImessenger
G4String ItoS (G4int i)
 
G4String DtoS (G4double a)
 
G4String BtoS (G4bool b)
 
G4int StoI (G4String s)
 
G4double StoD (G4String s)
 
G4bool StoB (G4String s)
 
void AddUIcommand (G4UIcommand *newCommand)
 
void CreateDirectory (const G4String &path, const G4String &dsc, G4bool commandsToBeBroadcasted=true)
 
template<typename T >
T * CreateCommand (const G4String &cname, const G4String &dsc)
 
- Protected Attributes inherited from G4UImessenger
G4UIdirectorybaseDir
 
G4String baseDirName
 
G4bool commandsShouldBeInMaster
 

Detailed Description

Definition at line 46 of file G4P1Messenger.hh.

Constructor & Destructor Documentation

◆ G4P1Messenger()

G4P1Messenger::G4P1Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 43 of file G4P1Messenger.cc.

44  : G4UImessenger(),
45  fManager(manager),
46  fHelper(nullptr),
47  fDirectory(nullptr),
48  fCreateP1Cmd(nullptr),
49  fSetP1Cmd(nullptr),
50  fSetP1TitleCmd(nullptr),
51  fSetP1XAxisCmd(nullptr),
52  fSetP1YAxisCmd(nullptr),
53  fXData()
54 {
55  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p1");
56 
57  fDirectory = fHelper->CreateHnDirectory();
58 
59  CreateP1Cmd();
60 
61  SetP1Cmd();
62  fSetP1XCmd = fHelper->CreateSetBinsCommand("x", this);
63  fSetP1YCmd = fHelper->CreateSetValuesCommand("y", this);
64 
65  fSetP1TitleCmd = fHelper->CreateSetTitleCommand(this);
66  fSetP1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
67  fSetP1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
68 }
std::unique_ptr< G4UIcommand > fSetP1XAxisCmd
G4AnalysisMessengerHelper::BinData fXData
std::unique_ptr< G4UIcommand > fSetP1Cmd
std::unique_ptr< G4UIcommand > fSetP1XCmd
std::unique_ptr< G4UIcommand > fSetP1TitleCmd
G4VAnalysisManager * fManager
Associated class.
std::unique_ptr< G4UIdirectory > fDirectory
std::unique_ptr< G4UIcommand > fSetP1YAxisCmd
std::unique_ptr< G4UIcommand > fCreateP1Cmd
std::unique_ptr< G4UIcommand > fSetP1YCmd
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
void CreateP1Cmd()
Here is the call graph for this function:

◆ ~G4P1Messenger()

G4P1Messenger::~G4P1Messenger ( )
virtual

Definition at line 71 of file G4P1Messenger.cc.

72 {}

Member Function Documentation

◆ CreateP1Cmd()

void G4P1Messenger::CreateP1Cmd ( )
private

Definition at line 79 of file G4P1Messenger.cc.

80 {
81  auto p1Name = new G4UIparameter("name", 's', false);
82  p1Name->SetGuidance("Profile name (label)");
83 
84  auto p1Title = new G4UIparameter("title", 's', false);
85  p1Title->SetGuidance("Profile title");
86 
87  auto p1xNbins0 = new G4UIparameter("xnbins0", 'i', true);
88  p1xNbins0->SetGuidance("Number of x-bins (default = 100)");
89  p1xNbins0->SetGuidance("Can be reset with /analysis/p1/set command");
90  p1xNbins0->SetDefaultValue(100);
91 
92  auto p1xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
93  p1xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
94  p1xValMin0->SetGuidance("Can be reset with /analysis/p1/set command");
95  p1xValMin0->SetDefaultValue(0.);
96 
97  auto p1xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
98  p1xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
99  p1xValMax0->SetGuidance("Can be reset with /analysis/p1/set command");
100  p1xValMax0->SetDefaultValue(1.);
101 
102  auto p1xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
103  p1xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
104  p1xValUnit0->SetDefaultValue("none");
105 
106  auto p1xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
107  G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
108  fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
109  fcnxGuidance += "but none value should be used insted.";
110  p1xValFcn0->SetGuidance(fcnxGuidance);
111  p1xValFcn0->SetParameterCandidates("log log10 exp none");
112  p1xValFcn0->SetDefaultValue("none");
113 
114  auto p1xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
115  G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
116  p1xValBinScheme0->SetParameterCandidates("linear log");
117  binSchemeGuidance
118  += "Note that the unit and fcn parameters cannot be omitted in this case,\n";
119  binSchemeGuidance += "but none value should be used insted.";
120  p1xValBinScheme0->SetGuidance(binSchemeGuidance);
121  p1xValBinScheme0->SetDefaultValue("linear");
122 
123  auto p1yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
124  p1yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
125  p1yValMin0->SetGuidance("Can be reset with /analysis/p1/set command");
126  p1yValMin0->SetDefaultValue(0.);
127 
128  auto p1yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
129  p1yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
130  p1yValMax0->SetGuidance("Can be reset with /analysis/p1/set command");
131  p1yValMax0->SetDefaultValue(1.);
132 
133  auto p1yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
134  p1yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
135  p1yValUnit0->SetDefaultValue("none");
136 
137  auto p1yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
138  G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).\n";
139  fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
140  fcnyGuidance += "but none value should be used insted.";
141  p1yValFcn0->SetGuidance(fcnyGuidance);
142  p1yValFcn0->SetParameterCandidates("log log10 exp none");
143  p1yValFcn0->SetDefaultValue("none");
144 
145  fCreateP1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p1/create", this);
146  fCreateP1Cmd->SetGuidance("Create 1D profile");
147  fCreateP1Cmd->SetParameter(p1Name);
148  fCreateP1Cmd->SetParameter(p1Title);
149  fCreateP1Cmd->SetParameter(p1xNbins0);
150  fCreateP1Cmd->SetParameter(p1xValMin0);
151  fCreateP1Cmd->SetParameter(p1xValMax0);
152  fCreateP1Cmd->SetParameter(p1xValUnit0);
153  fCreateP1Cmd->SetParameter(p1xValFcn0);
154  fCreateP1Cmd->SetParameter(p1xValBinScheme0);
155  fCreateP1Cmd->SetParameter(p1yValMin0);
156  fCreateP1Cmd->SetParameter(p1yValMax0);
157  fCreateP1Cmd->SetParameter(p1yValUnit0);
158  fCreateP1Cmd->SetParameter(p1yValFcn0);
159  fCreateP1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
160 }
std::unique_ptr< G4UIcommand > fCreateP1Cmd
Here is the caller graph for this function:

◆ SetNewValue()

void G4P1Messenger::SetNewValue ( G4UIcommand command,
G4String  value 
)
finalvirtual

Reimplemented from G4UImessenger.

Definition at line 241 of file G4P1Messenger.cc.

242 {
243  // tokenize parameters in a vector
244  std::vector<G4String> parameters;
245  G4Analysis::Tokenize(newValues, parameters);
246  // check consistency
247  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
248  // Should never happen but let's check anyway for consistency
249  fHelper->WarnAboutParameters(command, parameters.size());
250  return;
251  }
252 
253  if ( command == fCreateP1Cmd.get() ) {
254  auto counter = 0;
255  auto name = parameters[counter++];
256  auto title = parameters[counter++];
258  fHelper->GetBinData(xdata, parameters, counter);
259  auto xunit = GetUnitValue(xdata.fSunit);
261  fHelper->GetValueData(ydata, parameters, counter);
262  auto yunit = GetUnitValue(ydata.fSunit);
264  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
265  ydata.fVmin*yunit, ydata.fVmax*yunit,
266  xdata.fSunit, ydata.fSunit,
267  xdata.fSfcn, ydata.fSfcn,
268  xdata.fSbinScheme);
269  }
270  else if ( command == fSetP1Cmd.get() ) {
271  auto counter = 0;
272  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
274  fHelper->GetBinData(xdata, parameters, counter);
275  auto xunit = GetUnitValue(xdata.fSunit);
277  fHelper->GetValueData(ydata, parameters, counter);
278  auto yunit = GetUnitValue(ydata.fSunit);
279  fManager->SetP1(id,
280  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
281  ydata.fVmin*yunit, ydata.fVmax*yunit,
282  xdata.fSunit, ydata.fSunit,
283  xdata.fSfcn, ydata.fSfcn,
284  xdata.fSbinScheme);
285  }
286  else if ( command == fSetP1XCmd.get() ) {
287  // Only save values
288  auto counter = 0;
289  fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
290  fHelper->GetBinData(fXData, parameters, counter);
291  }
292  else if ( command == fSetP1YCmd.get() ) {
293  // Check if setX command was called
294  auto counter = 0;
295  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
296  if ( fXId == -1 || fXId != id ) {
297  // add exception
298  return;
299  }
300  auto xunit = GetUnitValue(fXData.fSunit);
302  fHelper->GetValueData(ydata, parameters, counter);
303  auto yunit = GetUnitValue(ydata.fSunit);
304  fManager->SetP1(id,
305  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
306  ydata.fVmin*yunit, ydata.fVmax*yunit,
307  fXData.fSunit, ydata.fSunit,
308  fXData.fSfcn, ydata.fSfcn,
310  fXId = -1;
311  }
312  else if ( command == fSetP1TitleCmd.get() ) {
313  auto counter = 0;
314  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
315  auto title = parameters[counter++];
316  fManager->SetP1Title(id, title);
317  }
318  else if ( command == fSetP1XAxisCmd.get() ) {
319  auto counter = 0;
320  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
321  auto xaxis = parameters[counter++];
323  }
324  else if ( command == fSetP1YAxisCmd.get() ) {
325  auto counter = 0;
326  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
327  auto yaxis = parameters[counter++];
328  fManager->SetP1YAxisTitle(id, yaxis);
329  }
330 }
std::unique_ptr< G4UIcommand > fSetP1XAxisCmd
G4AnalysisMessengerHelper::BinData fXData
std::unique_ptr< G4UIcommand > fSetP1Cmd
G4String name
Definition: TRTMaterials.hh:40
std::unique_ptr< G4UIcommand > fSetP1XCmd
std::unique_ptr< G4UIcommand > fSetP1TitleCmd
G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4VAnalysisManager * fManager
Associated class.
int G4int
Definition: G4Types.hh:78
std::unique_ptr< G4UIcommand > fSetP1YAxisCmd
G4bool SetP1YAxisTitle(G4int id, const G4String &title)
G4bool SetP1(G4int id, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
std::unique_ptr< G4UIcommand > fCreateP1Cmd
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
TGaxis * xaxis
Definition: plot_hist.C:61
G4bool SetP1XAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
std::unique_ptr< G4UIcommand > fSetP1YCmd
G4bool SetP1Title(G4int id, const G4String &title)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
subroutine title
Definition: hijing1.383.f:5981
Here is the call graph for this function:

◆ SetP1Cmd()

void G4P1Messenger::SetP1Cmd ( )
private

Definition at line 164 of file G4P1Messenger.cc.

165 {
166  auto p1Id = new G4UIparameter("id", 'i', false);
167  p1Id->SetGuidance("Profile id");
168  p1Id->SetParameterRange("id>=0");
169 
170  auto p1xNbins = new G4UIparameter("xnbins", 'i', false);
171  p1xNbins->SetGuidance("Number of x-bins");
172 
173  auto p1xValMin = new G4UIparameter("xvalMin", 'd', false);
174  p1xValMin->SetGuidance("Minimum x-value, expressed in unit");
175 
176  auto p1xValMax = new G4UIparameter("xvalMax", 'd', false);
177  p1xValMax->SetGuidance("Maximum x-value, expressed in unit");
178 
179  auto p1xValUnit = new G4UIparameter("xvalUnit", 's', false);
180  p1xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
181  p1xValUnit->SetDefaultValue("none");
182 
183  auto p1xValFcn = new G4UIparameter("xvalFcn", 's', false);
184  p1xValFcn->SetParameterCandidates("log log10 exp none");
185  G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).\n";
186  fcnxGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
187  fcnxGuidance += "but none value should be used insted.";
188  p1xValFcn->SetGuidance(fcnxGuidance);
189  p1xValFcn->SetDefaultValue("none");
190 
191  auto p1xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
192  G4String binSchemeGuidance = "The binning scheme (linear, log).\n";
193  p1xValBinScheme->SetParameterCandidates("linear log");
194  binSchemeGuidance
195  += "Note that the unit and fcn parameters cannot be omitted in this case,\n";
196  binSchemeGuidance += "but none value should be used insted.";
197  p1xValBinScheme->SetGuidance(binSchemeGuidance);
198  p1xValBinScheme->SetDefaultValue("linear");
199 
200  auto p1yValMin = new G4UIparameter("yvalMin", 'd', false);
201  p1yValMin->SetGuidance("Minimum y-value, expressed in unit");
202 
203  auto p1yValMax = new G4UIparameter("yvalMax", 'd', false);
204  p1yValMax->SetGuidance("Maximum y-value, expressed in unit");
205 
206  auto p1yValUnit = new G4UIparameter("yvalUnit", 's', true);
207  p1yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
208  p1yValUnit->SetDefaultValue("none");
209 
210  auto p1yValFcn = new G4UIparameter("yvalFcn", 's', false);
211  p1yValFcn->SetParameterCandidates("log log10 exp none");
212  G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).\n";
213  fcnyGuidance += "Note that the unit parameter cannot be omitted in this case,\n";
214  fcnyGuidance += "but none value should be used insted.";
215  p1yValFcn->SetGuidance(fcnyGuidance);
216  p1yValFcn->SetDefaultValue("none");
217 
218  fSetP1Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/p1/set", this);
219  fSetP1Cmd->SetGuidance("Set parameters for the 1D profile of given id:");
220  fSetP1Cmd->SetGuidance(" nbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
221  fSetP1Cmd->SetGuidance(" yvalMin; yvalMax; yunit; yfunction");
222  fSetP1Cmd->SetParameter(p1Id);
223  fSetP1Cmd->SetParameter(p1xNbins);
224  fSetP1Cmd->SetParameter(p1xValMin);
225  fSetP1Cmd->SetParameter(p1xValMax);
226  fSetP1Cmd->SetParameter(p1xValUnit);
227  fSetP1Cmd->SetParameter(p1xValFcn);
228  fSetP1Cmd->SetParameter(p1xValBinScheme);
229  fSetP1Cmd->SetParameter(p1yValMin);
230  fSetP1Cmd->SetParameter(p1yValMax);
231  fSetP1Cmd->SetParameter(p1yValUnit);
232  fSetP1Cmd->SetParameter(p1yValFcn);
233  fSetP1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
234 }
std::unique_ptr< G4UIcommand > fSetP1Cmd
Here is the caller graph for this function:

Member Data Documentation

◆ fCreateP1Cmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fCreateP1Cmd
private

Definition at line 63 of file G4P1Messenger.hh.

◆ fDirectory

std::unique_ptr<G4UIdirectory> G4P1Messenger::fDirectory
private

Definition at line 61 of file G4P1Messenger.hh.

◆ fHelper

std::unique_ptr<G4AnalysisMessengerHelper> G4P1Messenger::fHelper
private

Definition at line 60 of file G4P1Messenger.hh.

◆ fManager

G4VAnalysisManager* G4P1Messenger::fManager
private

Associated class.

Definition at line 59 of file G4P1Messenger.hh.

◆ fSetP1Cmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1Cmd
private

Definition at line 64 of file G4P1Messenger.hh.

◆ fSetP1TitleCmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1TitleCmd
private

Definition at line 67 of file G4P1Messenger.hh.

◆ fSetP1XAxisCmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1XAxisCmd
private

Definition at line 68 of file G4P1Messenger.hh.

◆ fSetP1XCmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1XCmd
private

Definition at line 65 of file G4P1Messenger.hh.

◆ fSetP1YAxisCmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1YAxisCmd
private

Definition at line 69 of file G4P1Messenger.hh.

◆ fSetP1YCmd

std::unique_ptr<G4UIcommand> G4P1Messenger::fSetP1YCmd
private

Definition at line 66 of file G4P1Messenger.hh.

◆ fXData

G4AnalysisMessengerHelper::BinData G4P1Messenger::fXData
private

Definition at line 72 of file G4P1Messenger.hh.

◆ fXId

G4int G4P1Messenger::fXId
private

Definition at line 71 of file G4P1Messenger.hh.


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