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

#include <G4P2Messenger.hh>

+ Inheritance 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)
 
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 G4P2Messenger.hh.

Constructor & Destructor Documentation

◆ G4P2Messenger()

G4P2Messenger::G4P2Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 42 of file G4P2Messenger.cc.

43 : G4UImessenger(),
44 fManager(manager),
45 fHelper(nullptr),
46 fDirectory(nullptr),
47 fCreateP2Cmd(nullptr),
48 fSetP2Cmd(nullptr),
49 fSetP2XCmd(nullptr),
50 fSetP2YCmd(nullptr),
51 fSetP2ZCmd(nullptr),
52 fSetP2TitleCmd(nullptr),
53 fSetP2XAxisCmd(nullptr),
54 fSetP2YAxisCmd(nullptr),
55 fXId(-1),
56 fYId(-1),
57 fXData(),
58 fYData()
59{
60 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p2");
61
62 fDirectory = fHelper->CreateHnDirectory();
63
64 CreateP2Cmd();
65
66 SetP2Cmd();
67 fSetP2XCmd = fHelper->CreateSetBinsCommand("x", this);
68 fSetP2YCmd = fHelper->CreateSetBinsCommand("y", this);
69 fSetP2ZCmd = fHelper->CreateSetValuesCommand("z", this);
70
71 fSetP2TitleCmd = fHelper->CreateSetTitleCommand(this);
72 fSetP2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
73 fSetP2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
74 fSetP2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
75 fSetP2XAxisLogCmd = fHelper->CreateSetAxisLogCommand("x", this);
76 fSetP2YAxisLogCmd = fHelper->CreateSetAxisLogCommand("y", this);
77 fSetP2ZAxisLogCmd = fHelper->CreateSetAxisLogCommand("z", this);
78}

◆ ~G4P2Messenger()

G4P2Messenger::~G4P2Messenger ( )
virtual

Definition at line 81 of file G4P2Messenger.cc.

82{}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 305 of file G4P2Messenger.cc.

306{
307 // tokenize parameters in a vector
308 std::vector<G4String> parameters;
309 G4Analysis::Tokenize(newValues, parameters);
310 // check consistency
311 if ( parameters.size() != command->GetParameterEntries() ) {
312 // Should never happen but let's check anyway for consistency
313 fHelper->WarnAboutParameters(command, parameters.size());
314 return;
315 }
316
317 if ( command == fCreateP2Cmd.get() ) {
318 auto counter = 0;
319 auto name = parameters[counter++];
320 auto title = parameters[counter++];
322 fHelper->GetBinData(xdata, parameters, counter);
323 auto xunit = GetUnitValue(xdata.fSunit);
325 fHelper->GetBinData(ydata, parameters, counter);
326 auto yunit = GetUnitValue(ydata.fSunit);
328 fHelper->GetValueData(zdata, parameters, counter);
329 auto zunit = GetUnitValue(zdata.fSunit);
330 fManager->CreateP2(name, title,
331 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
332 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
333 zdata.fVmin*zunit, zdata.fVmax*zunit,
334 xdata.fSunit, ydata.fSunit, zdata.fSunit,
335 xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
336 xdata.fSbinScheme, ydata.fSbinScheme);
337 }
338 else if ( command == fSetP2Cmd.get() ) {
339 auto counter = 0;
340 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
342 fHelper->GetBinData(xdata, parameters, counter);
343 auto xunit = GetUnitValue(xdata.fSunit);
345 fHelper->GetBinData(ydata, parameters, counter);
346 auto yunit = GetUnitValue(ydata.fSunit);
348 fHelper->GetValueData(zdata, parameters, counter);
349 auto zunit = GetUnitValue(zdata.fSunit);
350 fManager->SetP2(id,
351 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
352 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
353 zdata.fVmin*zunit, zdata.fVmax*zunit,
354 xdata.fSunit, ydata.fSunit, zdata.fSunit,
355 xdata.fSfcn, ydata.fSfcn, zdata.fSfcn,
356 xdata.fSbinScheme, ydata.fSbinScheme);
357 }
358 else if ( command == fSetP2XCmd.get() ) {
359 // Only save values
360 auto counter = 0;
361 fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
362 fHelper->GetBinData(fXData, parameters, counter);
363 }
364 else if ( command == fSetP2YCmd.get() ) {
365 // Save values
366 auto counter = 0;
367 fYId = G4UIcommand::ConvertToInt(parameters[counter++]);
368 // Check if setX command was called
369 if ( fXId == -1 || fXId != fYId ) {
370 fHelper->WarnAboutSetCommands();
371 return;
372 }
373 fHelper->GetBinData(fYData, parameters, counter);
374 // Set values
375 // (another set may follow if setZ is also called)
376 auto xunit = GetUnitValue(fXData.fSunit);
377 auto yunit = GetUnitValue(fYData.fSunit);
378 fManager->SetP2(fYId,
379 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
380 fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
381 0., 0.,
382 fXData.fSunit, fYData.fSunit, "none",
383 fXData.fSfcn, fYData.fSfcn, "none",
384 fXData.fSbinScheme, fYData.fSbinScheme);
385 }
386 else if ( command == fSetP2ZCmd.get() ) {
387 auto counter = 0;
388 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
389 // Check if setX and setY command was called
390 if ( fXId == -1 || fXId != id ||
391 fYId == -1 || fYId != id ) {
392 fHelper->WarnAboutSetCommands();
393 return;
394 }
395 auto xunit = GetUnitValue(fXData.fSunit);
396 auto yunit = GetUnitValue(fYData.fSunit);
398 fHelper->GetValueData(zdata, parameters, counter);
399 auto zunit = GetUnitValue(zdata.fSunit);
400 fManager->SetP2(id,
401 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
402 fYData.fNbins, fYData.fVmin*yunit, fYData.fVmax*yunit,
403 zdata.fVmin*zunit, zdata.fVmax*zunit,
404 fXData.fSunit, fYData.fSunit, zdata.fSunit,
405 fXData.fSfcn, fYData.fSfcn, zdata.fSfcn,
406 fXData.fSbinScheme, fYData.fSbinScheme);
407 fXId = -1;
408 fYId = -1;
409 }
410 else if ( command == fSetP2TitleCmd.get() ) {
411 auto counter = 0;
412 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
413 auto title = parameters[counter++];
414 fManager->SetP2Title(id, title);
415 }
416 else if ( command == fSetP2XAxisCmd.get() ) {
417 auto counter = 0;
418 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
419 auto xaxis = parameters[counter++];
420 fManager->SetP2XAxisTitle(id, xaxis);
421 }
422 else if ( command == fSetP2YAxisCmd.get() ) {
423 auto counter = 0;
424 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
425 auto yaxis = parameters[counter++];
426 fManager->SetP2YAxisTitle(id, yaxis);
427 }
428 else if ( command == fSetP2ZAxisCmd.get() ) {
429 auto counter = 0;
430 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
431 auto zaxis = parameters[counter++];
432 fManager->SetP2ZAxisTitle(id, zaxis);
433 }
434 else if ( command == fSetP2XAxisLogCmd.get() ) {
435 auto counter = 0;
436 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
437 auto xaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
438 fManager->SetP2XAxisIsLog(id, xaxisLog);
439 }
440 else if ( command == fSetP2YAxisLogCmd.get() ) {
441 auto counter = 0;
442 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
443 auto yaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
444 fManager->SetP2YAxisIsLog(id, yaxisLog);
445 }
446 else if ( command == fSetP2ZAxisLogCmd.get() ) {
447 auto counter = 0;
448 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
449 auto zaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
450 fManager->SetP2ZAxisIsLog(id, zaxisLog);
451 }
452}
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 SetP2YAxisTitle(G4int id, const G4String &title)
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")
G4bool SetP2ZAxisIsLog(G4int id, G4bool isLog)
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 SetP2Title(G4int id, const G4String &title)
G4bool SetP2ZAxisTitle(G4int id, const G4String &title)
G4bool SetP2YAxisIsLog(G4int id, G4bool isLog)
G4bool SetP2XAxisIsLog(G4int id, G4bool isLog)
G4bool SetP2XAxisTitle(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: