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

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

Definition at line 75 of file G4H2Messenger.cc.

76 {}

Member Function Documentation

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);
278  fManager->CreateH2(name, title,
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++];
337  fManager->SetH2XAxisTitle(id, xaxis);
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 }
const XML_Char * name
Definition: expat.h:151
G4bool SetH2YAxisTitle(G4int id, const G4String &title)
int G4int
Definition: G4Types.hh:78
G4bool SetH2ZAxisTitle(G4int id, const G4String &title)
G4double GetUnitValue(const G4String &unit)
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:447
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")
G4bool SetH2Title(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4int GetParameterEntries() const
Definition: G4UIcommand.hh:143
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)

Here is the call graph for this function:


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