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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 ]

  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 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
 27 //
 28 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
 29 //
 30 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
 31 //  under the contract NNJ15HK11B.
 32 //
 33 // ********************************************************************
 34 //
 35 // GRPhysicsListMessenger.cc
 36 //   A messenger class that handles Gorad physics list options.
 37 //
 38 // History
 39 //   September 8th, 2020 : first implementation
 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(GRPhysicsList* pl)
 54 : pPL(pl)
 55 {
 56   G4UIparameter* param = nullptr;
 57 
 58   physDir = new G4UIdirectory("/gorad/physics/");
 59   physDir->SetGuidance("GORAD physics selection");
 60 
 61   selectEMCmd = new G4UIcmdWithAString("/gorad/physics/EM",this);
 62   selectEMCmd->AvailableForStates(G4State_PreInit);
 63   selectEMCmd->SetToBeBroadcasted(false);
 64   selectEMCmd->SetParameterName("EM_option",true);
 65   selectEMCmd->SetCandidates("Op_0 Op_1 Op_3 Op_4 LIV LIV_Pol");
 66   selectEMCmd->SetDefaultValue("Op_0");
 67   selectEMCmd->SetGuidance("Select EM Physics option");
 68   selectEMCmd->SetGuidance(" Op_0 (default) : Suitable to medium and high energy applications");
 69   selectEMCmd->SetGuidance(" Op_1 : Faster than Op_0 because of less accurate MSC step limitation");
 70   selectEMCmd->SetGuidance(" Op_3 : Suitable for medical applications - more accurate MSC for all particles");
 71   selectEMCmd->SetGuidance(" Op_4 : Most accurate (GS MSC model with Mott correction and error-free stepping for e+/-");
 72   selectEMCmd->SetGuidance(" LIV  : Livermore models for e-/gamma below 1 GeV, otherwise Op_0");
 73   selectEMCmd->SetGuidance(" LIV_Pol : Polarized extension of Livermore models (t.b.a.)");
 74 
 75   selectHadCmd = new G4UIcmdWithAString("/gorad/physics/Hadronic",this);
 76   selectHadCmd->AvailableForStates(G4State_PreInit);
 77   selectHadCmd->SetToBeBroadcasted(false);
 78   selectHadCmd->SetParameterName("Had_option",true);
 79   selectHadCmd->SetCandidates("FTFP_BERT QGSP_BIC Shielding");
 80   selectHadCmd->SetDefaultValue("FTFP_BERT");
 81   selectHadCmd->SetGuidance("Select Hadronic Physics option");
 82   selectHadCmd->SetGuidance(" FTFP_BERT (default) : Fritiof string + Bertini cascade + Precompound de-excitation");
 83   selectHadCmd->SetGuidance("                       suitable to most of midium and high energy applications");
 84   selectHadCmd->SetGuidance(" QGSP_BIC : Quark-Gluon-String + Fritiof string + Binary cascade + Precompound de-excitation");
 85   selectHadCmd->SetGuidance("            suitable for lower energy applications such as medical");
 86   selectHadCmd->SetGuidance(" Shielding : Similar to FTFP+BERT with better ion-ion interactions.");
 87   selectHadCmd->SetGuidance("             High-Precision neutron and Radioactive Decay models are included by default.");
 88 
 89   addHPCmd = new G4UIcmdWithoutParameter("/gorad/physics/addHP",this);
 90   addHPCmd->AvailableForStates(G4State_PreInit);
 91   addHPCmd->SetToBeBroadcasted(false);
 92   addHPCmd->SetGuidance("Add High-Precision neutron model.");
 93   addHPCmd->SetGuidance(" Note: Shielding option has already had HP. This command does not make effect to Shielding option.");
 94 
 95   addRDMCmd = new G4UIcmdWithoutParameter("/gorad/physics/addRDM",this);
 96   addRDMCmd->AvailableForStates(G4State_PreInit);
 97   addRDMCmd->SetToBeBroadcasted(false);
 98   addRDMCmd->SetGuidance("Add Radioactive Decay model.");
 99   addRDMCmd->SetGuidance(" Note: Shielding option has already had RDM. This command does not make effect to Shielding option.");
100 
101   addRMCCmd = new G4UIcmdWithoutParameter("/gorad/physics/addRMC",this);
102   addRMCCmd->AvailableForStates(G4State_PreInit);
103   addRMCCmd->SetToBeBroadcasted(false);
104   addRMCCmd->SetGuidance("Add Reverse Monte Carlo.");
105 
106   addOpticalCmd = new G4UIcmdWithoutParameter("/gorad/physics/addOptical",this);
107   addOpticalCmd->AvailableForStates(G4State_PreInit);
108   addOpticalCmd->SetToBeBroadcasted(false);
109   addOpticalCmd->SetGuidance("Add Optical physics");
110 
111   addStepLimitCmd = new G4UIcmdWithAString("/gorad/physics/addStepLimit",this);
112   addStepLimitCmd->AvailableForStates(G4State_PreInit);
113   addStepLimitCmd->SetToBeBroadcasted(false);
114   addStepLimitCmd->SetGuidance("Add step-limiter process to artificially limit step length.");
115   addStepLimitCmd->SetGuidance("Specify particle types to be applied.");
116   addStepLimitCmd->SetGuidance("  charged (default) : applied only to the charged particles");
117   addStepLimitCmd->SetGuidance("  neutral : applied only to the neutral particles");
118   addStepLimitCmd->SetGuidance("  all : applied to all particle types");
119   addStepLimitCmd->SetGuidance("  e+/- : applied only to e+/e-");
120   addStepLimitCmd->SetGuidance(" Note: In addition to this command, you need to specify the limitation value by");
121   addStepLimitCmd->SetGuidance("       /gorad/physics/limit/stepLimit or /gorad/physics/limit/localStepLimt command.");
122   addStepLimitCmd->SetParameterName("particle",true);
123   addStepLimitCmd->SetDefaultValue("charged");
124   addStepLimitCmd->SetCandidates("charged neutral all e+/-");
125 
126   physLimitDir = new G4UIdirectory("/gorad/physics/limit/");
127   physLimitDir->SetGuidance("Specify step limitation");
128 
129   setStepLimitCmd = new G4UIcmdWithADoubleAndUnit("/gorad/physics/limit/stepLimit",this);
130   setStepLimitCmd->AvailableForStates(G4State_Idle);
131   setStepLimitCmd->SetToBeBroadcasted(false);
132   setStepLimitCmd->SetParameterName("length",false);
133   setStepLimitCmd->SetDefaultUnit("mm");
134   setStepLimitCmd->SetGuidance("Define the limitation of the step length");
135   setStepLimitCmd->SetGuidance("This limitation is applied to the entire geometry except regions that has its dedicated limit.");
136 
137   setRegionStepLimitCmd = new G4UIcommand("/gorad/physics/limit/regionStepLimit",this);
138   setRegionStepLimitCmd->AvailableForStates(G4State_Idle);
139   setRegionStepLimitCmd->SetToBeBroadcasted(false);
140   setRegionStepLimitCmd->SetGuidance("Define the limitation of the step length for the specified region");
141   setRegionStepLimitCmd->SetGuidance("   [usage] /gorad/physics/limit/regionStepLimit region length [unit]");
142   setRegionStepLimitCmd->SetGuidance("      region (string) : region name");
143   setRegionStepLimitCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
144   setRegionStepLimitCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
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/physics/cuts/");
154   physCutDir->SetGuidance("Specify production thresholds (a.k.a. cuts)");
155 
156   setCutCmd = new G4UIcmdWithADoubleAndUnit("/gorad/physics/cuts/setCuts",this);
157   setCutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
158   setCutCmd->SetToBeBroadcasted(false);
159   setCutCmd->SetParameterName("length",false);
160   setCutCmd->SetDefaultUnit("mm");
161   setCutCmd->SetGuidance("Specify production thresholds (a.k.a. cuts) that is applied to the entire geometry");
162   setCutCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
163   setCutCmd->SetGuidance("Threshold of each particle can be overwitted by /gorad/physics/cuts/setParticleCut command");
164 
165   setCutParticleCmd = new G4UIcommand("/gorad/physics/cuts/setParticleCut",this);
166   setCutParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
167   setCutParticleCmd->SetToBeBroadcasted(false);
168   setCutParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) for the specified particle that is applied to the entire geometry");
169   setCutParticleCmd->SetGuidance("  [usage] /gorad/physics/setParticleCut particle cut unit");
170   param = new G4UIparameter("particle",'s',false);
171   param->SetParameterCandidates("e- e+ gamma proton");
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/physics/cuts/setRegionCut",this);
180   setCutRegionCmd->AvailableForStates(G4State_Idle);
181   setCutRegionCmd->SetToBeBroadcasted(false);
182   setCutRegionCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
183   setCutRegionCmd->SetGuidance("  [usage] /gorad/physics/setRegionCut region cut unit");
184   setCutRegionCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
185   setCutRegionCmd->SetGuidance("Threshold of each particle can be overwitted by /gorad/physics/cuts/setRegionParticleCut command");
186   setCutRegionCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
187   setCutRegionCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
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("/gorad/physics/cuts/setRegionParticleCut",this);
197   setCutRegionParticleCmd->AvailableForStates(G4State_Idle);
198   setCutRegionParticleCmd->SetToBeBroadcasted(false);
199   setCutRegionParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
200   setCutRegionParticleCmd->SetGuidance("  [usage] /gorad/physics/setRegionParticleCut region particle cut unit");
201   setCutRegionParticleCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
202   setCutRegionParticleCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
203   param = new G4UIparameter("region",'s',false);
204   setCutRegionParticleCmd->SetParameter(param);
205   param = new G4UIparameter("particle",'s',false);
206   param->SetParameterCandidates("e- e+ gamma proton");
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::~GRPhysicsListMessenger()
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(G4UIcommand* cmd, G4String val)
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->GetNewDoubleValue(val)); }
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,setRegionStepLimitCmd->ConvertToDimensionedDouble(newVal));
271     if(!regPtr)
272     {
273       G4ExceptionDescription ed;
274       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
275          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
276       setRegionStepLimitCmd->CommandFailed(ed);
277     }
278   }
279   else if(cmd==setCutCmd)
280   { pPL->SetGlobalCuts(setCutCmd->GetNewDoubleValue(val)); }
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->ConvertToDimensionedDouble(newVal));
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,setCutRegionCmd->ConvertToDimensionedDouble(newVal));
303     if(!regPtr)
304     {
305       G4ExceptionDescription ed;
306       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
307          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
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,setCutRegionParticleCmd->ConvertToDimensionedDouble(newVal));
325     if(!regPtr)
326     {
327       G4ExceptionDescription ed;
328       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
329          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
330       setRegionStepLimitCmd->CommandFailed(ed);
331     }
332   }
333   
334 }
335 
336 G4String GRPhysicsListMessenger::GetCurrentValue(G4UIcommand* cmd)
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