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/DetectorMessenge << 26 // $Id: DetectorMessenger.cc,v 1.7 2007/05/16 11:43:30 vnivanch Exp $ 27 /// \brief Implementation of the DetectorMesse << 27 // GEANT4 tag $Name: geant4-09-02 $ 28 // << 29 // 28 // 30 ////////////////////////////////////////////// 29 ///////////////////////////////////////////////////////////////////////// 31 // 30 // 32 // DetectorMessenger 31 // DetectorMessenger 33 // 32 // 34 // Created: 31.01.03 V.Ivanchenko 33 // Created: 31.01.03 V.Ivanchenko 35 // 34 // 36 // Modified: 35 // Modified: 37 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchen << 36 // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) 38 // 16.11.2006 Add beamCmd (V.Ivanchenko) 37 // 16.11.2006 Add beamCmd (V.Ivanchenko) 39 // 38 // 40 ////////////////////////////////////////////// 39 //////////////////////////////////////////////////////////////////////// 41 // 40 // 42 41 43 #include "DetectorMessenger.hh" 42 #include "DetectorMessenger.hh" 44 43 45 #include "DetectorConstruction.hh" 44 #include "DetectorConstruction.hh" 46 #include "HistoManager.hh" << 45 #include "G4UIdirectory.hh" 47 << 48 #include "G4HadronicParameters.hh" << 49 #include "G4UIcmdWith3Vector.hh" << 50 #include "G4UIcmdWithABool.hh" 46 #include "G4UIcmdWithABool.hh" 51 #include "G4UIcmdWithADoubleAndUnit.hh" << 52 #include "G4UIcmdWithAString.hh" 47 #include "G4UIcmdWithAString.hh" 53 #include "G4UIcmdWithAnInteger.hh" 48 #include "G4UIcmdWithAnInteger.hh" >> 49 #include "G4UIcmdWith3Vector.hh" >> 50 #include "G4UIcmdWithADoubleAndUnit.hh" 54 #include "G4UIcmdWithoutParameter.hh" 51 #include "G4UIcmdWithoutParameter.hh" 55 #include "G4UIdirectory.hh" << 52 #include "HistoManager.hh" 56 53 57 //....oooOO0OOooo........oooOO0OOooo........oo 54 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 58 55 59 DetectorMessenger::DetectorMessenger(DetectorC << 56 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 60 : G4UImessenger(), << 57 :Detector(Det) 61 fDetector(Det), << 62 fTestDir(0), << 63 fMatCmd(0), << 64 fMat1Cmd(0), << 65 fRCmd(0), << 66 fLCmd(0), << 67 fEdepCmd(0), << 68 fBinCmd(0), << 69 fNOfAbsCmd(0), << 70 fVerbCmd(0), << 71 fBeamCmd(0) << 72 { 58 { 73 fTestDir = new G4UIdirectory("/testhadr/"); << 59 testDir = new G4UIdirectory("/testhadr/"); 74 fTestDir->SetGuidance(" Hadronic Extended Ex << 60 testDir->SetGuidance(" Hadronic Extended Example."); 75 61 76 fMatCmd = new G4UIcmdWithAString("/testhadr/ << 62 matCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this); 77 fMatCmd->SetGuidance("Select Material for th << 63 matCmd->SetGuidance("Select Material for the target"); 78 fMatCmd->SetParameterName("tMaterial", false << 64 matCmd->SetParameterName("tMaterial",false); 79 fMatCmd->AvailableForStates(G4State_PreInit, << 65 matCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 80 << 66 81 fMat1Cmd = new G4UIcmdWithAString("/testhadr << 67 mat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this); 82 fMat1Cmd->SetGuidance("Select Material for w << 68 mat1Cmd->SetGuidance("Select Material for world"); 83 fMat1Cmd->SetParameterName("wMaterial", fals << 69 mat1Cmd->SetParameterName("wMaterial",false); 84 fMat1Cmd->AvailableForStates(G4State_PreInit << 70 mat1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle); 85 << 71 86 fRCmd = new G4UIcmdWithADoubleAndUnit("/test << 72 rCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this); 87 fRCmd->SetGuidance("Set radius of the target << 73 rCmd->SetGuidance("Set radius of the target"); 88 fRCmd->SetParameterName("radius", false); << 74 rCmd->SetParameterName("radius",false); 89 fRCmd->SetUnitCategory("Length"); << 75 rCmd->SetUnitCategory("Length"); 90 fRCmd->SetRange("radius>0"); << 76 rCmd->SetRange("radius>0"); 91 fRCmd->AvailableForStates(G4State_PreInit); << 77 rCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 92 << 78 93 fLCmd = new G4UIcmdWithADoubleAndUnit("/test << 79 lCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this); 94 fLCmd->SetGuidance("Set length of the target << 80 lCmd->SetGuidance("Set length of the target"); 95 fLCmd->SetParameterName("length", false); << 81 lCmd->SetParameterName("length",false); 96 fLCmd->SetUnitCategory("Length"); << 82 lCmd->SetUnitCategory("Length"); 97 fLCmd->SetRange("length>0"); << 83 lCmd->SetRange("length>0"); 98 fLCmd->AvailableForStates(G4State_PreInit); << 84 lCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 99 << 85 100 fBinCmd = new G4UIcmdWithAnInteger("/testhad << 86 binCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE",this); 101 fBinCmd->SetGuidance("Set number of bins for << 87 binCmd->SetGuidance("Set number of bins for Energy"); 102 fBinCmd->SetParameterName("NEbins", false); << 88 binCmd->SetParameterName("NEbins",false); 103 fBinCmd->AvailableForStates(G4State_PreInit) << 89 binCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 104 << 90 105 fNOfAbsCmd = new G4UIcmdWithAnInteger("/test << 91 nOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ",this); 106 fNOfAbsCmd->SetGuidance("Set number of slice << 92 nOfAbsCmd->SetGuidance("Set number of slices"); 107 fNOfAbsCmd->SetParameterName("NZ", false); << 93 nOfAbsCmd->SetParameterName("NZ",false); 108 fNOfAbsCmd->AvailableForStates(G4State_PreIn << 94 nOfAbsCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 109 << 95 110 fEdepCmd = new G4UIcmdWithADoubleAndUnit("/t << 96 edepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep",this); 111 fEdepCmd->SetGuidance("Set max energy in his << 97 edepCmd->SetGuidance("Set max energy in histogram"); 112 fEdepCmd->SetParameterName("edep", false); << 98 edepCmd->SetParameterName("edep",false); 113 fEdepCmd->SetUnitCategory("Energy"); << 99 edepCmd->SetUnitCategory("Energy"); 114 fEdepCmd->SetRange("edep>0"); << 100 edepCmd->SetRange("edep>0"); 115 fEdepCmd->AvailableForStates(G4State_PreInit << 101 edepCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 116 << 102 117 fBeamCmd = new G4UIcmdWithABool("/testhadr/D << 103 updateCmd = new G4UIcmdWithoutParameter("/testhadr/Update",this); 118 fBeamCmd->SetGuidance("Use default beam posi << 104 updateCmd->SetGuidance("Update geometry."); 119 fBeamCmd->AvailableForStates(G4State_PreInit << 105 updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); 120 << 106 updateCmd->SetGuidance("if you changed geometrical value(s)"); 121 fVerbCmd = new G4UIcmdWithAnInteger("/testha << 107 updateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 122 fVerbCmd->SetGuidance("Set verbose for "); << 108 123 fVerbCmd->SetParameterName("verb", false); << 109 beamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition",this); 124 fVerbCmd->AvailableForStates(G4State_PreInit << 110 beamCmd->SetGuidance("show inelastic and elastic cross sections"); 125 << 111 126 fBertCmd = new G4UIcmdWithAnInteger("/testha << 112 verbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this); 127 fBertCmd->SetGuidance("Set printout of Berti << 113 verbCmd->SetGuidance("Set verbose for "); 128 fBertCmd->SetParameterName("bert", false); << 114 verbCmd->SetParameterName("verb",false); 129 fBertCmd->AvailableForStates(G4State_PreInit << 115 verbCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 130 << 131 fBCCmd = new G4UIcmdWithABool("/testhadr/BCP << 132 fBCCmd->SetGuidance("Enable b-, c- hadronic << 133 fBCCmd->SetParameterName("BCparticles", fals << 134 fBCCmd->AvailableForStates(G4State_PreInit); << 135 << 136 fHNCmd = new G4UIcmdWithABool("/testhadr/Hyp << 137 fHNCmd->SetGuidance("Enable hyper-nuclei had << 138 fHNCmd->SetParameterName("HyperNuclei", fals << 139 fHNCmd->AvailableForStates(G4State_PreInit); << 140 << 141 fNGPCmd = new G4UIcmdWithABool("/testhadr/Ne << 142 fNGPCmd->SetGuidance("Enable neutron general << 143 fNGPCmd->SetParameterName("NeutronGeneralPro << 144 fNGPCmd->AvailableForStates(G4State_PreInit) << 145 } 116 } 146 117 147 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 148 119 149 DetectorMessenger::~DetectorMessenger() 120 DetectorMessenger::~DetectorMessenger() 150 { 121 { 151 delete fMatCmd; << 122 delete matCmd; 152 delete fMat1Cmd; << 123 delete mat1Cmd; 153 delete fRCmd; << 124 delete rCmd; 154 delete fLCmd; << 125 delete lCmd; 155 delete fBinCmd; << 126 delete nOfAbsCmd; 156 delete fNOfAbsCmd; << 127 delete updateCmd; 157 delete fTestDir; << 128 delete testDir; 158 delete fBeamCmd; << 129 delete beamCmd; 159 delete fVerbCmd; << 130 delete verbCmd; 160 delete fBertCmd; << 131 delete edepCmd; 161 delete fEdepCmd; << 162 delete fBCCmd; << 163 delete fHNCmd; << 164 delete fNGPCmd; << 165 } 132 } 166 133 167 //....oooOO0OOooo........oooOO0OOooo........oo 134 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 168 135 169 void DetectorMessenger::SetNewValue(G4UIcomman 136 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 170 { 137 { 171 HistoManager* h = HistoManager::GetPointer() 138 HistoManager* h = HistoManager::GetPointer(); 172 if (command == fMatCmd) { << 139 if( command == matCmd ) 173 fDetector->SetTargetMaterial(newValue); << 140 Detector->SetTargetMaterial(newValue); 174 } << 141 else if( command == mat1Cmd ) 175 else if (command == fMat1Cmd) { << 142 Detector->SetWorldMaterial(newValue); 176 fDetector->SetWorldMaterial(newValue); << 143 else if( command == rCmd ) 177 } << 144 Detector->SetTargetRadius(rCmd->GetNewDoubleValue(newValue)); 178 else if (command == fRCmd) { << 145 else if( command == lCmd ) 179 h->SetTargetRadius(fRCmd->GetNewDoubleValu << 146 h->SetTargetLength(lCmd->GetNewDoubleValue(newValue)); 180 } << 147 else if( command == nOfAbsCmd ) 181 else if (command == fLCmd) { << 148 h->SetNumberOfSlices(nOfAbsCmd->GetNewIntValue(newValue)); 182 h->SetTargetLength(fLCmd->GetNewDoubleValu << 149 else if( command == binCmd ) 183 } << 150 h->SetNumberOfBinsE(binCmd->GetNewIntValue(newValue)); 184 else if (command == fNOfAbsCmd) { << 151 else if( command == verbCmd ) 185 h->SetNumberOfSlices(fNOfAbsCmd->GetNewInt << 152 h->SetVerbose(verbCmd->GetNewIntValue(newValue)); 186 } << 153 else if (command == beamCmd) 187 else if (command == fBinCmd) { << 154 h->SetDefaultBeamPositionFlag(beamCmd->GetNewBoolValue(newValue)); 188 h->SetNumberOfBinsE(fBinCmd->GetNewIntValu << 155 else if (command == edepCmd) 189 } << 156 h->SetMaxEnergyDeposit(edepCmd->GetNewDoubleValue(newValue)); 190 else if (command == fVerbCmd) { << 157 else if( command == updateCmd ) 191 h->SetVerbose(fVerbCmd->GetNewIntValue(new << 158 Detector->UpdateGeometry(); 192 } << 193 else if (command == fBertCmd) { << 194 h->SetPrintBertiniXS(fBertCmd->GetNewIntVa << 195 } << 196 else if (command == fBeamCmd) { << 197 h->SetDefaultBeamPositionFlag(fBeamCmd->Ge << 198 } << 199 else if (command == fEdepCmd) { << 200 h->SetMaxEnergyDeposit(fEdepCmd->GetNewDou << 201 } << 202 else if (command == fBCCmd) { << 203 G4HadronicParameters::Instance()->SetEnabl << 204 } << 205 else if (command == fHNCmd) { << 206 G4HadronicParameters::Instance()->SetEnabl << 207 } << 208 else if (command == fNGPCmd) { << 209 G4HadronicParameters::Instance()->SetEnabl << 210 fNGPCmd->GetNewBoolValue(newValue)); << 211 } << 212 } 159 } 213 160 214 //....oooOO0OOooo........oooOO0OOooo........oo 161 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 162 215 163