Geant4 VMC Version 6.6
Loading...
Searching...
No Matches
TG4ParticlesCheckerMessenger.cxx
Go to the documentation of this file.
1//------------------------------------------------
2// The Geant4 Virtual Monte Carlo package
3// Copyright (C) 2007 - 2014 Ivana Hrivnacova
4// All rights reserved.
5//
6// For the licensing terms see geant4_vmc/LICENSE.
7// Contact: root-vmc@cern.ch
8//-------------------------------------------------
9
14
16#include "TG4Globals.h"
17#include "TG4ParticlesChecker.h"
19
20#include <G4UIcmdWithABool.hh>
21#include <G4UIcmdWithADouble.hh>
22#include <G4UIcmdWithAString.hh>
23#include <G4UIcmdWithAnInteger.hh>
24#include <G4UIcmdWithoutParameter.hh>
25#include <G4UIdirectory.hh>
26
27//_____________________________________________________________________________
29 TG4ParticlesChecker* particlesChecker)
30 : G4UImessenger(),
31 fParticlesChecker(particlesChecker),
32 fDirectory(0),
33 fSelectedProperty(""),
34 fCheckParticlesCmd(0),
35 fCheckParticleCmd(0),
36 fSelectPropertyCmd(0),
37 fSetCheckingCmd(0),
38 fSetPrecisionCmd(0)
39{
41
42 fDirectory = new G4UIdirectory("/mcParticlesChecker/");
43 fDirectory->SetGuidance("Particles checker commands.");
44
46 new G4UIcmdWithoutParameter("/mcParticlesChecker/checkParticles", this);
47 fCheckParticlesCmd->SetGuidance(
48 "Check properties for all instantiated particles");
49 fCheckParticlesCmd->AvailableForStates(G4State_Idle);
50
52 new G4UIcmdWithAnInteger("/mcParticlesChecker/checkParticle", this);
53 fCheckParticleCmd->SetGuidance(
54 "Check properties for the particle with given PDG encoding");
55 fCheckParticleCmd->SetParameterName("PDGEncoding", false);
56 fCheckParticleCmd->AvailableForStates(G4State_Idle);
57
59 new G4UIcmdWithAString("/mcParticlesChecker/selectProperty", this);
60 fSelectPropertyCmd->SetParameterName("propertyName", true);
61 fSelectPropertyCmd->AvailableForStates(G4State_Idle);
62
64 new G4UIcmdWithABool("/mcParticlesChecker/setChecking", this);
65 fSetCheckingCmd->SetGuidance("(In)Activate checking for a selected property");
66 fSetCheckingCmd->SetParameterName("Checking", false);
67 fSetCheckingCmd->AvailableForStates(G4State_Idle);
68
70 new G4UIcmdWithADouble("/mcParticlesChecker/setPrecision", this);
71 fSetPrecisionCmd->SetGuidance("Set number of bins in P");
72 fSetPrecisionCmd->SetParameterName("nofBinsE", false);
73 fSetPrecisionCmd->AvailableForStates(
74 G4State_PreInit, G4State_Init, G4State_Idle);
75}
76
77//_____________________________________________________________________________
89
90//
91// public methods
92//
93
94//_____________________________________________________________________________
96{
101
102 G4String candidates;
103 const std::set<TG4ParticlesChecker::ParticleProperty>& availableProperties =
105 std::set<TG4ParticlesChecker::ParticleProperty>::const_iterator it;
106 for (it = availableProperties.begin(); it != availableProperties.end();
107 it++) {
108 candidates = candidates + TG4ParticlesChecker::GetParticlePropertyName(*it);
109 candidates = candidates + G4String(" ");
110 }
111 fSelectPropertyCmd->SetCandidates(candidates);
112
113 G4String guidance = "Select particle property to be checked.\n";
114 guidance = guidance + "Available: ";
115 guidance = guidance + candidates;
116 fSelectPropertyCmd->SetGuidance(guidance);
117}
118
119//_____________________________________________________________________________
121 G4UIcommand* command, G4String newValue)
122{
124
125 if (command == fCheckParticlesCmd) {
127 }
128 else if (command == fCheckParticleCmd) {
130 fCheckParticleCmd->GetNewIntValue(newValue));
131 }
132 else if (command == fSelectPropertyCmd) {
133 fSelectedProperty = newValue;
134 }
135 else if (command == fSetCheckingCmd) {
136 if (fSelectedProperty == "") {
137 TString text = "The particle property has to be selected first.\n";
138 text = text + "The command will have no effect.";
139 TG4Globals::Warning("TG4ParticlesCheckerMessenger", "SetNewValue",
140 "The particle property has not been yet seleceted.");
141 return;
142 }
145 fSetCheckingCmd->GetNewBoolValue(newValue));
146 }
147 else if (command == fSetPrecisionCmd) {
149 fSetPrecisionCmd->GetNewDoubleValue(newValue));
150 }
151}
Definition of the TG4Globals class and basic container types.
Definition of the TG4ParticlesCheckerMessenger class.
Definition of the TG4ParticlesChecker class.
Definition of the TG4UICmdWithAComplexString class.
static void Warning(const TString &className, const TString &methodName, const TString &text)
G4UIcmdWithoutParameter * fCheckParticlesCmd
command: checkParticles
G4UIcmdWithADouble * fSetPrecisionCmd
command: setPrecision
G4UIcmdWithAString * fSelectPropertyCmd
command: selectProperty
virtual void SetNewValue(G4UIcommand *command, G4String string)
G4UIcmdWithAnInteger * fCheckParticleCmd
command: checkParticle
TG4ParticlesCheckerMessenger()
Not implemented.
G4UIcmdWithABool * fSetCheckingCmd
command: setChecking
G4UIdirectory * fDirectory
command directory
TG4ParticlesChecker * fParticlesChecker
associated class
G4String fSelectedProperty
selected property
A helper class for comparing the basic particles properties in between Root and Geant4.
const std::set< ParticleProperty > & GetAvailableProperties() const
G4bool CheckParticle(G4int pdgEncoding) const
void SetChecking(ParticleProperty property, G4bool check)
static G4String GetParticlePropertyName(ParticleProperty property)
static ParticleProperty GetParticleProperty(const G4String &propertyName)
void SetPrecision(G4double precision)