Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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
 

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 ( 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 }
G4P1Messenger::~G4P1Messenger ( )
virtual

Definition at line 71 of file G4P1Messenger.cc.

72 {}

Member Function Documentation

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);
263  fManager->CreateP1(name, title,
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  // Save values
288  auto counter = 0;
289  fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
290  fHelper->GetBinData(fXData, parameters, counter);
291  // Set values
292  // (another set may follow if setY is also called)
293  auto xunit = GetUnitValue(fXData.fSunit);
294  fManager->SetP1(fXId,
295  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
296  0., 0.,
297  fXData.fSunit, "none",
298  fXData.fSfcn, "none",
299  fXData.fSbinScheme);
300  }
301  else if ( command == fSetP1YCmd.get() ) {
302  // Check if setX command was called
303  auto counter = 0;
304  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
305  if ( fXId == -1 || fXId != id ) {
306  fHelper->WarnAboutSetCommands();
307  return;
308  }
309  auto xunit = GetUnitValue(fXData.fSunit);
311  fHelper->GetValueData(ydata, parameters, counter);
312  auto yunit = GetUnitValue(ydata.fSunit);
313  fManager->SetP1(id,
314  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
315  ydata.fVmin*yunit, ydata.fVmax*yunit,
316  fXData.fSunit, ydata.fSunit,
317  fXData.fSfcn, ydata.fSfcn,
318  fXData.fSbinScheme);
319  fXId = -1;
320  }
321  else if ( command == fSetP1TitleCmd.get() ) {
322  auto counter = 0;
323  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
324  auto title = parameters[counter++];
325  fManager->SetP1Title(id, title);
326  }
327  else if ( command == fSetP1XAxisCmd.get() ) {
328  auto counter = 0;
329  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
330  auto xaxis = parameters[counter++];
331  fManager->SetP1XAxisTitle(id, xaxis);
332  }
333  else if ( command == fSetP1YAxisCmd.get() ) {
334  auto counter = 0;
335  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
336  auto yaxis = parameters[counter++];
337  fManager->SetP1YAxisTitle(id, yaxis);
338  }
339 }
const XML_Char * name
Definition: expat.h:151
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")
int G4int
Definition: G4Types.hh:78
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")
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
G4bool SetP1XAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4bool SetP1Title(G4int id, const G4String &title)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143

Here is the call graph for this function:


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