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 101245 2016-11-10 08:45:38Z 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); 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); 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); 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); 99 100 100 fXMagFieldCmd = new G4UIcmdWithADoubleAndUni << 101 fXMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/checkShiftZ",this); 101 fXMagFieldCmd->SetGuidance("Define checkShft 102 fXMagFieldCmd->SetGuidance("Define checkShftZ"); 102 fXMagFieldCmd->SetParameterName("CheckSZ", f << 103 fXMagFieldCmd->SetParameterName("CheckSZ",false); 103 fXMagFieldCmd->SetUnitCategory("Length"); 104 fXMagFieldCmd->SetUnitCategory("Length"); 104 fXMagFieldCmd->AvailableForStates(G4State_Pr 105 fXMagFieldCmd->AvailableForStates(G4State_PreInit); 105 106 106 fYMagFieldCmd = new G4UIcmdWithADoubleAndUni << 107 fYMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/sdZ",this); 107 fYMagFieldCmd->SetGuidance("Define sensitive 108 fYMagFieldCmd->SetGuidance("Define sensitive detector Z"); 108 fYMagFieldCmd->SetParameterName("sdZ", false << 109 fYMagFieldCmd->SetParameterName("sdZ",false); 109 fYMagFieldCmd->SetUnitCategory("Length"); 110 fYMagFieldCmd->SetUnitCategory("Length"); 110 fYMagFieldCmd->AvailableForStates(G4State_Pr 111 fYMagFieldCmd->AvailableForStates(G4State_PreInit); 111 112 112 fZMagFieldCmd = new G4UIcmdWithADoubleAndUni << 113 fZMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/sdShiftZ",this); 113 fZMagFieldCmd->SetGuidance("Define shift of 114 fZMagFieldCmd->SetGuidance("Define shift of sensitive detector"); 114 fZMagFieldCmd->SetParameterName("sdShiftZ", << 115 fZMagFieldCmd->SetParameterName("sdShiftZ",false); 115 fZMagFieldCmd->SetUnitCategory("Length"); 116 fZMagFieldCmd->SetUnitCategory("Length"); 116 fZMagFieldCmd->AvailableForStates(G4State_Pr 117 fZMagFieldCmd->AvailableForStates(G4State_PreInit); 117 118 118 fNumOfAbsCmd = new G4UIcmdWithAnInteger("/te << 119 fHistoCmd = new G4UIcmdWithAString("/testem/histoName",this); >> 120 fHistoCmd->SetGuidance("Set the name of the histo file"); >> 121 fHistoCmd->SetParameterName("histo",false); >> 122 fHistoCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 123 >> 124 fNumOfAbsCmd = new G4UIcmdWithAnInteger("/testem/numberDivR",this); 119 fNumOfAbsCmd->SetGuidance("Set number divisi 125 fNumOfAbsCmd->SetGuidance("Set number divisions R"); 120 fNumOfAbsCmd->SetParameterName("NR", false); << 126 fNumOfAbsCmd->SetParameterName("NR",false); 121 fNumOfAbsCmd->AvailableForStates(G4State_Pre 127 fNumOfAbsCmd->AvailableForStates(G4State_PreInit); 122 128 123 fNumOfEvt = new G4UIcmdWithAnInteger("/teste << 129 fNumOfEvt = new G4UIcmdWithAnInteger("/testem/numberDivZ",this); 124 fNumOfEvt->SetGuidance("Set number of divisi 130 fNumOfEvt->SetGuidance("Set number of divisions Z"); 125 fNumOfEvt->SetParameterName("NZ", false); << 131 fNumOfEvt->SetParameterName("NZ",false); 126 fNumOfEvt->AvailableForStates(G4State_PreIni 132 fNumOfEvt->AvailableForStates(G4State_PreInit); 127 133 128 fVerbCmd = new G4UIcmdWithAnInteger("/testem << 134 fVerbCmd = new G4UIcmdWithAnInteger("/testem/verbose",this); 129 fVerbCmd->SetGuidance("Set verbose for "); 135 fVerbCmd->SetGuidance("Set verbose for "); 130 fVerbCmd->SetParameterName("verb", false); << 136 fVerbCmd->SetParameterName("verb",false); 131 fVerbCmd->AvailableForStates(G4State_PreInit << 137 fVerbCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 132 138 133 fIntCmd = new G4UIcmdWithAnInteger("/testem/ << 139 fIntCmd = new G4UIcmdWithAnInteger("/testem/numberDivE",this); 134 fIntCmd->SetGuidance("Set number of division 140 fIntCmd->SetGuidance("Set number of divisions E"); 135 fIntCmd->SetParameterName("NZ", false); << 141 fIntCmd->SetParameterName("NZ",false); 136 fIntCmd->AvailableForStates(G4State_PreInit) 142 fIntCmd->AvailableForStates(G4State_PreInit); 137 143 138 fDeltaECmd = new G4UIcmdWithADoubleAndUnit(" << 144 fDeltaECmd = new G4UIcmdWithADoubleAndUnit("/testem/maxEnergy",this); 139 fDeltaECmd->SetGuidance("Define scale of sec 145 fDeltaECmd->SetGuidance("Define scale of secondary energy histogram"); 140 fDeltaECmd->SetParameterName("DeltaE", false << 146 fDeltaECmd->SetParameterName("DeltaE",false); 141 fDeltaECmd->SetUnitCategory("Energy"); 147 fDeltaECmd->SetUnitCategory("Energy"); 142 fDeltaECmd->AvailableForStates(G4State_PreIn << 148 fDeltaECmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 149 143 } 150 } 144 151 145 //....oooOO0OOooo........oooOO0OOooo........oo 152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 146 153 147 DetectorMessenger::~DetectorMessenger() 154 DetectorMessenger::~DetectorMessenger() 148 { 155 { 149 delete fDetDir; << 156 delete fNumOfAbsCmd; 150 delete fDetDir1; << 151 delete fDetDir2; << 152 << 153 delete fAbsMaterCmd; 157 delete fAbsMaterCmd; 154 delete fAbsThickCmd; 158 delete fAbsThickCmd; 155 delete fAbsGapCmd; 159 delete fAbsGapCmd; 156 delete fAbsSizYZCmd; 160 delete fAbsSizYZCmd; 157 delete fWorldMaterCmd; 161 delete fWorldMaterCmd; 158 delete fWorldXCmd; 162 delete fWorldXCmd; 159 delete fXMagFieldCmd; 163 delete fXMagFieldCmd; 160 delete fYMagFieldCmd; 164 delete fYMagFieldCmd; 161 delete fZMagFieldCmd; 165 delete fZMagFieldCmd; 162 delete fNumOfAbsCmd; << 166 delete fHistoCmd; 163 delete fNumOfEvt; 167 delete fNumOfEvt; 164 delete fVerbCmd; 168 delete fVerbCmd; 165 delete fIntCmd; 169 delete fIntCmd; >> 170 delete fDetDir; >> 171 delete fDetDir1; >> 172 delete fDetDir2; 166 delete fDeltaECmd; 173 delete fDeltaECmd; 167 } 174 } 168 175 169 //....oooOO0OOooo........oooOO0OOooo........oo 176 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 170 177 171 void DetectorMessenger::SetNewValue(G4UIcomman << 178 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 172 { 179 { 173 if (command == fAbsMaterCmd) { << 180 if( command == fAbsMaterCmd ) 174 fDetector->SetTarget1Material(newValue); << 181 { fDetector->SetTarget1Material(newValue);} 175 } << 182 176 << 183 if( command == fWorldMaterCmd ) 177 if (command == fWorldMaterCmd) { << 184 { fDetector->SetTarget2Material(newValue);} 178 fDetector->SetTarget2Material(newValue); << 185 179 } << 186 if( command == fAbsThickCmd ) 180 << 187 { fDetector->SetMylarZ(fAbsThickCmd->GetNewDoubleValue(newValue));} 181 if (command == fAbsThickCmd) { << 188 182 fDetector->SetMylarZ(fAbsThickCmd->GetNewD << 189 if( command == fAbsGapCmd ) 183 } << 190 { fDetector->SetGap(fAbsGapCmd->GetNewDoubleValue(newValue));} 184 << 191 185 if (command == fAbsGapCmd) { << 192 if( command == fAbsSizYZCmd ) 186 fDetector->SetGap(fAbsGapCmd->GetNewDouble << 193 { fDetector->SetTarget1Z(fAbsSizYZCmd->GetNewDoubleValue(newValue));} 187 } << 194 188 << 195 if( command == fWorldXCmd ) 189 if (command == fAbsSizYZCmd) { << 196 { fDetector->SetTarget2Z(fWorldXCmd->GetNewDoubleValue(newValue));} 190 fDetector->SetTarget1Z(fAbsSizYZCmd->GetNe << 197 191 } << 198 if( command == fXMagFieldCmd ) 192 << 199 { fDetector->SetCheckShiftZ(fXMagFieldCmd->GetNewDoubleValue(newValue));} 193 if (command == fWorldXCmd) { << 200 194 fDetector->SetTarget2Z(fWorldXCmd->GetNewD << 201 if( command == fYMagFieldCmd ) 195 } << 202 { G4double x = fYMagFieldCmd->GetNewDoubleValue(newValue); 196 << 203 fDetector->SetAbsorberZ(x); 197 if (command == fXMagFieldCmd) { << 204 } 198 fDetector->SetCheckShiftZ(fXMagFieldCmd->G << 205 199 } << 206 if( command == fZMagFieldCmd ) 200 << 207 { fDetector->SetAbsorberShiftZ(fZMagFieldCmd->GetNewDoubleValue(newValue));} 201 if (command == fYMagFieldCmd) { << 208 202 G4double x = fYMagFieldCmd->GetNewDoubleVa << 209 if( command == fHistoCmd ) 203 fDetector->SetAbsorberZ(x); << 210 { (Histo::GetPointer())->SetHistoName(newValue);} 204 } << 211 205 << 212 if( command == fNumOfAbsCmd ) 206 if (command == fZMagFieldCmd) { << 213 {(Histo::GetPointer()) 207 fDetector->SetAbsorberShiftZ(fZMagFieldCmd << 214 ->SetNumberDivR(fNumOfAbsCmd->GetNewIntValue(newValue));} 208 } << 215 209 << 216 if( command == fNumOfEvt ) 210 if (command == fNumOfAbsCmd) { << 217 {(Histo::GetPointer())->SetNumberDivZ(fNumOfEvt->GetNewIntValue(newValue));} 211 fDetector->SetNumberDivR(fNumOfAbsCmd->Get << 218 212 } << 219 if( command == fVerbCmd ){ 213 << 220 G4int ver = fVerbCmd->GetNewIntValue(newValue); 214 if (command == fNumOfEvt) { << 221 (Histo::GetPointer())->SetVerbose(ver); 215 fDetector->SetNumberDivZ(fNumOfEvt->GetNew << 222 } 216 } << 223 217 << 224 if( command == fIntCmd ) 218 if (command == fIntCmd) { << 225 {(Histo::GetPointer())->SetNumberDivE(fIntCmd->GetNewIntValue(newValue));} 219 fDetector->SetNumberDivE(fIntCmd->GetNewIn << 226 220 } << 227 if( command == fDeltaECmd ) 221 if (command == fDeltaECmd) { << 228 {(Histo::GetPointer()) 222 fDetector->SetMaxEnergy(fDeltaECmd->GetNew << 229 ->SetMaxEnergy(fDeltaECmd->GetNewDoubleValue(newValue));} 223 } << 230 224 << 225 if (command == fVerbCmd) { << 226 G4int ver = fVerbCmd->GetNewIntValue(newVa << 227 fDetector->SetVerbose(ver); << 228 } << 229 } 231 } 230 232 231 //....oooOO0OOooo........oooOO0OOooo........oo 233 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 232 234