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