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