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