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] [ 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 /examples/advanced/underground_physics/src/DMXParticleSourceMessenger.cc (Version 11.3.0) and /examples/advanced/underground_physics/src/DMXParticleSourceMessenger.cc (Version 5.0)


  1 //                                                  1 
  2 // *******************************************    
  3 // * License and Disclaimer                       
  4 // *                                              
  5 // * The  Geant4 software  is  copyright of th    
  6 // * the Geant4 Collaboration.  It is provided    
  7 // * conditions of the Geant4 Software License    
  8 // * LICENSE and available at  http://cern.ch/    
  9 // * include a list of copyright holders.         
 10 // *                                              
 11 // * Neither the authors of this software syst    
 12 // * institutes,nor the agencies providing fin    
 13 // * work  make  any representation or  warran    
 14 // * regarding  this  software system or assum    
 15 // * use.  Please see the license in the file     
 16 // * for the full disclaimer and the limitatio    
 17 // *                                              
 18 // * This  code  implementation is the result     
 19 // * technical work of the GEANT4 collaboratio    
 20 // * By using,  copying,  modifying or  distri    
 21 // * any work based  on the software)  you  ag    
 22 // * use  in  resulting  scientific  publicati    
 23 // * acceptance of all terms of the Geant4 Sof    
 24 // *******************************************    
 25 //                                                
 26 //                                                
 27 // -------------------------------------------    
 28 //   GEANT 4 - Underground Dark Matter Detecto    
 29 //                                                
 30 //      For information related to this code c    
 31 //      e-mail: alexander.howard@cern.ch          
 32 // -------------------------------------------    
 33 // Comments                                       
 34 //                                                
 35 //                  Underground Advanced          
 36 //               by A. Howard and H. Araujo       
 37 //                    (27th November 2001)        
 38 //                                                
 39 // ParticleSourceMessenger program                
 40 // -------------------------------------------    
 41 //////////////////////////////////////////////    
 42 // This particle source is a shortened version    
 43 // C Ferguson, F Lei & P Truscott (University     
 44 // some minor modifications.                      
 45 //////////////////////////////////////////////    
 46                                                   
 47 #include <fstream>                                
 48 #include <iomanip>                                
 49                                                   
 50 #include "DMXParticleSourceMessenger.hh"          
 51 #include "DMXParticleSource.hh"                   
 52                                                   
 53 #include "G4SystemOfUnits.hh"                     
 54 #include "G4Geantino.hh"                          
 55 #include "G4ThreeVector.hh"                       
 56 #include "G4ParticleTable.hh"                     
 57 #include "G4IonTable.hh"                          
 58 #include "G4UIdirectory.hh"                       
 59 #include "G4UIcmdWithoutParameter.hh"             
 60 #include "G4UIcmdWithAString.hh"                  
 61 #include "G4UIcmdWithADoubleAndUnit.hh"           
 62 #include "G4UIcmdWith3Vector.hh"                  
 63 #include "G4UIcmdWith3VectorAndUnit.hh"           
 64 #include "G4UIcmdWithAnInteger.hh"                
 65 #include "G4UIcmdWithADouble.hh"                  
 66 #include "G4UIcmdWithABool.hh"                    
 67 #include "G4ios.hh"                               
 68 #include "G4Tokenizer.hh"                         
 69                                                   
 70 //////////////////////////////////////////////    
 71 DMXParticleSourceMessenger::DMXParticleSourceM    
 72 (DMXParticleSource *fPtclGun) : fParticleGun(f    
 73                                                   
 74   particleTable = G4ParticleTable::GetParticle    
 75                                                   
 76   // create directory                             
 77   gunDirectory = new G4UIdirectory("/dmx/gun/"    
 78   gunDirectory->SetGuidance("Particle Source c    
 79                                                   
 80   // list available particles                     
 81   listCmd = new G4UIcmdWithoutParameter("/dmx/    
 82   listCmd->SetGuidance("List available particl    
 83   listCmd->SetGuidance(" Invoke G4ParticleTabl    
 84                                                   
 85   // set particle                                 
 86   particleCmd = new G4UIcmdWithAString("/dmx/g    
 87   particleCmd->SetGuidance("Set particle to be    
 88   particleCmd->SetGuidance(" (geantino is defa    
 89   particleCmd->SetGuidance(" (ion can be speci    
 90   particleCmd->SetParameterName("particleName"    
 91   particleCmd->SetDefaultValue("geantino");       
 92   G4String candidateList;                         
 93   G4int nPtcl = particleTable->entries();         
 94   for(G4int i=0;i<nPtcl;i++)                      
 95     {                                             
 96       candidateList += particleTable->GetParti    
 97       candidateList += " ";                       
 98     }                                             
 99   candidateList += "ion ";                        
100   particleCmd->SetCandidates(candidateList);      
101                                                   
102                                                   
103   // particle direction                           
104   directionCmd = new G4UIcmdWith3Vector("/dmx/    
105   directionCmd->SetGuidance("Set momentum dire    
106   directionCmd->SetGuidance("Direction needs n    
107   directionCmd->SetParameterName("Px","Py","Pz    
108   directionCmd->SetRange("Px != 0 || Py != 0 |    
109                                                   
110   // particle energy                              
111   energyCmd = new G4UIcmdWithADoubleAndUnit("/    
112   energyCmd->SetGuidance("Set kinetic energy."    
113   energyCmd->SetParameterName("Energy",true,tr    
114   energyCmd->SetDefaultUnit("GeV");               
115   //energyCmd->SetUnitCategory("Energy");         
116   //energyCmd->SetUnitCandidates("eV keV MeV G    
117                                                   
118   positionCmd = new G4UIcmdWith3VectorAndUnit(    
119   positionCmd->SetGuidance("Set starting posit    
120   positionCmd->SetParameterName("X","Y","Z",tr    
121   positionCmd->SetDefaultUnit("cm");              
122   //positionCmd->SetUnitCategory("Length");       
123   //positionCmd->SetUnitCandidates("microm mm     
124                                                   
125                                                   
126   // ion                                          
127   ionCmd = new G4UIcommand("/dmx/gun/ion",this    
128   ionCmd->SetGuidance("Set properties of ion t    
129   ionCmd->SetGuidance("[usage] /gun/ion Z A Q     
130   ionCmd->SetGuidance("        Z:(int) AtomicN    
131   ionCmd->SetGuidance("        A:(int) AtomicM    
132   ionCmd->SetGuidance("        Q:(int) Charge     
133   ionCmd->SetGuidance("        E:(double) Exci    
134                                                   
135   G4UIparameter* param;                           
136   param = new G4UIparameter("Z",'i',false);       
137   param->SetDefaultValue("1");                    
138   ionCmd->SetParameter(param);                    
139   param = new G4UIparameter("A",'i',false);       
140   param->SetDefaultValue("1");                    
141   ionCmd->SetParameter(param);                    
142   param = new G4UIparameter("Q",'i',true);        
143   param->SetDefaultValue("0");                    
144   ionCmd->SetParameter(param);                    
145   param = new G4UIparameter("E",'d',true);        
146   param->SetDefaultValue("0.0");                  
147   ionCmd->SetParameter(param);                    
148                                                   
149                                                   
150   // source distribution type                     
151   typeCmd = new G4UIcmdWithAString("/dmx/gun/t    
152   typeCmd->SetGuidance("Sets source distributi    
153   typeCmd->SetGuidance("Either Point or Volume    
154   typeCmd->SetParameterName("DisType",true,tru    
155   typeCmd->SetDefaultValue("Point");              
156   typeCmd->SetCandidates("Point Volume");         
157                                                   
158   // source shape                                 
159   shapeCmd = new G4UIcmdWithAString("/dmx/gun/    
160   shapeCmd->SetGuidance("Sets source shape typ    
161   shapeCmd->SetParameterName("Shape",true,true    
162   shapeCmd->SetDefaultValue("NULL");              
163   shapeCmd->SetCandidates("Sphere Cylinder");     
164                                                   
165   // centre coordinates                           
166   centreCmd = new G4UIcmdWith3VectorAndUnit("/    
167   centreCmd->SetGuidance("Set centre coordinat    
168   centreCmd->SetParameterName("X","Y","Z",true    
169   centreCmd->SetDefaultUnit("cm");                
170   centreCmd->SetUnitCandidates("nm um mm cm m     
171                                                   
172   // half height of source                        
173   halfzCmd = new G4UIcmdWithADoubleAndUnit("/d    
174   halfzCmd->SetGuidance("Set z half length of     
175   halfzCmd->SetParameterName("Halfz",true,true    
176   halfzCmd->SetDefaultUnit("cm");                 
177   halfzCmd->SetUnitCandidates("nm um mm cm m k    
178                                                   
179   // radius of source                             
180   radiusCmd = new G4UIcmdWithADoubleAndUnit("/    
181   radiusCmd->SetGuidance("Set radius of source    
182   radiusCmd->SetParameterName("Radius",true,tr    
183   radiusCmd->SetDefaultUnit("cm");                
184   radiusCmd->SetUnitCandidates("nm um mm cm m     
185                                                   
186   // confine to volume                            
187   confineCmd = new G4UIcmdWithAString("/dmx/gu    
188   confineCmd->SetGuidance("Confine source to v    
189   confineCmd->SetGuidance("usage: confine VolN    
190   confineCmd->SetParameterName("VolName",true,    
191   confineCmd->SetDefaultValue("NULL");            
192                                                   
193   // angular distribution                         
194   angtypeCmd = new G4UIcmdWithAString("/dmx/gu    
195   angtypeCmd->SetGuidance("Sets angular source    
196   angtypeCmd->SetGuidance("Possible variables     
197   angtypeCmd->SetParameterName("AngDis",true,t    
198   angtypeCmd->SetDefaultValue("iso");             
199   angtypeCmd->SetCandidates("iso direction");     
200                                                   
201   // energy distribution                          
202   energytypeCmd = new G4UIcmdWithAString("/dmx    
203   energytypeCmd->SetGuidance("Sets energy dist    
204   energytypeCmd->SetGuidance("Possible variabl    
205   energytypeCmd->SetParameterName("EnergyDis",    
206   energytypeCmd->SetDefaultValue("Mono");         
207   energytypeCmd->SetCandidates("Mono");           
208                                                   
209   // verbosity                                    
210   verbosityCmd = new G4UIcmdWithAnInteger("/dm    
211   verbosityCmd->SetGuidance("Set Verbose level    
212   verbosityCmd->SetGuidance(" 0 : Silent");       
213   verbosityCmd->SetGuidance(" 1 : Limited info    
214   verbosityCmd->SetGuidance(" 2 : Detailed inf    
215   verbosityCmd->SetParameterName("level",false    
216   verbosityCmd->SetRange("level>=0 && level <=    
217                                                   
218 }                                                 
219                                                   
220                                                   
221 DMXParticleSourceMessenger::~DMXParticleSource    
222                                                   
223   delete typeCmd;                                 
224   delete shapeCmd;                                
225   delete centreCmd;                               
226   delete halfzCmd;                                
227   delete radiusCmd;                               
228   delete confineCmd;                              
229   delete angtypeCmd;                              
230   delete energytypeCmd;                           
231   delete verbosityCmd;                            
232   delete ionCmd;                                  
233   delete particleCmd;                             
234   delete positionCmd;                             
235   delete directionCmd;                            
236   delete energyCmd;                               
237   delete listCmd;                                 
238                                                   
239   delete gunDirectory;                            
240 }                                                 
241                                                   
242 void DMXParticleSourceMessenger::SetNewValue      
243    (G4UIcommand *command, G4String newValues)     
244                                                   
245   if(command == typeCmd)                          
246     fParticleGun->SetPosDisType(newValues);       
247                                                   
248   else if(command == shapeCmd)                    
249     fParticleGun->SetPosDisShape(newValues);      
250                                                   
251   else if(command == centreCmd)                   
252     fParticleGun->SetCentreCoords(centreCmd->G    
253                                                   
254   else if(command == halfzCmd)                    
255     fParticleGun->SetHalfZ(halfzCmd->GetNewDou    
256                                                   
257   else if(command == radiusCmd)                   
258     fParticleGun->SetRadius(radiusCmd->GetNewD    
259                                                   
260   else if(command == angtypeCmd)                  
261       fParticleGun->SetAngDistType(newValues);    
262                                                   
263   else if(command == confineCmd)                  
264     fParticleGun->ConfineSourceToVolume(newVal    
265                                                   
266   else if(command == energytypeCmd)               
267     fParticleGun->SetEnergyDisType(newValues);    
268                                                   
269   else if(command == verbosityCmd)                
270     fParticleGun->SetVerbosity(verbosityCmd->G    
271                                                   
272   else if( command==particleCmd ) {               
273     if (newValues =="ion") {                      
274       fShootIon = true;                           
275     } else {                                      
276       fShootIon = false;                          
277       G4ParticleDefinition* pd = particleTable    
278       if(pd != NULL)                              
279     { fParticleGun->SetParticleDefinition( pd     
280     }                                             
281   }                                               
282                                                   
283   else if( command==ionCmd ) {                    
284     if (fShootIon) {                              
285       G4Tokenizer next( newValues );              
286       // check argument                           
287       fAtomicNumber = StoI(next());               
288       fAtomicMass = StoI(next());                 
289       G4String sQ = next();                       
290       if (sQ.empty()) {                           
291   fIonCharge = fAtomicNumber;                     
292       } else {                                    
293   fIonCharge = StoI(sQ);                          
294   sQ = next();                                    
295   if (sQ.empty()) {                               
296     fIonExciteEnergy = 0.0;                       
297   } else {                                        
298     fIonExciteEnergy = StoD(sQ) * keV;            
299   }                                               
300       }                                           
301                                                   
302       G4ParticleDefinition* ion;                  
303       ion =  G4IonTable::GetIonTable()->GetIon    
304       if (ion==0) {                               
305   G4cout << "Ion with Z=" << fAtomicNumber;       
306   G4cout << " A=" << fAtomicMass << "is not be    
307       } else {                                    
308   fParticleGun->SetParticleDefinition(ion);       
309   fParticleGun->SetParticleCharge(fIonCharge*e    
310       }                                           
311     } else {                                      
312       G4cout<<"Set /dmx/gun/particle to ion be    
313       G4cout<<G4endl;                             
314     }                                             
315   }                                               
316                                                   
317   else if( command==listCmd )                     
318     particleTable->DumpTable();                   
319                                                   
320   else if( command==directionCmd ) {              
321     fParticleGun->SetAngDistType("direction");    
322     fParticleGun->SetParticleMomentumDirection    
323       (directionCmd->GetNew3VectorValue(newVal    
324   }                                               
325                                                   
326   else if( command==energyCmd ) {                 
327     fParticleGun->SetEnergyDisType("Mono");       
328     fParticleGun->SetMonoEnergy(energyCmd->Get    
329   }                                               
330                                                   
331   else if( command==positionCmd ) {               
332     fParticleGun->SetPosDisType("Point");         
333     fParticleGun->SetCentreCoords(positionCmd-    
334   }                                               
335   else                                            
336     G4cout << "Error entering command" << G4en    
337 }                                                 
338                                                   
339                                                   
340                                                   
341                                                   
342