Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 /// \file hadronic/Hadr01/src/PhysicsListMesse 26 /// \file hadronic/Hadr01/src/PhysicsListMessenger.cc 27 /// \brief Implementation of the PhysicsListMe 27 /// \brief Implementation of the PhysicsListMessenger class 28 // 28 // 29 // 29 // >> 30 // $Id$ >> 31 // >> 32 // 30 ////////////////////////////////////////////// 33 ///////////////////////////////////////////////////////////////////////// 31 // 34 // 32 // PhysicsListMessenger 35 // PhysicsListMessenger 33 // 36 // 34 // Created: 31.01.2006 V.Ivanchenko 37 // Created: 31.01.2006 V.Ivanchenko 35 // 38 // 36 // Modified: 39 // Modified: 37 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchen 40 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko) 38 // 41 // 39 ////////////////////////////////////////////// 42 //////////////////////////////////////////////////////////////////////// 40 // 43 // 41 // << 44 // 42 45 43 #include "PhysicsListMessenger.hh" 46 #include "PhysicsListMessenger.hh" 44 47 45 #include "PhysicsList.hh" 48 #include "PhysicsList.hh" 46 << 49 #include "G4UIcmdWithADoubleAndUnit.hh" 47 #include "G4UIcmdWithAString.hh" 50 #include "G4UIcmdWithAString.hh" 48 #include "G4UIcmdWithoutParameter.hh" 51 #include "G4UIcmdWithoutParameter.hh" >> 52 #include "G4UImanager.hh" 49 53 50 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 51 55 52 PhysicsListMessenger::PhysicsListMessenger(Phy 56 PhysicsListMessenger::PhysicsListMessenger(PhysicsList* pPhys) 53 : G4UImessenger(), fPhysicsList(pPhys) << 57 :fPhysicsList(pPhys) 54 { << 58 { 55 fPListCmd = new G4UIcmdWithAString("/testhad << 59 fGammaCutCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/CutGamma",this); 56 fPListCmd->SetGuidance("Add modular physics << 60 fGammaCutCmd->SetGuidance("Set gamma cut."); 57 fPListCmd->SetParameterName("PList", false); << 61 fGammaCutCmd->SetParameterName("Gcut",false); >> 62 fGammaCutCmd->SetUnitCategory("Length"); >> 63 fGammaCutCmd->SetRange("Gcut>=0.0"); >> 64 fGammaCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 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"); >> 71 fElectCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 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"); >> 78 fPosCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 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"); >> 85 fCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 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"); >> 92 fAllCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 93 >> 94 fPListCmd = new G4UIcmdWithAString("/testhadr/Physics",this); >> 95 fPListCmd->SetGuidance("Add modula physics list."); >> 96 fPListCmd->SetParameterName("PList",false); 58 fPListCmd->AvailableForStates(G4State_PreIni 97 fPListCmd->AvailableForStates(G4State_PreInit); 59 98 60 fListCmd = new G4UIcmdWithoutParameter("/tes << 99 fListCmd = new G4UIcmdWithoutParameter("/testhadr/ListPhysics",this); 61 fListCmd->SetGuidance("Available Physics Lis 100 fListCmd->SetGuidance("Available Physics Lists"); 62 fListCmd->AvailableForStates(G4State_PreInit << 101 fListCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 102 63 } 103 } 64 104 65 //....oooOO0OOooo........oooOO0OOooo........oo 105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 66 106 67 PhysicsListMessenger::~PhysicsListMessenger() 107 PhysicsListMessenger::~PhysicsListMessenger() 68 { 108 { >> 109 delete fGammaCutCmd; >> 110 delete fElectCutCmd; >> 111 delete fPosCutCmd; >> 112 delete fCutCmd; >> 113 delete fAllCutCmd; 69 delete fPListCmd; 114 delete fPListCmd; 70 delete fListCmd; 115 delete fListCmd; 71 } 116 } 72 117 73 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 74 119 75 void PhysicsListMessenger::SetNewValue(G4UIcom 120 void PhysicsListMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 76 { 121 { 77 if (command == fPListCmd) { << 122 G4UImanager* UI = G4UImanager::GetUIpointer(); 78 if (fPhysicsList) { << 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) { 79 G4String name = newValue; 165 G4String name = newValue; 80 if (name == "PHYSLIST") { << 166 if(name == "PHYSLIST") { 81 char* path = std::getenv(name); << 167 char* path = getenv(name); 82 if (path) << 168 if (path) name = G4String(path); 83 name = G4String(path); << 84 else { 169 else { 85 G4cout << "### PhysicsListMessenger 170 G4cout << "### PhysicsListMessenger WARNING: " 86 << " environment variable PHY << 171 << " environment variable PHYSLIST is not defined" 87 return; << 172 << G4endl; >> 173 return; 88 } 174 } 89 } 175 } 90 fPhysicsList->AddPhysicsList(name); 176 fPhysicsList->AddPhysicsList(name); 91 } << 177 } else { 92 else { << 93 G4cout << "### PhysicsListMessenger WARN 178 G4cout << "### PhysicsListMessenger WARNING: " 94 << " /testhadr/Physics UI command 179 << " /testhadr/Physics UI command is not available " 95 << "for reference Physics List" < 180 << "for reference Physics List" << G4endl; 96 } 181 } 97 } << 182 98 else if (command == fListCmd) { << 183 } else if( command == fListCmd ) { 99 if (fPhysicsList) { << 184 if(fPhysicsList) { 100 fPhysicsList->List(); 185 fPhysicsList->List(); 101 } << 186 } else { 102 else { << 103 G4cout << "### PhysicsListMessenger WARN 187 G4cout << "### PhysicsListMessenger WARNING: " 104 << " /testhadr/ListPhysics UI com 188 << " /testhadr/ListPhysics UI command is not available " 105 << "for reference Physics List" < 189 << "for reference Physics List" << G4endl; 106 } 190 } 107 } 191 } 108 } 192 } 109 193 110 //....oooOO0OOooo........oooOO0OOooo........oo 194 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 111 195