Geant4  10.02.p03
G4H2Messenger Class Reference

#include <G4H2Messenger.hh>

Inheritance diagram for G4H2Messenger:
Collaboration diagram for G4H2Messenger:

Public Member Functions

 G4H2Messenger (G4VAnalysisManager *manager)
 
virtual ~G4H2Messenger ()
 
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 CreateH2Cmd ()
 
void SetH2Cmd ()
 

Private Attributes

G4VAnalysisManagerfManager
 Associated class. More...
 
std::unique_ptr< G4AnalysisMessengerHelperfHelper
 
std::unique_ptr< G4UIdirectoryfDirectory
 
std::unique_ptr< G4UIcommandfCreateH2Cmd
 
std::unique_ptr< G4UIcommandfSetH2Cmd
 
std::unique_ptr< G4UIcommandfSetH2XCmd
 
std::unique_ptr< G4UIcommandfSetH2YCmd
 
std::unique_ptr< G4UIcommandfSetH2TitleCmd
 
std::unique_ptr< G4UIcommandfSetH2XAxisCmd
 
std::unique_ptr< G4UIcommandfSetH2YAxisCmd
 
std::unique_ptr< G4UIcommandfSetH2ZAxisCmd
 
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 G4H2Messenger.hh.

Constructor & Destructor Documentation

◆ G4H2Messenger()

G4H2Messenger::G4H2Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 43 of file G4H2Messenger.cc.

44  : G4UImessenger(),
45  fManager(manager),
46  fHelper(nullptr),
47  fDirectory(nullptr),
48  fCreateH2Cmd(nullptr),
49  fSetH2Cmd(nullptr),
50  fSetH2XCmd(nullptr),
51  fSetH2YCmd(nullptr),
52  fSetH2TitleCmd(nullptr),
53  fSetH2XAxisCmd(nullptr),
54  fSetH2YAxisCmd(nullptr),
55  fXId(-1),
56  fXData()
57 {
58  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h2");
59 
60  fDirectory = fHelper->CreateHnDirectory();
61 
62  CreateH2Cmd();
63 
64  SetH2Cmd();
65  fSetH2XCmd = fHelper->CreateSetBinsCommand("x", this);
66  fSetH2YCmd = fHelper->CreateSetBinsCommand("y", this);
67 
68  fSetH2TitleCmd = fHelper->CreateSetTitleCommand(this);
69  fSetH2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
70  fSetH2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
71  fSetH2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
72 }
G4AnalysisMessengerHelper::BinData fXData
std::unique_ptr< G4UIcommand > fSetH2Cmd
std::unique_ptr< G4UIdirectory > fDirectory
std::unique_ptr< G4UIcommand > fSetH2YAxisCmd
std::unique_ptr< G4UIcommand > fSetH2ZAxisCmd
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
std::unique_ptr< G4UIcommand > fSetH2XAxisCmd
std::unique_ptr< G4UIcommand > fSetH2YCmd
G4VAnalysisManager * fManager
Associated class.
void CreateH2Cmd()
std::unique_ptr< G4UIcommand > fSetH2TitleCmd
std::unique_ptr< G4UIcommand > fSetH2XCmd
std::unique_ptr< G4UIcommand > fCreateH2Cmd
Here is the call graph for this function:

◆ ~G4H2Messenger()

G4H2Messenger::~G4H2Messenger ( )
virtual

Definition at line 75 of file G4H2Messenger.cc.

76 {}

Member Function Documentation

◆ CreateH2Cmd()

void G4H2Messenger::CreateH2Cmd ( )
private

Definition at line 83 of file G4H2Messenger.cc.

84 {
85  auto h2Name = new G4UIparameter("name", 's', false);
86  h2Name->SetGuidance("Histogram name (label)");
87 
88  auto h2Title = new G4UIparameter("title", 's', false);
89  h2Title->SetGuidance("Histogram title");
90 
91  auto h2xNbins0 = new G4UIparameter("xnbins0", 'i', true);
92  h2xNbins0->SetGuidance("Number of x-bins (default = 100)");
93  h2xNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
94  h2xNbins0->SetDefaultValue(100);
95 
96  auto h2xValMin0 = new G4UIparameter("xvalMin0", 'd', true);
97  h2xValMin0->SetGuidance("Minimum x-value, expressed in unit (default = 0.)");
98  h2xValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
99  h2xValMin0->SetDefaultValue(0.);
100 
101  auto h2xValMax0 = new G4UIparameter("xvalMax0", 'd', true);
102  h2xValMax0->SetGuidance("Maximum x-value, expressed in unit (default = 1.)");
103  h2xValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
104  h2xValMax0->SetDefaultValue(1.);
105 
106  auto h2xValUnit0 = new G4UIparameter("xvalUnit0", 's', true);
107  h2xValUnit0->SetGuidance("The unit applied to filled x-values and xvalMin0, xvalMax0");
108  h2xValUnit0->SetDefaultValue("none");
109 
110  auto h2xValFcn0 = new G4UIparameter("xvalFcn0", 's', true);
111  G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
112  h2xValFcn0->SetGuidance(fcnxGuidance);
113  h2xValFcn0->SetParameterCandidates("log log10 exp none");
114  h2xValFcn0->SetDefaultValue("none");
115 
116  auto h2xValBinScheme0 = new G4UIparameter("xvalBinScheme0", 's', true);
117  G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
118  h2xValBinScheme0->SetParameterCandidates("linear log");
119  h2xValBinScheme0->SetGuidance(xbinSchemeGuidance);
120  h2xValBinScheme0->SetDefaultValue("linear");
121 
122  auto h2yNbins0 = new G4UIparameter("ynbins0", 'i', true);
123  h2yNbins0->SetGuidance("Number of y-bins (default = 100)");
124  h2yNbins0->SetGuidance("Can be reset with /analysis/h2/set command");
125  h2yNbins0->SetDefaultValue(100);
126 
127  auto h2yValMin0 = new G4UIparameter("yvalMin0", 'd', true);
128  h2yValMin0->SetGuidance("Minimum y-value, expressed in unit (default = 0.)");
129  h2yValMin0->SetGuidance("Can be reset with /analysis/h2/set command");
130  h2yValMin0->SetDefaultValue(0.);
131 
132  auto h2yValMax0 = new G4UIparameter("yvalMax0", 'd', true);
133  h2yValMax0->SetGuidance("Maximum y-value, expressed in unit (default = 1.)");
134  h2yValMax0->SetGuidance("Can be reset with /analysis/h2/set command");
135  h2yValMax0->SetDefaultValue(1.);
136 
137  auto h2yValUnit0 = new G4UIparameter("yvalUnit0", 's', true);
138  h2yValUnit0->SetGuidance("The unit applied to filled y-values and yvalMin0, yvalMax0");
139  h2yValUnit0->SetDefaultValue("none");
140 
141  auto h2yValFcn0 = new G4UIparameter("yvalFcn0", 's', true);
142  G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
143  h2yValFcn0->SetGuidance(fcnyGuidance);
144  h2yValFcn0->SetParameterCandidates("log log10 exp none");
145  h2yValFcn0->SetDefaultValue("none");
146 
147  auto h2yValBinScheme0 = new G4UIparameter("yvalBinScheme0", 's', true);
148  G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
149  h2yValBinScheme0->SetParameterCandidates("linear log");
150  h2yValBinScheme0->SetGuidance(ybinSchemeGuidance);
151  h2yValBinScheme0->SetDefaultValue("linear");
152 
153  fCreateH2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h2/create", this);
154  fCreateH2Cmd->SetGuidance("Create 2D histogram");
155  fCreateH2Cmd->SetParameter(h2Name);
156  fCreateH2Cmd->SetParameter(h2Title);
157  fCreateH2Cmd->SetParameter(h2xNbins0);
158  fCreateH2Cmd->SetParameter(h2xValMin0);
159  fCreateH2Cmd->SetParameter(h2xValMax0);
160  fCreateH2Cmd->SetParameter(h2xValUnit0);
161  fCreateH2Cmd->SetParameter(h2xValFcn0);
162  fCreateH2Cmd->SetParameter(h2xValBinScheme0);
163  fCreateH2Cmd->SetParameter(h2yNbins0);
164  fCreateH2Cmd->SetParameter(h2yValMin0);
165  fCreateH2Cmd->SetParameter(h2yValMax0);
166  fCreateH2Cmd->SetParameter(h2yValUnit0);
167  fCreateH2Cmd->SetParameter(h2yValFcn0);
168  fCreateH2Cmd->SetParameter(h2yValBinScheme0);
169  fCreateH2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
170 }
std::unique_ptr< G4UIcommand > fCreateH2Cmd
Here is the caller graph for this function:

◆ SetH2Cmd()

void G4H2Messenger::SetH2Cmd ( )
private

Definition at line 174 of file G4H2Messenger.cc.

175 {
176  auto h2Id = new G4UIparameter("id", 'i', false);
177  h2Id->SetGuidance("Histogram id");
178  h2Id->SetParameterRange("id>=0");
179 
180  auto h2xNbins = new G4UIparameter("xnbins", 'i', false);
181  h2xNbins->SetGuidance("Number of x-bins");
182 
183  auto h2xValMin = new G4UIparameter("xvalMin", 'd', false);
184  h2xValMin->SetGuidance("Minimum x-value, expressed in unit");
185 
186  auto h2xValMax = new G4UIparameter("xvalMax", 'd', false);
187  h2xValMax->SetGuidance("Maximum x-value, expressed in unit");
188 
189  auto h2xValUnit = new G4UIparameter("xvalUnit", 's', false);
190  h2xValUnit->SetGuidance("The unit applied to filled x-values and xvalMin, xvalMax");
191  h2xValUnit->SetDefaultValue("none");
192 
193  auto h2xValFcn = new G4UIparameter("xvalFcn", 's', false);
194  h2xValFcn->SetParameterCandidates("log log10 exp none");
195  G4String fcnxGuidance = "The function applied to filled x-values (log, log10, exp, none).";
196  h2xValFcn->SetGuidance(fcnxGuidance);
197  h2xValFcn->SetDefaultValue("none");
198 
199  auto h2xValBinScheme = new G4UIparameter("xvalBinScheme", 's', true);
200  G4String xbinSchemeGuidance = "The binning scheme (linear, log).";
201  h2xValBinScheme->SetParameterCandidates("linear log");
202  h2xValBinScheme->SetGuidance(xbinSchemeGuidance);
203  h2xValBinScheme->SetDefaultValue("linear");
204 
205  auto h2yNbins = new G4UIparameter("nybins", 'i', false);
206  h2yNbins->SetGuidance("Number of y-bins");
207 
208  auto h2yValMin = new G4UIparameter("yvalMin", 'd', false);
209  h2yValMin->SetGuidance("Minimum y-value, expressed in unit");
210 
211  auto h2yValMax = new G4UIparameter("yvalMax", 'd', false);
212  h2yValMax->SetGuidance("Maximum y-value, expressed in unit");
213 
214  auto h2yValUnit = new G4UIparameter("yvalUnit", 's', true);
215  h2yValUnit->SetGuidance("The unit applied to filled y-values and yvalMin, yvalMax");
216  h2yValUnit->SetDefaultValue("none");
217 
218  auto h2yValFcn = new G4UIparameter("yvalFcn", 's', false);
219  h2yValFcn->SetParameterCandidates("log log10 exp none");
220  G4String fcnyGuidance = "The function applied to filled y-values (log, log10, exp, none).";
221  h2yValFcn->SetGuidance(fcnyGuidance);
222  h2yValFcn->SetDefaultValue("none");
223 
224  auto h2yValBinScheme = new G4UIparameter("yvalBinScheme", 's', true);
225  G4String ybinSchemeGuidance = "The binning scheme (linear, log).";
226  h2yValBinScheme->SetParameterCandidates("linear log");
227  h2yValBinScheme->SetGuidance(ybinSchemeGuidance);
228  h2yValBinScheme->SetDefaultValue("linear");
229 
230  fSetH2Cmd = G4Analysis::make_unique<G4UIcommand>("/analysis/h2/set", this);
231  fSetH2Cmd->SetGuidance("Set parameters for the 2D histogram of given id:");
232  fSetH2Cmd->SetGuidance(" nxbins; xvalMin; xvalMax; xunit; xfunction; xbinScheme");
233  fSetH2Cmd->SetGuidance(" nybins; yvalMin; yvalMax; yunit; yfunction; ybinScheme");
234  fSetH2Cmd->SetParameter(h2Id);
235  fSetH2Cmd->SetParameter(h2xNbins);
236  fSetH2Cmd->SetParameter(h2xValMin);
237  fSetH2Cmd->SetParameter(h2xValMax);
238  fSetH2Cmd->SetParameter(h2xValUnit);
239  fSetH2Cmd->SetParameter(h2xValFcn);
240  fSetH2Cmd->SetParameter(h2xValBinScheme);
241  fSetH2Cmd->SetParameter(h2yNbins);
242  fSetH2Cmd->SetParameter(h2yValMin);
243  fSetH2Cmd->SetParameter(h2yValMax);
244  fSetH2Cmd->SetParameter(h2yValUnit);
245  fSetH2Cmd->SetParameter(h2yValFcn);
246  fSetH2Cmd->SetParameter(h2yValBinScheme);
247  fSetH2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle);
248 }
std::unique_ptr< G4UIcommand > fSetH2Cmd
Here is the caller graph for this function:

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 256 of file G4H2Messenger.cc.

257 {
258  // tokenize parameters in a vector
259  std::vector<G4String> parameters;
260  G4Analysis::Tokenize(newValues, parameters);
261  // check consistency
262  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
263  // Should never happen but let's check anyway for consistency
264  fHelper->WarnAboutParameters(command, parameters.size());
265  return;
266  }
267 
268  if ( command == fCreateH2Cmd.get() ) {
269  auto counter = 0;
270  auto name = parameters[counter++];
271  auto title = parameters[counter++];
273  fHelper->GetBinData(xdata, parameters, counter);
274  auto xunit = GetUnitValue(xdata.fSunit);
276  fHelper->GetBinData(ydata, parameters, counter);
277  auto yunit = GetUnitValue(ydata.fSunit);
279  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
280  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
281  xdata.fSunit, ydata.fSunit,
282  xdata.fSfcn, ydata.fSfcn,
283  xdata.fSbinScheme, ydata.fSbinScheme);
284  }
285  else if ( command == fSetH2Cmd.get() ) {
286  auto counter = 0;
287  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
289  fHelper->GetBinData(xdata, parameters, counter);
290  auto xunit = GetUnitValue(xdata.fSunit);
292  fHelper->GetBinData(ydata, parameters, counter);
293  auto yunit = GetUnitValue(ydata.fSunit);
294  fManager->SetH2(id,
295  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
296  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
297  xdata.fSunit, ydata.fSunit,
298  xdata.fSfcn, ydata.fSfcn,
299  xdata.fSbinScheme, ydata.fSbinScheme);
300  }
301  else if ( command == fSetH2XCmd.get() ) {
302  // Only save values
303  auto counter = 0;
304  fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
305  fHelper->GetBinData(fXData, parameters, counter);
306  }
307  else if ( command == fSetH2YCmd.get() ) {
308  // Check if setX command was called
309  auto counter = 0;
310  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
311  if ( fXId == -1 || fXId != id ) {
312  fHelper->WarnAboutSetCommands();
313  return;
314  }
315  auto xunit = GetUnitValue(fXData.fSunit);
317  fHelper->GetBinData(ydata, parameters, counter);
318  auto yunit = GetUnitValue(ydata.fSunit);
319  fManager->SetH2(id,
320  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
321  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
322  fXData.fSunit, ydata.fSunit,
323  fXData.fSfcn, ydata.fSfcn,
324  fXData.fSbinScheme, ydata.fSbinScheme);
325  fXId = -1;
326  }
327  else if ( command == fSetH2TitleCmd.get() ) {
328  auto counter = 0;
329  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
330  auto title = parameters[counter++];
331  fManager->SetH2Title(id, title);
332  }
333  else if ( command == fSetH2XAxisCmd.get() ) {
334  auto counter = 0;
335  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
336  auto xaxis = parameters[counter++];
338  }
339  else if ( command == fSetH2YAxisCmd.get() ) {
340  auto counter = 0;
341  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
342  auto yaxis = parameters[counter++];
343  fManager->SetH2YAxisTitle(id, yaxis);
344  }
345  else if ( command == fSetH2ZAxisCmd.get() ) {
346  auto counter = 0;
347  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
348  auto zaxis = parameters[counter++];
349  fManager->SetH2ZAxisTitle(id, zaxis);
350  }
351 }
G4AnalysisMessengerHelper::BinData fXData
std::unique_ptr< G4UIcommand > fSetH2Cmd
G4bool SetH2YAxisTitle(G4int id, const G4String &title)
G4String name
Definition: TRTMaterials.hh:40
int G4int
Definition: G4Types.hh:78
G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
std::unique_ptr< G4UIcommand > fSetH2YAxisCmd
std::unique_ptr< G4UIcommand > fSetH2ZAxisCmd
std::unique_ptr< G4AnalysisMessengerHelper > fHelper
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:435
TGaxis * xaxis
Definition: plot_hist.C:61
G4bool SetH2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
std::unique_ptr< G4UIcommand > fSetH2XAxisCmd
G4bool SetH2Title(G4int id, const G4String &title)
std::unique_ptr< G4UIcommand > fSetH2YCmd
G4VAnalysisManager * fManager
Associated class.
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
std::unique_ptr< G4UIcommand > fSetH2TitleCmd
std::unique_ptr< G4UIcommand > fSetH2XCmd
subroutine title
Definition: hijing1.383.f:5981
G4int CreateH2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool SetH2XAxisTitle(G4int id, const G4String &title)
std::unique_ptr< G4UIcommand > fCreateH2Cmd
Here is the call graph for this function:

Member Data Documentation

◆ fCreateH2Cmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fCreateH2Cmd
private

Definition at line 63 of file G4H2Messenger.hh.

◆ fDirectory

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

Definition at line 61 of file G4H2Messenger.hh.

◆ fHelper

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

Definition at line 60 of file G4H2Messenger.hh.

◆ fManager

G4VAnalysisManager* G4H2Messenger::fManager
private

Associated class.

Definition at line 59 of file G4H2Messenger.hh.

◆ fSetH2Cmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2Cmd
private

Definition at line 64 of file G4H2Messenger.hh.

◆ fSetH2TitleCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2TitleCmd
private

Definition at line 67 of file G4H2Messenger.hh.

◆ fSetH2XAxisCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2XAxisCmd
private

Definition at line 68 of file G4H2Messenger.hh.

◆ fSetH2XCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2XCmd
private

Definition at line 65 of file G4H2Messenger.hh.

◆ fSetH2YAxisCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2YAxisCmd
private

Definition at line 69 of file G4H2Messenger.hh.

◆ fSetH2YCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2YCmd
private

Definition at line 66 of file G4H2Messenger.hh.

◆ fSetH2ZAxisCmd

std::unique_ptr<G4UIcommand> G4H2Messenger::fSetH2ZAxisCmd
private

Definition at line 70 of file G4H2Messenger.hh.

◆ fXData

G4AnalysisMessengerHelper::BinData G4H2Messenger::fXData
private

Definition at line 73 of file G4H2Messenger.hh.

◆ fXId

G4int G4H2Messenger::fXId
private

Definition at line 72 of file G4H2Messenger.hh.


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