Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/hadronic/Hadr01/src/PhysicsListMessenger.cc
Go to the documentation of this file.
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 /// \file hadronic/Hadr01/src/PhysicsListMessenger.cc
27 /// \brief Implementation of the PhysicsListMessenger class
28 //
29 //
30 // $Id: PhysicsListMessenger.cc 70761 2013-06-05 12:30:51Z gcosmo $
31 //
32 //
33 /////////////////////////////////////////////////////////////////////////
34 //
35 // PhysicsListMessenger
36 //
37 // Created: 31.01.2006 V.Ivanchenko
38 //
39 // Modified:
40 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
41 //
42 ////////////////////////////////////////////////////////////////////////
43 //
44 //
45 
46 #include "PhysicsListMessenger.hh"
47 
48 #include "PhysicsList.hh"
50 #include "G4UIcmdWithAString.hh"
52 #include "G4UImanager.hh"
53 
54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 
57 :G4UImessenger(), fPhysicsList(pPhys),
58  fGammaCutCmd(0), fElectCutCmd(0), fPosCutCmd(0), fCutCmd(0), fAllCutCmd(0),
59  fPListCmd(0), fListCmd(0)
60 {
61  fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutGamma",this);
62  fGammaCutCmd->SetGuidance("Set gamma cut.");
63  fGammaCutCmd->SetParameterName("Gcut",false);
64  fGammaCutCmd->SetUnitCategory("Length");
65  fGammaCutCmd->SetRange("Gcut>=0.0");
67 
68  fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutEl",this);
69  fElectCutCmd->SetGuidance("Set electron cut.");
70  fElectCutCmd->SetParameterName("Ecut",false);
71  fElectCutCmd->SetUnitCategory("Length");
72  fElectCutCmd->SetRange("Ecut>=0.0");
74 
75  fPosCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutPos",this);
76  fPosCutCmd->SetGuidance("Set positron cut.");
77  fPosCutCmd->SetParameterName("Pcut",false);
78  fPosCutCmd->SetUnitCategory("Length");
79  fPosCutCmd->SetRange("Pcut>=0.0");
81 
82  fCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutProt",this);
83  fCutCmd->SetGuidance("Set proton cut.");
84  fCutCmd->SetParameterName("ProtCut",false);
85  fCutCmd->SetUnitCategory("Length");
86  fCutCmd->SetRange("ProtCut>=0.0");
88 
89  fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutsAll",this);
90  fAllCutCmd->SetGuidance("Set cut for all.");
91  fAllCutCmd->SetParameterName("cut",false);
92  fAllCutCmd->SetUnitCategory("Length");
93  fAllCutCmd->SetRange("cut>=0.0");
95 
96  fPListCmd = new G4UIcmdWithAString("/testhadr/Physics",this);
97  fPListCmd->SetGuidance("Add modula physics list.");
98  fPListCmd->SetParameterName("PList",false);
100 
101  fListCmd = new G4UIcmdWithoutParameter("/testhadr/ListPhysics",this);
102  fListCmd->SetGuidance("Available Physics Lists");
104 
105 }
106 
107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
108 
110 {
111  delete fGammaCutCmd;
112  delete fElectCutCmd;
113  delete fPosCutCmd;
114  delete fCutCmd;
115  delete fAllCutCmd;
116  delete fPListCmd;
117  delete fListCmd;
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
125  if( command == fGammaCutCmd ) {
126  if(fPhysicsList) {
127  fPhysicsList->SetCutForGamma(fGammaCutCmd->GetNewDoubleValue(newValue));
128  } else {
129  UI->ApplyCommand("/run/setCutForAGivenParticle gamma " + newValue);
130  }
131 
132  } else if( command == fElectCutCmd ) {
133  if(fPhysicsList) {
134  fPhysicsList->SetCutForElectron(
135  fElectCutCmd->GetNewDoubleValue(newValue));
136  } else {
137  UI->ApplyCommand("/run/setCutForAGivenParticle e- " + newValue);
138  }
139 
140  } else if( command == fPosCutCmd ) {
141  if(fPhysicsList) {
142  fPhysicsList->SetCutForPositron(fPosCutCmd->GetNewDoubleValue(newValue));
143  } else {
144  UI->ApplyCommand("/run/setCutForAGivenParticle e+ " + newValue);
145  }
146 
147  } else if( command == fCutCmd ) {
148  if(fPhysicsList) {
149  fPhysicsList->SetCutForProton(fCutCmd->GetNewDoubleValue(newValue));
150  } else {
151  UI->ApplyCommand("/run/setCutForAGivenParticle proton " + newValue);
152  }
153 
154  } else if( command == fAllCutCmd ) {
155 
156  if(fPhysicsList) {
157  G4double cut = fAllCutCmd->GetNewDoubleValue(newValue);
158  fPhysicsList->SetCutForGamma(cut);
159  fPhysicsList->SetCutForElectron(cut);
160  fPhysicsList->SetCutForPositron(cut);
161  fPhysicsList->SetCutForProton(cut);
162  } else {
163  UI->ApplyCommand("/run/setCut " + newValue);
164  }
165 
166  } else if( command == fPListCmd ) {
167  if(fPhysicsList) {
168  G4String name = newValue;
169  if(name == "PHYSLIST") {
170  char* path = getenv(name);
171  if (path) name = G4String(path);
172  else {
173  G4cout << "### PhysicsListMessenger WARNING: "
174  << " environment variable PHYSLIST is not defined"
175  << G4endl;
176  return;
177  }
178  }
179  fPhysicsList->AddPhysicsList(name);
180  } else {
181  G4cout << "### PhysicsListMessenger WARNING: "
182  << " /testhadr/Physics UI command is not available "
183  << "for reference Physics List" << G4endl;
184  }
185 
186  } else if( command == fListCmd ) {
187  if(fPhysicsList) {
188  fPhysicsList->List();
189  } else {
190  G4cout << "### PhysicsListMessenger WARNING: "
191  << " /testhadr/ListPhysics UI command is not available "
192  << "for reference Physics List" << G4endl;
193  }
194  }
195 }
196 
197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
const XML_Char * name
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
static G4UImanager * GetUIpointer()
Definition: G4UImanager.cc:58
G4GLOB_DLL std::ostream G4cout
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4int ApplyCommand(const char *aCommand)
Definition: G4UImanager.cc:419