PhysicsListMessenger.cc
Go to the documentation of this file.
1 // Taken directly from G4 sources //
3 #include "PhysicsListMessenger.h"
4 #include "PhysicsList.h"
6 
7 #include <G4UIcmdWithADoubleAndUnit.hh>
8 #include <G4UIcmdWithAString.hh>
9 #include <G4UIcmdWithoutParameter.hh>
10 #include <G4UImanager.hh>
11 
12 using namespace GroundPropagatorAG;
13 
15 :pPhysicsList(pPhys)
16 {
17 
18  gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/physlist/CutGamma",this);
19  gammaCutCmd->SetGuidance("Set gamma cut.");
20  gammaCutCmd->SetParameterName("Gcut",false);
21  gammaCutCmd->SetUnitCategory("Length");
22  gammaCutCmd->SetRange("Gcut>=0.0");
23  gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
24 
25  electCutCmd = new G4UIcmdWithADoubleAndUnit("/physlist/CutEl",this);
26  electCutCmd->SetGuidance("Set electron cut.");
27  electCutCmd->SetParameterName("Ecut",false);
28  electCutCmd->SetUnitCategory("Length");
29  electCutCmd->SetRange("Ecut>=0.0");
30  electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
31 
32  posCutCmd = new G4UIcmdWithADoubleAndUnit("/physlist/CutPos",this);
33  posCutCmd->SetGuidance("Set positron cut.");
34  posCutCmd->SetParameterName("Pcut",false);
35  posCutCmd->SetUnitCategory("Length");
36  posCutCmd->SetRange("Pcut>=0.0");
37  posCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
38 
39  pCutCmd = new G4UIcmdWithADoubleAndUnit("/physlist/CutProt",this);
40  pCutCmd->SetGuidance("Set proton cut.");
41  pCutCmd->SetParameterName("ProtCut",false);
42  pCutCmd->SetUnitCategory("Length");
43  pCutCmd->SetRange("ProtCut>=0.0");
44  pCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
45 
46  allCutCmd = new G4UIcmdWithADoubleAndUnit("/physlist/CutsAll",this);
47  allCutCmd->SetGuidance("Set cut for all.");
48  allCutCmd->SetParameterName("cut",false);
49  allCutCmd->SetUnitCategory("Length");
50  allCutCmd->SetRange("cut>=0.0");
51  allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
52 
53  pListCmd = new G4UIcmdWithAString("/physlist/Physics",this);
54  pListCmd->SetGuidance("Add modula physics list.");
55  pListCmd->SetParameterName("PList",false);
56  pListCmd->AvailableForStates(G4State_PreInit);
57 
58  listCmd = new G4UIcmdWithoutParameter("/physlist/ListPhysics",this);
59  listCmd->SetGuidance("Available Physics Lists");
60  listCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
61 
62 }
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
65 
67 {
68  delete gammaCutCmd;
69  delete electCutCmd;
70  delete posCutCmd;
71  delete pCutCmd;
72  delete allCutCmd;
73  delete pListCmd;
74  delete listCmd;
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
79 void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
80 {
81  G4UImanager* UI = G4UImanager::GetUIpointer();
82  if( command == gammaCutCmd ) {
83  if(pPhysicsList) {
84  pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue));
85  } else {
86  UI->ApplyCommand("/run/setCutForAGivenParticle gamma " + newValue);
87  }
88 
89  } else if( command == electCutCmd ) {
90  if(pPhysicsList) {
91  pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue));
92  } else {
93  UI->ApplyCommand("/run/setCutForAGivenParticle e- " + newValue);
94  }
95 
96  } else if( command == posCutCmd ) {
97  if(pPhysicsList) {
98  pPhysicsList->SetCutForPositron(posCutCmd->GetNewDoubleValue(newValue));
99  } else {
100  UI->ApplyCommand("/run/setCutForAGivenParticle e+ " + newValue);
101  }
102 
103  } else if( command == pCutCmd ) {
104  if(pPhysicsList) {
105  pPhysicsList->SetCutForProton(pCutCmd->GetNewDoubleValue(newValue));
106  } else {
107  UI->ApplyCommand("/run/setCutForAGivenParticle proton " + newValue);
108  }
109 
110  } else if( command == allCutCmd ) {
111 
112  if(pPhysicsList) {
113  G4double cut = allCutCmd->GetNewDoubleValue(newValue);
118  } else {
119  UI->ApplyCommand("/run/setCut " + newValue);
120  }
121 
122  } else if( command == pListCmd ) {
123  if(pPhysicsList) {
124  G4String name = newValue;
125  if(name == "PHYSLIST") {
126  char* path = getenv(name);
127  if (path) {
128  name = G4String(path);
129  } else {
130  G4cerr << "### PhysicsListMessenger WARNING: "
131  << " environment variable PHYSLIST is not defined"
132  << G4endl;
133  return;
134  }
135  }
137  } else {
138  G4cerr << "### PhysicsListMessenger WARNING: "
139  << " /physlist/Physics UI command is not available "
140  << "for reference Physics List" << G4endl;
141  }
142 
143  } else if( command == listCmd ) {
144  if(pPhysicsList) {
145  pPhysicsList->List();
146  } else {
147  G4cerr << "### PhysicsListMessenger WARNING: "
148  << " /physlist/ListPhysics UI command is not available "
149  << "for reference Physics List" << G4endl;
150  }
151  }
152 }
153 
void SetNewValue(G4UIcommand *, G4String)

, generated on Tue Sep 26 2023.