source: trunk/source/geometry/magneticfield/test/NTST/src/NTSTGunMessenger.cc@ 1199

Last change on this file since 1199 was 1199, checked in by garnier, 16 years ago

nvx fichiers dans CVS

File size: 9.1 KB
Line 
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: NTSTGunMessenger.cc,v 1.4 2006/06/29 18:26:18 gunter Exp $
27// GEANT4 tag $Name: HEAD $
28//
29
30#include "NTSTGunMessenger.hh"
31#include "NTSTGunGenerator.hh"
32#include "G4Geantino.hh"
33#include "G4ThreeVector.hh"
34#include "G4ParticleTable.hh"
35#include "G4UIdirectory.hh"
36#include "G4UIcmdWithoutParameter.hh"
37#include "G4UIcmdWithAString.hh"
38#include "G4UIcmdWithADouble.hh"
39#include "G4UIcmdWithADoubleAndUnit.hh"
40#include "G4UIcmdWith3Vector.hh"
41#include "G4UIcmdWith3VectorAndUnit.hh"
42#include "G4UIcmdWithAnInteger.hh"
43#include "G4ios.hh"
44
45NTSTGunMessenger::NTSTGunMessenger(NTSTGunGenerator * NTSTGun)
46 : fNTSTGun(NTSTGun), gunDirectory(0), listCmd(0), particleCmd(0),
47 plowCmd(0), phighCmd(0), t0Cmd(0), polCmd(0), numberCmd(0),
48 meanVertexCmd(0), rmsVertexCmd(0),
49 coslowCmd(0), coshighCmd(0), philowCmd(0), phihighCmd(0)
50{
51 particleTable = G4ParticleTable::GetParticleTable();
52
53 // directory
54 gunDirectory = new G4UIdirectory("/gen/gun/");
55 gunDirectory->SetGuidance("NTST Particle Gun control commands.");
56
57 // list command
58 listCmd = new G4UIcmdWithoutParameter("/gen/gun/List",this);
59 listCmd->SetGuidance("List available particles.");
60 listCmd->SetGuidance(" Invokes G4ParticleTable.");
61
62 // particle command
63 particleCmd = new G4UIcmdWithAString("/gen/gun/particle",this);
64 particleCmd->SetGuidance("Set particle to be generated.");
65 particleCmd->SetGuidance(" (geantino is default)");
66 particleCmd->SetParameterName("particleName",true);
67 particleCmd->SetDefaultValue("geantino");
68 G4String candidateList;
69 G4int nPtcl = particleTable->entries();
70 for(G4int i=0;i<nPtcl;i++)
71 {
72 candidateList += particleTable->GetParticleName(i);
73 candidateList += " ";
74 }
75 particleCmd->SetCandidates(candidateList);
76
77 // meanVertex command
78
79 meanVertexCmd = new G4UIcmdWith3VectorAndUnit("/gen/gun/vertex", this);
80 meanVertexCmd->SetGuidance("Set vertex position.");
81 meanVertexCmd->SetParameterName("x","y","z", true, true);
82 meanVertexCmd->SetDefaultUnit("mm");
83 meanVertexCmd->SetDefaultValue(G4ThreeVector(0,0,0));
84
85 // rmsVertex command
86
87 rmsVertexCmd = new G4UIcmdWith3VectorAndUnit("/gen/gun/spotsize", this);
88 rmsVertexCmd->SetGuidance("Set vertex size.");
89 rmsVertexCmd->SetParameterName("sx","sy","sz", true, true);
90 rmsVertexCmd->SetDefaultUnit("mm");
91 rmsVertexCmd->SetDefaultValue(G4ThreeVector(0,0,0));
92
93 // plow command
94 plowCmd = new G4UIcmdWithADoubleAndUnit("/gen/gun/plow",this);
95 plowCmd->SetGuidance("Set low momentum limit.");
96 plowCmd->SetParameterName("plow",true,true);
97 plowCmd->SetDefaultValue(1.0);
98 plowCmd->SetDefaultUnit("GeV");
99
100 // phigh command
101 phighCmd = new G4UIcmdWithADoubleAndUnit("/gen/gun/phigh",this);
102 phighCmd->SetGuidance("Set high momentum limit.");
103 phighCmd->SetParameterName("phigh",true,true);
104 phighCmd->SetDefaultValue(1.0);
105 phighCmd->SetDefaultUnit("GeV");
106
107 // coslow command
108 coslowCmd=new G4UIcmdWithADouble("/gen/gun/coslow",this);
109 coslowCmd->SetGuidance("Set lower cosine limit.");
110 coslowCmd->SetDefaultValue(-1.0);
111 coslowCmd->SetParameterName("coslow",true,true);
112
113 // coshigh command
114 coshighCmd=new G4UIcmdWithADouble("/gen/gun/coshigh",this);
115 coshighCmd->SetGuidance("Set upper cosine limit.");
116 coshighCmd->SetDefaultValue(1.0);
117 coshighCmd->SetParameterName("coshigh",true,true);
118
119 // philow command
120 philowCmd = new G4UIcmdWithADoubleAndUnit("/gen/gun/philow",this);
121 philowCmd->SetGuidance("Set low phi limit.");
122 philowCmd->SetParameterName("philow",true,true);
123 philowCmd->SetDefaultValue(0.0);
124 philowCmd->SetDefaultUnit("degree");
125
126 // phihigh command
127 phihighCmd = new G4UIcmdWithADoubleAndUnit("/gen/gun/phihigh",this);
128 phihighCmd->SetGuidance("Set high phi limit.");
129 phihighCmd->SetParameterName("phihigh",true,true);
130 phihighCmd->SetDefaultValue(360.0);
131 phihighCmd->SetDefaultUnit("degree");
132
133 // t0 command
134 t0Cmd = new G4UIcmdWithADoubleAndUnit("/gen/gun/t0",this);
135 t0Cmd->SetGuidance("Set initial t0 of the particle.");
136 t0Cmd->SetParameterName("t0",true,true);
137 t0Cmd->SetDefaultValue(0.0);
138 t0Cmd->SetDefaultUnit("ns");
139
140 // polarization command
141 polCmd = new G4UIcmdWith3Vector("/gen/gun/polarization",this);
142 polCmd->SetGuidance("Set polarization.");
143 polCmd->SetParameterName("Px","Py","Pz",true,true);
144 polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
145 polCmd->SetDefaultValue(G4ThreeVector(0,0,0));
146
147 // number command
148 numberCmd = new G4UIcmdWithAnInteger("/gen/gun/number",this);
149 numberCmd->SetGuidance("Set number of particles to be generated.");
150 numberCmd->SetParameterName("N",true,true);
151 numberCmd->SetRange("N>0");
152
153 // set initial value to NTSTGunGenerator
154 fNTSTGun->SetParticleDefinition( G4Geantino::Geantino() );
155}
156
157NTSTGunMessenger::~NTSTGunMessenger()
158{
159 delete listCmd;
160 delete particleCmd;
161 delete meanVertexCmd;
162 delete rmsVertexCmd;
163 delete plowCmd;
164 delete phighCmd;
165 delete coslowCmd;
166 delete coshighCmd;
167 delete philowCmd;
168 delete phihighCmd;
169 delete t0Cmd;
170 delete polCmd;
171 delete numberCmd;
172 delete gunDirectory;
173}
174
175void NTSTGunMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
176{
177 if( command==listCmd )
178 { particleTable->DumpTable(); }
179 else if( command==particleCmd )
180 {
181 G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
182 if(pd != NULL)
183 { fNTSTGun->SetParticleDefinition( pd ); }
184 }
185 else if( command==meanVertexCmd )
186 { fNTSTGun->SetMeanVertex(meanVertexCmd->GetNew3VectorValue(newValues)); }
187 else if( command==rmsVertexCmd )
188 { fNTSTGun->SetRmsVertex(rmsVertexCmd->GetNew3VectorValue(newValues)); }
189 else if( command==plowCmd )
190 { fNTSTGun->SetPlow(plowCmd->GetNewDoubleValue(newValues)); }
191 else if( command==phighCmd )
192 { fNTSTGun->SetPhigh(phighCmd->GetNewDoubleValue(newValues)); }
193 else if( command==coslowCmd )
194 { fNTSTGun->SetCoslow(coslowCmd->GetNewDoubleValue(newValues)); }
195 else if( command==coshighCmd )
196 { fNTSTGun->SetCoshigh(coshighCmd->GetNewDoubleValue(newValues)); }
197 else if( command==philowCmd )
198 { fNTSTGun->SetPhilow(philowCmd->GetNewDoubleValue(newValues)); }
199 else if( command==phihighCmd )
200 { fNTSTGun->SetPhihigh(phihighCmd->GetNewDoubleValue(newValues)); }
201 else if( command==t0Cmd )
202 { fNTSTGun->SetT0(t0Cmd->GetNewDoubleValue(newValues)); }
203 else if( command==polCmd )
204 { fNTSTGun->SetPolarization(polCmd->GetNew3VectorValue(newValues)); }
205 else if( command==numberCmd )
206 { fNTSTGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); }
207}
208
209G4String NTSTGunMessenger::GetCurrentValue(G4UIcommand * command)
210{
211 G4String cv;
212
213 if( command==particleCmd )
214 { cv = fNTSTGun->GetParticleDefinition()->GetParticleName(); }
215 else if( command==plowCmd )
216 { cv = plowCmd->ConvertToString(fNTSTGun->GetPlow(),"GeV"); }
217 else if( command==plowCmd )
218 { cv = phighCmd->ConvertToString(fNTSTGun->GetPhigh(),"GeV"); }
219 else if( command==coslowCmd )
220 { cv = coslowCmd->ConvertToString(fNTSTGun->GetCoslow());}
221 else if( command==coshighCmd )
222 { cv = coshighCmd->ConvertToString(fNTSTGun->GetCoshigh()); }
223 else if( command==philowCmd )
224 { cv = philowCmd->ConvertToString(fNTSTGun->GetPhilow(),"degree"); }
225 else if( command==plowCmd )
226 { cv = phihighCmd->ConvertToString(fNTSTGun->GetPhihigh(),"degree"); }
227 else if( command==t0Cmd )
228 { cv = t0Cmd->ConvertToString(fNTSTGun->GetT0(),"ns"); }
229 else if( command==polCmd )
230 { cv = polCmd->ConvertToString(fNTSTGun->GetPolarization()); }
231 else if( command==numberCmd )
232 { cv = numberCmd->ConvertToString(fNTSTGun->GetNumberOfParticles()); }
233
234 return cv;
235}
236
237
238
239
Note: See TracBrowser for help on using the repository browser.