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 /// \file electromagnetic/TestEm16/src/Detecto 26 /// \file electromagnetic/TestEm16/src/DetectorMessenger.cc 27 /// \brief Implementation of the DetectorMesse 27 /// \brief Implementation of the DetectorMessenger class 28 // 28 // 29 // 29 // 30 //....oooOO0OOooo........oooOO0OOooo........oo 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 31 //....oooOO0OOooo........oooOO0OOooo........oo 31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 32 32 33 #include "DetectorMessenger.hh" 33 #include "DetectorMessenger.hh" 34 34 35 #include "DetectorConstruction.hh" 35 #include "DetectorConstruction.hh" 36 << 36 #include "G4UIdirectory.hh" 37 #include "G4UIcmdWithADoubleAndUnit.hh" << 38 #include "G4UIcmdWithAString.hh" 37 #include "G4UIcmdWithAString.hh" >> 38 #include "G4UIcmdWithADoubleAndUnit.hh" 39 #include "G4UIcmdWithoutParameter.hh" 39 #include "G4UIcmdWithoutParameter.hh" 40 #include "G4UIdirectory.hh" << 41 40 42 //....oooOO0OOooo........oooOO0OOooo........oo 41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 42 44 DetectorMessenger::DetectorMessenger(DetectorC << 43 DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) >> 44 :G4UImessenger(),fDetector(Det), >> 45 fTestemDir(0), >> 46 fDetDir(0), >> 47 fTrackdir(0), >> 48 fMaterCmd(0), >> 49 fSizeCmd(0), >> 50 fMaxStepCmd(0), >> 51 fMaxStepLength(0) 45 { 52 { 46 fTestemDir = new G4UIdirectory("/testem/"); 53 fTestemDir = new G4UIdirectory("/testem/"); 47 fTestemDir->SetGuidance(" detector control." 54 fTestemDir->SetGuidance(" detector control."); 48 55 49 fDetDir = new G4UIdirectory("/testem/det/"); 56 fDetDir = new G4UIdirectory("/testem/det/"); 50 fDetDir->SetGuidance("detector construction 57 fDetDir->SetGuidance("detector construction commands"); 51 58 52 fMaterCmd = new G4UIcmdWithAString("/testem/ << 59 fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this); 53 fMaterCmd->SetGuidance("Select material of t 60 fMaterCmd->SetGuidance("Select material of the box."); 54 fMaterCmd->SetParameterName("choice", false) << 61 fMaterCmd->SetParameterName("choice",false); 55 fMaterCmd->AvailableForStates(G4State_PreIni << 62 fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 56 63 57 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/t << 64 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this); 58 fSizeCmd->SetGuidance("Set size of the box") 65 fSizeCmd->SetGuidance("Set size of the box"); 59 fSizeCmd->SetParameterName("Size", false); << 66 fSizeCmd->SetParameterName("Size",false); 60 fSizeCmd->SetRange("Size>0."); 67 fSizeCmd->SetRange("Size>0."); 61 fSizeCmd->SetUnitCategory("Length"); 68 fSizeCmd->SetUnitCategory("Length"); 62 fSizeCmd->AvailableForStates(G4State_PreInit << 69 fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 63 << 64 fGeomFileCmd = new G4UIcmdWithAString("/test << 65 fGeomFileCmd->SetGuidance("Give sgml input f << 66 fGeomFileCmd->SetParameterName("choice", fal << 67 fGeomFileCmd->AvailableForStates(G4State_Pre << 68 70 69 fMaxStepCmd = new G4UIcmdWithADoubleAndUnit( << 71 fMaxStepCmd = new G4UIcmdWithADoubleAndUnit("/testem/tracking/stepMax",this); 70 fMaxStepCmd->SetGuidance("Set max allowed st 72 fMaxStepCmd->SetGuidance("Set max allowed step size"); 71 fMaxStepCmd->SetParameterName("Size", false) << 73 fMaxStepCmd->SetParameterName("Size",false); 72 fMaxStepCmd->SetRange("Size>0."); 74 fMaxStepCmd->SetRange("Size>0."); 73 fMaxStepCmd->SetUnitCategory("Length"); 75 fMaxStepCmd->SetUnitCategory("Length"); 74 fMaxStepCmd->AvailableForStates(G4State_Idle 76 fMaxStepCmd->AvailableForStates(G4State_Idle); 75 77 76 fTrackdir = new G4UIdirectory("/testem/track 78 fTrackdir = new G4UIdirectory("/testem/tracking/"); 77 fTrackdir->SetGuidance("step length"); 79 fTrackdir->SetGuidance("step length"); 78 fMaxStepLength = new G4UIcmdWithADoubleAndUn << 80 fMaxStepLength = >> 81 new G4UIcmdWithADoubleAndUnit("/testem/tracking/setMaxStepLength",this); 79 fMaxStepLength->SetGuidance("Set the maximum 82 fMaxStepLength->SetGuidance("Set the maximum length of tracking step"); 80 fMaxStepLength->SetGuidance("when integratin 83 fMaxStepLength->SetGuidance("when integrating magnetic field line."); 81 fMaxStepLength->SetParameterName("Size", fal << 84 fMaxStepLength->SetParameterName("Size",false); 82 fMaxStepLength->SetRange("Size>0."); 85 fMaxStepLength->SetRange("Size>0."); 83 fMaxStepLength->SetUnitCategory("Length"); 86 fMaxStepLength->SetUnitCategory("Length"); 84 fMaxStepLength->AvailableForStates(G4State_I 87 fMaxStepLength->AvailableForStates(G4State_Idle); 85 } 88 } 86 89 87 //....oooOO0OOooo........oooOO0OOooo........oo 90 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 91 89 void DetectorMessenger::SetNewValue(G4UIcomman << 92 DetectorMessenger::~DetectorMessenger() >> 93 { >> 94 delete fMaterCmd; >> 95 delete fSizeCmd; >> 96 delete fMaxStepCmd; >> 97 delete fMaxStepLength; >> 98 delete fDetDir; >> 99 delete fTestemDir; >> 100 delete fTrackdir; >> 101 } >> 102 >> 103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... >> 104 >> 105 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 90 { 106 { 91 if (command == fMaterCmd) { << 107 if( command == fMaterCmd ) 92 fDetector->SetMaterial(newValue); << 108 { fDetector->SetMaterial(newValue);} 93 } << 109 94 << 110 if( command == fSizeCmd ) 95 if (command == fSizeCmd) { << 111 { fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));} 96 fDetector->SetSize(fSizeCmd->GetNewDoubleV << 112 97 } << 113 if( command == fMaxStepCmd ) 98 << 114 { fDetector->SetMaxStepSize(fMaxStepCmd->GetNewDoubleValue(newValue));} 99 if (command == fMaxStepCmd) { << 115 100 fDetector->SetMaxStepSize(fMaxStepCmd->Get << 116 if( command == fMaxStepLength ) 101 } << 117 { fDetector->SetMaxStepLength(fMaxStepLength->GetNewDoubleValue(newValue));} 102 << 103 if (command == fMaxStepLength) { << 104 fDetector->SetMaxStepLength(fMaxStepLength << 105 } << 106 << 107 if (command == fGeomFileCmd) { << 108 fDetector->SetGeomFileName(newValue); << 109 } << 110 } 118 } 111 119 112 //....oooOO0OOooo........oooOO0OOooo........oo 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 113 121