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/TestEm11/src/Detecto << 26 // $Id: DetectorMessenger.cc,v 1.2 2006/06/29 16:40:12 gunter Exp $ 27 /// \brief Implementation of the DetectorMesse << 27 // GEANT4 tag $Name: geant4-08-02 $ 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" << 36 #include "G4UIcmdWithAString.hh" 38 #include "G4UIcmdWithAnInteger.hh" 37 #include "G4UIcmdWithAnInteger.hh" >> 38 #include "G4UIcmdWithADoubleAndUnit.hh" 39 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 40 #include "G4UIcommand.hh" << 41 #include "G4UIdirectory.hh" << 42 #include "G4UIparameter.hh" << 43 << 44 #include <sstream> << 45 40 46 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 47 42 48 DetectorMessenger::DetectorMessenger(DetectorC << 43 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 49 { << 44 :Detector(Det) 50 fTestemDir = new G4UIdirectory("/testem/"); << 45 { 51 fTestemDir->SetGuidance(" detector control." << 46 testemDir = new G4UIdirectory("/testem/"); 52 << 47 testemDir->SetGuidance(" detector control."); 53 fDetDir = new G4UIdirectory("/testem/det/"); << 48 54 fDetDir->SetGuidance("detector construction << 49 detDir = new G4UIdirectory("/testem/det/"); 55 << 50 detDir->SetGuidance("detector construction commands"); 56 fNbAbsorCmd = new G4UIcmdWithAnInteger("/tes << 51 57 fNbAbsorCmd->SetGuidance("Set number of Abso << 52 MaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this); 58 fNbAbsorCmd->SetParameterName("NbAbsor", fal << 53 MaterCmd->SetGuidance("Select material of the box."); 59 fNbAbsorCmd->SetRange("NbAbsor>0"); << 54 MaterCmd->SetParameterName("choice",false); 60 fNbAbsorCmd->AvailableForStates(G4State_PreI << 55 MaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 61 fNbAbsorCmd->SetToBeBroadcasted(false); << 56 62 << 57 SizeXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeX",this); 63 fAbsorCmd = new G4UIcommand("/testem/det/set << 58 SizeXCmd->SetGuidance("Set sizeX of the absorber"); 64 fAbsorCmd->SetGuidance("Set the absor nb, th << 59 SizeXCmd->SetParameterName("SizeX",false); 65 fAbsorCmd->SetGuidance(" absor number : fro << 60 SizeXCmd->SetRange("SizeX>0."); 66 fAbsorCmd->SetGuidance(" material name"); << 61 SizeXCmd->SetUnitCategory("Length"); 67 fAbsorCmd->SetGuidance(" thickness (with un << 62 SizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 68 // << 63 69 G4UIparameter* AbsNbPrm = new G4UIparameter( << 64 SizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this); 70 AbsNbPrm->SetGuidance("absor number : from 1 << 65 SizeYZCmd->SetGuidance("Set sizeYZ of the absorber"); 71 AbsNbPrm->SetParameterRange("AbsorNb>0"); << 66 SizeYZCmd->SetParameterName("SizeYZ",false); 72 fAbsorCmd->SetParameter(AbsNbPrm); << 67 SizeYZCmd->SetRange("SizeYZ>0."); 73 // << 68 SizeYZCmd->SetUnitCategory("Length"); 74 G4UIparameter* MatPrm = new G4UIparameter("m << 69 SizeYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 75 MatPrm->SetGuidance("material name"); << 70 76 fAbsorCmd->SetParameter(MatPrm); << 71 NbLayersCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfLayers",this); 77 // << 72 NbLayersCmd->SetGuidance("Set number of layers"); 78 G4UIparameter* ThickPrm = new G4UIparameter( << 73 NbLayersCmd->SetParameterName("NbLayers",false); 79 ThickPrm->SetGuidance("thickness of absorber << 74 NbLayersCmd->SetRange("NbLayers>0"); 80 ThickPrm->SetParameterRange("thickness>0."); << 75 NbLayersCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 81 fAbsorCmd->SetParameter(ThickPrm); << 76 82 // << 77 MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); 83 G4UIparameter* unitPrm = new G4UIparameter(" << 78 MagFieldCmd->SetGuidance("Define magnetic field."); 84 unitPrm->SetGuidance("unit of thickness"); << 79 MagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); 85 G4String unitList = G4UIcommand::UnitsList(G << 80 MagFieldCmd->SetParameterName("Bz",false); 86 unitPrm->SetParameterCandidates(unitList); << 81 MagFieldCmd->SetUnitCategory("Magnetic flux density"); 87 fAbsorCmd->SetParameter(unitPrm); << 82 MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 88 // << 83 89 fAbsorCmd->AvailableForStates(G4State_PreIni << 84 UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this); 90 fAbsorCmd->SetToBeBroadcasted(false); << 85 UpdateCmd->SetGuidance("Update calorimeter geometry."); 91 << 86 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); 92 fNdivCmd = new G4UIcommand("/testem/det/nDiv << 87 UpdateCmd->SetGuidance("if you changed geometrical value(s)."); 93 fNdivCmd->SetGuidance("Divide the absor nb : << 88 UpdateCmd->AvailableForStates(G4State_Idle); 94 fNdivCmd->SetGuidance(" absor number : from << 95 fNdivCmd->SetGuidance(" number of divisions << 96 // << 97 G4UIparameter* AbsNbPar = new G4UIparameter( << 98 AbsNbPar->SetGuidance("absor number : from 1 << 99 AbsNbPar->SetParameterRange("AbsorNb>0"); << 100 fNdivCmd->SetParameter(AbsNbPar); << 101 // << 102 G4UIparameter* NdivPrm = new G4UIparameter(" << 103 NdivPrm->SetGuidance("nb of divisions > 0"); << 104 NdivPrm->SetParameterRange("NdivNb>0"); << 105 fNdivCmd->SetParameter(NdivPrm); << 106 // << 107 fNdivCmd->AvailableForStates(G4State_PreInit << 108 fNdivCmd->SetToBeBroadcasted(false); << 109 << 110 fSizeYZCmd = new G4UIcmdWithADoubleAndUnit(" << 111 fSizeYZCmd->SetGuidance("Set sizeYZ of the a << 112 fSizeYZCmd->SetParameterName("SizeYZ", false << 113 fSizeYZCmd->SetRange("SizeYZ>0."); << 114 fSizeYZCmd->SetUnitCategory("Length"); << 115 fSizeYZCmd->AvailableForStates(G4State_PreIn << 116 fSizeYZCmd->SetToBeBroadcasted(false); << 117 } 89 } 118 90 119 //....oooOO0OOooo........oooOO0OOooo........oo 91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 120 92 121 DetectorMessenger::~DetectorMessenger() 93 DetectorMessenger::~DetectorMessenger() 122 { 94 { 123 delete fNbAbsorCmd; << 95 delete MaterCmd; 124 delete fAbsorCmd; << 96 delete SizeXCmd; 125 delete fNdivCmd; << 97 delete SizeYZCmd; 126 delete fSizeYZCmd; << 98 delete NbLayersCmd; 127 delete fDetDir; << 99 delete MagFieldCmd; 128 delete fTestemDir; << 100 delete UpdateCmd; >> 101 delete detDir; >> 102 delete testemDir; 129 } 103 } 130 104 131 //....oooOO0OOooo........oooOO0OOooo........oo 105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 132 106 133 void DetectorMessenger::SetNewValue(G4UIcomman << 107 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 134 { << 108 { 135 if (command == fNbAbsorCmd) { << 109 if( command == MaterCmd ) 136 fDetector->SetNbOfAbsor(fNbAbsorCmd->GetNe << 110 { Detector->SetMaterial(newValue);} 137 } << 111 138 << 112 if( command == SizeXCmd ) 139 if (command == fAbsorCmd) { << 113 { Detector->SetSizeX(SizeXCmd->GetNewDoubleValue(newValue));} 140 G4int num; << 114 141 G4double tick; << 115 if( command == SizeYZCmd ) 142 G4String unt, mat; << 116 { Detector->SetSizeYZ(SizeYZCmd->GetNewDoubleValue(newValue));} 143 std::istringstream is(newValue); << 117 144 is >> num >> mat >> tick >> unt; << 118 if( command == NbLayersCmd ) 145 G4String material = mat; << 119 { Detector->SetNbOfLayers(NbLayersCmd->GetNewIntValue(newValue));} 146 tick *= G4UIcommand::ValueOf(unt); << 120 147 fDetector->SetAbsorMaterial(num, material) << 121 if( command == MagFieldCmd ) 148 fDetector->SetAbsorThickness(num, tick); << 122 { Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));} 149 } << 123 150 << 124 if( command == UpdateCmd ) 151 if (command == fNdivCmd) { << 125 { Detector->UpdateGeometry();} 152 G4int num, ndiv; << 153 std::istringstream is(newValue); << 154 is >> num >> ndiv; << 155 fDetector->SetNbOfDivisions(num, ndiv); << 156 } << 157 << 158 if (command == fSizeYZCmd) { << 159 fDetector->SetAbsorSizeYZ(fSizeYZCmd->GetN << 160 } << 161 } 126 } 162 127 163 //....oooOO0OOooo........oooOO0OOooo........oo 128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 164 129