EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
eASTPhysicsListMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file eASTPhysicsListMessenger.cc
1 // ********************************************************************
2 //
3 // eASTPhysicsListMessenger.cc
4 // A messenger class that handles physics list options.
5 //
6 // History
7 // September 8th, 2020 : first implementation
8 //
9 // ********************************************************************
10 
12 
13 #include "eASTPhysicsList.hh"
14 #include "G4UIcommand.hh"
15 #include "G4UIparameter.hh"
16 #include "G4UIdirectory.hh"
17 #include "G4UIcmdWithAString.hh"
18 #include "G4UIcmdWithADoubleAndUnit.hh"
19 #include "G4UIcmdWithoutParameter.hh"
20 
22 : pPL(pl)
23 {
24  G4UIparameter* param = nullptr;
25 
26  physDir = new G4UIdirectory("/eAST/physics/");
27  physDir->SetGuidance("eAST physics selection");
28 
29  //addHPCmd = new G4UIcmdWithoutParameter("/eAST/physics/addHP",this);
30  //addHPCmd->AvailableForStates(G4State_PreInit);
31  //addHPCmd->SetToBeBroadcasted(false);
32  //addHPCmd->SetGuidance("Add High-Precision neutron model.");
33  //addHPCmd->SetGuidance(" Note: Shielding option has already had HP. This command does not make effect to Shielding option.");
34 
35  addRDMCmd = new G4UIcmdWithoutParameter("/eAST/physics/addRDM",this);
36  addRDMCmd->AvailableForStates(G4State_PreInit);
37  addRDMCmd->SetToBeBroadcasted(false);
38  addRDMCmd->SetGuidance("Add Radioactive Decay model.");
39  addRDMCmd->SetGuidance(" Note: Shielding option has already had RDM. This command does not make effect to Shielding option.");
40 
41  addOpticalCmd = new G4UIcmdWithoutParameter("/eAST/physics/addOptical",this);
42  addOpticalCmd->AvailableForStates(G4State_PreInit);
43  addOpticalCmd->SetToBeBroadcasted(false);
44  addOpticalCmd->SetGuidance("Add Optical physics");
45 
46  addStepLimitCmd = new G4UIcmdWithAString("/eAST/physics/addStepLimit",this);
47  addStepLimitCmd->AvailableForStates(G4State_PreInit);
48  addStepLimitCmd->SetToBeBroadcasted(false);
49  addStepLimitCmd->SetGuidance("Add step-limiter process to artificially limit step length.");
50  addStepLimitCmd->SetGuidance("Specify particle types to be applied.");
51  addStepLimitCmd->SetGuidance(" charged (default) : applied only to the charged particles");
52  addStepLimitCmd->SetGuidance(" neutral : applied only to the neutral particles");
53  addStepLimitCmd->SetGuidance(" all : applied to all particle types");
54  addStepLimitCmd->SetGuidance(" e+/- : applied only to e+/e-");
55  addStepLimitCmd->SetGuidance(" Note: In addition to this command, you need to specify the limitation value by");
56  addStepLimitCmd->SetGuidance(" /eAST/physics/limit/stepLimit or /eAST/physics/limit/localStepLimt command.");
57  addStepLimitCmd->SetParameterName("particle",true);
58  addStepLimitCmd->SetDefaultValue("charged");
59  addStepLimitCmd->SetCandidates("charged neutral all e+/-");
60 
61  physLimitDir = new G4UIdirectory("/eAST/physics/limit/");
62  physLimitDir->SetGuidance("Specify step limitation");
63 
64  setStepLimitCmd = new G4UIcmdWithADoubleAndUnit("/eAST/physics/limit/stepLimit",this);
65  setStepLimitCmd->AvailableForStates(G4State_Idle);
66  setStepLimitCmd->SetToBeBroadcasted(false);
67  setStepLimitCmd->SetParameterName("length",false);
68  setStepLimitCmd->SetDefaultUnit("mm");
69  setStepLimitCmd->SetGuidance("Define the limitation of the step length");
70  setStepLimitCmd->SetGuidance("This limitation is applied to the entire geometry except regions that has its dedicated limit.");
71 
72  setRegionStepLimitCmd = new G4UIcommand("/eAST/physics/limit/regionStepLimit",this);
73  setRegionStepLimitCmd->AvailableForStates(G4State_Idle);
74  setRegionStepLimitCmd->SetToBeBroadcasted(false);
75  setRegionStepLimitCmd->SetGuidance("Define the limitation of the step length for the specified region");
76  setRegionStepLimitCmd->SetGuidance(" [usage] /eAST/physics/limit/regionStepLimit region length [unit]");
77  setRegionStepLimitCmd->SetGuidance(" region (string) : region name");
78  setRegionStepLimitCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
79  setRegionStepLimitCmd->SetGuidance(" If new region is necessary, use /eAST/geometry/createRegion to create it.");
80  param = new G4UIparameter("region",'s',false);
81  setRegionStepLimitCmd->SetParameter(param);
82  param = new G4UIparameter("length",'d',false);
83  setRegionStepLimitCmd->SetParameter(param);
84  param = new G4UIparameter("unit",'s',true);
85  param->SetDefaultUnit("mm");
86  setRegionStepLimitCmd->SetParameter(param);
87 
88  physCutDir = new G4UIdirectory("/eAST/physics/cuts/");
89  physCutDir->SetGuidance("Specify production thresholds (a.k.a. cuts)");
90 
91  setCutCmd = new G4UIcmdWithADoubleAndUnit("/eAST/physics/cuts/setCuts",this);
92  setCutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
93  setCutCmd->SetToBeBroadcasted(false);
94  setCutCmd->SetParameterName("length",false);
95  setCutCmd->SetDefaultUnit("mm");
96  setCutCmd->SetGuidance("Specify production thresholds (a.k.a. cuts) that is applied to the entire geometry");
97  setCutCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
98  setCutCmd->SetGuidance("Threshold of each particle can be overwitted by /eAST/physics/cuts/setParticleCut command");
99 
100  setCutParticleCmd = new G4UIcommand("/eAST/physics/cuts/setParticleCut",this);
101  setCutParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
102  setCutParticleCmd->SetToBeBroadcasted(false);
103  setCutParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) for the specified particle that is applied to the entire geometry");
104  setCutParticleCmd->SetGuidance(" [usage] /eAST/physics/setParticleCut particle cut unit");
105  param = new G4UIparameter("particle",'s',false);
106  param->SetParameterCandidates("e- e+ gamma proton");
107  setCutParticleCmd->SetParameter(param);
108  param = new G4UIparameter("cut",'d',false);
109  setCutParticleCmd->SetParameter(param);
110  param = new G4UIparameter("unit",'s',true);
111  param->SetDefaultUnit("mm");
112  setCutParticleCmd->SetParameter(param);
113 
114  setCutRegionCmd = new G4UIcommand("/eAST/physics/cuts/setRegionCut",this);
115  setCutRegionCmd->AvailableForStates(G4State_Idle);
116  setCutRegionCmd->SetToBeBroadcasted(false);
117  setCutRegionCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
118  setCutRegionCmd->SetGuidance(" [usage] /eAST/physics/setRegionCut region cut unit");
119  setCutRegionCmd->SetGuidance("This threshold is applied to all of e-, e+, gamma and proton.");
120  setCutRegionCmd->SetGuidance("Threshold of each particle can be overwitted by /eAST/physics/cuts/setRegionParticleCut command");
121  setCutRegionCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
122  setCutRegionCmd->SetGuidance(" If new region is necessary, use /eAST/geometry/createRegion to create it.");
123  param = new G4UIparameter("region",'s',false);
124  setCutRegionCmd->SetParameter(param);
125  param = new G4UIparameter("cut",'d',false);
126  setCutRegionCmd->SetParameter(param);
127  param = new G4UIparameter("unit",'s',true);
128  param->SetDefaultUnit("mm");
129  setCutRegionCmd->SetParameter(param);
130 
131  setCutRegionParticleCmd = new G4UIcommand("/eAST/physics/cuts/setRegionParticleCut",this);
132  setCutRegionParticleCmd->AvailableForStates(G4State_Idle);
133  setCutRegionParticleCmd->SetToBeBroadcasted(false);
134  setCutRegionParticleCmd->SetGuidance("Specify production threshold (a.k.a. cut) that is applied to the specified region");
135  setCutRegionParticleCmd->SetGuidance(" [usage] /eAST/physics/setRegionParticleCut region particle cut unit");
136  setCutRegionParticleCmd->SetGuidance(" Note: Region has to be defined in advance to this command.");
137  setCutRegionParticleCmd->SetGuidance(" If new region is necessary, use /eAST/geometry/createRegion to create it.");
138  param = new G4UIparameter("region",'s',false);
139  setCutRegionParticleCmd->SetParameter(param);
140  param = new G4UIparameter("particle",'s',false);
141  param->SetParameterCandidates("e- e+ gamma proton");
142  setCutRegionParticleCmd->SetParameter(param);
143  param = new G4UIparameter("cut",'d',false);
144  setCutRegionParticleCmd->SetParameter(param);
145  param = new G4UIparameter("unit",'s',true);
146  param->SetDefaultUnit("mm");
147  setCutRegionParticleCmd->SetParameter(param);
148 
149 }
150 
152 {
153  //delete addHPCmd;
154  delete addRDMCmd;
155  delete addOpticalCmd;
156  delete addStepLimitCmd;
157  delete setStepLimitCmd;
158  delete setRegionStepLimitCmd;
159  delete setCutCmd;
160  delete setCutParticleCmd;
161  delete setCutRegionCmd;
163 
164  delete physLimitDir;
165  delete physCutDir;
166  delete physDir;
167 }
168 
169 #include "G4Tokenizer.hh"
170 
171 void eASTPhysicsListMessenger::SetNewValue(G4UIcommand* cmd, G4String val)
172 {
173  //if(cmd==addHPCmd)
174  //{ pPL->AddHP(); }
175  //else
176  if(cmd==addRDMCmd)
177  { pPL->AddRDM(); }
178  else if(cmd==addOpticalCmd)
179  { pPL->AddOptical(); }
180  else if(cmd==addStepLimitCmd)
181  {
182  G4int opt = 0;
183  if(val=="neutral") opt = 1;
184  else if(val=="all") opt = 2;
185  else if(val=="e+/-") opt = 3;
186  pPL->AddStepLimit(opt);
187  }
188  else if(cmd==setStepLimitCmd)
189  { pPL->SetGlobalStepLimit(setStepLimitCmd->GetNewDoubleValue(val)); }
190  else if(cmd==setRegionStepLimitCmd)
191  {
192  G4Tokenizer next(val);
193  G4String reg = next();
194  G4String newVal = next();
195  newVal += " ";
196  newVal += next();
197  auto regPtr = pPL->SetLocalStepLimit(reg,setRegionStepLimitCmd->ConvertToDimensionedDouble(newVal));
198  if(!regPtr)
199  {
200  G4ExceptionDescription ed;
201  ed << "Region <" << reg << "> is not defined.";
202  setRegionStepLimitCmd->CommandFailed(ed);
203  }
204  }
205  else if(cmd==setCutCmd)
206  { pPL->SetGlobalCuts(setCutCmd->GetNewDoubleValue(val)); }
207  else if(cmd==setCutParticleCmd)
208  {
209  G4Tokenizer next(val);
210  G4String pat = next();
211  G4String newVal = next();
212  newVal += " ";
213  newVal += next();
214  G4int i = 0;
215  if(pat=="e-") i = 0;
216  else if(pat=="e+") i = 1;
217  else if(pat=="gamma") i = 2;
218  else if(pat=="proton") i = 3;
219  pPL->SetGlobalCut(i,setCutParticleCmd->ConvertToDimensionedDouble(newVal));
220  }
221  else if(cmd==setCutRegionCmd)
222  {
223  G4Tokenizer next(val);
224  G4String reg = next();
225  G4String newVal = next();
226  newVal += " ";
227  newVal += next();
228  auto regPtr = pPL->SetLocalCuts(reg,setCutRegionCmd->ConvertToDimensionedDouble(newVal));
229  if(!regPtr)
230  {
231  G4ExceptionDescription ed;
232  ed << "Region <" << reg << "> is not defined.";
233  setRegionStepLimitCmd->CommandFailed(ed);
234  }
235  }
236  else if(cmd==setCutRegionParticleCmd)
237  {
238  G4Tokenizer next(val);
239  G4String reg = next();
240  G4String pat = next();
241  G4int i = 0;
242  if(pat=="e-") i = 0;
243  else if(pat=="e+") i = 1;
244  else if(pat=="gamma") i = 2;
245  else if(pat=="proton") i = 3;
246  G4String newVal = next();
247  newVal += " ";
248  newVal += next();
249  auto regPtr = pPL->SetLocalCut(reg,i,setCutRegionParticleCmd->ConvertToDimensionedDouble(newVal));
250  if(!regPtr)
251  {
252  G4ExceptionDescription ed;
253  ed << "Region <" << reg << "> is not defined.";
254  setRegionStepLimitCmd->CommandFailed(ed);
255  }
256  }
257 
258 }
259 
261 {
262  G4String val("");
263 
264  //if(cmd==addHPCmd)
265  //{ val = cmd->ConvertToString(pPL->IfHP()); }
266  //else
267  if(cmd==addRDMCmd)
268  { val = cmd->ConvertToString(pPL->IfRDM()); }
269  else if(cmd==addOpticalCmd)
270  { val = cmd->ConvertToString(pPL->IfOptical()); }
271  else if(cmd==addStepLimitCmd)
272  {
273  auto opt = pPL->IfStepLimit();
274  switch(opt)
275  {
276  case 0: val = "charged"; break;
277  case 1: val = "neutral"; break;
278  case 2: val = "all"; break;
279  case 3: val = "e+/-"; break;
280  default : val = "undefined"; break;
281  }
282  }
283  return val;
284 }
285 
286