Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-25 09:22:34

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 //  Gorad (Geant4 Open-source Radiation Analysis and Design)
0027 //
0028 //  Author : Makoto Asai (SLAC National Accelerator Laboratory)
0029 //
0030 //  Development of Gorad is funded by NASA Johnson Space Center (JSC)
0031 //  under the contract NNJ15HK11B.
0032 //
0033 // ********************************************************************
0034 //
0035 // GRPhysicsListMessenger.cc
0036 //   A messenger class that handles Gorad physics list options.
0037 //
0038 // History
0039 //   September 8th, 2020 : first implementation
0040 //
0041 // ********************************************************************
0042 
0043 #include "GRPhysicsListMessenger.hh"
0044 
0045 #include "GRPhysicsList.hh"
0046 #include "G4UIcommand.hh"
0047 #include "G4UIparameter.hh"
0048 #include "G4UIdirectory.hh"
0049 #include "G4UIcmdWithAString.hh"
0050 #include "G4UIcmdWithADoubleAndUnit.hh"
0051 #include "G4UIcmdWithoutParameter.hh"
0052 
0053 GRPhysicsListMessenger::GRPhysicsListMessenger(GRPhysicsList* pl)
0054 : pPL(pl)
0055 {
0056   G4UIparameter* param = nullptr;
0057 
0058   physDir = new G4UIdirectory("/gorad/physics/");
0059   physDir->SetGuidance("GORAD physics selection");
0060 
0061   selectEMCmd = new G4UIcmdWithAString("/gorad/physics/EM",this);
0062   selectEMCmd->AvailableForStates(G4State_PreInit);
0063   selectEMCmd->SetToBeBroadcasted(false);
0064   selectEMCmd->SetParameterName("EM_option",true);
0065   selectEMCmd->SetCandidates("Op_0 Op_1 Op_3 Op_4 LIV LIV_Pol");
0066   selectEMCmd->SetDefaultValue("Op_0");
0067   selectEMCmd->SetGuidance("Select EM Physics option");
0068   selectEMCmd->SetGuidance(" Op_0 (default) : Suitable to medium and high energy applications");
0069   selectEMCmd->SetGuidance(" Op_1 : Faster than Op_0 because of less accurate MSC step limitation");
0070   selectEMCmd->SetGuidance(" Op_3 : Suitable for medical applications - more accurate MSC for all particles");
0071   selectEMCmd->SetGuidance(" Op_4 : Most accurate (GS MSC model with Mott correction and error-free stepping for e+/-");
0072   selectEMCmd->SetGuidance(" LIV  : Livermore models for e-/gamma below 1 GeV, otherwise Op_0");
0073   selectEMCmd->SetGuidance(" LIV_Pol : Polarized extension of Livermore models (t.b.a.)");
0074 
0075   selectHadCmd = new G4UIcmdWithAString("/gorad/physics/Hadronic",this);
0076   selectHadCmd->AvailableForStates(G4State_PreInit);
0077   selectHadCmd->SetToBeBroadcasted(false);
0078   selectHadCmd->SetParameterName("Had_option",true);
0079   selectHadCmd->SetCandidates("FTFP_BERT QGSP_BIC Shielding");
0080   selectHadCmd->SetDefaultValue("FTFP_BERT");
0081   selectHadCmd->SetGuidance("Select Hadronic Physics option");
0082   selectHadCmd->SetGuidance(" FTFP_BERT (default) : Fritiof string + Bertini cascade + Precompound de-excitation");
0083   selectHadCmd->SetGuidance("                       suitable to most of midium and high energy applications");
0084   selectHadCmd->SetGuidance(" QGSP_BIC : Quark-Gluon-String + Fritiof string + Binary cascade + Precompound de-excitation");
0085   selectHadCmd->SetGuidance("            suitable for lower energy applications such as medical");
0086   selectHadCmd->SetGuidance(" Shielding : Similar to FTFP+BERT with better ion-ion interactions.");
0087   selectHadCmd->SetGuidance("             High-Precision neutron and Radioactive Decay models are included by default.");
0088 
0089   addHPCmd = new G4UIcmdWithoutParameter("/gorad/physics/addHP",this);
0090   addHPCmd->AvailableForStates(G4State_PreInit);
0091   addHPCmd->SetToBeBroadcasted(false);
0092   addHPCmd->SetGuidance("Add High-Precision neutron model.");
0093   addHPCmd->SetGuidance(" Note: Shielding option has already had HP. This command does not make effect to Shielding option.");
0094 
0095   addRDMCmd = new G4UIcmdWithoutParameter("/gorad/physics/addRDM",this);
0096   addRDMCmd->AvailableForStates(G4State_PreInit);
0097   addRDMCmd->SetToBeBroadcasted(false);
0098   addRDMCmd->SetGuidance("Add Radioactive Decay model.");
0099   addRDMCmd->SetGuidance(" Note: Shielding option has already had RDM. This command does not make effect to Shielding option.");
0100 
0101   addRMCCmd = new G4UIcmdWithoutParameter("/gorad/physics/addRMC",this);
0102   addRMCCmd->AvailableForStates(G4State_PreInit);
0103   addRMCCmd->SetToBeBroadcasted(false);
0104   addRMCCmd->SetGuidance("Add Reverse Monte Carlo.");
0105 
0106   addOpticalCmd = new G4UIcmdWithoutParameter("/gorad/physics/addOptical",this);
0107   addOpticalCmd->AvailableForStates(G4State_PreInit);
0108   addOpticalCmd->SetToBeBroadcasted(false);
0109   addOpticalCmd->SetGuidance("Add Optical physics");
0110 
0111   addStepLimitCmd = new G4UIcmdWithAString("/gorad/physics/addStepLimit",this);
0112   addStepLimitCmd->AvailableForStates(G4State_PreInit);
0113   addStepLimitCmd->SetToBeBroadcasted(false);
0114   addStepLimitCmd->SetGuidance("Add step-limiter process to artificially limit step length.");
0115   addStepLimitCmd->SetGuidance("Specify particle types to be applied.");
0116   addStepLimitCmd->SetGuidance("  charged (default) : applied only to the charged particles");
0117   addStepLimitCmd->SetGuidance("  neutral : applied only to the neutral particles");
0118   addStepLimitCmd->SetGuidance("  all : applied to all particle types");
0119   addStepLimitCmd->SetGuidance("  e+/- : applied only to e+/e-");
0120   addStepLimitCmd->SetGuidance(" Note: In addition to this command, you need to specify the limitation value by");
0121   addStepLimitCmd->SetGuidance("       /gorad/physics/limit/stepLimit or /gorad/physics/limit/localStepLimt command.");
0122   addStepLimitCmd->SetParameterName("particle",true);
0123   addStepLimitCmd->SetDefaultValue("charged");
0124   addStepLimitCmd->SetCandidates("charged neutral all e+/-");
0125 
0126   physLimitDir = new G4UIdirectory("/gorad/physics/limit/");
0127   physLimitDir->SetGuidance("Specify step limitation");
0128 
0129   setStepLimitCmd = new G4UIcmdWithADoubleAndUnit("/gorad/physics/limit/stepLimit",this);
0130   setStepLimitCmd->AvailableForStates(G4State_Idle);
0131   setStepLimitCmd->SetToBeBroadcasted(false);
0132   setStepLimitCmd->SetParameterName("length",false);
0133   setStepLimitCmd->SetDefaultUnit("mm");
0134   setStepLimitCmd->SetGuidance("Define the limitation of the step length");
0135   setStepLimitCmd->SetGuidance("This limitation is applied to the entire geometry except regions that has its dedicated limit.");
0136 
0137   setRegionStepLimitCmd = new G4UIcommand("/gorad/physics/limit/regionStepLimit",this);
0138   setRegionStepLimitCmd->AvailableForStates(G4State_Idle);
0139   setRegionStepLimitCmd->SetToBeBroadcasted(false);
0140   setRegionStepLimitCmd->SetGuidance("Define the limitation of the step length for the specified region");
0141   setRegionStepLimitCmd->SetGuidance("   [usage] /gorad/physics/limit/regionStepLimit region length [unit]");
0142   setRegionStepLimitCmd->SetGuidance("      region (string) : region name");
0143   setRegionStepLimitCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
0144   setRegionStepLimitCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
0145   param = new G4UIparameter("region",'s',false);
0146   setRegionStepLimitCmd->SetParameter(param);
0147   param = new G4UIparameter("length",'d',false);
0148   setRegionStepLimitCmd->SetParameter(param);
0149   param = new G4UIparameter("unit",'s',true);
0150   param->SetDefaultUnit("mm");
0151   setRegionStepLimitCmd->SetParameter(param);
0152 
0153   physCutDir = new G4UIdirectory("/gorad/physics/cuts/");
0154   physCutDir->SetGuidance("Specify production thresholds (a.k.a. cuts)");
0155 
0156   setCutCmd = new G4UIcmdWithADoubleAndUnit("/gorad/physics/cuts/setCuts",this);
0157   setCutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0158   setCutCmd->SetToBeBroadcasted(false);
0159   setCutCmd->SetParameterName("length",false);
0160   setCutCmd->SetDefaultUnit("mm");
0161   setCutCmd->SetGuidance("Specify production thresholds (a.k.a. cuts) that is applied to the entire geometry");
0162   setCutCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
0163   setCutCmd->SetGuidance("Threshold of each particle can be overwitted by /gorad/physics/cuts/setParticleCut command");
0164 
0165   setCutParticleCmd = new G4UIcommand("/gorad/physics/cuts/setParticleCut",this);
0166   setCutParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
0167   setCutParticleCmd->SetToBeBroadcasted(false);
0168   setCutParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) for the specified particle that is applied to the entire geometry");
0169   setCutParticleCmd->SetGuidance("  [usage] /gorad/physics/setParticleCut particle cut unit");
0170   param = new G4UIparameter("particle",'s',false);
0171   param->SetParameterCandidates("e- e+ gamma proton");
0172   setCutParticleCmd->SetParameter(param);
0173   param = new G4UIparameter("cut",'d',false);
0174   setCutParticleCmd->SetParameter(param);
0175   param = new G4UIparameter("unit",'s',true);
0176   param->SetDefaultUnit("mm");
0177   setCutParticleCmd->SetParameter(param);
0178 
0179   setCutRegionCmd = new G4UIcommand("/gorad/physics/cuts/setRegionCut",this);
0180   setCutRegionCmd->AvailableForStates(G4State_Idle);
0181   setCutRegionCmd->SetToBeBroadcasted(false);
0182   setCutRegionCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
0183   setCutRegionCmd->SetGuidance("  [usage] /gorad/physics/setRegionCut region cut unit");
0184   setCutRegionCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
0185   setCutRegionCmd->SetGuidance("Threshold of each particle can be overwitted by /gorad/physics/cuts/setRegionParticleCut command");
0186   setCutRegionCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
0187   setCutRegionCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
0188   param = new G4UIparameter("region",'s',false);
0189   setCutRegionCmd->SetParameter(param);
0190   param = new G4UIparameter("cut",'d',false);
0191   setCutRegionCmd->SetParameter(param);
0192   param = new G4UIparameter("unit",'s',true);
0193   param->SetDefaultUnit("mm");
0194   setCutRegionCmd->SetParameter(param);
0195 
0196   setCutRegionParticleCmd = new G4UIcommand("/gorad/physics/cuts/setRegionParticleCut",this);
0197   setCutRegionParticleCmd->AvailableForStates(G4State_Idle);
0198   setCutRegionParticleCmd->SetToBeBroadcasted(false);
0199   setCutRegionParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
0200   setCutRegionParticleCmd->SetGuidance("  [usage] /gorad/physics/setRegionParticleCut region particle cut unit");
0201   setCutRegionParticleCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
0202   setCutRegionParticleCmd->SetGuidance("       If new region is necessary, use /gorad/geometry/createRegion to create it.");
0203   param = new G4UIparameter("region",'s',false);
0204   setCutRegionParticleCmd->SetParameter(param);
0205   param = new G4UIparameter("particle",'s',false);
0206   param->SetParameterCandidates("e- e+ gamma proton");
0207   setCutRegionParticleCmd->SetParameter(param);
0208   param = new G4UIparameter("cut",'d',false);
0209   setCutRegionParticleCmd->SetParameter(param);
0210   param = new G4UIparameter("unit",'s',true);
0211   param->SetDefaultUnit("mm");
0212   setCutRegionParticleCmd->SetParameter(param);
0213 
0214 }
0215 
0216 GRPhysicsListMessenger::~GRPhysicsListMessenger()
0217 {
0218   delete selectEMCmd;
0219   delete selectHadCmd;
0220   delete addHPCmd;
0221   delete addRDMCmd;
0222   delete addRMCCmd;
0223   delete addOpticalCmd;
0224   delete addStepLimitCmd;
0225   delete setStepLimitCmd;
0226   delete setRegionStepLimitCmd;
0227   delete setCutCmd;
0228   delete setCutParticleCmd;
0229   delete setCutRegionCmd;
0230   delete setCutRegionParticleCmd;
0231 
0232   delete physLimitDir;
0233   delete physCutDir;
0234   delete physDir;
0235 }
0236 
0237 #include "G4Tokenizer.hh"
0238 
0239 void GRPhysicsListMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
0240 {
0241   if(cmd==selectEMCmd)
0242   { pPL->SetEM(val); }
0243   else if(cmd==selectHadCmd)
0244   { pPL->SetHad(val); }
0245   else if(cmd==addHPCmd)
0246   { pPL->AddHP(); }
0247   else if(cmd==addRDMCmd)
0248   { pPL->AddRDM(); }
0249   else if(cmd==addRMCCmd)
0250   { pPL->AddRMC(); }
0251   else if(cmd==addOpticalCmd)
0252   { G4cout<<"Not yet implemented."<<G4endl; }
0253   else if(cmd==addStepLimitCmd)
0254   {
0255     G4int opt = 0;
0256     if(val=="neutral") opt = 1; 
0257     else if(val=="all") opt = 2; 
0258     else if(val=="e+/-") opt = 3; 
0259     pPL->AddStepLimit(opt);
0260   }
0261   else if(cmd==setStepLimitCmd)
0262   { pPL->SetGlobalStepLimit(setStepLimitCmd->GetNewDoubleValue(val)); }
0263   else if(cmd==setRegionStepLimitCmd)
0264   {
0265     G4Tokenizer next(val);
0266     G4String reg = next();
0267     G4String newVal = next();
0268     newVal += " ";
0269     newVal += next();
0270     auto regPtr = pPL->SetLocalStepLimit(reg,setRegionStepLimitCmd->ConvertToDimensionedDouble(newVal));
0271     if(!regPtr)
0272     {
0273       G4ExceptionDescription ed;
0274       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
0275          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
0276       setRegionStepLimitCmd->CommandFailed(ed);
0277     }
0278   }
0279   else if(cmd==setCutCmd)
0280   { pPL->SetGlobalCuts(setCutCmd->GetNewDoubleValue(val)); }
0281   else if(cmd==setCutParticleCmd)
0282   {
0283     G4Tokenizer next(val);
0284     G4String pat = next();
0285     G4String newVal = next();
0286     newVal += " ";
0287     newVal += next();
0288     G4int i = 0;
0289     if(pat=="e-") i = 0; 
0290     else if(pat=="e+") i = 1; 
0291     else if(pat=="gamma") i = 2; 
0292     else if(pat=="proton") i = 3; 
0293     pPL->SetGlobalCut(i,setCutParticleCmd->ConvertToDimensionedDouble(newVal));
0294   }
0295   else if(cmd==setCutRegionCmd)
0296   {
0297     G4Tokenizer next(val);
0298     G4String reg = next();
0299     G4String newVal = next();
0300     newVal += " ";
0301     newVal += next();
0302     auto regPtr = pPL->SetLocalCuts(reg,setCutRegionCmd->ConvertToDimensionedDouble(newVal));
0303     if(!regPtr)
0304     {
0305       G4ExceptionDescription ed;
0306       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
0307          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
0308       setRegionStepLimitCmd->CommandFailed(ed);
0309     }
0310   }
0311   else if(cmd==setCutRegionParticleCmd)
0312   {
0313     G4Tokenizer next(val);
0314     G4String reg = next();
0315     G4String pat = next();
0316     G4int i = 0;
0317     if(pat=="e-") i = 0; 
0318     else if(pat=="e+") i = 1; 
0319     else if(pat=="gamma") i = 2; 
0320     else if(pat=="proton") i = 3; 
0321     G4String newVal = next();
0322     newVal += " ";
0323     newVal += next();
0324     auto regPtr = pPL->SetLocalCut(reg,i,setCutRegionParticleCmd->ConvertToDimensionedDouble(newVal));
0325     if(!regPtr)
0326     {
0327       G4ExceptionDescription ed;
0328       ed << "Region <" << reg << "> is not defined. Region has to be defined in advance to this command."
0329          << "\nIf new region is necessary, use /gorad/geometry/createRegion to create it.";
0330       setRegionStepLimitCmd->CommandFailed(ed);
0331     }
0332   }
0333   
0334 }
0335 
0336 G4String GRPhysicsListMessenger::GetCurrentValue(G4UIcommand* cmd)
0337 {
0338   G4String val("");
0339 
0340   if(cmd==selectEMCmd)
0341   { val = pPL->GetEM(); }
0342   else if(cmd==selectHadCmd)
0343   { val = pPL->GetHad(); }
0344   else if(cmd==addHPCmd)
0345   { val = cmd->ConvertToString(pPL->IfHP()); }
0346   else if(cmd==addRDMCmd)
0347   { val = cmd->ConvertToString(pPL->IfRDM()); }
0348   else if(cmd==addRMCCmd)
0349   { val = cmd->ConvertToString(pPL->IfRMC()); }
0350   else if(cmd==addOpticalCmd)
0351   { G4cout<<"Not yet implemented."<<G4endl; }
0352   else if(cmd==addStepLimitCmd)
0353   {
0354     auto opt = pPL->IfStepLimit();
0355     switch(opt)
0356     {
0357       case 0: val =  "charged"; break;
0358       case 1: val =  "neutral"; break;
0359       case 2: val =  "all"; break;
0360       case 3: val =  "e+/-"; break;
0361       default : val = "undefined"; break;
0362     }
0363   }
0364   return val;
0365 }
0366 
0367