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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/gorad/src/GRPhysicsListMessenger.cc (Version 11.3.0) and /examples/advanced/gorad/src/GRPhysicsListMessenger.cc (Version 6.2)


  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 //  Gorad (Geant4 Open-source Radiation Analys    
 27 //                                                
 28 //  Author : Makoto Asai (SLAC National Accele    
 29 //                                                
 30 //  Development of Gorad is funded by NASA Joh    
 31 //  under the contract NNJ15HK11B.                
 32 //                                                
 33 // *******************************************    
 34 //                                                
 35 // GRPhysicsListMessenger.cc                      
 36 //   A messenger class that handles Gorad phys    
 37 //                                                
 38 // History                                        
 39 //   September 8th, 2020 : first implementatio    
 40 //                                                
 41 // *******************************************    
 42                                                   
 43 #include "GRPhysicsListMessenger.hh"              
 44                                                   
 45 #include "GRPhysicsList.hh"                       
 46 #include "G4UIcommand.hh"                         
 47 #include "G4UIparameter.hh"                       
 48 #include "G4UIdirectory.hh"                       
 49 #include "G4UIcmdWithAString.hh"                  
 50 #include "G4UIcmdWithADoubleAndUnit.hh"           
 51 #include "G4UIcmdWithoutParameter.hh"             
 52                                                   
 53 GRPhysicsListMessenger::GRPhysicsListMessenger    
 54 : pPL(pl)                                         
 55 {                                                 
 56   G4UIparameter* param = nullptr;                 
 57                                                   
 58   physDir = new G4UIdirectory("/gorad/physics/    
 59   physDir->SetGuidance("GORAD physics selectio    
 60                                                   
 61   selectEMCmd = new G4UIcmdWithAString("/gorad    
 62   selectEMCmd->AvailableForStates(G4State_PreI    
 63   selectEMCmd->SetToBeBroadcasted(false);         
 64   selectEMCmd->SetParameterName("EM_option",tr    
 65   selectEMCmd->SetCandidates("Op_0 Op_1 Op_3 O    
 66   selectEMCmd->SetDefaultValue("Op_0");           
 67   selectEMCmd->SetGuidance("Select EM Physics     
 68   selectEMCmd->SetGuidance(" Op_0 (default) :     
 69   selectEMCmd->SetGuidance(" Op_1 : Faster tha    
 70   selectEMCmd->SetGuidance(" Op_3 : Suitable f    
 71   selectEMCmd->SetGuidance(" Op_4 : Most accur    
 72   selectEMCmd->SetGuidance(" LIV  : Livermore     
 73   selectEMCmd->SetGuidance(" LIV_Pol : Polariz    
 74                                                   
 75   selectHadCmd = new G4UIcmdWithAString("/gora    
 76   selectHadCmd->AvailableForStates(G4State_Pre    
 77   selectHadCmd->SetToBeBroadcasted(false);        
 78   selectHadCmd->SetParameterName("Had_option",    
 79   selectHadCmd->SetCandidates("FTFP_BERT QGSP_    
 80   selectHadCmd->SetDefaultValue("FTFP_BERT");     
 81   selectHadCmd->SetGuidance("Select Hadronic P    
 82   selectHadCmd->SetGuidance(" FTFP_BERT (defau    
 83   selectHadCmd->SetGuidance("                     
 84   selectHadCmd->SetGuidance(" QGSP_BIC : Quark    
 85   selectHadCmd->SetGuidance("            suita    
 86   selectHadCmd->SetGuidance(" Shielding : Simi    
 87   selectHadCmd->SetGuidance("             High    
 88                                                   
 89   addHPCmd = new G4UIcmdWithoutParameter("/gor    
 90   addHPCmd->AvailableForStates(G4State_PreInit    
 91   addHPCmd->SetToBeBroadcasted(false);            
 92   addHPCmd->SetGuidance("Add High-Precision ne    
 93   addHPCmd->SetGuidance(" Note: Shielding opti    
 94                                                   
 95   addRDMCmd = new G4UIcmdWithoutParameter("/go    
 96   addRDMCmd->AvailableForStates(G4State_PreIni    
 97   addRDMCmd->SetToBeBroadcasted(false);           
 98   addRDMCmd->SetGuidance("Add Radioactive Deca    
 99   addRDMCmd->SetGuidance(" Note: Shielding opt    
100                                                   
101   addRMCCmd = new G4UIcmdWithoutParameter("/go    
102   addRMCCmd->AvailableForStates(G4State_PreIni    
103   addRMCCmd->SetToBeBroadcasted(false);           
104   addRMCCmd->SetGuidance("Add Reverse Monte Ca    
105                                                   
106   addOpticalCmd = new G4UIcmdWithoutParameter(    
107   addOpticalCmd->AvailableForStates(G4State_Pr    
108   addOpticalCmd->SetToBeBroadcasted(false);       
109   addOpticalCmd->SetGuidance("Add Optical phys    
110                                                   
111   addStepLimitCmd = new G4UIcmdWithAString("/g    
112   addStepLimitCmd->AvailableForStates(G4State_    
113   addStepLimitCmd->SetToBeBroadcasted(false);     
114   addStepLimitCmd->SetGuidance("Add step-limit    
115   addStepLimitCmd->SetGuidance("Specify partic    
116   addStepLimitCmd->SetGuidance("  charged (def    
117   addStepLimitCmd->SetGuidance("  neutral : ap    
118   addStepLimitCmd->SetGuidance("  all : applie    
119   addStepLimitCmd->SetGuidance("  e+/- : appli    
120   addStepLimitCmd->SetGuidance(" Note: In addi    
121   addStepLimitCmd->SetGuidance("       /gorad/    
122   addStepLimitCmd->SetParameterName("particle"    
123   addStepLimitCmd->SetDefaultValue("charged");    
124   addStepLimitCmd->SetCandidates("charged neut    
125                                                   
126   physLimitDir = new G4UIdirectory("/gorad/phy    
127   physLimitDir->SetGuidance("Specify step limi    
128                                                   
129   setStepLimitCmd = new G4UIcmdWithADoubleAndU    
130   setStepLimitCmd->AvailableForStates(G4State_    
131   setStepLimitCmd->SetToBeBroadcasted(false);     
132   setStepLimitCmd->SetParameterName("length",f    
133   setStepLimitCmd->SetDefaultUnit("mm");          
134   setStepLimitCmd->SetGuidance("Define the lim    
135   setStepLimitCmd->SetGuidance("This limitatio    
136                                                   
137   setRegionStepLimitCmd = new G4UIcommand("/go    
138   setRegionStepLimitCmd->AvailableForStates(G4    
139   setRegionStepLimitCmd->SetToBeBroadcasted(fa    
140   setRegionStepLimitCmd->SetGuidance("Define t    
141   setRegionStepLimitCmd->SetGuidance("   [usag    
142   setRegionStepLimitCmd->SetGuidance("      re    
143   setRegionStepLimitCmd->SetGuidance(" Note: R    
144   setRegionStepLimitCmd->SetGuidance("       I    
145   param = new G4UIparameter("region",'s',false    
146   setRegionStepLimitCmd->SetParameter(param);     
147   param = new G4UIparameter("length",'d',false    
148   setRegionStepLimitCmd->SetParameter(param);     
149   param = new G4UIparameter("unit",'s',true);     
150   param->SetDefaultUnit("mm");                    
151   setRegionStepLimitCmd->SetParameter(param);     
152                                                   
153   physCutDir = new G4UIdirectory("/gorad/physi    
154   physCutDir->SetGuidance("Specify production     
155                                                   
156   setCutCmd = new G4UIcmdWithADoubleAndUnit("/    
157   setCutCmd->AvailableForStates(G4State_PreIni    
158   setCutCmd->SetToBeBroadcasted(false);           
159   setCutCmd->SetParameterName("length",false);    
160   setCutCmd->SetDefaultUnit("mm");                
161   setCutCmd->SetGuidance("Specify production t    
162   setCutCmd->SetGuidance("This threshold is ap    
163   setCutCmd->SetGuidance("Threshold of each pa    
164                                                   
165   setCutParticleCmd = new G4UIcommand("/gorad/    
166   setCutParticleCmd->AvailableForStates(G4Stat    
167   setCutParticleCmd->SetToBeBroadcasted(false)    
168   setCutParticleCmd->SetGuidance("Specify prod    
169   setCutParticleCmd->SetGuidance("  [usage] /g    
170   param = new G4UIparameter("particle",'s',fal    
171   param->SetParameterCandidates("e- e+ gamma p    
172   setCutParticleCmd->SetParameter(param);         
173   param = new G4UIparameter("cut",'d',false);     
174   setCutParticleCmd->SetParameter(param);         
175   param = new G4UIparameter("unit",'s',true);     
176   param->SetDefaultUnit("mm");                    
177   setCutParticleCmd->SetParameter(param);         
178                                                   
179   setCutRegionCmd = new G4UIcommand("/gorad/ph    
180   setCutRegionCmd->AvailableForStates(G4State_    
181   setCutRegionCmd->SetToBeBroadcasted(false);     
182   setCutRegionCmd->SetGuidance("Specify produc    
183   setCutRegionCmd->SetGuidance("  [usage] /gor    
184   setCutRegionCmd->SetGuidance("This threshold    
185   setCutRegionCmd->SetGuidance("Threshold of e    
186   setCutRegionCmd->SetGuidance(" Note: Region     
187   setCutRegionCmd->SetGuidance("       If new     
188   param = new G4UIparameter("region",'s',false    
189   setCutRegionCmd->SetParameter(param);           
190   param = new G4UIparameter("cut",'d',false);     
191   setCutRegionCmd->SetParameter(param);           
192   param = new G4UIparameter("unit",'s',true);     
193   param->SetDefaultUnit("mm");                    
194   setCutRegionCmd->SetParameter(param);           
195                                                   
196   setCutRegionParticleCmd = new G4UIcommand("/    
197   setCutRegionParticleCmd->AvailableForStates(    
198   setCutRegionParticleCmd->SetToBeBroadcasted(    
199   setCutRegionParticleCmd->SetGuidance("Specif    
200   setCutRegionParticleCmd->SetGuidance("  [usa    
201   setCutRegionParticleCmd->SetGuidance(" Note:    
202   setCutRegionParticleCmd->SetGuidance("          
203   param = new G4UIparameter("region",'s',false    
204   setCutRegionParticleCmd->SetParameter(param)    
205   param = new G4UIparameter("particle",'s',fal    
206   param->SetParameterCandidates("e- e+ gamma p    
207   setCutRegionParticleCmd->SetParameter(param)    
208   param = new G4UIparameter("cut",'d',false);     
209   setCutRegionParticleCmd->SetParameter(param)    
210   param = new G4UIparameter("unit",'s',true);     
211   param->SetDefaultUnit("mm");                    
212   setCutRegionParticleCmd->SetParameter(param)    
213                                                   
214 }                                                 
215                                                   
216 GRPhysicsListMessenger::~GRPhysicsListMessenge    
217 {                                                 
218   delete selectEMCmd;                             
219   delete selectHadCmd;                            
220   delete addHPCmd;                                
221   delete addRDMCmd;                               
222   delete addRMCCmd;                               
223   delete addOpticalCmd;                           
224   delete addStepLimitCmd;                         
225   delete setStepLimitCmd;                         
226   delete setRegionStepLimitCmd;                   
227   delete setCutCmd;                               
228   delete setCutParticleCmd;                       
229   delete setCutRegionCmd;                         
230   delete setCutRegionParticleCmd;                 
231                                                   
232   delete physLimitDir;                            
233   delete physCutDir;                              
234   delete physDir;                                 
235 }                                                 
236                                                   
237 #include "G4Tokenizer.hh"                         
238                                                   
239 void GRPhysicsListMessenger::SetNewValue(G4UIc    
240 {                                                 
241   if(cmd==selectEMCmd)                            
242   { pPL->SetEM(val); }                            
243   else if(cmd==selectHadCmd)                      
244   { pPL->SetHad(val); }                           
245   else if(cmd==addHPCmd)                          
246   { pPL->AddHP(); }                               
247   else if(cmd==addRDMCmd)                         
248   { pPL->AddRDM(); }                              
249   else if(cmd==addRMCCmd)                         
250   { pPL->AddRMC(); }                              
251   else if(cmd==addOpticalCmd)                     
252   { G4cout<<"Not yet implemented."<<G4endl; }     
253   else if(cmd==addStepLimitCmd)                   
254   {                                               
255     G4int opt = 0;                                
256     if(val=="neutral") opt = 1;                   
257     else if(val=="all") opt = 2;                  
258     else if(val=="e+/-") opt = 3;                 
259     pPL->AddStepLimit(opt);                       
260   }                                               
261   else if(cmd==setStepLimitCmd)                   
262   { pPL->SetGlobalStepLimit(setStepLimitCmd->G    
263   else if(cmd==setRegionStepLimitCmd)             
264   {                                               
265     G4Tokenizer next(val);                        
266     G4String reg = next();                        
267     G4String newVal = next();                     
268     newVal += " ";                                
269     newVal += next();                             
270     auto regPtr = pPL->SetLocalStepLimit(reg,s    
271     if(!regPtr)                                   
272     {                                             
273       G4ExceptionDescription ed;                  
274       ed << "Region <" << reg << "> is not def    
275          << "\nIf new region is necessary, use    
276       setRegionStepLimitCmd->CommandFailed(ed)    
277     }                                             
278   }                                               
279   else if(cmd==setCutCmd)                         
280   { pPL->SetGlobalCuts(setCutCmd->GetNewDouble    
281   else if(cmd==setCutParticleCmd)                 
282   {                                               
283     G4Tokenizer next(val);                        
284     G4String pat = next();                        
285     G4String newVal = next();                     
286     newVal += " ";                                
287     newVal += next();                             
288     G4int i = 0;                                  
289     if(pat=="e-") i = 0;                          
290     else if(pat=="e+") i = 1;                     
291     else if(pat=="gamma") i = 2;                  
292     else if(pat=="proton") i = 3;                 
293     pPL->SetGlobalCut(i,setCutParticleCmd->Con    
294   }                                               
295   else if(cmd==setCutRegionCmd)                   
296   {                                               
297     G4Tokenizer next(val);                        
298     G4String reg = next();                        
299     G4String newVal = next();                     
300     newVal += " ";                                
301     newVal += next();                             
302     auto regPtr = pPL->SetLocalCuts(reg,setCut    
303     if(!regPtr)                                   
304     {                                             
305       G4ExceptionDescription ed;                  
306       ed << "Region <" << reg << "> is not def    
307          << "\nIf new region is necessary, use    
308       setRegionStepLimitCmd->CommandFailed(ed)    
309     }                                             
310   }                                               
311   else if(cmd==setCutRegionParticleCmd)           
312   {                                               
313     G4Tokenizer next(val);                        
314     G4String reg = next();                        
315     G4String pat = next();                        
316     G4int i = 0;                                  
317     if(pat=="e-") i = 0;                          
318     else if(pat=="e+") i = 1;                     
319     else if(pat=="gamma") i = 2;                  
320     else if(pat=="proton") i = 3;                 
321     G4String newVal = next();                     
322     newVal += " ";                                
323     newVal += next();                             
324     auto regPtr = pPL->SetLocalCut(reg,i,setCu    
325     if(!regPtr)                                   
326     {                                             
327       G4ExceptionDescription ed;                  
328       ed << "Region <" << reg << "> is not def    
329          << "\nIf new region is necessary, use    
330       setRegionStepLimitCmd->CommandFailed(ed)    
331     }                                             
332   }                                               
333                                                   
334 }                                                 
335                                                   
336 G4String GRPhysicsListMessenger::GetCurrentVal    
337 {                                                 
338   G4String val("");                               
339                                                   
340   if(cmd==selectEMCmd)                            
341   { val = pPL->GetEM(); }                         
342   else if(cmd==selectHadCmd)                      
343   { val = pPL->GetHad(); }                        
344   else if(cmd==addHPCmd)                          
345   { val = cmd->ConvertToString(pPL->IfHP()); }    
346   else if(cmd==addRDMCmd)                         
347   { val = cmd->ConvertToString(pPL->IfRDM());     
348   else if(cmd==addRMCCmd)                         
349   { val = cmd->ConvertToString(pPL->IfRMC());     
350   else if(cmd==addOpticalCmd)                     
351   { G4cout<<"Not yet implemented."<<G4endl; }     
352   else if(cmd==addStepLimitCmd)                   
353   {                                               
354     auto opt = pPL->IfStepLimit();                
355     switch(opt)                                   
356     {                                             
357       case 0: val =  "charged"; break;            
358       case 1: val =  "neutral"; break;            
359       case 2: val =  "all"; break;                
360       case 3: val =  "e+/-"; break;               
361       default : val = "undefined"; break;         
362     }                                             
363   }                                               
364   return val;                                     
365 }                                                 
366                                                   
367                                                   
368