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/TestEm5/src/Detector << 23 // $Id: DetectorMessenger.cc,v 1.3 2004/09/24 09:58:07 maire Exp $ 27 /// \brief Implementation of the DetectorMesse << 24 // GEANT4 tag $Name: geant4-07-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 "G4UIcmdWithAnInteger.hh" >> 35 #include "G4UIcmdWithADoubleAndUnit.hh" 40 #include "G4UIcmdWithoutParameter.hh" 36 #include "G4UIcmdWithoutParameter.hh" 41 #include "G4UIdirectory.hh" << 42 37 43 //....oooOO0OOooo........oooOO0OOooo........oo 38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 44 39 45 DetectorMessenger::DetectorMessenger(DetectorC << 40 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) 46 { << 41 :Detector(Det) 47 fTestemDir = new G4UIdirectory("/testem/"); << 42 { 48 fTestemDir->SetGuidance("UI commands specifi << 43 testemDir = new G4UIdirectory("/testem/"); 49 << 44 testemDir->SetGuidance("UI commands specific to this example."); 50 fDetDir = new G4UIdirectory("/testem/det/", << 45 51 fDetDir->SetGuidance("detector construction << 46 detDir = new G4UIdirectory("/testem/det/"); >> 47 detDir->SetGuidance("detector construction commands"); >> 48 >> 49 AbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat",this); >> 50 AbsMaterCmd->SetGuidance("Select Material of the Absorber."); >> 51 AbsMaterCmd->SetParameterName("choice",false); >> 52 AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 53 >> 54 WorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this); >> 55 WorldMaterCmd->SetGuidance("Select Material of the World."); >> 56 WorldMaterCmd->SetParameterName("wchoice",false); >> 57 WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 58 >> 59 AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this); >> 60 AbsThickCmd->SetGuidance("Set Thickness of the Absorber"); >> 61 AbsThickCmd->SetParameterName("SizeZ",false); >> 62 AbsThickCmd->SetRange("SizeZ>0."); >> 63 AbsThickCmd->SetUnitCategory("Length"); >> 64 AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 65 >> 66 AbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this); >> 67 AbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber"); >> 68 AbsSizYZCmd->SetParameterName("SizeYZ",false); >> 69 AbsSizYZCmd->SetRange("SizeYZ>0."); >> 70 AbsSizYZCmd->SetUnitCategory("Length"); >> 71 AbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 72 >> 73 AbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this); >> 74 AbsXposCmd->SetGuidance("Set X pos. of the Absorber"); >> 75 AbsXposCmd->SetParameterName("Xpos",false); >> 76 AbsXposCmd->SetUnitCategory("Length"); >> 77 AbsXposCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 78 >> 79 WorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this); >> 80 WorldXCmd->SetGuidance("Set X size of the World"); >> 81 WorldXCmd->SetParameterName("WSizeX",false); >> 82 WorldXCmd->SetRange("WSizeX>0."); >> 83 WorldXCmd->SetUnitCategory("Length"); >> 84 WorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 85 >> 86 WorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this); >> 87 WorldYZCmd->SetGuidance("Set sizeYZ of the World"); >> 88 WorldYZCmd->SetParameterName("WSizeYZ",false); >> 89 WorldYZCmd->SetRange("WSizeYZ>0."); >> 90 WorldYZCmd->SetUnitCategory("Length"); >> 91 WorldYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 92 >> 93 UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this); >> 94 UpdateCmd->SetGuidance("Update calorimeter geometry."); >> 95 UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); >> 96 UpdateCmd->SetGuidance("if you changed geometrical value(s)."); >> 97 UpdateCmd->AvailableForStates(G4State_Idle); >> 98 >> 99 MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); >> 100 MagFieldCmd->SetGuidance("Define magnetic field."); >> 101 MagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); >> 102 MagFieldCmd->SetParameterName("Bz",false); >> 103 MagFieldCmd->SetUnitCategory("Magnetic flux density"); >> 104 MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 52 105 53 fAbsMaterCmd = new G4UIcmdWithAString("/test << 54 fAbsMaterCmd->SetGuidance("Select Material o << 55 fAbsMaterCmd->SetParameterName("choice", fal << 56 fAbsMaterCmd->AvailableForStates(G4State_Pre << 57 fAbsMaterCmd->SetToBeBroadcasted(false); << 58 << 59 fWorldMaterCmd = new G4UIcmdWithAString("/te << 60 fWorldMaterCmd->SetGuidance("Select Material << 61 fWorldMaterCmd->SetParameterName("wchoice", << 62 fWorldMaterCmd->AvailableForStates(G4State_P << 63 fWorldMaterCmd->SetToBeBroadcasted(false); << 64 << 65 fAbsThickCmd = new G4UIcmdWithADoubleAndUnit << 66 fAbsThickCmd->SetGuidance("Set Thickness of << 67 fAbsThickCmd->SetParameterName("SizeZ", fals << 68 fAbsThickCmd->SetRange("SizeZ>0."); << 69 fAbsThickCmd->SetUnitCategory("Length"); << 70 fAbsThickCmd->AvailableForStates(G4State_Pre << 71 fAbsThickCmd->SetToBeBroadcasted(false); << 72 << 73 fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit << 74 fAbsSizYZCmd->SetGuidance("Set sizeYZ of the << 75 fAbsSizYZCmd->SetParameterName("SizeYZ", fal << 76 fAbsSizYZCmd->SetRange("SizeYZ>0."); << 77 fAbsSizYZCmd->SetUnitCategory("Length"); << 78 fAbsSizYZCmd->AvailableForStates(G4State_Pre << 79 fAbsSizYZCmd->SetToBeBroadcasted(false); << 80 << 81 fAbsXposCmd = new G4UIcmdWithADoubleAndUnit( << 82 fAbsXposCmd->SetGuidance("Set X pos. of the << 83 fAbsXposCmd->SetParameterName("Xpos", false) << 84 fAbsXposCmd->SetUnitCategory("Length"); << 85 fAbsXposCmd->AvailableForStates(G4State_PreI << 86 fAbsXposCmd->SetToBeBroadcasted(false); << 87 << 88 fWorldXCmd = new G4UIcmdWithADoubleAndUnit(" << 89 fWorldXCmd->SetGuidance("Set X size of the W << 90 fWorldXCmd->SetParameterName("WSizeX", false << 91 fWorldXCmd->SetRange("WSizeX>0."); << 92 fWorldXCmd->SetUnitCategory("Length"); << 93 fWorldXCmd->AvailableForStates(G4State_PreIn << 94 fWorldXCmd->SetToBeBroadcasted(false); << 95 << 96 fWorldYZCmd = new G4UIcmdWithADoubleAndUnit( << 97 fWorldYZCmd->SetGuidance("Set sizeYZ of the << 98 fWorldYZCmd->SetParameterName("WSizeYZ", fal << 99 fWorldYZCmd->SetRange("WSizeYZ>0."); << 100 fWorldYZCmd->SetUnitCategory("Length"); << 101 fWorldYZCmd->AvailableForStates(G4State_PreI << 102 fWorldYZCmd->SetToBeBroadcasted(false); << 103 } 106 } 104 107 105 //....oooOO0OOooo........oooOO0OOooo........oo 108 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 106 109 107 DetectorMessenger::~DetectorMessenger() 110 DetectorMessenger::~DetectorMessenger() 108 { 111 { 109 delete fAbsMaterCmd; << 112 delete AbsMaterCmd; 110 delete fAbsThickCmd; << 113 delete AbsThickCmd; 111 delete fAbsSizYZCmd; << 114 delete AbsSizYZCmd; 112 delete fAbsXposCmd; << 115 delete AbsXposCmd; 113 delete fWorldMaterCmd; << 116 delete WorldMaterCmd; 114 delete fWorldXCmd; << 117 delete WorldXCmd; 115 delete fWorldYZCmd; << 118 delete WorldYZCmd; 116 delete fDetDir; << 119 delete UpdateCmd; 117 delete fTestemDir; << 120 delete MagFieldCmd; >> 121 delete detDir; >> 122 delete testemDir; 118 } 123 } 119 124 120 //....oooOO0OOooo........oooOO0OOooo........oo 125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 121 126 122 void DetectorMessenger::SetNewValue(G4UIcomman << 127 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 123 { << 128 { 124 if (command == fAbsMaterCmd) { << 129 if ( command == AbsMaterCmd ) 125 fDetector->SetAbsorberMaterial(newValue); << 130 {Detector->SetAbsorberMaterial(newValue);} 126 } << 131 127 << 132 if ( command == WorldMaterCmd ) 128 if (command == fWorldMaterCmd) { << 133 {Detector->SetWorldMaterial(newValue);} 129 fDetector->SetWorldMaterial(newValue); << 134 130 } << 135 if ( command == AbsThickCmd ) 131 << 136 {Detector->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue));} 132 if (command == fAbsThickCmd) { << 137 133 fDetector->SetAbsorberThickness(fAbsThickC << 138 if ( command == AbsSizYZCmd ) 134 } << 139 {Detector->SetAbsorberSizeYZ(AbsSizYZCmd->GetNewDoubleValue(newValue));} 135 << 140 136 if (command == fAbsSizYZCmd) { << 141 if ( command == AbsXposCmd ) 137 fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd- << 142 {Detector->SetAbsorberXpos(AbsXposCmd->GetNewDoubleValue(newValue));} 138 } << 143 139 << 144 if ( command == WorldXCmd ) 140 if (command == fAbsXposCmd) { << 145 {Detector->SetWorldSizeX(WorldXCmd->GetNewDoubleValue(newValue));} 141 fDetector->SetAbsorberXpos(fAbsXposCmd->Ge << 146 142 } << 147 if ( command == WorldYZCmd ) 143 << 148 {Detector->SetWorldSizeYZ(WorldYZCmd->GetNewDoubleValue(newValue));} 144 if (command == fWorldXCmd) { << 149 145 fDetector->SetWorldSizeX(fWorldXCmd->GetNe << 150 if ( command == UpdateCmd ) 146 } << 151 {Detector->UpdateGeometry(); } 147 << 152 148 if (command == fWorldYZCmd) { << 153 if( command == MagFieldCmd ) 149 fDetector->SetWorldSizeYZ(fWorldYZCmd->Get << 154 {Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));} 150 } << 151 } 155 } 152 156 153 //....oooOO0OOooo........oooOO0OOooo........oo 157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 154 158