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 electromagnetic/TestEm7/src/Detector << 26 // $Id: DetectorMessenger.cc,v 1.3 2006/06/29 16:58:13 gunter Exp $ 27 /// \brief Implementation of the DetectorMesse << 27 // GEANT4 tag $Name: geant4-09-02-patch-04 $ 28 // << 29 // 28 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 31 33 #include "DetectorMessenger.hh" 32 #include "DetectorMessenger.hh" 34 33 35 #include "DetectorConstruction.hh" 34 #include "DetectorConstruction.hh" 36 << 35 #include "G4UIdirectory.hh" 37 #include "G4UIcmdWithADoubleAndUnit.hh" << 38 #include "G4UIcmdWithAString.hh" 36 #include "G4UIcmdWithAString.hh" 39 #include "G4UIcmdWithAnInteger.hh" << 37 #include "G4UIcmdWithADoubleAndUnit.hh" >> 38 #include "G4UIcmdWith3VectorAndUnit.hh" 40 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 41 #include "G4UIcommand.hh" << 42 #include "G4UIdirectory.hh" << 43 #include "G4UIparameter.hh" << 44 40 45 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 42 47 DetectorMessenger::DetectorMessenger(DetectorC << 43 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 48 : G4UImessenger(), << 44 :Detector(Det) 49 fDetector(Det), << 45 { 50 fTestemDir(nullptr), << 46 testemDir = new G4UIdirectory("/testem/"); 51 fDetDir(nullptr), << 47 testemDir->SetGuidance(" detector control."); 52 fMaterCmd(nullptr), << 48 53 fWMaterCmd(nullptr), << 49 detDir = new G4UIdirectory("/testem/det/"); 54 fSizeXCmd(nullptr), << 50 detDir->SetGuidance("detector construction commands"); 55 fSizeYZCmd(nullptr), << 51 56 fMagFieldCmd(nullptr), << 52 MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this); 57 fTalNbCmd(nullptr), << 53 MaterCmd->SetGuidance("Select material of the box."); 58 fTalDefCmd(nullptr), << 54 MaterCmd->SetParameterName("choice",false); 59 fTalPosiCmd(nullptr) << 55 MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 60 { << 56 61 fTestemDir = new G4UIdirectory("/testem/"); << 57 SizeXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeX",this); 62 fTestemDir->SetGuidance(" detector control." << 58 SizeXCmd->SetGuidance("Set sizeX of the absorber"); 63 << 59 SizeXCmd->SetParameterName("SizeX",false); 64 fDetDir = new G4UIdirectory("/testem/det/"); << 60 SizeXCmd->SetRange("SizeX>0."); 65 fDetDir->SetGuidance("detector construction << 61 SizeXCmd->SetUnitCategory("Length"); 66 << 62 SizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 67 fMaterCmd = new G4UIcmdWithAString("/testem/ << 63 68 fMaterCmd->SetGuidance("Select material of t << 64 SizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this); 69 fMaterCmd->SetParameterName("choice", false) << 65 SizeYZCmd->SetGuidance("Set sizeYZ of the absorber"); 70 fMaterCmd->AvailableForStates(G4State_PreIni << 66 SizeYZCmd->SetParameterName("SizeYZ",false); 71 << 67 SizeYZCmd->SetRange("SizeYZ>0."); 72 fWMaterCmd = new G4UIcmdWithAString("/testem << 68 SizeYZCmd->SetUnitCategory("Length"); 73 fWMaterCmd->SetGuidance("Select material of << 69 SizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 74 fWMaterCmd->SetParameterName("choice", false << 70 75 fWMaterCmd->AvailableForStates(G4State_PreIn << 71 MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); 76 << 72 MagFieldCmd->SetGuidance("Define magnetic field."); 77 fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/ << 73 MagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); 78 fSizeXCmd->SetGuidance("Set sizeX of the abs << 74 MagFieldCmd->SetParameterName("Bz",false); 79 fSizeXCmd->SetParameterName("SizeX", false); << 75 MagFieldCmd->SetUnitCategory("Magnetic flux density"); 80 fSizeXCmd->SetRange("SizeX>0."); << 76 MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 81 fSizeXCmd->SetUnitCategory("Length"); << 77 82 fSizeXCmd->AvailableForStates(G4State_PreIni << 78 TalMateCmd = new G4UIcmdWithAString("/testem/det/tallyMat",this); 83 << 79 TalMateCmd->SetGuidance("Select material of the tallies."); 84 fSizeYZCmd = new G4UIcmdWithADoubleAndUnit(" << 80 TalMateCmd->SetParameterName("choice",false); 85 fSizeYZCmd->SetGuidance("Set sizeYZ of the a << 81 TalMateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 86 fSizeYZCmd->SetParameterName("SizeYZ", false << 82 87 fSizeYZCmd->SetRange("SizeYZ>0."); << 83 TalSizeCmd = new G4UIcmdWith3VectorAndUnit("/testem/det/tallySize",this); 88 fSizeYZCmd->SetUnitCategory("Length"); << 84 TalSizeCmd->SetGuidance("Set size of tally"); 89 fSizeYZCmd->AvailableForStates(G4State_PreIn << 85 TalSizeCmd->SetParameterName("sizeX","sizeY","sizeZ",false,false); 90 << 86 TalSizeCmd->SetUnitCategory("Length"); 91 fMagFieldCmd = new G4UIcmdWithADoubleAndUnit << 87 TalSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 92 fMagFieldCmd->SetGuidance("Define magnetic f << 88 93 fMagFieldCmd->SetGuidance("Magnetic field wi << 89 TalPosiCmd = new G4UIcmdWith3VectorAndUnit("/testem/det/tallyPosition",this); 94 fMagFieldCmd->SetParameterName("Bz", false); << 90 TalPosiCmd->SetGuidance("Set position of tallies"); 95 fMagFieldCmd->SetUnitCategory("Magnetic flux << 91 TalPosiCmd->SetParameterName("Xc","Yc","Zc",false,false); 96 fMagFieldCmd->AvailableForStates(G4State_Pre << 92 TalPosiCmd->SetUnitCategory("Length"); 97 << 93 TalPosiCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 98 fTalNbCmd = new G4UIcmdWithAnInteger("/teste << 94 99 fTalNbCmd->SetGuidance("Set number of fTalli << 95 UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this); 100 fTalNbCmd->SetParameterName("tallyNb", false << 96 UpdateCmd->SetGuidance("Update calorimeter geometry."); 101 fTalNbCmd->SetRange("tallyNb>=0"); << 97 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); 102 fTalNbCmd->AvailableForStates(G4State_PreIni << 98 UpdateCmd->SetGuidance("if you changed geometrical value(s)."); 103 << 99 UpdateCmd->AvailableForStates(G4State_Idle); 104 fTalDefCmd = new G4UIcommand("/testem/det/ta << 105 fTalDefCmd->SetGuidance("Set tally nb, box d << 106 fTalDefCmd->SetGuidance(" tally number : fr << 107 fTalDefCmd->SetGuidance(" material name"); << 108 fTalDefCmd->SetGuidance(" dimensions (3-vec << 109 // << 110 G4UIparameter* fTalNbPrm = new G4UIparameter << 111 fTalNbPrm->SetGuidance("tally number : from << 112 fTalNbPrm->SetParameterRange("tallyNb>=0"); << 113 fTalDefCmd->SetParameter(fTalNbPrm); << 114 // << 115 G4UIparameter* SizeXPrm = new G4UIparameter( << 116 SizeXPrm->SetGuidance("sizeX"); << 117 SizeXPrm->SetParameterRange("sizeX>0."); << 118 fTalDefCmd->SetParameter(SizeXPrm); << 119 // << 120 G4UIparameter* SizeYPrm = new G4UIparameter( << 121 SizeYPrm->SetGuidance("sizeY"); << 122 SizeYPrm->SetParameterRange("sizeY>0."); << 123 fTalDefCmd->SetParameter(SizeYPrm); << 124 // << 125 G4UIparameter* SizeZPrm = new G4UIparameter( << 126 SizeZPrm->SetGuidance("sizeZ"); << 127 SizeZPrm->SetParameterRange("sizeZ>0."); << 128 fTalDefCmd->SetParameter(SizeZPrm); << 129 // << 130 G4UIparameter* unitPrm = new G4UIparameter(" << 131 unitPrm->SetGuidance("unit of dimensions"); << 132 G4String unitList = G4UIcommand::UnitsList(G << 133 unitPrm->SetParameterCandidates(unitList); << 134 fTalDefCmd->SetParameter(unitPrm); << 135 // << 136 fTalDefCmd->AvailableForStates(G4State_PreIn << 137 << 138 fTalPosiCmd = new G4UIcommand("/testem/det/t << 139 fTalPosiCmd->SetGuidance("Set tally nb, posi << 140 fTalPosiCmd->SetGuidance(" tally number : f << 141 fTalPosiCmd->SetGuidance(" position (3-vect << 142 // << 143 G4UIparameter* fTalNumPrm = new G4UIparamete << 144 fTalNumPrm->SetGuidance("tally number : from << 145 fTalNumPrm->SetParameterRange("tallyNum>=0") << 146 fTalPosiCmd->SetParameter(fTalNumPrm); << 147 // << 148 G4UIparameter* PosiXPrm = new G4UIparameter( << 149 PosiXPrm->SetGuidance("position X"); << 150 fTalPosiCmd->SetParameter(PosiXPrm); << 151 // << 152 G4UIparameter* PosiYPrm = new G4UIparameter( << 153 PosiYPrm->SetGuidance("position Y"); << 154 fTalPosiCmd->SetParameter(PosiYPrm); << 155 // << 156 G4UIparameter* PosiZPrm = new G4UIparameter( << 157 PosiZPrm->SetGuidance("position Z"); << 158 fTalPosiCmd->SetParameter(PosiZPrm); << 159 // << 160 G4UIparameter* unitPr = new G4UIparameter("u << 161 unitPr->SetGuidance("unit of position"); << 162 unitPr->SetParameterCandidates(unitList); << 163 fTalPosiCmd->SetParameter(unitPr); << 164 // << 165 fTalPosiCmd->AvailableForStates(G4State_PreI << 166 } 100 } 167 101 168 //....oooOO0OOooo........oooOO0OOooo........oo 102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 169 103 170 DetectorMessenger::~DetectorMessenger() 104 DetectorMessenger::~DetectorMessenger() 171 { 105 { 172 delete fMaterCmd; << 106 delete MaterCmd; 173 delete fWMaterCmd; << 107 delete SizeXCmd; 174 delete fSizeXCmd; << 108 delete SizeYZCmd; 175 delete fSizeYZCmd; << 109 delete MagFieldCmd; 176 delete fMagFieldCmd; << 110 delete TalMateCmd; 177 delete fTalNbCmd; << 111 delete TalSizeCmd; 178 delete fTalDefCmd; << 112 delete TalPosiCmd; 179 delete fTalPosiCmd; << 113 delete UpdateCmd; 180 delete fDetDir; << 114 delete detDir; 181 delete fTestemDir; << 115 delete testemDir; 182 } 116 } 183 117 184 //....oooOO0OOooo........oooOO0OOooo........oo 118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 185 119 186 void DetectorMessenger::SetNewValue(G4UIcomman << 120 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 187 { << 121 { 188 if (command == fMaterCmd) { << 122 if( command == MaterCmd ) 189 fDetector->SetMaterial(newValue); << 123 { Detector->SetMaterial(newValue);} 190 } << 124 191 << 125 if( command == SizeXCmd ) 192 if (command == fWMaterCmd) { << 126 { Detector->SetSizeX(SizeXCmd->GetNewDoubleValue(newValue));} 193 fDetector->SetWorldMaterial(newValue); << 127 194 } << 128 if( command == SizeYZCmd ) 195 << 129 { Detector->SetSizeYZ(SizeYZCmd->GetNewDoubleValue(newValue));} 196 if (command == fSizeXCmd) { << 130 197 fDetector->SetSizeX(fSizeXCmd->GetNewDoubl << 131 if( command == MagFieldCmd ) 198 } << 132 { Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));} 199 << 133 200 if (command == fSizeYZCmd) { << 134 if( command == TalMateCmd ) 201 fDetector->SetSizeYZ(fSizeYZCmd->GetNewDou << 135 { Detector->SetTallyMaterial(newValue);} 202 } << 136 203 << 137 if( command == TalSizeCmd ) 204 if (command == fMagFieldCmd) { << 138 { Detector->SetTallySize(TalSizeCmd->GetNew3VectorValue(newValue));} 205 fDetector->SetMagField(fMagFieldCmd->GetNe << 139 206 } << 140 if( command == TalPosiCmd ) 207 << 141 { Detector->SetTallyPosition(TalPosiCmd->GetNew3VectorValue(newValue));} 208 if (command == fTalNbCmd) { << 142 209 fDetector->SetTallyNumber(fTalNbCmd->GetNe << 143 if( command == UpdateCmd ) 210 } << 144 { Detector->UpdateGeometry();} 211 << 212 if (command == fTalDefCmd) { << 213 G4int num; << 214 G4double v1, v2, v3; << 215 G4String unt; << 216 std::istringstream is(newValue); << 217 is >> num >> v1 >> v2 >> v3 >> unt; << 218 G4ThreeVector vec(v1, v2, v3); << 219 vec *= G4UIcommand::ValueOf(unt); << 220 fDetector->SetTallySize(num, vec); << 221 } << 222 << 223 if (command == fTalPosiCmd) { << 224 G4int num; << 225 G4double v1, v2, v3; << 226 G4String unt; << 227 std::istringstream is(newValue); << 228 is >> num >> v1 >> v2 >> v3 >> unt; << 229 G4ThreeVector vec(v1, v2, v3); << 230 vec *= G4UIcommand::ValueOf(unt); << 231 fDetector->SetTallyPosition(num, vec); << 232 } << 233 } 145 } 234 146 235 //....oooOO0OOooo........oooOO0OOooo........oo 147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 236 148