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 | // |
---|
27 | // $Id: PhysicsListMessenger.cc,v 1.7 2010/01/13 15:53:44 vnivanch Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-04-beta-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | ///////////////////////////////////////////////////////////////////////// |
---|
32 | // |
---|
33 | // PhysicsListMessenger |
---|
34 | // |
---|
35 | // Created: 31.01.2006 V.Ivanchenko |
---|
36 | // |
---|
37 | // Modified: |
---|
38 | // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) |
---|
39 | // |
---|
40 | //////////////////////////////////////////////////////////////////////// |
---|
41 | // |
---|
42 | // |
---|
43 | |
---|
44 | #include "PhysicsListMessenger.hh" |
---|
45 | |
---|
46 | #include "PhysicsList.hh" |
---|
47 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
48 | #include "G4UIcmdWithAString.hh" |
---|
49 | #include "G4UIcmdWithoutParameter.hh" |
---|
50 | #include "G4UImanager.hh" |
---|
51 | |
---|
52 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
53 | |
---|
54 | PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys) |
---|
55 | :pPhysicsList(pPhys) |
---|
56 | { |
---|
57 | gammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutGamma",this); |
---|
58 | gammaCutCmd->SetGuidance("Set gamma cut."); |
---|
59 | gammaCutCmd->SetParameterName("Gcut",false); |
---|
60 | gammaCutCmd->SetUnitCategory("Length"); |
---|
61 | gammaCutCmd->SetRange("Gcut>=0.0"); |
---|
62 | gammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
63 | |
---|
64 | electCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutEl",this); |
---|
65 | electCutCmd->SetGuidance("Set electron cut."); |
---|
66 | electCutCmd->SetParameterName("Ecut",false); |
---|
67 | electCutCmd->SetUnitCategory("Length"); |
---|
68 | electCutCmd->SetRange("Ecut>=0.0"); |
---|
69 | electCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
70 | |
---|
71 | posCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutPos",this); |
---|
72 | posCutCmd->SetGuidance("Set positron cut."); |
---|
73 | posCutCmd->SetParameterName("Pcut",false); |
---|
74 | posCutCmd->SetUnitCategory("Length"); |
---|
75 | posCutCmd->SetRange("Pcut>=0.0"); |
---|
76 | posCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
77 | |
---|
78 | pCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutProt",this); |
---|
79 | pCutCmd->SetGuidance("Set proton cut."); |
---|
80 | pCutCmd->SetParameterName("ProtCut",false); |
---|
81 | pCutCmd->SetUnitCategory("Length"); |
---|
82 | pCutCmd->SetRange("ProtCut>=0.0"); |
---|
83 | pCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
84 | |
---|
85 | allCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutsAll",this); |
---|
86 | allCutCmd->SetGuidance("Set cut for all."); |
---|
87 | allCutCmd->SetParameterName("cut",false); |
---|
88 | allCutCmd->SetUnitCategory("Length"); |
---|
89 | allCutCmd->SetRange("cut>=0.0"); |
---|
90 | allCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
91 | |
---|
92 | pListCmd = new G4UIcmdWithAString("/testhadr/Physics",this); |
---|
93 | pListCmd->SetGuidance("Add modula physics list."); |
---|
94 | pListCmd->SetParameterName("PList",false); |
---|
95 | pListCmd->AvailableForStates(G4State_PreInit); |
---|
96 | |
---|
97 | listCmd = new G4UIcmdWithoutParameter("/testhadr/ListPhysics",this); |
---|
98 | listCmd->SetGuidance("Available Physics Lists"); |
---|
99 | listCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
100 | |
---|
101 | } |
---|
102 | |
---|
103 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
104 | |
---|
105 | PhysicsListMessenger::~PhysicsListMessenger() |
---|
106 | { |
---|
107 | delete gammaCutCmd; |
---|
108 | delete electCutCmd; |
---|
109 | delete posCutCmd; |
---|
110 | delete pCutCmd; |
---|
111 | delete allCutCmd; |
---|
112 | delete pListCmd; |
---|
113 | delete listCmd; |
---|
114 | } |
---|
115 | |
---|
116 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
117 | |
---|
118 | void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue) |
---|
119 | { |
---|
120 | G4UImanager* UI = G4UImanager::GetUIpointer(); |
---|
121 | if( command == gammaCutCmd ) { |
---|
122 | if(pPhysicsList) { |
---|
123 | pPhysicsList->SetCutForGamma(gammaCutCmd->GetNewDoubleValue(newValue)); |
---|
124 | } else { |
---|
125 | UI->ApplyCommand("/run/setCutForAGivenParticle gamma " + newValue); |
---|
126 | } |
---|
127 | |
---|
128 | } else if( command == electCutCmd ) { |
---|
129 | if(pPhysicsList) { |
---|
130 | pPhysicsList->SetCutForElectron(electCutCmd->GetNewDoubleValue(newValue)); |
---|
131 | } else { |
---|
132 | UI->ApplyCommand("/run/setCutForAGivenParticle e- " + newValue); |
---|
133 | } |
---|
134 | |
---|
135 | } else if( command == posCutCmd ) { |
---|
136 | if(pPhysicsList) { |
---|
137 | pPhysicsList->SetCutForPositron(posCutCmd->GetNewDoubleValue(newValue)); |
---|
138 | } else { |
---|
139 | UI->ApplyCommand("/run/setCutForAGivenParticle e+ " + newValue); |
---|
140 | } |
---|
141 | |
---|
142 | } else if( command == pCutCmd ) { |
---|
143 | if(pPhysicsList) { |
---|
144 | pPhysicsList->SetCutForProton(pCutCmd->GetNewDoubleValue(newValue)); |
---|
145 | } else { |
---|
146 | UI->ApplyCommand("/run/setCutForAGivenParticle proton " + newValue); |
---|
147 | } |
---|
148 | |
---|
149 | } else if( command == allCutCmd ) { |
---|
150 | |
---|
151 | if(pPhysicsList) { |
---|
152 | G4double cut = allCutCmd->GetNewDoubleValue(newValue); |
---|
153 | pPhysicsList->SetCutForGamma(cut); |
---|
154 | pPhysicsList->SetCutForElectron(cut); |
---|
155 | pPhysicsList->SetCutForPositron(cut); |
---|
156 | pPhysicsList->SetCutForProton(cut); |
---|
157 | } else { |
---|
158 | UI->ApplyCommand("/run/setCut " + newValue); |
---|
159 | } |
---|
160 | |
---|
161 | } else if( command == pListCmd ) { |
---|
162 | if(pPhysicsList) { |
---|
163 | G4String name = newValue; |
---|
164 | if(name == "PHYSLIST") { |
---|
165 | char* path = getenv(name); |
---|
166 | if (path) name = G4String(path); |
---|
167 | else { |
---|
168 | G4cout << "### PhysicsListMessenger WARNING: " |
---|
169 | << " environment variable PHYSLIST is not defined" |
---|
170 | << G4endl; |
---|
171 | return; |
---|
172 | } |
---|
173 | } |
---|
174 | pPhysicsList->AddPhysicsList(name); |
---|
175 | } else { |
---|
176 | G4cout << "### PhysicsListMessenger WARNING: " |
---|
177 | << " /testhadr/Physics UI command is not available " |
---|
178 | << "for reference Physics List" << G4endl; |
---|
179 | } |
---|
180 | |
---|
181 | } else if( command == listCmd ) { |
---|
182 | if(pPhysicsList) { |
---|
183 | pPhysicsList->List(); |
---|
184 | } else { |
---|
185 | G4cout << "### PhysicsListMessenger WARNING: " |
---|
186 | << " /testhadr/ListPhysics UI command is not available " |
---|
187 | << "for reference Physics List" << G4endl; |
---|
188 | } |
---|
189 | } |
---|
190 | } |
---|
191 | |
---|
192 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|