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 68208 2013-03-18 18:17:16Z maire $ 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 fMagFieldCmd(0), >> 52 fMaxStepCmd(0), >> 53 fMaxStepLength(0), >> 54 fUpdateCmd(0) 45 { 55 { 46 fTestemDir = new G4UIdirectory("/testem/"); 56 fTestemDir = new G4UIdirectory("/testem/"); 47 fTestemDir->SetGuidance(" detector control." 57 fTestemDir->SetGuidance(" detector control."); 48 58 49 fDetDir = new G4UIdirectory("/testem/det/"); 59 fDetDir = new G4UIdirectory("/testem/det/"); 50 fDetDir->SetGuidance("detector construction 60 fDetDir->SetGuidance("detector construction commands"); 51 61 52 fMaterCmd = new G4UIcmdWithAString("/testem/ << 62 fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this); 53 fMaterCmd->SetGuidance("Select material of t 63 fMaterCmd->SetGuidance("Select material of the box."); 54 fMaterCmd->SetParameterName("choice", false) << 64 fMaterCmd->SetParameterName("choice",false); 55 fMaterCmd->AvailableForStates(G4State_PreIni << 65 fMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 56 66 57 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/t << 67 fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this); 58 fSizeCmd->SetGuidance("Set size of the box") 68 fSizeCmd->SetGuidance("Set size of the box"); 59 fSizeCmd->SetParameterName("Size", false); << 69 fSizeCmd->SetParameterName("Size",false); 60 fSizeCmd->SetRange("Size>0."); 70 fSizeCmd->SetRange("Size>0."); 61 fSizeCmd->SetUnitCategory("Length"); 71 fSizeCmd->SetUnitCategory("Length"); 62 fSizeCmd->AvailableForStates(G4State_PreInit << 72 fSizeCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 63 73 64 fGeomFileCmd = new G4UIcmdWithAString("/test << 74 fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); 65 fGeomFileCmd->SetGuidance("Give sgml input f << 75 fMagFieldCmd->SetGuidance("Define magnetic field."); 66 fGeomFileCmd->SetParameterName("choice", fal << 76 fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); 67 fGeomFileCmd->AvailableForStates(G4State_Pre << 77 fMagFieldCmd->SetParameterName("Bz",false); >> 78 fMagFieldCmd->SetUnitCategory("Magnetic flux density"); >> 79 fMagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); >> 80 >> 81 fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this); >> 82 fUpdateCmd->SetGuidance("Update calorimeter geometry."); >> 83 fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); >> 84 fUpdateCmd->SetGuidance("if you changed geometrical value(s)."); >> 85 fUpdateCmd->AvailableForStates(G4State_Idle); 68 86 69 fMaxStepCmd = new G4UIcmdWithADoubleAndUnit( << 87 fMaxStepCmd = new G4UIcmdWithADoubleAndUnit("/testem/tracking/stepMax",this); 70 fMaxStepCmd->SetGuidance("Set max allowed st 88 fMaxStepCmd->SetGuidance("Set max allowed step size"); 71 fMaxStepCmd->SetParameterName("Size", false) << 89 fMaxStepCmd->SetParameterName("Size",false); 72 fMaxStepCmd->SetRange("Size>0."); 90 fMaxStepCmd->SetRange("Size>0."); 73 fMaxStepCmd->SetUnitCategory("Length"); 91 fMaxStepCmd->SetUnitCategory("Length"); 74 fMaxStepCmd->AvailableForStates(G4State_Idle 92 fMaxStepCmd->AvailableForStates(G4State_Idle); 75 93 76 fTrackdir = new G4UIdirectory("/testem/track 94 fTrackdir = new G4UIdirectory("/testem/tracking/"); 77 fTrackdir->SetGuidance("step length"); 95 fTrackdir->SetGuidance("step length"); 78 fMaxStepLength = new G4UIcmdWithADoubleAndUn << 96 fMaxStepLength= new G4UIcmdWithADoubleAndUnit("/testem/tracking/setMaxStepLength",this); 79 fMaxStepLength->SetGuidance("Set the maximum 97 fMaxStepLength->SetGuidance("Set the maximum length of tracking step"); 80 fMaxStepLength->SetGuidance("when integratin 98 fMaxStepLength->SetGuidance("when integrating magnetic field line."); 81 fMaxStepLength->SetParameterName("Size", fal << 99 fMaxStepLength->SetParameterName("Size",false); 82 fMaxStepLength->SetRange("Size>0."); 100 fMaxStepLength->SetRange("Size>0."); 83 fMaxStepLength->SetUnitCategory("Length"); 101 fMaxStepLength->SetUnitCategory("Length"); 84 fMaxStepLength->AvailableForStates(G4State_I 102 fMaxStepLength->AvailableForStates(G4State_Idle); 85 } 103 } 86 104 87 //....oooOO0OOooo........oooOO0OOooo........oo 105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 88 106 89 void DetectorMessenger::SetNewValue(G4UIcomman << 107 DetectorMessenger::~DetectorMessenger() 90 { 108 { 91 if (command == fMaterCmd) { << 109 delete fMaterCmd; 92 fDetector->SetMaterial(newValue); << 110 delete fSizeCmd; 93 } << 111 delete fMagFieldCmd; 94 << 112 delete fUpdateCmd; 95 if (command == fSizeCmd) { << 113 delete fMaxStepCmd; 96 fDetector->SetSize(fSizeCmd->GetNewDoubleV << 114 delete fMaxStepLength; 97 } << 115 delete fDetDir; 98 << 116 delete fTestemDir; 99 if (command == fMaxStepCmd) { << 117 delete fTrackdir; 100 fDetector->SetMaxStepSize(fMaxStepCmd->Get << 118 } 101 } << 119 102 << 120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 103 if (command == fMaxStepLength) { << 121 104 fDetector->SetMaxStepLength(fMaxStepLength << 122 void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) 105 } << 123 { 106 << 124 if( command == fMaterCmd ) 107 if (command == fGeomFileCmd) { << 125 { fDetector->SetMaterial(newValue);} 108 fDetector->SetGeomFileName(newValue); << 126 109 } << 127 if( command == fSizeCmd ) >> 128 { fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));} >> 129 >> 130 if( command == fMagFieldCmd ) >> 131 { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));} >> 132 >> 133 if( command == fUpdateCmd ) >> 134 { fDetector->UpdateGeometry(); } >> 135 >> 136 if( command == fMaxStepCmd ) >> 137 { fDetector->SetMaxStepSize(fMaxStepCmd->GetNewDoubleValue(newValue));} >> 138 >> 139 if( command == fMaxStepLength ) >> 140 { fDetector->SetMaxStepLength(fMaxStepLength->GetNewDoubleValue(newValue));} 110 } 141 } 111 142 112 //....oooOO0OOooo........oooOO0OOooo........oo 143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 113 144