Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 //
30 // $Id$
31 //
32 //
34 //
35 // PhysicsListMessenger
36 //
37 // Created: 31.01.2006 V.Ivanchenko
38 //
39 // Modified:
40 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
41 //
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 :fPhysicsList(pPhys)
58 {
59  fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutGamma",this);
60  fGammaCutCmd->SetGuidance("Set gamma cut.");
61  fGammaCutCmd->SetParameterName("Gcut",false);
62  fGammaCutCmd->SetUnitCategory("Length");
63  fGammaCutCmd->SetRange("Gcut>=0.0");
65 
66  fElectCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutEl",this);
67  fElectCutCmd->SetGuidance("Set electron cut.");
68  fElectCutCmd->SetParameterName("Ecut",false);
69  fElectCutCmd->SetUnitCategory("Length");
70  fElectCutCmd->SetRange("Ecut>=0.0");
72 
73  fPosCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutPos",this);
74  fPosCutCmd->SetGuidance("Set positron cut.");
75  fPosCutCmd->SetParameterName("Pcut",false);
76  fPosCutCmd->SetUnitCategory("Length");
77  fPosCutCmd->SetRange("Pcut>=0.0");
79 
80  fCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutProt",this);
81  fCutCmd->SetGuidance("Set proton cut.");
82  fCutCmd->SetParameterName("ProtCut",false);
83  fCutCmd->SetUnitCategory("Length");
84  fCutCmd->SetRange("ProtCut>=0.0");
86 
87  fAllCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutsAll",this);
88  fAllCutCmd->SetGuidance("Set cut for all.");
89  fAllCutCmd->SetParameterName("cut",false);
90  fAllCutCmd->SetUnitCategory("Length");
91  fAllCutCmd->SetRange("cut>=0.0");
93 
94  fPListCmd = new G4UIcmdWithAString("/testhadr/Physics",this);
95  fPListCmd->SetGuidance("Add modula physics list.");
96  fPListCmd->SetParameterName("PList",false);
98 
99  fListCmd = new G4UIcmdWithoutParameter("/testhadr/ListPhysics",this);
100  fListCmd->SetGuidance("Available Physics Lists");
102 
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  delete fGammaCutCmd;
110  delete fElectCutCmd;
111  delete fPosCutCmd;
112  delete fCutCmd;
113  delete fAllCutCmd;
114  delete fPListCmd;
115  delete fListCmd;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
121 {
123  if( command == fGammaCutCmd ) {
124  if(fPhysicsList) {
125  fPhysicsList->SetCutForGamma(fGammaCutCmd->GetNewDoubleValue(newValue));
126  } else {
127  UI->ApplyCommand("/run/setCutForAGivenParticle gamma " + newValue);
128  }
129 
130  } else if( command == fElectCutCmd ) {
131  if(fPhysicsList) {
132  fPhysicsList->SetCutForElectron(fElectCutCmd->GetNewDoubleValue(newValue));
133  } else {
134  UI->ApplyCommand("/run/setCutForAGivenParticle e- " + newValue);
135  }
136 
137  } else if( command == fPosCutCmd ) {
138  if(fPhysicsList) {
139  fPhysicsList->SetCutForPositron(fPosCutCmd->GetNewDoubleValue(newValue));
140  } else {
141  UI->ApplyCommand("/run/setCutForAGivenParticle e+ " + newValue);
142  }
143 
144  } else if( command == fCutCmd ) {
145  if(fPhysicsList) {
146  fPhysicsList->SetCutForProton(fCutCmd->GetNewDoubleValue(newValue));
147  } else {
148  UI->ApplyCommand("/run/setCutForAGivenParticle proton " + newValue);
149  }
150 
151  } else if( command == fAllCutCmd ) {
152 
153  if(fPhysicsList) {
154  G4double cut = fAllCutCmd->GetNewDoubleValue(newValue);
155  fPhysicsList->SetCutForGamma(cut);
156  fPhysicsList->SetCutForElectron(cut);
157  fPhysicsList->SetCutForPositron(cut);
158  fPhysicsList->SetCutForProton(cut);
159  } else {
160  UI->ApplyCommand("/run/setCut " + newValue);
161  }
162 
163  } else if( command == fPListCmd ) {
164  if(fPhysicsList) {
165  G4String name = newValue;
166  if(name == "PHYSLIST") {
167  char* path = getenv(name);
168  if (path) name = G4String(path);
169  else {
170  G4cout << "### PhysicsListMessenger WARNING: "
171  << " environment variable PHYSLIST is not defined"
172  << G4endl;
173  return;
174  }
175  }
176  fPhysicsList->AddPhysicsList(name);
177  } else {
178  G4cout << "### PhysicsListMessenger WARNING: "
179  << " /testhadr/Physics UI command is not available "
180  << "for reference Physics List" << G4endl;
181  }
182 
183  } else if( command == fListCmd ) {
184  if(fPhysicsList) {
185  fPhysicsList->List();
186  } else {
187  G4cout << "### PhysicsListMessenger WARNING: "
188  << " /testhadr/ListPhysics UI command is not available "
189  << "for reference Physics List" << G4endl;
190  }
191  }
192 }
193 
194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......