Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
GarfieldMessenger.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// $Id: GarfieldMessenger.cc 999995 2015-12-11 14:47:43Z dpfeiffe $
27//
28/// \file GarfieldMessenger.cc
29/// \brief Implementation of the GarfieldMessenger class
30
31#include "GarfieldMessenger.hh"
32#include "GarfieldPhysics.hh"
34#include "G4UIdirectory.hh"
35#include "G4UIcommand.hh"
36#include "G4UIparameter.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithADoubleAndUnit.hh"
39#include "G4UIcmdWithoutParameter.hh"
40
42 G4UImessenger(), fDetector(Det), fExampleDir(0), fAbsorberDir(0), fGarfieldPhysicsDir(
43 0), fMaterialCmd(0), fIsotopeCmd(0), fIonizationModelCmd(0), fGeant4ParticleCmd(
44 0) {
45 fExampleDir = new G4UIdirectory("/exampleGarfield/");
46 fExampleDir->SetGuidance("Commands specific to this example");
47
48 G4bool broadcast = false;
49 fAbsorberDir = new G4UIdirectory("/exampleGarfield/absorber/", broadcast);
50 fAbsorberDir->SetGuidance("Absorber construction commands");
51
52 fGarfieldPhysicsDir = new G4UIdirectory("/exampleGarfield/physics/",
53 broadcast);
54 fGarfieldPhysicsDir->SetGuidance(
55 "Particle and energy ranges for Garfield++ physics model");
56
57 fMaterialCmd = new G4UIcmdWithAString("/exampleGarfield/absorber/setMat",
58 this);
59 fMaterialCmd->SetGuidance("Select material of the absorber:");
60 fMaterialCmd->SetParameterName("choice", false);
61 fMaterialCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
62
63 fIsotopeCmd = new G4UIcommand("/exampleGarfield/absorber/setIsotopeMat",
64 this);
65 fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
66 fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
67 //
68 G4UIparameter* symbPrm = new G4UIparameter("isotope", 's', false);
69 symbPrm->SetGuidance("isotope symbol");
70 fIsotopeCmd->SetParameter(symbPrm);
71 //
72 G4UIparameter* ZPrm = new G4UIparameter("Z", 'i', false);
73 ZPrm->SetGuidance("Z");
74 ZPrm->SetParameterRange("Z>0");
75 fIsotopeCmd->SetParameter(ZPrm);
76 //
77 G4UIparameter* APrm = new G4UIparameter("A", 'i', false);
78 APrm->SetGuidance("A");
79 APrm->SetParameterRange("A>0");
80 fIsotopeCmd->SetParameter(APrm);
81 //
82 G4UIparameter* densityPrm = new G4UIparameter("density", 'd', false);
83 densityPrm->SetGuidance("density of material");
84 densityPrm->SetParameterRange("density>0.");
85 fIsotopeCmd->SetParameter(densityPrm);
86 //
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);
93 //
94 fIsotopeCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
95
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");
102 //
103 G4UIparameter* ionizationModelPrm = new G4UIparameter("ionizationModel",
104 's', false);
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);
110 //
111 G4UIparameter* useDefaultsPrm = new G4UIparameter("useDefaults", 'b',
112 false);
113 useDefaultsPrm->SetGuidance(
114 "true to use default, false to manually choose particles and energies");
115 fIonizationModelCmd->SetParameter(useDefaultsPrm);
116 //
117 fIonizationModelCmd->AvailableForStates(G4State_PreInit);
118
119
120
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");
126 //
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);
131 //
132 G4UIparameter* minEnergyGeant4Prm = new G4UIparameter("minimumEnergyGeant4", 'd',
133 false);
134 minEnergyGeant4Prm->SetGuidance("minimum energy");
135 minEnergyGeant4Prm->SetParameterRange("minimumEnergyGeant4>=0");
136 fGeant4ParticleCmd->SetParameter(minEnergyGeant4Prm);
137 //
138 G4UIparameter* maxEnergyGeant4Prm = new G4UIparameter("maximumEnergyGeant4", 'd',
139 false);
140 maxEnergyGeant4Prm->SetGuidance("maximum energy");
141 maxEnergyGeant4Prm->SetParameterRange("maximumEnergyGeant4>=0");
142 fGeant4ParticleCmd->SetParameter(maxEnergyGeant4Prm);
143 //
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);
149 //
150 fGeant4ParticleCmd->AvailableForStates(G4State_PreInit);
151
152
153
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");
162 //
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);
166 //
167 G4UIparameter* minEnergyGarfieldPrm = new G4UIparameter("minimumEnergyGarfield", 'd',
168 false);
169 minEnergyGarfieldPrm->SetGuidance("minimum energy");
170 minEnergyGarfieldPrm->SetParameterRange("minimumEnergyGarfield>=0");
171 fGarfieldParticleCmd->SetParameter(minEnergyGarfieldPrm);
172 //
173 G4UIparameter* maxEnergyGarfieldPrm = new G4UIparameter("maximumEnergyGarfield", 'd',
174 false);
175 maxEnergyGarfieldPrm->SetGuidance("maximum energy");
176 maxEnergyGarfieldPrm->SetParameterRange("maximumEnergyGarfield>=0");
177 fGarfieldParticleCmd->SetParameter(maxEnergyGarfieldPrm);
178 //
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);
184 //
185 fGarfieldParticleCmd->AvailableForStates(G4State_PreInit);
186
187}
188
189//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
190
192 delete fMaterialCmd;
193 delete fIsotopeCmd;
194 delete fAbsorberDir;
195 delete fExampleDir;
196 delete fGarfieldPhysicsDir;
197 delete fIonizationModelCmd;
198 delete fGeant4ParticleCmd;
199 delete fGarfieldParticleCmd;
200}
201
202//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
203
204void GarfieldMessenger::SetNewValue(G4UIcommand* command, G4String newValue) {
205 if (command == fMaterialCmd) {
206 fDetector->SetAbsorberMaterial(newValue);
207 } else if (command == fIsotopeCmd) {
208 G4int Z;
209 G4int A;
210 G4double dens;
211 G4String name, unt;
212 std::istringstream is(newValue);
213 is >> name >> Z >> A >> dens >> unt;
214 dens *= G4UIcommand::ValueOf(unt);
215 fDetector->AbsorberMaterialWithSingleIsotope(name, name, dens, Z, A);
216 fDetector->SetAbsorberMaterial(name);
217 } else if (command == fIonizationModelCmd) {
219 G4String modelName;
220 G4bool useDefaults;
221 std::istringstream is(newValue);
222 is >> modelName >> std::boolalpha >> useDefaults;
223 garfieldPhysics->SetIonizationModel(modelName, useDefaults);
224 } else if (command == fGeant4ParticleCmd) {
226 G4String particleName, unit, programName;
227 G4double minEnergy;
228 G4double maxEnergy;
229 std::istringstream is(newValue);
230 is >> particleName >> minEnergy >> maxEnergy >> unit;
231 minEnergy *= G4UIcommand::ValueOf(unit);
232 maxEnergy *= G4UIcommand::ValueOf(unit);
233 garfieldPhysics->AddParticleName(particleName, minEnergy, maxEnergy,
234 "geant4");
235 } else if (command == fGarfieldParticleCmd) {
237 G4String particleName, unit, programName;
238 G4double minEnergy;
239 G4double maxEnergy;
240 std::istringstream is(newValue);
241 is >> particleName >> minEnergy >> maxEnergy >> unit;
242 minEnergy *= G4UIcommand::ValueOf(unit);
243 maxEnergy *= G4UIcommand::ValueOf(unit);
244 garfieldPhysics->AddParticleName(particleName, minEnergy, maxEnergy,
245 "garfield");
246 }
247}
248
249//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
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)