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 | // $Id: F03FieldMessenger.cc,v 1.7 2006/06/29 17:19:32 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: geant4-09-03-cand-01 $ |
---|
29 | // |
---|
30 | // |
---|
31 | |
---|
32 | #include "F03FieldMessenger.hh" |
---|
33 | |
---|
34 | #include "F03FieldSetup.hh" |
---|
35 | #include "G4UIdirectory.hh" |
---|
36 | #include "G4UIcmdWithAString.hh" |
---|
37 | #include "G4UIcmdWithAnInteger.hh" |
---|
38 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
39 | #include "G4UIcmdWithoutParameter.hh" |
---|
40 | |
---|
41 | ////////////////////////////////////////////////////////////////////////////// |
---|
42 | |
---|
43 | F03FieldMessenger::F03FieldMessenger(F03FieldSetup* pEMfield) |
---|
44 | : fEMfieldSetup(pEMfield) |
---|
45 | { |
---|
46 | F03detDir = new G4UIdirectory("/field/"); |
---|
47 | F03detDir->SetGuidance("F03 field tracking control."); |
---|
48 | |
---|
49 | StepperCmd = new G4UIcmdWithAnInteger("/field/setStepperType",this); |
---|
50 | StepperCmd->SetGuidance("Select stepper type for magnetic field"); |
---|
51 | StepperCmd->SetParameterName("choice",true); |
---|
52 | StepperCmd->SetDefaultValue(4); |
---|
53 | StepperCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
54 | |
---|
55 | |
---|
56 | UpdateCmd = new G4UIcmdWithoutParameter("/field/update",this); |
---|
57 | UpdateCmd->SetGuidance("Update calorimeter geometry."); |
---|
58 | UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); |
---|
59 | UpdateCmd->SetGuidance("if you changed geometrical value(s)."); |
---|
60 | UpdateCmd->AvailableForStates(G4State_Idle); |
---|
61 | |
---|
62 | MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ",this); |
---|
63 | MagFieldCmd->SetGuidance("Define magnetic field."); |
---|
64 | MagFieldCmd->SetGuidance("Magnetic field will be in Z direction."); |
---|
65 | MagFieldCmd->SetParameterName("Bz",false,false); |
---|
66 | MagFieldCmd->SetDefaultUnit("tesla"); |
---|
67 | MagFieldCmd->AvailableForStates(G4State_Idle); |
---|
68 | |
---|
69 | MinStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setMinStep",this); |
---|
70 | MinStepCmd->SetGuidance("Define minimal step"); |
---|
71 | MinStepCmd->SetGuidance("Magnetic field will be in Z direction."); |
---|
72 | MinStepCmd->SetParameterName("min step",false,false); |
---|
73 | MinStepCmd->SetDefaultUnit("mm"); |
---|
74 | MinStepCmd->AvailableForStates(G4State_Idle); |
---|
75 | |
---|
76 | AbsMaterCmd = new G4UIcmdWithAString("/field/setAbsMat",this); |
---|
77 | AbsMaterCmd->SetGuidance("Select Material of the Absorber."); |
---|
78 | AbsMaterCmd->SetParameterName("choice",true); |
---|
79 | AbsMaterCmd->SetDefaultValue("Xe"); |
---|
80 | AbsMaterCmd->AvailableForStates(G4State_Idle); |
---|
81 | |
---|
82 | |
---|
83 | } |
---|
84 | |
---|
85 | /////////////////////////////////////////////////////////////////////////////// |
---|
86 | |
---|
87 | F03FieldMessenger::~F03FieldMessenger() |
---|
88 | { |
---|
89 | delete StepperCmd; |
---|
90 | delete MagFieldCmd; |
---|
91 | delete MinStepCmd; |
---|
92 | delete F03detDir; |
---|
93 | delete UpdateCmd; |
---|
94 | |
---|
95 | delete AbsMaterCmd; |
---|
96 | } |
---|
97 | |
---|
98 | //////////////////////////////////////////////////////////////////////////// |
---|
99 | // |
---|
100 | // |
---|
101 | |
---|
102 | void F03FieldMessenger::SetNewValue( G4UIcommand* command, G4String newValue) |
---|
103 | { |
---|
104 | if( command == StepperCmd ) |
---|
105 | { |
---|
106 | fEMfieldSetup->SetStepperType(StepperCmd->GetNewIntValue(newValue)); |
---|
107 | } |
---|
108 | if( command == UpdateCmd ) |
---|
109 | { |
---|
110 | fEMfieldSetup->UpdateField(); |
---|
111 | } |
---|
112 | if( command == MagFieldCmd ) |
---|
113 | { |
---|
114 | fEMfieldSetup->SetFieldValue(MagFieldCmd->GetNewDoubleValue(newValue)); |
---|
115 | // Check the value |
---|
116 | // fEMfieldSetup->GetConstantFieldValue(); |
---|
117 | // GetLocalFieldManager() |
---|
118 | G4cout << "Set field value to " << |
---|
119 | fEMfieldSetup->GetConstantFieldValue() / gauss << " Gauss " << G4endl; |
---|
120 | |
---|
121 | } |
---|
122 | if( command == MinStepCmd ) |
---|
123 | { |
---|
124 | fEMfieldSetup->SetMinStep(MinStepCmd->GetNewDoubleValue(newValue)); |
---|
125 | } |
---|
126 | } |
---|
127 | |
---|
128 | // |
---|
129 | // |
---|
130 | ///////////////////////////////////////////////////////////////////////// |
---|