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

#include <G4P1Messenger.hh>

+ Inheritance diagram for G4P1Messenger:

Public Member Functions

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

Constructor & Destructor Documentation

◆ G4P1Messenger()

G4P1Messenger::G4P1Messenger ( G4VAnalysisManager manager)
explicit

Definition at line 42 of file G4P1Messenger.cc.

43 : G4UImessenger(),
44 fManager(manager),
45 fHelper(nullptr),
46 fDirectory(nullptr),
47 fCreateP1Cmd(nullptr),
48 fSetP1Cmd(nullptr),
49 fSetP1TitleCmd(nullptr),
50 fSetP1XAxisCmd(nullptr),
51 fSetP1YAxisCmd(nullptr),
52 fXId(-1),
53 fXData()
54{
55 fHelper = G4Analysis::make_unique<G4AnalysisMessengerHelper>("p1");
56
57 fDirectory = fHelper->CreateHnDirectory();
58
59 CreateP1Cmd();
60
61 SetP1Cmd();
62 fSetP1XCmd = fHelper->CreateSetBinsCommand("x", this);
63 fSetP1YCmd = fHelper->CreateSetValuesCommand("y", this);
64
65 fSetP1TitleCmd = fHelper->CreateSetTitleCommand(this);
66 fSetP1XAxisCmd = fHelper->CreateSetAxisCommand("x", this);
67 fSetP1YAxisCmd = fHelper->CreateSetAxisCommand("y", this);
68 fSetP1XAxisLogCmd = fHelper->CreateSetAxisLogCommand("x", this);
69 fSetP1YAxisLogCmd = fHelper->CreateSetAxisLogCommand("y", this);
70}

◆ ~G4P1Messenger()

G4P1Messenger::~G4P1Messenger ( )
virtual

Definition at line 73 of file G4P1Messenger.cc.

74{}

Member Function Documentation

◆ SetNewValue()

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

Reimplemented from G4UImessenger.

Definition at line 243 of file G4P1Messenger.cc.

244{
245 // tokenize parameters in a vector
246 std::vector<G4String> parameters;
247 G4Analysis::Tokenize(newValues, parameters);
248 // check consistency
249 if ( parameters.size() != command->GetParameterEntries() ) {
250 // Should never happen but let's check anyway for consistency
251 fHelper->WarnAboutParameters(command, parameters.size());
252 return;
253 }
254
255 if ( command == fCreateP1Cmd.get() ) {
256 auto counter = 0;
257 auto name = parameters[counter++];
258 auto title = parameters[counter++];
260 fHelper->GetBinData(xdata, parameters, counter);
261 auto xunit = GetUnitValue(xdata.fSunit);
263 fHelper->GetValueData(ydata, parameters, counter);
264 auto yunit = GetUnitValue(ydata.fSunit);
265 fManager->CreateP1(name, title,
266 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
267 ydata.fVmin*yunit, ydata.fVmax*yunit,
268 xdata.fSunit, ydata.fSunit,
269 xdata.fSfcn, ydata.fSfcn,
270 xdata.fSbinScheme);
271 }
272 else if ( command == fSetP1Cmd.get() ) {
273 auto counter = 0;
274 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
276 fHelper->GetBinData(xdata, parameters, counter);
277 auto xunit = GetUnitValue(xdata.fSunit);
279 fHelper->GetValueData(ydata, parameters, counter);
280 auto yunit = GetUnitValue(ydata.fSunit);
281 fManager->SetP1(id,
282 xdata.fNbins, xdata.fVmin*xunit, xdata.fVmax*xunit,
283 ydata.fVmin*yunit, ydata.fVmax*yunit,
284 xdata.fSunit, ydata.fSunit,
285 xdata.fSfcn, ydata.fSfcn,
286 xdata.fSbinScheme);
287 }
288 else if ( command == fSetP1XCmd.get() ) {
289 // Save values
290 auto counter = 0;
291 fXId = G4UIcommand::ConvertToInt(parameters[counter++]);
292 fHelper->GetBinData(fXData, parameters, counter);
293 // Set values
294 // (another set may follow if setY is also called)
295 auto xunit = GetUnitValue(fXData.fSunit);
296 fManager->SetP1(fXId,
297 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
298 0., 0.,
299 fXData.fSunit, "none",
300 fXData.fSfcn, "none",
301 fXData.fSbinScheme);
302 }
303 else if ( command == fSetP1YCmd.get() ) {
304 // Check if setX command was called
305 auto counter = 0;
306 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
307 if ( fXId == -1 || fXId != id ) {
308 fHelper->WarnAboutSetCommands();
309 return;
310 }
311 auto xunit = GetUnitValue(fXData.fSunit);
313 fHelper->GetValueData(ydata, parameters, counter);
314 auto yunit = GetUnitValue(ydata.fSunit);
315 fManager->SetP1(id,
316 fXData.fNbins, fXData.fVmin*xunit, fXData.fVmax*xunit,
317 ydata.fVmin*yunit, ydata.fVmax*yunit,
318 fXData.fSunit, ydata.fSunit,
319 fXData.fSfcn, ydata.fSfcn,
320 fXData.fSbinScheme);
321 fXId = -1;
322 }
323 else if ( command == fSetP1TitleCmd.get() ) {
324 auto counter = 0;
325 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
326 auto title = parameters[counter++];
327 fManager->SetP1Title(id, title);
328 }
329 else if ( command == fSetP1XAxisCmd.get() ) {
330 auto counter = 0;
331 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
332 auto xaxis = parameters[counter++];
333 fManager->SetP1XAxisTitle(id, xaxis);
334 }
335 else if ( command == fSetP1YAxisCmd.get() ) {
336 auto counter = 0;
337 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
338 auto yaxis = parameters[counter++];
339 fManager->SetP1YAxisTitle(id, yaxis);
340 }
341 else if ( command == fSetP1XAxisLogCmd.get() ) {
342 auto counter = 0;
343 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
344 auto xaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
345 fManager->SetP1XAxisIsLog(id, xaxisLog);
346 }
347 else if ( command == fSetP1YAxisLogCmd.get() ) {
348 auto counter = 0;
349 auto id = G4UIcommand::ConvertToInt(parameters[counter++]);
350 auto yaxisLog = G4UIcommand::ConvertToBool(parameters[counter++]);
351 fManager->SetP1YAxisIsLog(id, yaxisLog);
352 }
353}
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
G4int CreateP1(const G4String &name, const G4String &title, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4bool SetP1XAxisTitle(G4int id, const G4String &title)
G4bool SetP1(G4int id, G4int nbins, G4double xmin, G4double xmax, G4double ymin=0, G4double ymax=0, const G4String &xunitName="none", const G4String &yunitName="none", const G4String &xfcnName="none", const G4String &yfcnName="none", const G4String &xbinSchemeName="linear")
G4bool SetP1YAxisIsLog(G4int id, G4bool isLog)
G4bool SetP1YAxisTitle(G4int id, const G4String &title)
G4bool SetP1XAxisIsLog(G4int id, G4bool isLog)
G4bool SetP1Title(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: