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 // $Id: DetectorMessenger.cc 67994 2013-03-13 11:05:39Z gcosmo $ 26 // 27 // 27 /// \file medical/GammaTherapy/src/DetectorMes 28 /// \file medical/GammaTherapy/src/DetectorMessenger.cc 28 /// \brief Implementation of the DetectorMesse 29 /// \brief Implementation of the DetectorMessenger class 29 // 30 // 30 // ------------------------------------------- 31 // ------------------------------------------------------------- 31 // GEANT4 test IBREM 32 // GEANT4 test IBREM 32 // 33 // 33 // Authors: V.Grichine, V.Ivanchenko 34 // Authors: V.Grichine, V.Ivanchenko 34 // 35 // 35 // Modified: 36 // Modified: 36 // 37 // 37 // 18-02-03 V.Ivanchenko create 38 // 18-02-03 V.Ivanchenko create 38 // 39 // 39 // ------------------------------------------- 40 // ------------------------------------------------------------- 40 41 41 //....oooOO0OOooo........oooOO0OOooo........oo << 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 42 //....oooOO0OOooo........oooOO0OOooo........oo << 43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 43 44 44 #include "DetectorMessenger.hh" 45 #include "DetectorMessenger.hh" 45 << 46 #include "DetectorConstruction.hh" 46 #include "DetectorConstruction.hh" 47 << 47 #include "Histo.hh" >> 48 #include "G4UIdirectory.hh" 48 #include "G4UIcmdWithABool.hh" 49 #include "G4UIcmdWithABool.hh" 49 #include "G4UIcmdWithADoubleAndUnit.hh" << 50 #include "G4UIcmdWithAString.hh" 50 #include "G4UIcmdWithAString.hh" 51 #include "G4UIcmdWithAnInteger.hh" 51 #include "G4UIcmdWithAnInteger.hh" >> 52 #include "G4UIcmdWithADoubleAndUnit.hh" 52 #include "G4UIcmdWithoutParameter.hh" 53 #include "G4UIcmdWithoutParameter.hh" 53 #include "G4UIdirectory.hh" << 54 54 55 //....oooOO0OOooo........oooOO0OOooo........oo << 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 56 56 57 DetectorMessenger::DetectorMessenger(DetectorC << 57 DetectorMessenger::DetectorMessenger(DetectorConstruction* h): >> 58 fDetector(h) 58 { 59 { 59 fDetDir = new G4UIdirectory("/testem/"); 60 fDetDir = new G4UIdirectory("/testem/"); 60 fDetDir->SetGuidance("General commands"); 61 fDetDir->SetGuidance("General commands"); 61 fDetDir1 = new G4UIdirectory("/testem/physic << 62 fDetDir1= new G4UIdirectory("/testem/physics/"); 62 fDetDir1->SetGuidance(" commands to define p 63 fDetDir1->SetGuidance(" commands to define physics"); 63 fDetDir2 = new G4UIdirectory("/testem/gun/") << 64 fDetDir2= new G4UIdirectory("/testem/gun/"); 64 fDetDir2->SetGuidance(" commands to define g 65 fDetDir2->SetGuidance(" commands to define gun"); 65 66 66 fAbsMaterCmd = new G4UIcmdWithAString("/test << 67 fAbsMaterCmd = new G4UIcmdWithAString("/testem/target1Material",this); 67 fAbsMaterCmd->SetGuidance("Select Material o 68 fAbsMaterCmd->SetGuidance("Select Material of the target1."); 68 fAbsMaterCmd->SetParameterName("Material1", << 69 fAbsMaterCmd->SetParameterName("Material1",false); 69 fAbsMaterCmd->AvailableForStates(G4State_Pre << 70 fAbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 70 71 71 fWorldMaterCmd = new G4UIcmdWithAString("/te << 72 fWorldMaterCmd = new G4UIcmdWithAString("/testem/target2Material",this); 72 fWorldMaterCmd->SetGuidance("Select Material 73 fWorldMaterCmd->SetGuidance("Select Material of the target2."); 73 fWorldMaterCmd->SetParameterName("Material2" << 74 fWorldMaterCmd->SetParameterName("Material2",false); 74 fWorldMaterCmd->AvailableForStates(G4State_P << 75 fWorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 75 76 76 fAbsThickCmd = new G4UIcmdWithADoubleAndUnit << 77 fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/mylarZ",this); 77 fAbsThickCmd->SetGuidance("Set mylarZ"); 78 fAbsThickCmd->SetGuidance("Set mylarZ"); 78 fAbsThickCmd->SetParameterName("mylarZ", fal << 79 fAbsThickCmd->SetParameterName("mylarZ",false); 79 fAbsThickCmd->SetUnitCategory("Length"); 80 fAbsThickCmd->SetUnitCategory("Length"); 80 fAbsThickCmd->AvailableForStates(G4State_Pre << 81 fAbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 81 82 82 fAbsGapCmd = new G4UIcmdWithADoubleAndUnit(" << 83 fAbsGapCmd = new G4UIcmdWithADoubleAndUnit("/testem/delta",this); 83 fAbsGapCmd->SetGuidance("Set gap between abs 84 fAbsGapCmd->SetGuidance("Set gap between absorbers"); 84 fAbsGapCmd->SetParameterName("delta", false) << 85 fAbsGapCmd->SetParameterName("delta",false); 85 fAbsGapCmd->SetUnitCategory("Length"); 86 fAbsGapCmd->SetUnitCategory("Length"); 86 fAbsGapCmd->AvailableForStates(G4State_PreIn << 87 fAbsGapCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 87 88 88 fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit << 89 fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/target1Z",this); 89 fAbsSizYZCmd->SetGuidance("Set targeet1Z"); 90 fAbsSizYZCmd->SetGuidance("Set targeet1Z"); 90 fAbsSizYZCmd->SetParameterName("target1Z", f << 91 fAbsSizYZCmd->SetParameterName("target1Z",false); 91 fAbsSizYZCmd->SetUnitCategory("Length"); 92 fAbsSizYZCmd->SetUnitCategory("Length"); 92 fAbsSizYZCmd->AvailableForStates(G4State_Pre << 93 fAbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 93 94 94 fWorldXCmd = new G4UIcmdWithADoubleAndUnit(" << 95 fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/target2Z",this); 95 fWorldXCmd->SetGuidance("Set target2Z"); 96 fWorldXCmd->SetGuidance("Set target2Z"); 96 fWorldXCmd->SetParameterName("target2Z", fal << 97 fWorldXCmd->SetParameterName("target2Z",false); 97 fWorldXCmd->SetUnitCategory("Length"); 98 fWorldXCmd->SetUnitCategory("Length"); 98 fWorldXCmd->AvailableForStates(G4State_PreIn << 99 fWorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 100 >> 101 fUpdateCmd = new G4UIcmdWithoutParameter("/testem/update",this); >> 102 fUpdateCmd->SetGuidance("Update calorimeter geometry."); >> 103 fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); >> 104 fUpdateCmd->SetGuidance("if you changed geometrical value(s)."); >> 105 fUpdateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 99 106 100 fXMagFieldCmd = new G4UIcmdWithADoubleAndUni << 107 fXMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/checkShiftZ",this); 101 fXMagFieldCmd->SetGuidance("Define checkShft 108 fXMagFieldCmd->SetGuidance("Define checkShftZ"); 102 fXMagFieldCmd->SetParameterName("CheckSZ", f << 109 fXMagFieldCmd->SetParameterName("CheckSZ",false); 103 fXMagFieldCmd->SetUnitCategory("Length"); 110 fXMagFieldCmd->SetUnitCategory("Length"); 104 fXMagFieldCmd->AvailableForStates(G4State_Pr << 111 fXMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 105 112 106 fYMagFieldCmd = new G4UIcmdWithADoubleAndUni << 113 fYMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/sdZ",this); 107 fYMagFieldCmd->SetGuidance("Define sensitive 114 fYMagFieldCmd->SetGuidance("Define sensitive detector Z"); 108 fYMagFieldCmd->SetParameterName("sdZ", false << 115 fYMagFieldCmd->SetParameterName("sdZ",false); 109 fYMagFieldCmd->SetUnitCategory("Length"); 116 fYMagFieldCmd->SetUnitCategory("Length"); 110 fYMagFieldCmd->AvailableForStates(G4State_Pr << 117 fYMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 111 118 112 fZMagFieldCmd = new G4UIcmdWithADoubleAndUni << 119 fZMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/sdShiftZ",this); 113 fZMagFieldCmd->SetGuidance("Define shift of 120 fZMagFieldCmd->SetGuidance("Define shift of sensitive detector"); 114 fZMagFieldCmd->SetParameterName("sdShiftZ", << 121 fZMagFieldCmd->SetParameterName("sdShiftZ",false); 115 fZMagFieldCmd->SetUnitCategory("Length"); 122 fZMagFieldCmd->SetUnitCategory("Length"); 116 fZMagFieldCmd->AvailableForStates(G4State_Pr << 123 fZMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 117 124 118 fNumOfAbsCmd = new G4UIcmdWithAnInteger("/te << 125 fHistoCmd = new G4UIcmdWithAString("/testem/histoName",this); >> 126 fHistoCmd->SetGuidance("Set the name of the histo file"); >> 127 fHistoCmd->SetParameterName("histo",false); >> 128 fHistoCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 129 >> 130 fNumOfAbsCmd = new G4UIcmdWithAnInteger("/testem/numberDivR",this); 119 fNumOfAbsCmd->SetGuidance("Set number divisi 131 fNumOfAbsCmd->SetGuidance("Set number divisions R"); 120 fNumOfAbsCmd->SetParameterName("NR", false); << 132 fNumOfAbsCmd->SetParameterName("NR",false); 121 fNumOfAbsCmd->AvailableForStates(G4State_Pre << 133 fNumOfAbsCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 122 134 123 fNumOfEvt = new G4UIcmdWithAnInteger("/teste << 135 fNumOfEvt = new G4UIcmdWithAnInteger("/testem/numberDivZ",this); 124 fNumOfEvt->SetGuidance("Set number of divisi 136 fNumOfEvt->SetGuidance("Set number of divisions Z"); 125 fNumOfEvt->SetParameterName("NZ", false); << 137 fNumOfEvt->SetParameterName("NZ",false); 126 fNumOfEvt->AvailableForStates(G4State_PreIni << 138 fNumOfEvt->AvailableForStates(G4State_PreInit,G4State_Idle); 127 139 128 fVerbCmd = new G4UIcmdWithAnInteger("/testem << 140 fVerbCmd = new G4UIcmdWithAnInteger("/testem/verbose",this); 129 fVerbCmd->SetGuidance("Set verbose for "); 141 fVerbCmd->SetGuidance("Set verbose for "); 130 fVerbCmd->SetParameterName("verb", false); << 142 fVerbCmd->SetParameterName("verb",false); 131 fVerbCmd->AvailableForStates(G4State_PreInit << 143 fVerbCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 132 144 133 fIntCmd = new G4UIcmdWithAnInteger("/testem/ << 145 fIntCmd = new G4UIcmdWithAnInteger("/testem/numberDivE",this); 134 fIntCmd->SetGuidance("Set number of division 146 fIntCmd->SetGuidance("Set number of divisions E"); 135 fIntCmd->SetParameterName("NZ", false); << 147 fIntCmd->SetParameterName("NZ",false); 136 fIntCmd->AvailableForStates(G4State_PreInit) 148 fIntCmd->AvailableForStates(G4State_PreInit); 137 149 138 fDeltaECmd = new G4UIcmdWithADoubleAndUnit(" << 150 fDeltaECmd = new G4UIcmdWithADoubleAndUnit("/testem/maxEnergy",this); 139 fDeltaECmd->SetGuidance("Define scale of sec 151 fDeltaECmd->SetGuidance("Define scale of secondary energy histogram"); 140 fDeltaECmd->SetParameterName("DeltaE", false << 152 fDeltaECmd->SetParameterName("DeltaE",false); 141 fDeltaECmd->SetUnitCategory("Energy"); 153 fDeltaECmd->SetUnitCategory("Energy"); 142 fDeltaECmd->AvailableForStates(G4State_PreIn << 154 fDeltaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 155 143 } 156 } 144 157 145 //....oooOO0OOooo........oooOO0OOooo........oo << 158 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 146 159 147 DetectorMessenger::~DetectorMessenger() 160 DetectorMessenger::~DetectorMessenger() 148 { 161 { 149 delete fDetDir; << 162 delete fNumOfAbsCmd; 150 delete fDetDir1; << 151 delete fDetDir2; << 152 << 153 delete fAbsMaterCmd; 163 delete fAbsMaterCmd; 154 delete fAbsThickCmd; 164 delete fAbsThickCmd; 155 delete fAbsGapCmd; 165 delete fAbsGapCmd; 156 delete fAbsSizYZCmd; 166 delete fAbsSizYZCmd; 157 delete fWorldMaterCmd; 167 delete fWorldMaterCmd; 158 delete fWorldXCmd; 168 delete fWorldXCmd; >> 169 delete fUpdateCmd; 159 delete fXMagFieldCmd; 170 delete fXMagFieldCmd; 160 delete fYMagFieldCmd; 171 delete fYMagFieldCmd; 161 delete fZMagFieldCmd; 172 delete fZMagFieldCmd; 162 delete fNumOfAbsCmd; << 173 delete fHistoCmd; 163 delete fNumOfEvt; 174 delete fNumOfEvt; 164 delete fVerbCmd; 175 delete fVerbCmd; 165 delete fIntCmd; 176 delete fIntCmd; >> 177 delete fDetDir; >> 178 delete fDetDir1; >> 179 delete fDetDir2; 166 delete fDeltaECmd; 180 delete fDeltaECmd; 167 } 181 } 168 182 169 //....oooOO0OOooo........oooOO0OOooo........oo << 183 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 170 184 171 void DetectorMessenger::SetNewValue(G4UIcomman << 185 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 172 { 186 { 173 if (command == fAbsMaterCmd) { << 187 if( command == fAbsMaterCmd ) 174 fDetector->SetTarget1Material(newValue); << 188 { fDetector->SetTarget1Material(newValue);} 175 } << 189 176 << 190 if( command == fWorldMaterCmd ) 177 if (command == fWorldMaterCmd) { << 191 { fDetector->SetTarget2Material(newValue);} 178 fDetector->SetTarget2Material(newValue); << 192 179 } << 193 if( command == fAbsThickCmd ) 180 << 194 { fDetector->SetMylarZ(fAbsThickCmd->GetNewDoubleValue(newValue));} 181 if (command == fAbsThickCmd) { << 195 182 fDetector->SetMylarZ(fAbsThickCmd->GetNewD << 196 if( command == fAbsGapCmd ) 183 } << 197 { fDetector->SetGap(fAbsGapCmd->GetNewDoubleValue(newValue));} 184 << 198 185 if (command == fAbsGapCmd) { << 199 if( command == fAbsSizYZCmd ) 186 fDetector->SetGap(fAbsGapCmd->GetNewDouble << 200 { fDetector->SetTarget1Z(fAbsSizYZCmd->GetNewDoubleValue(newValue));} 187 } << 201 188 << 202 if( command == fWorldXCmd ) 189 if (command == fAbsSizYZCmd) { << 203 { fDetector->SetTarget2Z(fWorldXCmd->GetNewDoubleValue(newValue));} 190 fDetector->SetTarget1Z(fAbsSizYZCmd->GetNe << 204 191 } << 205 if( command == fUpdateCmd ) 192 << 206 { fDetector->UpdateGeometry(); } 193 if (command == fWorldXCmd) { << 207 194 fDetector->SetTarget2Z(fWorldXCmd->GetNewD << 208 if( command == fXMagFieldCmd ) 195 } << 209 { fDetector->SetCheckShiftZ(fXMagFieldCmd->GetNewDoubleValue(newValue));} 196 << 210 197 if (command == fXMagFieldCmd) { << 211 if( command == fYMagFieldCmd ) 198 fDetector->SetCheckShiftZ(fXMagFieldCmd->G << 212 { G4double x = fYMagFieldCmd->GetNewDoubleValue(newValue); 199 } << 213 fDetector->SetAbsorberZ(x); 200 << 214 } 201 if (command == fYMagFieldCmd) { << 215 202 G4double x = fYMagFieldCmd->GetNewDoubleVa << 216 if( command == fZMagFieldCmd ) 203 fDetector->SetAbsorberZ(x); << 217 { fDetector->SetAbsorberShiftZ(fZMagFieldCmd->GetNewDoubleValue(newValue));} 204 } << 218 205 << 219 if( command == fHistoCmd ) 206 if (command == fZMagFieldCmd) { << 220 { (Histo::GetPointer())->SetHistoName(newValue);} 207 fDetector->SetAbsorberShiftZ(fZMagFieldCmd << 221 208 } << 222 if( command == fNumOfAbsCmd ) 209 << 223 {(Histo::GetPointer())->SetNumberDivR(fNumOfAbsCmd->GetNewIntValue(newValue));} 210 if (command == fNumOfAbsCmd) { << 224 211 fDetector->SetNumberDivR(fNumOfAbsCmd->Get << 225 if( command == fNumOfEvt ) 212 } << 226 {(Histo::GetPointer())->SetNumberDivZ(fNumOfEvt->GetNewIntValue(newValue));} 213 << 227 214 if (command == fNumOfEvt) { << 228 if( command == fVerbCmd ){ 215 fDetector->SetNumberDivZ(fNumOfEvt->GetNew << 229 G4int ver = fVerbCmd->GetNewIntValue(newValue); 216 } << 230 (Histo::GetPointer())->SetVerbose(ver); 217 << 231 } 218 if (command == fIntCmd) { << 232 219 fDetector->SetNumberDivE(fIntCmd->GetNewIn << 233 if( command == fIntCmd ) 220 } << 234 {(Histo::GetPointer())->SetNumberDivE(fIntCmd->GetNewIntValue(newValue));} 221 if (command == fDeltaECmd) { << 235 222 fDetector->SetMaxEnergy(fDeltaECmd->GetNew << 236 if( command == fDeltaECmd ) 223 } << 237 {(Histo::GetPointer()) ->SetMaxEnergy(fDeltaECmd->GetNewDoubleValue(newValue));} 224 << 238 225 if (command == fVerbCmd) { << 226 G4int ver = fVerbCmd->GetNewIntValue(newVa << 227 fDetector->SetVerbose(ver); << 228 } << 229 } 239 } 230 240 231 //....oooOO0OOooo........oooOO0OOooo........oo << 241 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 232 242