34#include "G4UIdirectory.hh"
35#include "G4UIcommand.hh"
36#include "G4UIparameter.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithADoubleAndUnit.hh"
39#include "G4UIcmdWithoutParameter.hh"
42 G4UImessenger(), fDetector(Det), fExampleDir(0), fAbsorberDir(0), fGarfieldPhysicsDir(
43 0), fMaterialCmd(0), fIsotopeCmd(0), fIonizationModelCmd(0), fGeant4ParticleCmd(
45 fExampleDir =
new G4UIdirectory(
"/exampleGarfield/");
46 fExampleDir->SetGuidance(
"Commands specific to this example");
48 G4bool broadcast =
false;
49 fAbsorberDir =
new G4UIdirectory(
"/exampleGarfield/absorber/", broadcast);
50 fAbsorberDir->SetGuidance(
"Absorber construction commands");
52 fGarfieldPhysicsDir =
new G4UIdirectory(
"/exampleGarfield/physics/",
54 fGarfieldPhysicsDir->SetGuidance(
55 "Particle and energy ranges for Garfield++ physics model");
57 fMaterialCmd =
new G4UIcmdWithAString(
"/exampleGarfield/absorber/setMat",
59 fMaterialCmd->SetGuidance(
"Select material of the absorber:");
60 fMaterialCmd->SetParameterName(
"choice",
false);
61 fMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
63 fIsotopeCmd =
new G4UIcommand(
"/exampleGarfield/absorber/setIsotopeMat",
65 fIsotopeCmd->SetGuidance(
"Build and select a material with single isotope");
66 fIsotopeCmd->SetGuidance(
" symbol of isotope, Z, A, density of material");
68 G4UIparameter* symbPrm =
new G4UIparameter(
"isotope",
's',
false);
69 symbPrm->SetGuidance(
"isotope symbol");
70 fIsotopeCmd->SetParameter(symbPrm);
72 G4UIparameter* ZPrm =
new G4UIparameter(
"Z",
'i',
false);
73 ZPrm->SetGuidance(
"Z");
74 ZPrm->SetParameterRange(
"Z>0");
75 fIsotopeCmd->SetParameter(ZPrm);
77 G4UIparameter* APrm =
new G4UIparameter(
"A",
'i',
false);
78 APrm->SetGuidance(
"A");
79 APrm->SetParameterRange(
"A>0");
80 fIsotopeCmd->SetParameter(APrm);
82 G4UIparameter* densityPrm =
new G4UIparameter(
"density",
'd',
false);
83 densityPrm->SetGuidance(
"density of material");
84 densityPrm->SetParameterRange(
"density>0.");
85 fIsotopeCmd->SetParameter(densityPrm);
87 G4UIparameter* unitPrm =
new G4UIparameter(
"unit",
's',
false);
88 unitPrm->SetGuidance(
"unit of density");
89 G4String unitList = G4UIcommand::UnitsList(
90 G4UIcommand::CategoryOf(
"g/cm3"));
91 unitPrm->SetParameterCandidates(unitList);
92 fIsotopeCmd->SetParameter(unitPrm);
94 fIsotopeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
96 fIonizationModelCmd =
new G4UIcommand(
97 "/exampleGarfield/physics/setIonizationModel",
this);
98 fIonizationModelCmd->SetGuidance(
"Select ionization model for Garfield++");
99 fIonizationModelCmd->SetGuidance(
100 " and choose whether to use default particles");
101 fIonizationModelCmd->SetGuidance(
" and energy ranges for the chosen model");
103 G4UIparameter* ionizationModelPrm =
new G4UIparameter(
"ionizationModel",
105 ionizationModelPrm->SetGuidance(
"ionization model (1. PAIPhot, 2. PAI or 3. Heed)");
106 ionizationModelPrm->SetGuidance(
" 1. PAIPhot model in Geant4, delta electrons transported by Heed");
107 ionizationModelPrm->SetGuidance(
" 2. PAI model in Geant4, delta electrons transported by Heed");
108 ionizationModelPrm->SetGuidance(
" 3. Use directly Heed");
109 fIonizationModelCmd->SetParameter(ionizationModelPrm);
111 G4UIparameter* useDefaultsPrm =
new G4UIparameter(
"useDefaults",
'b',
113 useDefaultsPrm->SetGuidance(
114 "true to use default, false to manually choose particles and energies");
115 fIonizationModelCmd->SetParameter(useDefaultsPrm);
117 fIonizationModelCmd->AvailableForStates(G4State_PreInit);
121 fGeant4ParticleCmd =
new G4UIcommand(
122 "/exampleGarfield/physics/setGeant4ParticleTypeAndEnergy",
this);
123 fGeant4ParticleCmd->SetGuidance(
124 "Select particle types and energies for PAI and PAIPhot model");
125 fGeant4ParticleCmd->SetGuidance(
" in Geant4");
127 G4UIparameter* particleGeant4Prm =
new G4UIparameter(
"particleName",
's',
false);
128 particleGeant4Prm->SetGuidance(
129 "Particle name (e-, e+, mu-, mu+, proton, pi-, pi+, alpha, He3, GenericIon)");
130 fGeant4ParticleCmd->SetParameter(particleGeant4Prm);
132 G4UIparameter* minEnergyGeant4Prm =
new G4UIparameter(
"minimumEnergyGeant4",
'd',
134 minEnergyGeant4Prm->SetGuidance(
"minimum energy");
135 minEnergyGeant4Prm->SetParameterRange(
"minimumEnergyGeant4>=0");
136 fGeant4ParticleCmd->SetParameter(minEnergyGeant4Prm);
138 G4UIparameter* maxEnergyGeant4Prm =
new G4UIparameter(
"maximumEnergyGeant4",
'd',
140 maxEnergyGeant4Prm->SetGuidance(
"maximum energy");
141 maxEnergyGeant4Prm->SetParameterRange(
"maximumEnergyGeant4>=0");
142 fGeant4ParticleCmd->SetParameter(maxEnergyGeant4Prm);
144 G4UIparameter* unitGeant4Prm =
new G4UIparameter(
"unit",
's',
false);
145 unitGeant4Prm->SetGuidance(
"unit of energy");
146 G4String unitListGeant4 = G4UIcommand::UnitsList(G4UIcommand::CategoryOf(
"MeV"));
147 unitGeant4Prm->SetParameterCandidates(unitListGeant4);
148 fGeant4ParticleCmd->SetParameter(unitGeant4Prm);
150 fGeant4ParticleCmd->AvailableForStates(G4State_PreInit);
154 fGarfieldParticleCmd =
new G4UIcommand(
155 "/exampleGarfield/physics/setGarfieldParticleTypeAndEnergy",
this);
156 fGarfieldParticleCmd->SetGuidance(
157 "Select particle types and energies for Heed model.");
158 fGarfieldParticleCmd->SetGuidance(
159 " For PAI and PAIPhot model choose at which energy electrons are");
160 fGarfieldParticleCmd->SetGuidance(
161 " transported as delta electrons by Heed, and treatment of gammas");
163 G4UIparameter* particleGarfieldPrm =
new G4UIparameter(
"particleName",
's',
false);
164 particleGarfieldPrm->SetGuidance(
"Particle name (gamma, e-, e+, mu-, mu+, proton, anti_proton, pi-, pi+, kaon, kaon+, alpha, deuteron)");
165 fGarfieldParticleCmd->SetParameter(particleGarfieldPrm);
167 G4UIparameter* minEnergyGarfieldPrm =
new G4UIparameter(
"minimumEnergyGarfield",
'd',
169 minEnergyGarfieldPrm->SetGuidance(
"minimum energy");
170 minEnergyGarfieldPrm->SetParameterRange(
"minimumEnergyGarfield>=0");
171 fGarfieldParticleCmd->SetParameter(minEnergyGarfieldPrm);
173 G4UIparameter* maxEnergyGarfieldPrm =
new G4UIparameter(
"maximumEnergyGarfield",
'd',
175 maxEnergyGarfieldPrm->SetGuidance(
"maximum energy");
176 maxEnergyGarfieldPrm->SetParameterRange(
"maximumEnergyGarfield>=0");
177 fGarfieldParticleCmd->SetParameter(maxEnergyGarfieldPrm);
179 G4UIparameter* unitGarfieldPrm =
new G4UIparameter(
"unit",
's',
false);
180 unitGarfieldPrm->SetGuidance(
"unit of energy");
181 G4String unitListGarfield = G4UIcommand::UnitsList(G4UIcommand::CategoryOf(
"MeV"));
182 unitGarfieldPrm->SetParameterCandidates(unitListGarfield);
183 fGarfieldParticleCmd->SetParameter(unitGarfieldPrm);
185 fGarfieldParticleCmd->AvailableForStates(G4State_PreInit);
196 delete fGarfieldPhysicsDir;
197 delete fIonizationModelCmd;
198 delete fGeant4ParticleCmd;
199 delete fGarfieldParticleCmd;
205 if (command == fMaterialCmd) {
207 }
else if (command == fIsotopeCmd) {
212 std::istringstream is(newValue);
213 is >> name >> Z >> A >> dens >> unt;
214 dens *= G4UIcommand::ValueOf(unt);
217 }
else if (command == fIonizationModelCmd) {
221 std::istringstream is(newValue);
222 is >> modelName >> std::boolalpha >> useDefaults;
224 }
else if (command == fGeant4ParticleCmd) {
226 G4String particleName, unit, programName;
229 std::istringstream is(newValue);
230 is >> particleName >> minEnergy >> maxEnergy >> unit;
231 minEnergy *= G4UIcommand::ValueOf(unit);
232 maxEnergy *= G4UIcommand::ValueOf(unit);
235 }
else if (command == fGarfieldParticleCmd) {
237 G4String particleName, unit, programName;
240 std::istringstream is(newValue);
241 is >> particleName >> minEnergy >> maxEnergy >> unit;
242 minEnergy *= G4UIcommand::ValueOf(unit);
243 maxEnergy *= G4UIcommand::ValueOf(unit);
Definition of the GarfieldDetectorConstruction class.
Definition of the GarfieldMessenger class.
Definition of the GarfieldPhysics class.
void SetAbsorberMaterial(G4String materialChoice)
G4Material * AbsorberMaterialWithSingleIsotope(G4String name, G4String symbol, G4double density, G4int Z, G4int A)
GarfieldMessenger(GarfieldDetectorConstruction *)
virtual void SetNewValue(G4UIcommand *, G4String)
static GarfieldPhysics * GetInstance()
void SetIonizationModel(std::string model, bool useDefaults=true)
void AddParticleName(const std::string particleName, double ekin_min_MeV, double ekin_max_MeV, std::string program)