Geant4 Cross Reference |
1 // 2 // ******************************************************************** 3 // * License and Disclaimer * 4 // * * 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. * 10 // * * 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitation of liability. * 17 // * * 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************************************** 25 // 26 // 27 /// \file field/field04/src/F04FieldMessenger.cc 28 /// \brief Implementation of the F04FieldMessenger class 29 // 30 31 #include "F04FieldMessenger.hh" 32 33 #include "F04DetectorConstruction.hh" 34 #include "F04GlobalField.hh" 35 36 #include "G4UIcmdWithADoubleAndUnit.hh" 37 #include "G4UIcmdWithAString.hh" 38 #include "G4UIcmdWithAnInteger.hh" 39 #include "G4UIcmdWithoutParameter.hh" 40 #include "G4UIdirectory.hh" 41 42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 43 44 F04FieldMessenger::F04FieldMessenger(F04GlobalField* pEMfield, F04DetectorConstruction* detector) 45 : fGlobalField(pEMfield) 46 { 47 fDetector = detector; 48 49 fDetDir = new G4UIdirectory("/field/"); 50 fDetDir->SetGuidance(" Field tracking control "); 51 52 fCaptureB1Cmd = new G4UIcmdWithADoubleAndUnit("/field/SetCaptureB1", this); 53 fCaptureB1Cmd->SetGuidance("Set B1 of the Capture Magnet"); 54 fCaptureB1Cmd->SetParameterName("CSizeB1", false, false); 55 fCaptureB1Cmd->SetDefaultUnit("tesla"); 56 fCaptureB1Cmd->SetRange("CSizeB1>0."); 57 fCaptureB1Cmd->AvailableForStates(G4State_PreInit, G4State_Idle); 58 59 fCaptureB2Cmd = new G4UIcmdWithADoubleAndUnit("/field/SetCaptureB2", this); 60 fCaptureB2Cmd->SetGuidance("Set B2 of the Capture Magnet"); 61 fCaptureB2Cmd->SetParameterName("CSizeB2", false, false); 62 fCaptureB2Cmd->SetDefaultUnit("tesla"); 63 fCaptureB2Cmd->SetRange("CSizeB2>0."); 64 fCaptureB2Cmd->AvailableForStates(G4State_PreInit, G4State_Idle); 65 66 fTransferBCmd = new G4UIcmdWithADoubleAndUnit("/field/SetTransferB", this); 67 fTransferBCmd->SetGuidance("Set B of the Transfer Magnet"); 68 fTransferBCmd->SetParameterName("TSizeB", false, false); 69 fTransferBCmd->SetDefaultUnit("tesla"); 70 fTransferBCmd->SetRange("TSizeB>0."); 71 fTransferBCmd->AvailableForStates(G4State_PreInit, G4State_Idle); 72 73 fStepperCMD = new G4UIcmdWithAnInteger("/field/setStepperType", this); 74 fStepperCMD->SetGuidance("Select stepper type for field"); 75 fStepperCMD->SetParameterName("choice", true); 76 fStepperCMD->SetDefaultValue(4); 77 fStepperCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 78 79 fMinStepCMD = new G4UIcmdWithADoubleAndUnit("/field/setMinStep", this); 80 fMinStepCMD->SetGuidance("Define minimal step"); 81 fMinStepCMD->SetParameterName("min step", false, false); 82 fMinStepCMD->SetDefaultUnit("mm"); 83 fMinStepCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 84 85 fDeltaChordCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaChord", this); 86 fDeltaChordCMD->SetGuidance("Define delta chord"); 87 fDeltaChordCMD->SetParameterName("delta chord", false, false); 88 fDeltaChordCMD->SetDefaultUnit("mm"); 89 fDeltaChordCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 90 91 fDeltaOneStepCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaOneStep", this); 92 fDeltaOneStepCMD->SetGuidance("Define delta one step"); 93 fDeltaOneStepCMD->SetParameterName("delta one step", false, false); 94 fDeltaOneStepCMD->SetDefaultUnit("mm"); 95 fDeltaOneStepCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 96 97 fDeltaIntersectionCMD = new G4UIcmdWithADoubleAndUnit("/field/setDeltaIntersection", this); 98 fDeltaIntersectionCMD->SetGuidance("Define delta intersection"); 99 fDeltaIntersectionCMD->SetParameterName("delta intersection", false, false); 100 fDeltaIntersectionCMD->SetDefaultUnit("mm"); 101 fDeltaIntersectionCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 102 103 fEpsMinCMD = new G4UIcmdWithADoubleAndUnit("/field/setEpsMin", this); 104 fEpsMinCMD->SetGuidance("Define eps min"); 105 fEpsMinCMD->SetParameterName("eps min", false, false); 106 fEpsMinCMD->SetDefaultUnit("mm"); 107 fEpsMinCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 108 109 fEpsMaxCMD = new G4UIcmdWithADoubleAndUnit("/field/setEpsMax", this); 110 fEpsMaxCMD->SetGuidance("Define eps max"); 111 fEpsMaxCMD->SetParameterName("eps max", false, false); 112 fEpsMaxCMD->SetDefaultUnit("mm"); 113 fEpsMaxCMD->AvailableForStates(G4State_PreInit, G4State_Idle); 114 } 115 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 117 118 F04FieldMessenger::~F04FieldMessenger() 119 { 120 delete fDetDir; 121 122 delete fCaptureB1Cmd; 123 delete fCaptureB2Cmd; 124 delete fTransferBCmd; 125 126 delete fStepperCMD; 127 delete fMinStepCMD; 128 delete fDeltaChordCMD; 129 delete fDeltaOneStepCMD; 130 delete fDeltaIntersectionCMD; 131 delete fEpsMinCMD; 132 delete fEpsMaxCMD; 133 } 134 135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 136 137 void F04FieldMessenger::SetNewValue(G4UIcommand* command, G4String newValue) 138 { 139 if (command == fCaptureB1Cmd) 140 fDetector->SetCaptureMgntB1(fCaptureB1Cmd->GetNewDoubleValue(newValue)); 141 142 if (command == fCaptureB2Cmd) 143 fDetector->SetCaptureMgntB2(fCaptureB2Cmd->GetNewDoubleValue(newValue)); 144 145 if (command == fTransferBCmd) 146 fDetector->SetTransferMgntB(fTransferBCmd->GetNewDoubleValue(newValue)); 147 148 if (command == fStepperCMD) { 149 fGlobalField->SetStepperType(fStepperCMD->GetNewIntValue(newValue)); 150 } 151 if (command == fMinStepCMD) { 152 fGlobalField->SetMinStep(fMinStepCMD->GetNewDoubleValue(newValue)); 153 } 154 if (command == fDeltaChordCMD) { 155 fGlobalField->SetDeltaChord(fDeltaChordCMD->GetNewDoubleValue(newValue)); 156 } 157 if (command == fDeltaOneStepCMD) { 158 fGlobalField->SetDeltaOneStep(fDeltaOneStepCMD->GetNewDoubleValue(newValue)); 159 } 160 if (command == fDeltaIntersectionCMD) { 161 fGlobalField->SetDeltaIntersection(fDeltaIntersectionCMD->GetNewDoubleValue(newValue)); 162 } 163 if (command == fEpsMinCMD) { 164 fGlobalField->SetEpsMin(fEpsMinCMD->GetNewDoubleValue(newValue)); 165 } 166 if (command == fEpsMaxCMD) { 167 fGlobalField->SetEpsMax(fEpsMaxCMD->GetNewDoubleValue(newValue)); 168 } 169 } 170