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

#include <G4H2Messenger.hh>

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

Constructor & Destructor Documentation

◆ G4H2Messenger()

G4H2Messenger::G4H2Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 42 of file G4H2Messenger.cc.

43 : G4UImessenger(),
44 fManager(manager),
45 fHelper(nullptr),
46 fDirectory(nullptr),
47 fCreateH2Cmd(nullptr),
48 fSetH2Cmd(nullptr),
49 fSetH2XCmd(nullptr),
50 fSetH2YCmd(nullptr),
51 fSetH2TitleCmd(nullptr),
52 fSetH2XAxisCmd(nullptr),
53 fSetH2YAxisCmd(nullptr),
54 fXId(-1),
55 fXData()
56{
57 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("h2");
58
59 fDirectory = fHelper->CreateHnDirectory();
60
61 CreateH2Cmd();
62
63 SetH2Cmd();
64 fSetH2XCmd = fHelper->CreateSetBinsCommand("x", this);
65 fSetH2YCmd = fHelper->CreateSetBinsCommand("y", this);
66
67 fSetH2TitleCmd = fHelper->CreateSetTitleCommand(this);
68 fSetH2XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
69 fSetH2YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
70 fSetH2ZAxisCmd = fHelper->CreateSetAxisCommand("z", this);
71 fSetH2XAxisLogCmd = fHelper->CreateSetAxisLogCommand("x", this);
72 fSetH2YAxisLogCmd = fHelper->CreateSetAxisLogCommand("y", this);
73 fSetH2ZAxisLogCmd = fHelper->CreateSetAxisLogCommand("z", this);
74}

◆ ~G4H2Messenger()

G4H2Messenger::~G4H2Messenger ( )
virtual

Definition at line 77 of file G4H2Messenger.cc.

78{}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 258 of file G4H2Messenger.cc.

259{
260 // tokenize parameters in a vector
261 std::vector<G4String> parameters;
262 G4Analysis::Tokenize(newValues, parameters);
263 // check consistency
264 if ( parameters.size() != command->GetParameterEntries() ) {
265 // Should never happen but let's check anyway for consistency
266 fHelper->WarnAboutParameters(command, parameters.size());
267 return;
268 }
269
270 if ( command == fCreateH2Cmd.get() ) {
271 auto counter = 0;
272 auto name = parameters[counter++];
273 auto title = parameters[counter++];
275 fHelper->GetBinData(xdata, parameters, counter);
276 auto xunit = GetUnitValue(xdata.fSunit);
278 fHelper->GetBinData(ydata, parameters, counter);
279 auto yunit = GetUnitValue(ydata.fSunit);
280 fManager->CreateH2(name, title,
281 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
282 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
283 xdata.fSunit, ydata.fSunit,
284 xdata.fSfcn, ydata.fSfcn,
285 xdata.fSbinScheme, ydata.fSbinScheme);
286 }
287 else if ( command == fSetH2Cmd.get() ) {
288 auto counter = 0;
289 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
291 fHelper->GetBinData(xdata, parameters, counter);
292 auto xunit = GetUnitValue(xdata.fSunit);
294 fHelper->GetBinData(ydata, parameters, counter);
295 auto yunit = GetUnitValue(ydata.fSunit);
296 fManager->SetH2(id,
297 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
298 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
299 xdata.fSunit, ydata.fSunit,
300 xdata.fSfcn, ydata.fSfcn,
301 xdata.fSbinScheme, ydata.fSbinScheme);
302 }
303 else if ( command == fSetH2XCmd.get() ) {
304 // Only save values
305 auto counter = 0;
306 fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
307 fHelper->GetBinData(fXData, parameters, counter);
308 }
309 else if ( command == fSetH2YCmd.get() ) {
310 // Check if setX command was called
311 auto counter = 0;
312 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
313 if ( fXId == -1 || fXId != id ) {
314 fHelper->WarnAboutSetCommands();
315 return;
316 }
317 auto xunit = GetUnitValue(fXData.fSunit);
319 fHelper->GetBinData(ydata, parameters, counter);
320 auto yunit = GetUnitValue(ydata.fSunit);
321 fManager->SetH2(id,
322 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
323 ydata.fNbins, ydata.fVmin*yunit, ydata.fVmax*yunit,
324 fXData.fSunit, ydata.fSunit,
325 fXData.fSfcn, ydata.fSfcn,
326 fXData.fSbinScheme, ydata.fSbinScheme);
327 fXId = -1;
328 }
329 else if ( command == fSetH2TitleCmd.get() ) {
330 auto counter = 0;
331 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
332 auto title = parameters[counter++];
333 fManager->SetH2Title(id, title);
334 }
335 else if ( command == fSetH2XAxisCmd.get() ) {
336 auto counter = 0;
337 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
338 auto xaxis = parameters[counter++];
339 fManager->SetH2XAxisTitle(id, xaxis);
340 }
341 else if ( command == fSetH2YAxisCmd.get() ) {
342 auto counter = 0;
343 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
344 auto yaxis = parameters[counter++];
345 fManager->SetH2YAxisTitle(id, yaxis);
346 }
347 else if ( command == fSetH2ZAxisCmd.get() ) {
348 auto counter = 0;
349 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
350 auto zaxis = parameters[counter++];
351 fManager->SetH2ZAxisTitle(id, zaxis);
352 }
353 else if ( command == fSetH2XAxisLogCmd.get() ) {
354 auto counter = 0;
355 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
356 auto xaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
357 fManager->SetH2XAxisIsLog(id, xaxisLog);
358 }
359 else if ( command == fSetH2YAxisLogCmd.get() ) {
360 auto counter = 0;
361 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
362 auto yaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
363 fManager->SetH2YAxisIsLog(id, yaxisLog);
364 }
365 else if ( command == fSetH2ZAxisLogCmd.get() ) {
366 auto counter = 0;
367 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
368 auto zaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
369 fManager->SetH2ZAxisIsLog(id, zaxisLog);
370 }
371}
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 SetH2XAxisIsLog(G4int id, G4bool isLog)
G4bool SetH2Title(G4int id, const G4String &title)
G4bool SetH2YAxisIsLog(G4int id, G4bool isLog)
G4bool SetH2XAxisTitle(G4int id, const G4String &title)
G4bool SetH2YAxisTitle(G4int id, const G4String &title)
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 SetH2ZAxisIsLog(G4int id, G4bool isLog)
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 SetH2ZAxisTitle(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: