Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4H3Messenger Class Reference

#include <G4H3Messenger.hh>

Inheritance diagram for G4H3Messenger:
Collaboration diagram for G4H3Messenger:

Public Member Functions

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

Constructor & Destructor Documentation

G4H3Messenger::G4H3Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 43 of file G4H3Messenger.cc.

44  : G4UImessenger(),
45  fManager(manager),
46  fHelper(nullptr),
47  fDirectory(nullptr),
48  fCreateH3Cmd(nullptr),
49  fSetH3Cmd(nullptr),
50  fSetH3XCmd(nullptr),
51  fSetH3YCmd(nullptr),
52  fSetH3ZCmd(nullptr),
53  fSetH3TitleCmd(nullptr),
54  fSetH3XAxisCmd(nullptr),
55  fSetH3YAxisCmd(nullptr),
56  fSetH3ZAxisCmd(nullptr),
57  fXId(-1),
58  fYId(-1),
59  fXData(),
60  fYData()
61 {
62  fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h3");
63 
64  fDirectory = fHelper->CreateHnDirectory();
65 
66  CreateH3Cmd();
67 
68  SetH3Cmd();
69  fSetH3XCmd = fHelper->CreateSetBinsCommand("x", this);
70  fSetH3YCmd = fHelper->CreateSetBinsCommand("y", this);
71 
72  fSetH3TitleCmd = fHelper->CreateSetTitleCommand(this);
73  fSetH3XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
74  fSetH3YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
75  fSetH3ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
76 }
G4H3Messenger::~G4H3Messenger ( )
virtual

Definition at line 79 of file G4H3Messenger.cc.

80 {}

Member Function Documentation

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

Reimplemented from G4UImessenger.

Definition at line 329 of file G4H3Messenger.cc.

330 {
331  // tokenize parameters in a vector
332  std::vector<G4String> parameters;
333  G4Analysis::Tokenize(newValues, parameters);
334  // check consistency
335  if ( G4int(parameters.size()) != command->GetParameterEntries() ) {
336  // Should never happen but let's check anyway for consistency
337  fHelper->WarnAboutParameters(command, parameters.size());
338  return;
339  }
340 
341  if ( command == fCreateH3Cmd.get() ) {
342  auto counter = 0;
343  auto name = parameters[counter++];
344  auto title = parameters[counter++];
346  fHelper->GetBinData(xdata, parameters, counter);
347  auto xunit = GetUnitValue(xdata.fSunit);
349  fHelper->GetBinData(ydata, parameters, counter);
350  auto yunit = GetUnitValue(ydata.fSunit);
352  fHelper->GetBinData(zdata, parameters, counter);
353  auto zunit = GetUnitValue(zdata.fSunit);
354  fManager->CreateH3(name, title,
355  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
356  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
357  zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
358  xdata.fSunit, ydata.fSunit, zdata.fSunit,
359  xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
360  xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
361  }
362  else if ( command == fSetH3Cmd.get() ) {
363  auto counter = 0;
364  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
366  fHelper->GetBinData(xdata, parameters, counter);
367  auto xunit = GetUnitValue(xdata.fSunit);
369  fHelper->GetBinData(ydata, parameters, counter);
370  auto yunit = GetUnitValue(ydata.fSunit);
372  fHelper->GetBinData(zdata, parameters, counter);
373  auto zunit = GetUnitValue(zdata.fSunit);
374  fManager->SetH3(id,
375  xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
376  ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
377  zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
378  xdata.fSunit, ydata.fSunit, zdata.fSunit,
379  xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
380  xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
381  }
382  else if ( command == fSetH3XCmd.get() ) {
383  // Only save values
384  auto counter = 0;
385  fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
386  fHelper->GetBinData(fXData, parameters, counter);
387  }
388  else if ( command == fSetH3YCmd.get() ) {
389  // Only save values
390  auto counter = 0;
391  fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
392  fHelper->GetBinData(fYData, parameters, counter);
393  }
394  else if ( command == fSetH3ZCmd.get() ) {
395  auto counter = 0;
396  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
397  // Check if setX and setY command was called
398  if ( fXId == -1 || fXId != id ||
399  fYId == -1 || fYId != id ) {
400  fHelper->WarnAboutSetCommands();
401  return;
402  }
403  auto xunit = GetUnitValue(fXData.fSunit);
404  auto yunit = GetUnitValue(fYData.fSunit);
406  fHelper->GetBinData(zdata, parameters, counter);
407  auto zunit = GetUnitValue(zdata.fSunit);
408  fManager->SetH3(id,
409  fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
410  fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
411  zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
412  fXData.fSunit, fYData.fSunit, zdata.fSunit,
413  fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
414  fXData.fSbinScheme, fYData.fSbinScheme, zdata.fSbinScheme);
415  fXId = -1;
416  fYId = -1;
417  }
418  else if ( command == fSetH3TitleCmd.get() ) {
419  auto counter = 0;
420  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
421  auto title = parameters[counter++];
422  fManager->SetH3Title(id, title);
423  }
424  else if ( command == fSetH3XAxisCmd.get() ) {
425  auto counter = 0;
426  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
427  auto xaxis = parameters[counter++];
428  fManager->SetH3XAxisTitle(id, xaxis);
429  }
430  else if ( command == fSetH3YAxisCmd.get() ) {
431  auto counter = 0;
432  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
433  auto yaxis = parameters[counter++];
434  fManager->SetH3YAxisTitle(id, yaxis);
435  }
436  else if ( command == fSetH3ZAxisCmd.get() ) {
437  auto counter = 0;
438  auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
439  auto zaxis = parameters[counter++];
440  fManager->SetH3ZAxisTitle(id, zaxis);
441  }
442 }
G4int CreateH3(const G4String &name, const G4String &title, G4int nxbins, G4double xmin, G4double xmax, G4int nybins, G4double ymin, G4double ymax, G4int nzbins, G4double zmin, G4double zmax, 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", const G4String &zbinSchemeName="linear")
const XML_Char * name
Definition: expat.h:151
int G4int
Definition: G4Types.hh:78
G4bool SetH3(G4int id, G4int nxbins, G4double xmin, G4double xmax, G4int nzbins, G4double zmin, G4double zmax, G4int nybins, G4double ymin, G4double ymax, 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", const G4String &zbinSchemeName="linear")
G4bool SetH3Title(G4int id, const G4String &title)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4bool SetH3XAxisTitle(G4int id, const G4String &title)
G4bool SetH3ZAxisTitle(G4int id, const G4String &title)
subroutine title
Definition: hijing1.383.f:5980
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
G4bool SetH3YAxisTitle(G4int id, const G4String &title)

Here is the call graph for this function:


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