Geant4 Cross Reference

Cross-Referencing   Geant4
Geant4/event/src/G4ParticleGunMessenger.cc

Version: [ ReleaseNotes ] [ 1.0 ] [ 1.1 ] [ 2.0 ] [ 3.0 ] [ 3.1 ] [ 3.2 ] [ 4.0 ] [ 4.0.p1 ] [ 4.0.p2 ] [ 4.1 ] [ 4.1.p1 ] [ 5.0 ] [ 5.0.p1 ] [ 5.1 ] [ 5.1.p1 ] [ 5.2 ] [ 5.2.p1 ] [ 5.2.p2 ] [ 6.0 ] [ 6.0.p1 ] [ 6.1 ] [ 6.2 ] [ 6.2.p1 ] [ 6.2.p2 ] [ 7.0 ] [ 7.0.p1 ] [ 7.1 ] [ 7.1.p1 ] [ 8.0 ] [ 8.0.p1 ] [ 8.1 ] [ 8.1.p1 ] [ 8.1.p2 ] [ 8.2 ] [ 8.2.p1 ] [ 8.3 ] [ 8.3.p1 ] [ 8.3.p2 ] [ 9.0 ] [ 9.0.p1 ] [ 9.0.p2 ] [ 9.1 ] [ 9.1.p1 ] [ 9.1.p2 ] [ 9.1.p3 ] [ 9.2 ] [ 9.2.p1 ] [ 9.2.p2 ] [ 9.2.p3 ] [ 9.2.p4 ] [ 9.3 ] [ 9.3.p1 ] [ 9.3.p2 ] [ 9.4 ] [ 9.4.p1 ] [ 9.4.p2 ] [ 9.4.p3 ] [ 9.4.p4 ] [ 9.5 ] [ 9.5.p1 ] [ 9.5.p2 ] [ 9.6 ] [ 9.6.p1 ] [ 9.6.p2 ] [ 9.6.p3 ] [ 9.6.p4 ] [ 10.0 ] [ 10.0.p1 ] [ 10.0.p2 ] [ 10.0.p3 ] [ 10.0.p4 ] [ 10.1 ] [ 10.1.p1 ] [ 10.1.p2 ] [ 10.1.p3 ] [ 10.2 ] [ 10.2.p1 ] [ 10.2.p2 ] [ 10.2.p3 ] [ 10.3 ] [ 10.3.p1 ] [ 10.3.p2 ] [ 10.3.p3 ] [ 10.4 ] [ 10.4.p1 ] [ 10.4.p2 ] [ 10.4.p3 ] [ 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /event/src/G4ParticleGunMessenger.cc (Version 11.3.0) and /event/src/G4ParticleGunMessenger.cc (Version 10.6.p2)


  1 //                                                  1 //
  2 // *******************************************      2 // ********************************************************************
  3 // * License and Disclaimer                         3 // * License and Disclaimer                                           *
  4 // *                                                4 // *                                                                  *
  5 // * The  Geant4 software  is  copyright of th      5 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
  6 // * the Geant4 Collaboration.  It is provided      6 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
  7 // * conditions of the Geant4 Software License      7 // * conditions of the Geant4 Software License,  included in the file *
  8 // * LICENSE and available at  http://cern.ch/      8 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
  9 // * include a list of copyright holders.           9 // * include a list of copyright holders.                             *
 10 // *                                               10 // *                                                                  *
 11 // * Neither the authors of this software syst     11 // * Neither the authors of this software system, nor their employing *
 12 // * institutes,nor the agencies providing fin     12 // * institutes,nor the agencies providing financial support for this *
 13 // * work  make  any representation or  warran     13 // * work  make  any representation or  warranty, express or implied, *
 14 // * regarding  this  software system or assum     14 // * regarding  this  software system or assume any liability for its *
 15 // * use.  Please see the license in the file      15 // * use.  Please see the license in the file  LICENSE  and URL above *
 16 // * for the full disclaimer and the limitatio     16 // * for the full disclaimer and the limitation of liability.         *
 17 // *                                               17 // *                                                                  *
 18 // * This  code  implementation is the result      18 // * This  code  implementation is the result of  the  scientific and *
 19 // * technical work of the GEANT4 collaboratio     19 // * technical work of the GEANT4 collaboration.                      *
 20 // * By using,  copying,  modifying or  distri     20 // * By using,  copying,  modifying or  distributing the software (or *
 21 // * any work based  on the software)  you  ag     21 // * any work based  on the software)  you  agree  to acknowledge its *
 22 // * use  in  resulting  scientific  publicati     22 // * use  in  resulting  scientific  publications,  and indicate your *
 23 // * acceptance of all terms of the Geant4 Sof     23 // * acceptance of all terms of the Geant4 Software license.          *
 24 // *******************************************     24 // ********************************************************************
 25 //                                                 25 //
 26 // G4ParticleGunMessenger class implementation << 
 27 //                                                 26 //
 28 // Author: Makoto Asai, 1997                   <<  27 //
 29 // ------------------------------------------- << 
 30                                                    28 
 31 #include "G4ParticleGunMessenger.hh"               29 #include "G4ParticleGunMessenger.hh"
 32 #include "G4SystemOfUnits.hh"                      30 #include "G4SystemOfUnits.hh"
 33 #include "G4ParticleGun.hh"                        31 #include "G4ParticleGun.hh"
 34 #include "G4Geantino.hh"                           32 #include "G4Geantino.hh"
 35 #include "G4ThreeVector.hh"                        33 #include "G4ThreeVector.hh"
 36 #include "G4ParticleTable.hh"                      34 #include "G4ParticleTable.hh"
 37 #include "G4IonTable.hh"                           35 #include "G4IonTable.hh"
 38 #include "G4UIdirectory.hh"                        36 #include "G4UIdirectory.hh"
 39 #include "G4UIcmdWithoutParameter.hh"              37 #include "G4UIcmdWithoutParameter.hh"
 40 #include "G4UIcmdWithAString.hh"                   38 #include "G4UIcmdWithAString.hh"
 41 #include "G4UIcmdWithADoubleAndUnit.hh"            39 #include "G4UIcmdWithADoubleAndUnit.hh"
 42 #include "G4UIcmdWith3Vector.hh"                   40 #include "G4UIcmdWith3Vector.hh"
 43 #include "G4UIcmdWith3VectorAndUnit.hh"            41 #include "G4UIcmdWith3VectorAndUnit.hh"
 44 #include "G4UIcmdWithAnInteger.hh"                 42 #include "G4UIcmdWithAnInteger.hh"
 45 #include "G4UIcmdWithABool.hh"                 << 
 46 #include "G4ios.hh"                                43 #include "G4ios.hh"
 47 #include "G4Tokenizer.hh"                          44 #include "G4Tokenizer.hh"
 48                                                    45 
 49 G4ParticleGunMessenger::G4ParticleGunMessenger <<  46 G4ParticleGunMessenger::G4ParticleGunMessenger(G4ParticleGun * fPtclGun)
 50   : fParticleGun(fPtclGun)                     <<  47   :fParticleGun(fPtclGun),fShootIon(false),
                                                   >>  48    fAtomicNumber(0),fAtomicMass(0),fIonCharge(0),fIonExciteEnergy(0.0),
                                                   >>  49    fIonFloatingLevelBase('\0'),fIonEnergyLevel(0)
 51 {                                                  50 {
 52   particleTable = G4ParticleTable::GetParticle     51   particleTable = G4ParticleTable::GetParticleTable();
 53                                                    52 
 54   gunDirectory = new G4UIdirectory("/gun/");       53   gunDirectory = new G4UIdirectory("/gun/");
 55   gunDirectory->SetGuidance("Particle Gun cont     54   gunDirectory->SetGuidance("Particle Gun control commands.");
 56                                                    55 
 57   listCmd = new G4UIcmdWithoutParameter("/gun/     56   listCmd = new G4UIcmdWithoutParameter("/gun/List",this);
 58   listCmd->SetGuidance("List available particl     57   listCmd->SetGuidance("List available particles.");
 59   listCmd->SetGuidance(" Invoke G4ParticleTabl     58   listCmd->SetGuidance(" Invoke G4ParticleTable.");
 60                                                    59 
 61   particleCmd = new G4UIcmdWithAString("/gun/p     60   particleCmd = new G4UIcmdWithAString("/gun/particle",this);
 62   particleCmd->SetGuidance("Set particle to be     61   particleCmd->SetGuidance("Set particle to be generated.");
 63   particleCmd->SetGuidance(" (geantino is defa     62   particleCmd->SetGuidance(" (geantino is default)");
 64   particleCmd->SetGuidance(" (ion can be speci     63   particleCmd->SetGuidance(" (ion can be specified for shooting ions)");
 65   particleCmd->SetParameterName("particleName"     64   particleCmd->SetParameterName("particleName",true);
 66   particleCmd->SetDefaultValue("geantino");        65   particleCmd->SetDefaultValue("geantino");
 67   G4String candidateList;                          66   G4String candidateList; 
 68   G4ParticleTable::G4PTblDicIterator* itr = pa     67   G4ParticleTable::G4PTblDicIterator* itr = particleTable->GetIterator();
 69   itr->reset();                                    68   itr->reset();
 70   while( (*itr)() )                                69   while( (*itr)() )
 71   {                                                70   {
 72     G4ParticleDefinition* pd = itr->value();       71     G4ParticleDefinition* pd = itr->value();
 73     if( !(pd->IsShortLived()) || pd->GetDecayT <<  72     if( !(pd->IsShortLived()) || pd->GetDecayTable() )
 74     {                                              73     {
 75       candidateList += pd->GetParticleName();      74       candidateList += pd->GetParticleName();
 76       candidateList += " ";                        75       candidateList += " ";
 77     }                                              76     }
 78   }                                                77   }
 79   candidateList += "ion ";                         78   candidateList += "ion ";
 80   particleCmd->SetCandidates(candidateList);       79   particleCmd->SetCandidates(candidateList);
 81                                                    80 
 82   directionCmd = new G4UIcmdWith3Vector("/gun/     81   directionCmd = new G4UIcmdWith3Vector("/gun/direction",this);
 83   directionCmd->SetGuidance("Set momentum dire     82   directionCmd->SetGuidance("Set momentum direction.");
 84   directionCmd->SetGuidance(" Direction needs  <<  83   directionCmd->SetGuidance("Direction needs not to be a unit vector.");
 85   directionCmd->SetParameterName("ex","ey","ez     84   directionCmd->SetParameterName("ex","ey","ez",true,true); 
 86   directionCmd->SetRange("ex != 0 || ey != 0 |     85   directionCmd->SetRange("ex != 0 || ey != 0 || ez != 0");
 87                                                    86   
 88   energyCmd = new G4UIcmdWithADoubleAndUnit("/     87   energyCmd = new G4UIcmdWithADoubleAndUnit("/gun/energy",this);
 89   energyCmd->SetGuidance("Set kinetic energy."     88   energyCmd->SetGuidance("Set kinetic energy.");
 90   energyCmd->SetParameterName("Energy",true,tr     89   energyCmd->SetParameterName("Energy",true,true);
 91   energyCmd->SetDefaultUnit("GeV");                90   energyCmd->SetDefaultUnit("GeV");
 92   //energyCmd->SetUnitCategory("Energy");          91   //energyCmd->SetUnitCategory("Energy");
 93   //energyCmd->SetUnitCandidates("eV keV MeV G     92   //energyCmd->SetUnitCandidates("eV keV MeV GeV TeV");
 94                                                    93 
 95   momCmd = new G4UIcmdWith3VectorAndUnit("/gun     94   momCmd = new G4UIcmdWith3VectorAndUnit("/gun/momentum",this);
 96   momCmd->SetGuidance("Set momentum. This comm <<  95   momCmd->SetGuidance("Set momentum. This command is equivalent to two commands /gun/direction and /gun/momentumAmp");
 97   momCmd->SetGuidance(" /gun/direction and /gu << 
 98   momCmd->SetParameterName("px","py","pz",true     96   momCmd->SetParameterName("px","py","pz",true,true); 
 99   momCmd->SetRange("px != 0 || py != 0 || pz !     97   momCmd->SetRange("px != 0 || py != 0 || pz != 0");
100   momCmd->SetDefaultUnit("GeV");                   98   momCmd->SetDefaultUnit("GeV");
101                                                    99 
102   momAmpCmd = new G4UIcmdWithADoubleAndUnit("/    100   momAmpCmd = new G4UIcmdWithADoubleAndUnit("/gun/momentumAmp",this);
103   momAmpCmd->SetGuidance("Set absolute value o    101   momAmpCmd->SetGuidance("Set absolute value of momentum.");
104   momAmpCmd->SetGuidance(" Direction should be << 102   momAmpCmd->SetGuidance("Direction should be set by /gun/direction command.");
105   momAmpCmd->SetGuidance(" This command should << 103   momAmpCmd->SetGuidance("This command should be used alternatively with /gun/energy.");
106   momAmpCmd->SetParameterName("Momentum",true,    104   momAmpCmd->SetParameterName("Momentum",true,true);
107   momAmpCmd->SetDefaultUnit("GeV");               105   momAmpCmd->SetDefaultUnit("GeV");
108                                                   106 
109   positionCmd = new G4UIcmdWith3VectorAndUnit(    107   positionCmd = new G4UIcmdWith3VectorAndUnit("/gun/position",this);
110   positionCmd->SetGuidance("Set starting posit    108   positionCmd->SetGuidance("Set starting position of the particle.");
111   positionCmd->SetGuidance(" Position must be  << 
112   positionCmd->SetParameterName("X","Y","Z",tr    109   positionCmd->SetParameterName("X","Y","Z",true,true);
113   positionCmd->SetDefaultUnit("cm");              110   positionCmd->SetDefaultUnit("cm");
114   // positionCmd->SetUnitCategory("Length");   << 111   //positionCmd->SetUnitCategory("Length");
115   // positionCmd->SetUnitCandidates("microm mm << 112   //positionCmd->SetUnitCandidates("microm mm cm m km");
116                                                   113 
117   timeCmd = new G4UIcmdWithADoubleAndUnit("/gu    114   timeCmd = new G4UIcmdWithADoubleAndUnit("/gun/time",this);
118   timeCmd->SetGuidance("Set initial time of th    115   timeCmd->SetGuidance("Set initial time of the particle.");
119   timeCmd->SetParameterName("t0",true,true);      116   timeCmd->SetParameterName("t0",true,true);
120   timeCmd->SetDefaultUnit("ns");                  117   timeCmd->SetDefaultUnit("ns");
121   // timeCmd->SetUnitCategory("Time");         << 118   //timeCmd->SetUnitCategory("Time");
122   // timeCmd->SetUnitCandidates("ns ms s");    << 119   //timeCmd->SetUnitCandidates("ns ms s");
123                                                   120   
124   polCmd = new G4UIcmdWith3Vector("/gun/polari    121   polCmd = new G4UIcmdWith3Vector("/gun/polarization",this);
125   polCmd->SetGuidance("Set polarization.");       122   polCmd->SetGuidance("Set polarization.");
126   polCmd->SetParameterName("Px","Py","Pz",true    123   polCmd->SetParameterName("Px","Py","Pz",true,true); 
127   polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&    124   polCmd->SetRange("Px>=-1.&&Px<=1.&&Py>=-1.&&Py<=1.&&Pz>=-1.&&Pz<=1.");
128                                                   125 
129   numberCmd = new G4UIcmdWithAnInteger("/gun/n    126   numberCmd = new G4UIcmdWithAnInteger("/gun/number",this);
130   numberCmd->SetGuidance("Set number of partic    127   numberCmd->SetGuidance("Set number of particles to be generated.");
131   numberCmd->SetParameterName("N",true,true);     128   numberCmd->SetParameterName("N",true,true);
132   numberCmd->SetRange("N>0");                     129   numberCmd->SetRange("N>0");
133                                                   130 
134   ionCmd = new G4UIcommand("/gun/ion",this);      131   ionCmd = new G4UIcommand("/gun/ion",this);
135   ionCmd->SetGuidance("Set properties of ion t    132   ionCmd->SetGuidance("Set properties of ion to be generated.");
136   ionCmd->SetGuidance("[usage] /gun/ion Z A [Q    133   ionCmd->SetGuidance("[usage] /gun/ion Z A [Q E flb]");
137   ionCmd->SetGuidance("        Z:(int) AtomicN    134   ionCmd->SetGuidance("        Z:(int) AtomicNumber");
138   ionCmd->SetGuidance("        A:(int) AtomicM    135   ionCmd->SetGuidance("        A:(int) AtomicMass");
139   ionCmd->SetGuidance("        Q:(int) Charge     136   ionCmd->SetGuidance("        Q:(int) Charge of Ion (in unit of e)");
140   ionCmd->SetGuidance("        E:(double) Exci    137   ionCmd->SetGuidance("        E:(double) Excitation energy (in keV)");
141   ionCmd->SetGuidance("        flb:(char) Floa    138   ionCmd->SetGuidance("        flb:(char) Floating level base");
142                                                   139   
143   G4UIparameter* param;                           140   G4UIparameter* param;
144   param = new G4UIparameter("Z",'i',false);       141   param = new G4UIparameter("Z",'i',false);
145   ionCmd->SetParameter(param);                    142   ionCmd->SetParameter(param);
146   param = new G4UIparameter("A",'i',false);       143   param = new G4UIparameter("A",'i',false);
147   ionCmd->SetParameter(param);                    144   ionCmd->SetParameter(param);
148   param = new G4UIparameter("Q",'i',true);        145   param = new G4UIparameter("Q",'i',true);
149   param->SetDefaultValue(-1);                     146   param->SetDefaultValue(-1);
150   ionCmd->SetParameter(param);                    147   ionCmd->SetParameter(param);
151   param = new G4UIparameter("E",'d',true);        148   param = new G4UIparameter("E",'d',true);
152   param->SetDefaultValue(0.0);                    149   param->SetDefaultValue(0.0);
153   ionCmd->SetParameter(param);                    150   ionCmd->SetParameter(param);
154   param = new G4UIparameter("flb",'c',true);      151   param = new G4UIparameter("flb",'c',true);
155   param->SetDefaultValue("noFloat");              152   param->SetDefaultValue("noFloat");
156   param->SetParameterCandidates("noFloat X Y Z    153   param->SetParameterCandidates("noFloat X Y Z U V W R S T A B C D E");
157   ionCmd->SetParameter(param);                    154   ionCmd->SetParameter(param);
158                                                   155 
159   ionLvlCmd = new G4UIcommand("/gun/ionL",this    156   ionLvlCmd = new G4UIcommand("/gun/ionL",this);
160   ionLvlCmd->SetGuidance("THIS COMMAND IS DEPR << 157   ionLvlCmd->SetGuidance("THIS COMMAND IS DEPRECATED and will be removed in release 10.5.");
161   ionLvlCmd->SetGuidance(" Use /gun/ion instea << 158   ionLvlCmd->SetGuidance("Use /gun/ion instead.");
162   ionLvlCmd->SetGuidance(" Set properties of i << 159   ionLvlCmd->SetGuidance("Set properties of ion to be generated.");
163   ionLvlCmd->SetGuidance(" [usage] /gun/ionL Z << 160   ionLvlCmd->SetGuidance("[usage] /gun/ionL Z A [Q I]");
164   ionLvlCmd->SetGuidance("        Z:(int) Atom    161   ionLvlCmd->SetGuidance("        Z:(int) AtomicNumber");
165   ionLvlCmd->SetGuidance("        A:(int) Atom    162   ionLvlCmd->SetGuidance("        A:(int) AtomicMass");
166   ionLvlCmd->SetGuidance("        Q:(int) Char    163   ionLvlCmd->SetGuidance("        Q:(int) Charge of Ion (in unit of e)");
167   ionLvlCmd->SetGuidance("        I:(int) Leve    164   ionLvlCmd->SetGuidance("        I:(int) Level number of metastable state (0 = ground)");
168                                                   165 
169   G4UIparameter* paraml;                          166   G4UIparameter* paraml;
170   paraml = new G4UIparameter("Z",'i',false);      167   paraml = new G4UIparameter("Z",'i',false);
171   ionLvlCmd->SetParameter(paraml);                168   ionLvlCmd->SetParameter(paraml);
172   paraml = new G4UIparameter("A",'i',false);      169   paraml = new G4UIparameter("A",'i',false);
173   ionLvlCmd->SetParameter(paraml);                170   ionLvlCmd->SetParameter(paraml);
174   paraml = new G4UIparameter("Q",'i',true);       171   paraml = new G4UIparameter("Q",'i',true);
175   paraml->SetDefaultValue(-1);                    172   paraml->SetDefaultValue(-1);
176   ionLvlCmd->SetParameter(paraml);                173   ionLvlCmd->SetParameter(paraml);
177   paraml = new G4UIparameter("I",'i',true);       174   paraml = new G4UIparameter("I",'i',true);
178   paraml->SetDefaultValue("0");                   175   paraml->SetDefaultValue("0");
179   ionLvlCmd->SetParameter(paraml);                176   ionLvlCmd->SetParameter(paraml);
180                                                   177 
181   volChkCmd = new G4UIcmdWithABool("/gun/check << 178   // set initial value to G4ParticleGun
182   volChkCmd->SetGuidance("Switch on/off the ch << 
183   volChkCmd->SetGuidance("By default the check << 
184   volChkCmd->SetGuidance("but the user has to  << 
185   volChkCmd->SetParameterName("switch",true,tr << 
186                                                << 
187   // Set initial value to G4ParticleGun        << 
188   //                                           << 
189   fParticleGun->SetParticleDefinition( G4Geant    179   fParticleGun->SetParticleDefinition( G4Geantino::Geantino() );
190   fParticleGun->SetParticleMomentumDirection(     180   fParticleGun->SetParticleMomentumDirection( G4ThreeVector(1.0,0.0,0.0) );
191   fParticleGun->SetParticleEnergy( 1.0*GeV );     181   fParticleGun->SetParticleEnergy( 1.0*GeV );
                                                   >> 182   fParticleGun->SetParticlePosition(G4ThreeVector(0.0*cm, 0.0*cm, 0.0*cm));
192   fParticleGun->SetParticleTime( 0.0*ns );        183   fParticleGun->SetParticleTime( 0.0*ns );
193 }                                                 184 }
194                                                   185 
195 G4ParticleGunMessenger::~G4ParticleGunMessenge    186 G4ParticleGunMessenger::~G4ParticleGunMessenger()
196 {                                                 187 {
197   delete listCmd;                                 188   delete listCmd;
198   delete particleCmd;                             189   delete particleCmd;
199   delete directionCmd;                            190   delete directionCmd;
200   delete energyCmd;                               191   delete energyCmd;
201   delete momCmd;                                  192   delete momCmd;
202   delete momAmpCmd;                               193   delete momAmpCmd;
203   delete positionCmd;                             194   delete positionCmd;
204   delete timeCmd;                                 195   delete timeCmd;
205   delete polCmd;                                  196   delete polCmd;
206   delete numberCmd;                               197   delete numberCmd;
207   delete ionCmd;                                  198   delete ionCmd;
208   delete ionLvlCmd;                               199   delete ionLvlCmd;
209   delete volChkCmd;                            << 
210   delete gunDirectory;                            200   delete gunDirectory;
211 }                                                 201 }
212                                                   202 
213 void G4ParticleGunMessenger::                  << 203 void G4ParticleGunMessenger::SetNewValue(G4UIcommand * command,G4String newValues)
214 SetNewValue(G4UIcommand* command, G4String new << 
215 {                                                 204 {
216   G4ExceptionDescription ed;                      205   G4ExceptionDescription ed;
217   if (command==listCmd)                        << 206   if (command==listCmd) {
218   {                                            << 
219     particleTable->DumpTable();                   207     particleTable->DumpTable();
220   }                                            << 208   } else if (command==particleCmd) {
221   else if (command==particleCmd)               << 209     if (newValues =="ion") {
222   {                                            << 
223     if (newValues =="ion")                     << 
224     {                                          << 
225       fShootIon = true;                           210       fShootIon = true;
226     }                                          << 211     } else {
227     else                                       << 
228     {                                          << 
229       fShootIon = false;                          212       fShootIon = false;
230       G4ParticleDefinition* pd = particleTable    213       G4ParticleDefinition* pd = particleTable->FindParticle(newValues);
231       if(pd != nullptr)                        << 214       if(pd != 0) {
232       {                                        << 
233         fParticleGun->SetParticleDefinition( p    215         fParticleGun->SetParticleDefinition( pd );
234       }                                        << 216       } else {
235       else                                     << 
236       {                                        << 
237         ed << "Particle [" << newValues << "]     217         ed << "Particle [" << newValues << "] is not found.";
238         command->CommandFailed(ed);               218         command->CommandFailed(ed);
239       }                                           219       }
240     }                                             220     }
241                                                   221 
242   } else if( command==directionCmd )              222   } else if( command==directionCmd )
243   { fParticleGun->SetParticleMomentumDirection    223   { fParticleGun->SetParticleMomentumDirection(directionCmd->GetNew3VectorValue(newValues)); }
244   else if( command==energyCmd )                   224   else if( command==energyCmd )
245   { fParticleGun->SetParticleEnergy(energyCmd-    225   { fParticleGun->SetParticleEnergy(energyCmd->GetNewDoubleValue(newValues)); }
246   else if( command==momCmd )                      226   else if( command==momCmd )
247   { fParticleGun->SetParticleMomentum(momCmd->    227   { fParticleGun->SetParticleMomentum(momCmd->GetNew3VectorValue(newValues)); }
248   else if( command==momAmpCmd )                   228   else if( command==momAmpCmd )
249   { fParticleGun->SetParticleMomentum(momAmpCm    229   { fParticleGun->SetParticleMomentum(momAmpCmd->GetNewDoubleValue(newValues)); }
250   else if( command==positionCmd )                 230   else if( command==positionCmd )
251   { fParticleGun->SetParticlePosition(position    231   { fParticleGun->SetParticlePosition(positionCmd->GetNew3VectorValue(newValues)); }
252   else if( command==timeCmd )                     232   else if( command==timeCmd )
253   { fParticleGun->SetParticleTime(timeCmd->Get    233   { fParticleGun->SetParticleTime(timeCmd->GetNewDoubleValue(newValues)); }
254   else if( command==polCmd )                      234   else if( command==polCmd )
255   { fParticleGun->SetParticlePolarization(polC    235   { fParticleGun->SetParticlePolarization(polCmd->GetNew3VectorValue(newValues)); }
256   else if( command==numberCmd )                   236   else if( command==numberCmd )
257   { fParticleGun->SetNumberOfParticles(numberC    237   { fParticleGun->SetNumberOfParticles(numberCmd->GetNewIntValue(newValues)); }
258   else if( command==ionCmd )                      238   else if( command==ionCmd ) 
259   {                                               239   {
260     if (fShootIon)                             << 240     if (fShootIon) {
261     {                                          << 
262       IonCommand(newValues);                      241       IonCommand(newValues);
263     }                                          << 242     } else {
264     else                                       << 
265     {                                          << 
266       ed << "Set /gun/particle to ion before u    243       ed << "Set /gun/particle to ion before using /gun/ion command";
267       command->CommandFailed(ed);                 244       command->CommandFailed(ed);
268     }                                             245     }
269   }                                               246   }
270   else if( command==ionLvlCmd )                   247   else if( command==ionLvlCmd ) 
271   {                                               248   {
272     G4ExceptionDescription depWarn;               249     G4ExceptionDescription depWarn; 
273     depWarn << "\nCommand /gun/ionL is depreca << 250     depWarn << "\nCommand /gun/ionL is deprecated and will be removed in release 10.5.\n"
274             << "Use /gun/ion instead.\n";         251             << "Use /gun/ion instead.\n";
275     G4Exception("G4ParticleGunMessenger::SetNe << 252     G4Exception("G4ParticleGunMessenger::SetNewValue","IonLWarn",JustWarning,depWarn);
276                 JustWarning, depWarn);         << 
277                                                   253 
278     if (fShootIon)                             << 254     if (fShootIon) {
279     {                                          << 
280       IonLevelCommand(newValues);                 255       IonLevelCommand(newValues);
281     }                                          << 256     } else {
282     else                                       << 
283     {                                          << 
284       ed << "Set /gun/particle to ion before u    257       ed << "Set /gun/particle to ion before using /gun/ion command";
285       command->CommandFailed(ed);                 258       command->CommandFailed(ed);
286     }                                             259     }
287   }                                               260   }
288   else if( command==volChkCmd )                << 
289   {                                            << 
290     fParticleGun->CheckInside(volChkCmd->GetNe << 
291   }                                            << 
292 }                                                 261 }
293                                                   262 
294 G4String G4ParticleGunMessenger::GetCurrentVal << 263 G4String G4ParticleGunMessenger::GetCurrentValue(G4UIcommand * command)
295 {                                                 264 {
296   G4String cv;                                    265   G4String cv;
297                                                   266   
298   if( command==directionCmd )                     267   if( command==directionCmd )
299   { cv = directionCmd->ConvertToString(fPartic    268   { cv = directionCmd->ConvertToString(fParticleGun->GetParticleMomentumDirection()); }
300   else if( command==particleCmd )                 269   else if( command==particleCmd )
301   { cv = fParticleGun->GetParticleDefinition()    270   { cv = fParticleGun->GetParticleDefinition()->GetParticleName(); }
302   else if( command==energyCmd )                   271   else if( command==energyCmd )
303   {                                               272   {
304     G4double ene = fParticleGun->GetParticleEn    273     G4double ene = fParticleGun->GetParticleEnergy();
305     if(ene == 0.)                                 274     if(ene == 0.)
306     { G4cerr << " G4ParticleGun:  was defined     275     { G4cerr << " G4ParticleGun:  was defined in terms of momentum." << G4endl; }
307     else                                          276     else
308     { cv = energyCmd->ConvertToString(ene,"GeV    277     { cv = energyCmd->ConvertToString(ene,"GeV"); }
309   }                                               278   }
310   else if( command==momCmd || command==momAmpC    279   else if( command==momCmd || command==momAmpCmd )
311   {                                               280   {
312     G4double mom = fParticleGun->GetParticleMo    281     G4double mom = fParticleGun->GetParticleMomentum();
313     if(mom == 0.)                                 282     if(mom == 0.)
314     {                                          << 283     { G4cerr << " G4ParticleGun:  was defined in terms of kinetic energy." << G4endl; }
315       G4cerr << " G4ParticleGun:  was defined  << 
316              << G4endl;                        << 
317     }                                          << 
318     else                                          284     else
319     {                                             285     {
320       if( command==momCmd )                       286       if( command==momCmd )
321       { cv = momCmd->ConvertToString(mom*(fPar    287       { cv = momCmd->ConvertToString(mom*(fParticleGun->GetParticleMomentumDirection()),"GeV"); }
322       else                                        288       else
323       { cv = momAmpCmd->ConvertToString(mom,"G    289       { cv = momAmpCmd->ConvertToString(mom,"GeV"); }
324     }                                             290     }
325   }                                               291   }
326   else if( command==positionCmd )                 292   else if( command==positionCmd )
327   { cv = positionCmd->ConvertToString(fParticl    293   { cv = positionCmd->ConvertToString(fParticleGun->GetParticlePosition(),"cm"); }
328   else if( command==timeCmd )                     294   else if( command==timeCmd )
329   { cv = timeCmd->ConvertToString(fParticleGun    295   { cv = timeCmd->ConvertToString(fParticleGun->GetParticleTime(),"ns"); }
330   else if( command==polCmd )                      296   else if( command==polCmd )
331   { cv = polCmd->ConvertToString(fParticleGun-    297   { cv = polCmd->ConvertToString(fParticleGun->GetParticlePolarization()); }
332   else if( command==numberCmd )                   298   else if( command==numberCmd )
333   { cv = numberCmd->ConvertToString(fParticleG    299   { cv = numberCmd->ConvertToString(fParticleGun->GetNumberOfParticles()); }
334   else if( command==ionCmd )                      300   else if( command==ionCmd )
335   {                                               301   { 
336     if (fShootIon)                             << 302     if (fShootIon) {
337     {                                          << 
338       cv = ItoS(fAtomicNumber) + " " + ItoS(fA    303       cv = ItoS(fAtomicNumber) + " " + ItoS(fAtomicMass) + " ";
339       cv += ItoS(fIonCharge);                     304       cv += ItoS(fIonCharge);
340     }                                          << 305     } else {
341     else                                       << 
342     {                                          << 
343       cv = "";                                    306       cv = "";
344     }                                             307     }  
345   }                                               308   }    
346   else if( command==volChkCmd )                << 
347   { cv = volChkCmd->ConvertToString(fParticleG << 
348   return cv;                                      309   return cv;
349 }                                                 310 }
350                                                   311 
351 void G4ParticleGunMessenger::IonLevelCommand(c << 312 #include "G4IonTable.hh"
                                                   >> 313 
                                                   >> 314 void G4ParticleGunMessenger::IonLevelCommand(G4String newValues)
352 {                                                 315 {
353   G4Tokenizer next( newValues );                  316   G4Tokenizer next( newValues );
354                                                << 317   // check argument
355   // Check argument                            << 
356   //                                           << 
357   fAtomicNumber = StoI(next());                   318   fAtomicNumber = StoI(next());
358   fAtomicMass = StoI(next());                     319   fAtomicMass = StoI(next());
359   G4String sQ = next();                           320   G4String sQ = next();
360   if (sQ.empty() || StoI(sQ)<0)                << 321   if (sQ.isNull() || StoI(sQ)<0) {
361   {                                            << 
362     fIonCharge = fAtomicNumber;                   322     fIonCharge = fAtomicNumber;
363   }                                            << 323   } else {
364   else                                         << 
365   {                                            << 
366     fIonCharge = StoI(sQ);                        324     fIonCharge = StoI(sQ);
367   }                                               325   }
368   sQ = next();                                    326   sQ = next();
369   if (sQ.empty())                              << 327   if (sQ.isNull()) {
370   {                                            << 
371     fIonEnergyLevel = 0;                          328     fIonEnergyLevel = 0;
372   }                                            << 329   } else {
373   else                                         << 
374   {                                            << 
375     fIonEnergyLevel = StoI(sQ);                   330     fIonEnergyLevel = StoI(sQ);
376   }                                               331   }
377   G4ParticleDefinition* ion = G4IonTable::GetI << 332   G4ParticleDefinition* ion = 0;
378       ->GetIon(fAtomicNumber,fAtomicMass,fIonE << 333   ion =  G4IonTable::GetIonTable()->GetIon(fAtomicNumber,fAtomicMass,fIonEnergyLevel);
379   if (ion == nullptr)                          << 334   if (ion == 0) {
380   {                                            << 
381     G4ExceptionDescription ed;                    335     G4ExceptionDescription ed;
382     ed << "Ion with Z = " << fAtomicNumber <<     336     ed << "Ion with Z = " << fAtomicNumber << ", A = " << fAtomicMass
383        << ", I = " << fIonEnergyLevel << " is     337        << ", I = " << fIonEnergyLevel << " is not defined ";
384     ionLvlCmd->CommandFailed(ed);                 338     ionLvlCmd->CommandFailed(ed);
385   }                                            << 339   } else {
386   else                                         << 
387   {                                            << 
388     fParticleGun->SetParticleDefinition(ion);     340     fParticleGun->SetParticleDefinition(ion);
389     fParticleGun->SetParticleCharge(fIonCharge    341     fParticleGun->SetParticleCharge(fIonCharge*eplus);
390   }                                               342   }
391 }                                                 343 }
392                                                   344 
393 void G4ParticleGunMessenger::IonCommand(const  << 345 void G4ParticleGunMessenger::IonCommand(G4String newValues)
394 {                                                 346 {
395   G4Tokenizer next( newValues );                  347   G4Tokenizer next( newValues );
396                                                << 348   // check argument
397   // Check argument                            << 
398   //                                           << 
399   fAtomicNumber = StoI(next());                   349   fAtomicNumber = StoI(next());
400   fAtomicMass = StoI(next());                     350   fAtomicMass = StoI(next());
401   fIonCharge = fAtomicNumber;                     351   fIonCharge = fAtomicNumber;
402   fIonExciteEnergy = 0.0;                         352   fIonExciteEnergy = 0.0;
403   fIonFloatingLevelBase = '\0';                   353   fIonFloatingLevelBase = '\0';
404   G4String sQ = next();                           354   G4String sQ = next();
405   if (!(sQ.empty()))                           << 355   if (!(sQ.isNull()))
406   {                                               356   {
407     if (StoI(sQ)>=0)                              357     if (StoI(sQ)>=0)
408     fIonCharge = StoI(sQ);                        358     fIonCharge = StoI(sQ);
409                                                   359 
410     sQ = next();                                  360     sQ = next();
411     if (!(sQ.empty()))                         << 361     if (!(sQ.isNull()))
412     {                                             362     {
413       fIonExciteEnergy = StoD(sQ) * keV;          363       fIonExciteEnergy = StoD(sQ) * keV;
414                                                   364 
415       sQ = next();                                365       sQ = next();
416       if (sQ.empty()||sQ=="noFloat")           << 366       if (sQ.isNull()||sQ=="noFloat")
417       { fIonFloatingLevelBase = '\0'; }           367       { fIonFloatingLevelBase = '\0'; }
418       else                                        368       else
419       { fIonFloatingLevelBase = sQ[(std::size_ << 369       { fIonFloatingLevelBase = sQ[(size_t)0]; }
420     }                                             370     }
421   }                                               371   }
422   G4ParticleDefinition* ion = G4IonTable::GetI << 372   G4ParticleDefinition* ion = 0;
423     ->GetIon(fAtomicNumber,fAtomicMass,fIonExc << 373   ion =  G4IonTable::GetIonTable()->GetIon( fAtomicNumber, fAtomicMass,
424   if (ion==nullptr)                            << 374                    fIonExciteEnergy, fIonFloatingLevelBase);
425   {                                            << 375   if (ion==0) {
426     G4ExceptionDescription ed;                    376     G4ExceptionDescription ed;
427     ed << "Ion with Z=" << fAtomicNumber;         377     ed << "Ion with Z=" << fAtomicNumber;
428     ed << " A=" << fAtomicMass << "is not defi    378     ed << " A=" << fAtomicMass << "is not defined";    
429     ionCmd->CommandFailed(ed);                    379     ionCmd->CommandFailed(ed);
430   }                                            << 380   } else {
431   else                                         << 
432   {                                            << 
433     fParticleGun->SetParticleDefinition(ion);     381     fParticleGun->SetParticleDefinition(ion);
434     fParticleGun->SetParticleCharge(fIonCharge    382     fParticleGun->SetParticleCharge(fIonCharge*eplus);
435   }                                               383   }
436 }                                                 384 }
                                                   >> 385 
437                                                   386