Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4H3Messenger Class Reference

#include <G4H3Messenger.hh>

+ Inheritance 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)
 
virtual void SetNewValue (G4UIcommand *command, G4String newValue)
 
G4bool operator== (const G4UImessenger &messenger) const
 
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)
 
G4long StoL (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 = nullptr
 
G4String baseDirName = ""
 
G4bool commandsShouldBeInMaster = false
 

Detailed Description

Definition at line 45 of file G4H3Messenger.hh.

Constructor & Destructor Documentation

◆ G4H3Messenger()

G4H3Messenger::G4H3Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 42 of file G4H3Messenger.cc.

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

◆ ~G4H3Messenger()

G4H3Messenger::~G4H3Messenger ( )
virtual

Definition at line 81 of file G4H3Messenger.cc.

82{}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 331 of file G4H3Messenger.cc.

332{
333 // tokenize parameters in a vector
334 std::vector<G4String> parameters;
335 G4Analysis::Tokenize(newValues, parameters);
336 // check consistency
337 if ( parameters.size() != command->GetParameterEntries() ) {
338 // Should never happen but let's check anyway for consistency
339 fHelper->WarnAboutParameters(command, parameters.size());
340 return;
341 }
342
343 if ( command == fCreateH3Cmd.get() ) {
344 auto counter = 0;
345 auto name = parameters[counter++];
346 auto title = parameters[counter++];
348 fHelper->GetBinData(xdata, parameters, counter);
349 auto xunit = GetUnitValue(xdata.fSunit);
351 fHelper->GetBinData(ydata, parameters, counter);
352 auto yunit = GetUnitValue(ydata.fSunit);
354 fHelper->GetBinData(zdata, parameters, counter);
355 auto zunit = GetUnitValue(zdata.fSunit);
356 fManager->CreateH3(name, title,
357 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
358 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
359 zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
360 xdata.fSunit, ydata.fSunit, zdata.fSunit,
361 xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
362 xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
363 }
364 else if ( command == fSetH3Cmd.get() ) {
365 auto counter = 0;
366 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
368 fHelper->GetBinData(xdata, parameters, counter);
369 auto xunit = GetUnitValue(xdata.fSunit);
371 fHelper->GetBinData(ydata, parameters, counter);
372 auto yunit = GetUnitValue(ydata.fSunit);
374 fHelper->GetBinData(zdata, parameters, counter);
375 auto zunit = GetUnitValue(zdata.fSunit);
376 fManager->SetH3(id,
377 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
378 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
379 zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
380 xdata.fSunit, ydata.fSunit, zdata.fSunit,
381 xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
382 xdata.fSbinScheme, ydata.fSbinScheme, zdata.fSbinScheme);
383 }
384 else if ( command == fSetH3XCmd.get() ) {
385 // Only save values
386 auto counter = 0;
387 fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
388 fHelper->GetBinData(fXData, parameters, counter);
389 }
390 else if ( command == fSetH3YCmd.get() ) {
391 // Only save values
392 auto counter = 0;
393 fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
394 fHelper->GetBinData(fYData, parameters, counter);
395 }
396 else if ( command == fSetH3ZCmd.get() ) {
397 auto counter = 0;
398 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
399 // Check if setX and setY command was called
400 if ( fXId == -1 || fXId != id ||
401 fYId == -1 || fYId != id ) {
402 fHelper->WarnAboutSetCommands();
403 return;
404 }
405 auto xunit = GetUnitValue(fXData.fSunit);
406 auto yunit = GetUnitValue(fYData.fSunit);
408 fHelper->GetBinData(zdata, parameters, counter);
409 auto zunit = GetUnitValue(zdata.fSunit);
410 fManager->SetH3(id,
411 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
412 fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
413 zdata.fNbins, zdata.fVmin*zunit, zdata.fVmax*zunit,
414 fXData.fSunit, fYData.fSunit, zdata.fSunit,
415 fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
416 fXData.fSbinScheme, fYData.fSbinScheme, zdata.fSbinScheme);
417 fXId = -1;
418 fYId = -1;
419 }
420 else if ( command == fSetH3TitleCmd.get() ) {
421 auto counter = 0;
422 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
423 auto title = parameters[counter++];
424 fManager->SetH3Title(id, title);
425 }
426 else if ( command == fSetH3XAxisCmd.get() ) {
427 auto counter = 0;
428 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
429 auto xaxis = parameters[counter++];
430 fManager->SetH3XAxisTitle(id, xaxis);
431 }
432 else if ( command == fSetH3YAxisCmd.get() ) {
433 auto counter = 0;
434 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
435 auto yaxis = parameters[counter++];
436 fManager->SetH3YAxisTitle(id, yaxis);
437 }
438 else if ( command == fSetH3ZAxisCmd.get() ) {
439 auto counter = 0;
440 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
441 auto zaxis = parameters[counter++];
442 fManager->SetH3ZAxisTitle(id, zaxis);
443 }
444 else if ( command == fSetH3XAxisLogCmd.get() ) {
445 auto counter = 0;
446 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
447 auto xaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
448 fManager->SetH3XAxisIsLog(id, xaxisLog);
449 }
450 else if ( command == fSetH3YAxisLogCmd.get() ) {
451 auto counter = 0;
452 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
453 auto yaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
454 fManager->SetH3YAxisIsLog(id, yaxisLog);
455 }
456 else if ( command == fSetH3ZAxisLogCmd.get() ) {
457 auto counter = 0;
458 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
459 auto zaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
460 fManager->SetH3ZAxisIsLog(id, zaxisLog);
461 }
462}
std::size_t GetParameterEntries() const
Definition: G4UIcommand.hh:138
static G4int ConvertToInt(const char *st)
Definition: G4UIcommand.cc:543
static G4bool ConvertToBool(const char *st)
Definition: G4UIcommand.cc:530
G4bool SetH3Title(G4int id, const G4String &title)
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 SetH3YAxisTitle(G4int id, const G4String &title)
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")
G4bool SetH3XAxisIsLog(G4int id, G4bool isLog)
G4bool SetH3XAxisTitle(G4int id, const G4String &title)
G4bool SetH3YAxisIsLog(G4int id, G4bool isLog)
G4bool SetH3ZAxisIsLog(G4int id, G4bool isLog)
G4bool SetH3ZAxisTitle(G4int id, const G4String &title)
void Tokenize(const G4String &line, std::vector< G4String > &tokens)
G4double GetUnitValue(const G4String &unit)
const char * name(G4int ptype)

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