QwGeant4
QweakSimMagneticFieldMessenger.cc
Go to the documentation of this file.
1 //=============================================================================
2 //
3 // ---------------------------
4 // | Doxygen File Information |
5 // ---------------------------
6 //
7 /**
8 
9  \file QweakSimMagneticFieldMessenger.cc
10 
11  $Revision: 1.2 $
12  $Date: 2005/12/27 19:12:59 $
13 
14  \author Klaus Hans Grimm
15 
16 */
17 //=============================================================================
18 
19 //=============================================================================
20 // -----------------------
21 // | CVS File Information |
22 // -----------------------
23 //
24 // Last Update: $Author: grimm $
25 // Update Date: $Date: 2005/12/27 19:12:59 $
26 // CVS/RCS Revision: $Revision: 1.2 $
27 // Status: $State: Exp $
28 //
29 // ===================================
30 // CVS Revision Log at end of file !!
31 // ===================================
32 //
33 //============================================================================
34 
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
36 
38 
39 // user includes
41 #include "QweakSimMagneticField.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
45  : fMagneticField(magneticfield)
46 {
47  MagneticFieldDir = new G4UIdirectory("/MagneticField/");
48  MagneticFieldDir->SetGuidance("Main Magnet control.");
49 
50  ReadCmd = new G4UIcmdWithAString("/MagneticField/ReadFieldMap",this);
51  ReadCmd->SetGuidance("Read the specified magnetic field from file");
52  ReadCmd->SetParameterName("file",true);
53  ReadCmd->SetDefaultValue("MainMagnet_FieldMap.dat");
54  ReadCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
55 
56 
57  PrintCmd = new G4UIcmdWith3VectorAndUnit("/MagneticField/PrintValue",this);
58  PrintCmd->SetGuidance("Print the magnetic field value for specified position");
59  PrintCmd->SetParameterName("x","y","z",false);
60  PrintCmd->SetDefaultValue(G4ThreeVector(0.0,0.0,0.0));
61  PrintCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
62 
63 
64  RefCurrentCmd = new G4UIcmdWithADouble("/MagneticField/SetReferenceCurrent",this);
65  RefCurrentCmd->SetGuidance("Set reference current of read field map");
66  RefCurrentCmd->SetParameterName("current",false);
67  RefCurrentCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
68 
69  ActCurrentCmd = new G4UIcmdWithADouble("/MagneticField/SetActualCurrent",this);
70  ActCurrentCmd->SetGuidance("Set actual current of the magnetic field for simulation");
71  ActCurrentCmd->SetParameterName("current",false);
72  ActCurrentCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
73 
74  ScaleCmd = new G4UIcmdWithADouble("/MagneticField/SetScale",this);
75  ScaleCmd->SetGuidance("Set scale of the magnetic field for simulation");
76  ScaleCmd->SetParameterName("bfil",false);
77  ScaleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
78 
79 
80  RotationCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetRotation",this);
81  RotationCmd->SetGuidance("Set rotation angle of the magnetic field to be read");
82  RotationCmd->SetParameterName("rotation",false);
83  RotationCmd->SetDefaultUnit("degree");
84  RotationCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
85 
86  TranslationCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetTranslation",this);
87  TranslationCmd->SetGuidance("Set translation in z of the magnetic field (applied on field read-in)");
88  TranslationCmd->SetParameterName("z",false);
89  TranslationCmd->SetDefaultUnit("cm");
90  TranslationCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
91 
92  TranslationVectorCmd = new G4UIcmdWith3VectorAndUnit("/MagneticField/SetTranslationVector",this);
93  TranslationVectorCmd->SetGuidance("Set translation vector of the magnetic field (applied on field evaluation)");
94  TranslationVectorCmd->SetParameterName("x","y","z",false);
95  TranslationVectorCmd->SetDefaultUnit("cm");
96  TranslationVectorCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
97 
98 
99  MinZCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMinZ",this);
100  MinZCmd->SetGuidance("Set the minimum z position of the field map grid to be read");
101  MinZCmd->SetParameterName("min_r",false);
102  MinZCmd->SetDefaultUnit("cm");
103  MinZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
104 
105  MaxZCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMaxZ",this);
106  MaxZCmd->SetGuidance("Set the maximum z position of the field map grid to be read");
107  MaxZCmd->SetParameterName("max_r",false);
108  MaxZCmd->SetDefaultUnit("cm");
109  MaxZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
110 
111  StepZCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetStepZ",this);
112  StepZCmd->SetGuidance("Set the step z position of the field map grid to be read");
113  StepZCmd->SetParameterName("step_r",false);
114  StepZCmd->SetDefaultUnit("cm");
115  StepZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
116 
117 
118  MinRCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMinR",this);
119  MinRCmd->SetGuidance("Set the minimum radius of the field map grid to be read");
120  MinRCmd->SetParameterName("min_r",false);
121  MinRCmd->SetDefaultUnit("cm");
122  MinRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
123 
124  MaxRCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMaxR",this);
125  MaxRCmd->SetGuidance("Set the maximum radius of the field map grid to be read");
126  MaxRCmd->SetParameterName("max_r",false);
127  MaxRCmd->SetDefaultUnit("cm");
128  MaxRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
129 
130  StepRCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetStepR",this);
131  StepRCmd->SetGuidance("Set the step radius of the field map grid to be read");
132  StepRCmd->SetParameterName("step_r",false);
133  StepRCmd->SetDefaultUnit("cm");
134  StepRCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
135 
136 
137  MinPhiCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMinPhi",this);
138  MinPhiCmd->SetGuidance("Set the minimum phi of the field map grid to be read");
139  MinPhiCmd->SetParameterName("min_phi",false);
140  MinPhiCmd->SetDefaultUnit("degree");
141  MinPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
142 
143  MaxPhiCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMaxPhi",this);
144  MaxPhiCmd->SetGuidance("Set the maximum phi of the field map grid to be read");
145  MaxPhiCmd->SetParameterName("max_phi",false);
146  MaxPhiCmd->SetDefaultUnit("degree");
147  MaxPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
148 
149  StepPhiCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetStepPhi",this);
150  StepPhiCmd->SetGuidance("Set the step phi of the field map grid to be read");
151  StepPhiCmd->SetParameterName("step_phi",false);
152  StepPhiCmd->SetDefaultUnit("degree");
153  StepPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
154 
155  WrapPhiCmd = new G4UIcmdWithAnInteger("/MagneticField/SetWrapPhi",this);
156  WrapPhiCmd->SetGuidance("Set the wrap in phi of the field map grid to be read");
157  WrapPhiCmd->SetParameterName("wrap_phi",false);
158  WrapPhiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
159 
160 
161  StepperCmd = new G4UIcmdWithAnInteger("/MagneticField/SetStepperType",this);
162  StepperCmd->SetGuidance("Select stepper type for magnetic field");
163  StepperCmd->SetParameterName("choice",true);
164  StepperCmd->SetDefaultValue(4);
165  StepperCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
166 
167  MinStepCmd = new G4UIcmdWithADoubleAndUnit("/MagneticField/SetMinStep",this);
168  MinStepCmd->SetGuidance("Define minimal step");
169  MinStepCmd->SetParameterName("min step",false,false);
170  MinStepCmd->SetDefaultUnit("mm");
171  MinStepCmd->AvailableForStates(G4State_Idle);
172 
173  UpdateCmd = new G4UIcmdWithoutParameter("/MagneticField/Update",this);
174  UpdateCmd->SetGuidance("Update Main Magnet geometry.");
175  UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
176  UpdateCmd->SetGuidance("if you changed geometrical value(s).");
177  UpdateCmd->AvailableForStates(G4State_Idle);
178 
179 }
180 
181 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
183 {
184 
185  delete ScaleCmd;
186  delete RefCurrentCmd;
187  delete ActCurrentCmd;
188 
189  delete MinZCmd;
190  delete MaxZCmd;
191  delete StepZCmd;
192 
193  delete MinRCmd;
194  delete MaxRCmd;
195  delete StepRCmd;
196 
197  delete MinPhiCmd;
198  delete MaxPhiCmd;
199  delete StepPhiCmd;
200  delete WrapPhiCmd;
201 
202  delete RotationCmd;
203  delete TranslationCmd;
204  delete TranslationVectorCmd;
205 
206  delete StepperCmd;
207  delete MinStepCmd;
208  delete UpdateCmd;
209 
210  delete MagneticFieldDir;
211 }
212 
213 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
214 void QweakSimMagneticFieldMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
215 {
216  if (command == ScaleCmd) {
217  fMagneticField->SetScaleFactor(ScaleCmd->GetNewDoubleValue(newValue));
218  } else if (command == ActCurrentCmd) {
219  fMagneticField->SetActualCurrent(ScaleCmd->GetNewDoubleValue(newValue));
220  } else if (command == RefCurrentCmd) {
221  fMagneticField->SetReferenceCurrent(ScaleCmd->GetNewDoubleValue(newValue));
222  } else if (command == MinZCmd) {
223  fMagneticField->SetMinimum(MinZCmd->GetNewDoubleValue(newValue)/cm,0);
224  } else if (command == MinRCmd) {
225  fMagneticField->SetMinimum(MinRCmd->GetNewDoubleValue(newValue)/cm,1);
226  } else if (command == MinPhiCmd) {
227  fMagneticField->SetMinimum(MinPhiCmd->GetNewDoubleValue(newValue)/radian,2);
228  } else if (command == MaxZCmd) {
229  fMagneticField->SetMaximum(MaxZCmd->GetNewDoubleValue(newValue)/cm,0);
230  } else if (command == MaxRCmd) {
231  fMagneticField->SetMaximum(MaxRCmd->GetNewDoubleValue(newValue)/cm,1);
232  } else if (command == MaxPhiCmd) {
233  fMagneticField->SetMaximum(MaxPhiCmd->GetNewDoubleValue(newValue)/radian,2);
234  } else if (command == StepZCmd) {
235  fMagneticField->SetStep(StepZCmd->GetNewDoubleValue(newValue)/cm,0);
236  } else if (command == StepRCmd) {
237  fMagneticField->SetStep(StepRCmd->GetNewDoubleValue(newValue)/cm,1);
238  } else if (command == StepPhiCmd) {
239  fMagneticField->SetStep(StepPhiCmd->GetNewDoubleValue(newValue)/radian,2);
240  } else if (command == WrapPhiCmd) {
241  fMagneticField->SetWrap(WrapPhiCmd->GetNewIntValue(newValue),2);
242  } else if (command == RotationCmd) {
243  fMagneticField->SetRotation(RotationCmd->GetNewDoubleValue(newValue));
244  } else if (command == TranslationCmd) {
245  fMagneticField->SetTranslation(TranslationCmd->GetNewDoubleValue(newValue));
246  } else if (command == TranslationVectorCmd) {
247  fMagneticField->SetTranslationVector(TranslationVectorCmd->GetNew3VectorValue(newValue));
248  } else if (command == PrintCmd) {
249  G4ThreeVector vector = PrintCmd->GetNew3VectorValue(newValue);
250  G4double point[4];
251  point[0] = vector.x();
252  point[1] = vector.y();
253  point[2] = vector.z();
254  point[3] = 0.0;
256  } else if (command == ReadCmd) {
257  fMagneticField->ReadFieldMap(newValue);
258  }
259 }
260 
261 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
262 
263 //=======================================================
264 // -----------------------
265 // | CVS File Information |
266 // -----------------------
267 //
268 // $Revisions$
269 // $Log: QweakSimMagneticFieldMessenger.cc,v $
270 // Revision 1.2 2005/12/27 19:12:59 grimm
271 // - Redesign of Doxygen header containing CVS info like revision and date
272 // - Added CVS revision log at the end of file
273 //
274 //
void SetTranslationVector(const G4ThreeVector translationvector)
Set the field translation vector.
void SetTranslation(const double translation)
Set the field translation along z.
void SetWrap(const int value, const int i)
Set the wrap.
void SetReferenceCurrent(const double referencecurrent)
Set the reference current.
void ReadFieldMap(const G4String &filename)
Read the field map.
QweakSimMagneticFieldMessenger(QweakSimMagneticField *)
void SetScaleFactor(const double scalefactor)
Set the scale factor.
void SetStep(const double value, const int i)
Set the step.
void SetNewValue(G4UIcommand *command, G4String newValue)
G4UIcmdWith3VectorAndUnit * TranslationVectorCmd
void SetRotation(const double rotation)
Set the field rotation around z.
void SetMaximum(const double value, const int i)
Set the maximum.
void PrintFieldValue(const G4double point[4]) const
Print the field value.
void SetMinimum(const double value, const int i)
Set the minimum.
void SetActualCurrent(const double actualcurrent)
Set the actual current.