Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 /// \file electromagnetic/TestEm7/src/Detector << 23 // $Id: DetectorMessenger.cc,v 1.2 2004/09/27 14:42:26 maire Exp $ 27 /// \brief Implementation of the DetectorMesse << 24 // GEANT4 tag $Name: geant4-07-00-patch-01 $ 28 // << 29 // 25 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 26 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 27 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 28 33 #include "DetectorMessenger.hh" 29 #include "DetectorMessenger.hh" 34 30 35 #include "DetectorConstruction.hh" 31 #include "DetectorConstruction.hh" 36 << 32 #include "G4UIdirectory.hh" 37 #include "G4UIcmdWithADoubleAndUnit.hh" << 38 #include "G4UIcmdWithAString.hh" 33 #include "G4UIcmdWithAString.hh" 39 #include "G4UIcmdWithAnInteger.hh" << 34 #include "G4UIcmdWithADoubleAndUnit.hh" >> 35 #include "G4UIcmdWith3VectorAndUnit.hh" 40 #include "G4UIcmdWithoutParameter.hh" 36 #include "G4UIcmdWithoutParameter.hh" 41 #include "G4UIcommand.hh" << 42 #include "G4UIdirectory.hh" << 43 #include "G4UIparameter.hh" << 44 37 45 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 46 39 47 DetectorMessenger::DetectorMessenger(DetectorC << 40 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 48 : G4UImessenger(), << 41 :Detector(Det) 49 fDetector(Det), << 42 { 50 fTestemDir(nullptr), << 43 testemDir = new G4UIdirectory("/testem/"); 51 fDetDir(nullptr), << 44 testemDir->SetGuidance(" detector control."); 52 fMaterCmd(nullptr), << 45 53 fWMaterCmd(nullptr), << 46 detDir = new G4UIdirectory("/testem/det/"); 54 fSizeXCmd(nullptr), << 47 detDir->SetGuidance("detector construction commands"); 55 fSizeYZCmd(nullptr), << 48 56 fMagFieldCmd(nullptr), << 49 MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this); 57 fTalNbCmd(nullptr), << 50 MaterCmd->SetGuidance("Select material of the box."); 58 fTalDefCmd(nullptr), << 51 MaterCmd->SetParameterName("choice",false); 59 fTalPosiCmd(nullptr) << 52 MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 60 { << 53 61 fTestemDir = new G4UIdirectory("/testem/"); << 54 SizeXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeX",this); 62 fTestemDir->SetGuidance(" detector control." << 55 SizeXCmd->SetGuidance("Set sizeX of the absorber"); 63 << 56 SizeXCmd->SetParameterName("SizeX",false); 64 fDetDir = new G4UIdirectory("/testem/det/"); << 57 SizeXCmd->SetRange("SizeX>0."); 65 fDetDir->SetGuidance("detector construction << 58 SizeXCmd->SetUnitCategory("Length"); 66 << 59 SizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 67 fMaterCmd = new G4UIcmdWithAString("/testem/ << 60 68 fMaterCmd->SetGuidance("Select material of t << 61 SizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this); 69 fMaterCmd->SetParameterName("choice", false) << 62 SizeYZCmd->SetGuidance("Set sizeYZ of the absorber"); 70 fMaterCmd->AvailableForStates(G4State_PreIni << 63 SizeYZCmd->SetParameterName("SizeYZ",false); 71 << 64 SizeYZCmd->SetRange("SizeYZ>0."); 72 fWMaterCmd = new G4UIcmdWithAString("/testem << 65 SizeYZCmd->SetUnitCategory("Length"); 73 fWMaterCmd->SetGuidance("Select material of << 66 SizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 74 fWMaterCmd->SetParameterName("choice", false << 67 75 fWMaterCmd->AvailableForStates(G4State_PreIn << 68 MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); 76 << 69 MagFieldCmd->SetGuidance("Define magnetic field."); 77 fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/ << 70 MagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); 78 fSizeXCmd->SetGuidance("Set sizeX of the abs << 71 MagFieldCmd->SetParameterName("Bz",false); 79 fSizeXCmd->SetParameterName("SizeX", false); << 72 MagFieldCmd->SetUnitCategory("Magnetic flux density"); 80 fSizeXCmd->SetRange("SizeX>0."); << 73 MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 81 fSizeXCmd->SetUnitCategory("Length"); << 74 82 fSizeXCmd->AvailableForStates(G4State_PreIni << 75 TalMateCmd = new G4UIcmdWithAString("/testem/det/tallyMat",this); 83 << 76 TalMateCmd->SetGuidance("Select material of the tallies."); 84 fSizeYZCmd = new G4UIcmdWithADoubleAndUnit(" << 77 TalMateCmd->SetParameterName("choice",false); 85 fSizeYZCmd->SetGuidance("Set sizeYZ of the a << 78 TalMateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 86 fSizeYZCmd->SetParameterName("SizeYZ", false << 79 87 fSizeYZCmd->SetRange("SizeYZ>0."); << 80 TalSizeCmd = new G4UIcmdWith3VectorAndUnit("/testem/det/tallySize",this); 88 fSizeYZCmd->SetUnitCategory("Length"); << 81 TalSizeCmd->SetGuidance("Set size of tally"); 89 fSizeYZCmd->AvailableForStates(G4State_PreIn << 82 TalSizeCmd->SetParameterName("sizeX","sizeY","sizeZ",false,false); 90 << 83 TalSizeCmd->SetUnitCategory("Length"); 91 fMagFieldCmd = new G4UIcmdWithADoubleAndUnit << 84 TalSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 92 fMagFieldCmd->SetGuidance("Define magnetic f << 85 93 fMagFieldCmd->SetGuidance("Magnetic field wi << 86 TalPosiCmd = new G4UIcmdWith3VectorAndUnit("/testem/det/tallyPosition",this); 94 fMagFieldCmd->SetParameterName("Bz", false); << 87 TalPosiCmd->SetGuidance("Set position of tallies"); 95 fMagFieldCmd->SetUnitCategory("Magnetic flux << 88 TalPosiCmd->SetParameterName("Xc","Yc","Zc",false,false); 96 fMagFieldCmd->AvailableForStates(G4State_Pre << 89 TalPosiCmd->SetUnitCategory("Length"); 97 << 90 TalPosiCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 98 fTalNbCmd = new G4UIcmdWithAnInteger("/teste << 91 99 fTalNbCmd->SetGuidance("Set number of fTalli << 92 UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this); 100 fTalNbCmd->SetParameterName("tallyNb", false << 93 UpdateCmd->SetGuidance("Update calorimeter geometry."); 101 fTalNbCmd->SetRange("tallyNb>=0"); << 94 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); 102 fTalNbCmd->AvailableForStates(G4State_PreIni << 95 UpdateCmd->SetGuidance("if you changed geometrical value(s)."); 103 << 96 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 } 97 } 167 98 168 //....oooOO0OOooo........oooOO0OOooo........oo 99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 169 100 170 DetectorMessenger::~DetectorMessenger() 101 DetectorMessenger::~DetectorMessenger() 171 { 102 { 172 delete fMaterCmd; << 103 delete MaterCmd; 173 delete fWMaterCmd; << 104 delete SizeXCmd; 174 delete fSizeXCmd; << 105 delete SizeYZCmd; 175 delete fSizeYZCmd; << 106 delete MagFieldCmd; 176 delete fMagFieldCmd; << 107 delete TalMateCmd; 177 delete fTalNbCmd; << 108 delete TalSizeCmd; 178 delete fTalDefCmd; << 109 delete TalPosiCmd; 179 delete fTalPosiCmd; << 110 delete UpdateCmd; 180 delete fDetDir; << 111 delete detDir; 181 delete fTestemDir; << 112 delete testemDir; 182 } 113 } 183 114 184 //....oooOO0OOooo........oooOO0OOooo........oo 115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 185 116 186 void DetectorMessenger::SetNewValue(G4UIcomman << 117 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 187 { << 118 { 188 if (command == fMaterCmd) { << 119 if( command == MaterCmd ) 189 fDetector->SetMaterial(newValue); << 120 { Detector->SetMaterial(newValue);} 190 } << 121 191 << 122 if( command == SizeXCmd ) 192 if (command == fWMaterCmd) { << 123 { Detector->SetSizeX(SizeXCmd->GetNewDoubleValue(newValue));} 193 fDetector->SetWorldMaterial(newValue); << 124 194 } << 125 if( command == SizeYZCmd ) 195 << 126 { Detector->SetSizeYZ(SizeYZCmd->GetNewDoubleValue(newValue));} 196 if (command == fSizeXCmd) { << 127 197 fDetector->SetSizeX(fSizeXCmd->GetNewDoubl << 128 if( command == MagFieldCmd ) 198 } << 129 { Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));} 199 << 130 200 if (command == fSizeYZCmd) { << 131 if( command == TalMateCmd ) 201 fDetector->SetSizeYZ(fSizeYZCmd->GetNewDou << 132 { Detector->SetTallyMaterial(newValue);} 202 } << 133 203 << 134 if( command == TalSizeCmd ) 204 if (command == fMagFieldCmd) { << 135 { Detector->SetTallySize(TalSizeCmd->GetNew3VectorValue(newValue));} 205 fDetector->SetMagField(fMagFieldCmd->GetNe << 136 206 } << 137 if( command == TalPosiCmd ) 207 << 138 { Detector->SetTallyPosition(TalPosiCmd->GetNew3VectorValue(newValue));} 208 if (command == fTalNbCmd) { << 139 209 fDetector->SetTallyNumber(fTalNbCmd->GetNe << 140 if( command == UpdateCmd ) 210 } << 141 { 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 } 142 } 234 143 235 //....oooOO0OOooo........oooOO0OOooo........oo 144 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 236 145