Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
F03FieldMessenger.cc
Go to the documentation of this file.
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 //
28 //
29 // $Id$
30 //
31 
32 #include "F03FieldMessenger.hh"
33 #include "F03FieldSetup.hh"
34 
35 #include "G4UIdirectory.hh"
36 #include "G4UIcmdWithAnInteger.hh"
39 #include "G4SystemOfUnits.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
42 
44  : G4UImessenger(),
45  fEMfieldSetup(pEMfield),
46  fFieldDir(0),
47  fStepperCmd(0),
48  fMagFieldCmd(0),
49  fMinStepCmd(0),
50  fUpdateCmd(0)
51 {
52  fFieldDir = new G4UIdirectory("/field/");
53  fFieldDir->SetGuidance("F03 field tracking control.");
54 
55  fStepperCmd = new G4UIcmdWithAnInteger("/field/setStepperType",this);
56  fStepperCmd->SetGuidance("Select stepper type for magnetic field");
57  fStepperCmd->SetParameterName("choice",true);
58  fStepperCmd->SetDefaultValue(4);
60 
61  fUpdateCmd = new G4UIcmdWithoutParameter("/field/update",this);
62  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
63  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
64  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
65  fUpdateCmd->AvailableForStates(G4State_Idle);
66 
67  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ",this);
68  fMagFieldCmd->SetGuidance("Define magnetic field.");
69  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
70  fMagFieldCmd->SetParameterName("Bz",false,false);
71  fMagFieldCmd->SetDefaultUnit("tesla");
72  fMagFieldCmd->AvailableForStates(G4State_Idle);
73 
74  fMinStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setMinStep",this);
75  fMinStepCmd->SetGuidance("Define minimal step");
76  fMinStepCmd->SetGuidance("Magnetic field will be in Z direction.");
77  fMinStepCmd->SetParameterName("min step",false,false);
78  fMinStepCmd->SetDefaultUnit("mm");
79  fMinStepCmd->AvailableForStates(G4State_Idle);
80 }
81 
82 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
83 
85 {
86  delete fStepperCmd;
87  delete fMagFieldCmd;
88  delete fMinStepCmd;
89  delete fUpdateCmd;
90  delete fFieldDir;
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
94 
96 {
97  if( command == fStepperCmd )
98  {
99  fEMfieldSetup->SetStepperType(fStepperCmd->GetNewIntValue(newValue));
100  }
101  if( command == fUpdateCmd )
102  {
103  fEMfieldSetup->UpdateField();
104  }
105  if( command == fMagFieldCmd )
106  {
107  fEMfieldSetup->SetFieldValue(fMagFieldCmd->GetNewDoubleValue(newValue));
108  // Check the value
109  G4cout << "Set field value to " <<
110  fEMfieldSetup->GetConstantFieldValue() / gauss << " Gauss " << G4endl;
111 
112  }
113  if( command == fMinStepCmd )
114  {
115  fEMfieldSetup->SetMinStep(fMinStepCmd->GetNewDoubleValue(newValue));
116  }
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....