Geant4  10.03.p01
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
G4P2Messenger Class Reference

#include <G4P2Messenger.hh>

Inheritance diagram for G4P2Messenger:
Collaboration diagram for G4P2Messenger:

Public Member Functions

 G4P2Messenger (G4VAnalysisManager *manager)
 
virtual ~G4P2Messenger ()
 
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 G4P2Messenger.hh.

Constructor & Destructor Documentation

G4P2Messenger::G4P2Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 43 of file G4P2Messenger.cc.

44  : G4UImessenger(),
45  fManager(manager),
46  fHelper(nullptr),
47  fDirectory(nullptr),
48  fCreateP2Cmd(nullptr),
49  fSetP2Cmd(nullptr),
50  fSetP2XCmd(nullptr),
51  fSetP2YCmd(nullptr),
52  fSetP2ZCmd(nullptr),
53  fSetP2TitleCmd(nullptr),
54  fSetP2XAxisCmd(nullptr),
55  fSetP2YAxisCmd(nullptr)
56 {
57  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p2");
58 
59  fDirectory = fHelper->CreateHnDirectory();
60 
61  CreateP2Cmd();
62 
63  SetP2Cmd();
64  fSetP2XCmd = fHelper->CreateSetBinsCommand("x", this);
65  fSetP2YCmd = fHelper->CreateSetBinsCommand("y", this);
66  fSetP2ZCmd = fHelper->CreateSetValuesCommand("z", this);
67 
68  fSetP2TitleCmd = fHelper->CreateSetTitleCommand(this);
69  fSetP2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
70  fSetP2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
71  fSetP2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
72 }
G4P2Messenger::~G4P2Messenger ( )
virtual

Definition at line 75 of file G4P2Messenger.cc.

76 {}

Member Function Documentation

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

Reimplemented from G4UImessenger.

Definition at line 299 of file G4P2Messenger.cc.

300 {
301  // tokenize parameters in a vector
302  std::vector<G4String> parameters;
303  G4Analysis::Tokenize(newValues, parameters);
304  // check consistency
305  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
306  // Should never happen but let's check anyway for consistency
307  fHelper->WarnAboutParameters(command, parameters.size());
308  return;
309  }
310 
311  if ( command == fCreateP2Cmd.get() ) {
312  auto counter = 0;
313  auto name = parameters[counter++];
314  auto title = parameters[counter++];
316  fHelper->GetBinData(xdata, parameters, counter);
317  auto xunit = GetUnitValue(xdata.fSunit);
319  fHelper->GetBinData(ydata, parameters, counter);
320  auto yunit = GetUnitValue(ydata.fSunit);
322  fHelper->GetValueData(zdata, parameters, counter);
323  auto zunit = GetUnitValue(zdata.fSunit);
324  fManager->CreateP2(name, title,
325  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
326  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
327  zdata.fVmin*zunit, zdata.fVmax*zunit,
328  xdata.fSunit, ydata.fSunit, zdata.fSunit,
329  xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
330  xdata.fSbinScheme, ydata.fSbinScheme);
331  }
332  else if ( command == fSetP2Cmd.get() ) {
333  auto counter = 0;
334  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
336  fHelper->GetBinData(xdata, parameters, counter);
337  auto xunit = GetUnitValue(xdata.fSunit);
339  fHelper->GetBinData(ydata, parameters, counter);
340  auto yunit = GetUnitValue(ydata.fSunit);
342  fHelper->GetValueData(zdata, parameters, counter);
343  auto zunit = GetUnitValue(zdata.fSunit);
344  fManager->SetP2(id,
345  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
346  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
347  zdata.fVmin*zunit, zdata.fVmax*zunit,
348  xdata.fSunit, ydata.fSunit, zdata.fSunit,
349  xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
350  xdata.fSbinScheme, ydata.fSbinScheme);
351  }
352  else if ( command == fSetP2XCmd.get() ) {
353  // Only save values
354  auto counter = 0;
355  fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
356  fHelper->GetBinData(fXData, parameters, counter);
357  }
358  else if ( command == fSetP2YCmd.get() ) {
359  // Save values
360  auto counter = 0;
361  fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
362  // Check if setX command was called
363  if ( fXId == -1 || fXId != fYId ) {
364  fHelper->WarnAboutSetCommands();
365  return;
366  }
367  fHelper->GetBinData(fYData, parameters, counter);
368  // Set values
369  // (another set may follow if setZ is also called)
370  auto xunit = GetUnitValue(fXData.fSunit);
371  auto yunit = GetUnitValue(fYData.fSunit);
372  fManager->SetP2(fYId,
373  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
374  fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
375  0., 0.,
376  fXData.fSunit, fYData.fSunit, "none",
377  fXData.fSfcn, fYData.fSfcn, "none",
378  fXData.fSbinScheme, fYData.fSbinScheme);
379  }
380  else if ( command == fSetP2ZCmd.get() ) {
381  auto counter = 0;
382  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
383  // Check if setX and setY command was called
384  if ( fXId == -1 || fXId != id ||
385  fYId == -1 || fYId != id ) {
386  fHelper->WarnAboutSetCommands();
387  return;
388  }
389  auto xunit = GetUnitValue(fXData.fSunit);
390  auto yunit = GetUnitValue(fYData.fSunit);
392  fHelper->GetValueData(zdata, parameters, counter);
393  auto zunit = GetUnitValue(zdata.fSunit);
394  fManager->SetP2(id,
395  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
396  fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
397  zdata.fVmin*zunit, zdata.fVmax*zunit,
398  fXData.fSunit, fYData.fSunit, zdata.fSunit,
399  fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
400  fXData.fSbinScheme, fYData.fSbinScheme);
401  fXId = -1;
402  fYId = -1;
403  }
404  else if ( command == fSetP2TitleCmd.get() ) {
405  auto counter = 0;
406  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
407  auto title = parameters[counter++];
408  fManager->SetP2Title(id, title);
409  }
410  else if ( command == fSetP2XAxisCmd.get() ) {
411  auto counter = 0;
412  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
413  auto xaxis = parameters[counter++];
414  fManager->SetP2XAxisTitle(id, xaxis);
415  }
416  else if ( command == fSetP2YAxisCmd.get() ) {
417  auto counter = 0;
418  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
419  auto yaxis = parameters[counter++];
420  fManager->SetP2YAxisTitle(id, yaxis);
421  }
422  else if ( command == fSetP2ZAxisCmd.get() ) {
423  auto counter = 0;
424  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
425  auto zaxis = parameters[counter++];
426  fManager->SetP2ZAxisTitle(id, zaxis);
427  }
428 }
const XML_Char * name
Definition: expat.h:151
G4bool SetP2ZAxisTitle(G4int id, const G4String &title)
G4bool SetP2Title(G4int id, const G4String &title)
int G4int
Definition: G4Types.hh:78
G4bool SetP2XAxisTitle(G4int id, const G4String &title)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
G4bool SetP2(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
G4bool SetP2YAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4int CreateP2(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4double zmin=0, G4double zmax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &zunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &zfcnName="none", const G4String &xbinSchemeName="linear", const G4String &ybinSchemeName="linear")
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: