Geant4.10
 All Data Structures 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 //
26 /// \file field/field03/src/F03FieldMessenger.cc
27 /// \brief Implementation of the F03FieldMessenger class
28 //
29 //
30 // $Id: F03FieldMessenger.cc 76602 2013-11-13 08:33:35Z gcosmo $
31 //
32 //
33 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 
36 #include "F03FieldMessenger.hh"
37 
38 #include "F03FieldSetup.hh"
39 #include "G4UIcmdWithAnInteger.hh"
42 
43 #include "G4SystemOfUnits.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48  : G4UImessenger(),
49  fEMfieldSetup(fieldSetup),
50  fFieldDir(0),
51  fStepperCmd(0),
52  fMagFieldCmd(0),
53  fMinStepCmd(0),
54  fUpdateCmd(0)
55 {
56  fFieldDir = new G4UIdirectory("/field/");
57  fFieldDir->SetGuidance("F03 field tracking control.");
58 
59  fStepperCmd = new G4UIcmdWithAnInteger("/field/setStepperType",this);
60  fStepperCmd->SetGuidance("Select stepper type for magnetic field");
61  fStepperCmd->SetParameterName("choice",true);
62  fStepperCmd->SetDefaultValue(4);
64 
65  fUpdateCmd = new G4UIcmdWithoutParameter("/field/update",this);
66  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
67  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
68  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
69  fUpdateCmd->AvailableForStates(G4State_Idle);
70 
71  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/field/setFieldZ",this);
72  fMagFieldCmd->SetGuidance("Define magnetic field.");
73  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
74  fMagFieldCmd->SetParameterName("Bz",false,false);
75  fMagFieldCmd->SetDefaultUnit("tesla");
76  fMagFieldCmd->AvailableForStates(G4State_Idle);
77 
78  fMinStepCmd = new G4UIcmdWithADoubleAndUnit("/field/setMinStep",this);
79  fMinStepCmd->SetGuidance("Define minimal step");
80  fMinStepCmd->SetGuidance("Magnetic field will be in Z direction.");
81  fMinStepCmd->SetParameterName("min step",false,false);
82  fMinStepCmd->SetDefaultUnit("mm");
83  fMinStepCmd->AvailableForStates(G4State_Idle);
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 {
90  delete fStepperCmd;
91  delete fMagFieldCmd;
92  delete fMinStepCmd;
93  delete fFieldDir;
94  delete fUpdateCmd;
95 }
96 
97 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
98 
100 {
101  if( command == fStepperCmd )
102  fEMfieldSetup->SetStepperType(fStepperCmd->GetNewIntValue(newValue));
103  if( command == fUpdateCmd )
104  fEMfieldSetup->UpdateField();
105  if( command == fMagFieldCmd )
106  fEMfieldSetup->SetFieldValue(fMagFieldCmd->GetNewDoubleValue(newValue));
107  // Check the value
108  G4cout << "Set field value to " <<
109  fEMfieldSetup->GetConstantFieldValue() / gauss << " Gauss " << G4endl;
110  if( command == fMinStepCmd )
111  fEMfieldSetup->SetMinStep(fMinStepCmd->GetNewDoubleValue(newValue));
112 }
113 
114 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetFieldValue(G4ThreeVector fieldVector)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4ThreeVector GetConstantFieldValue()
Definition of the F03FieldMessenger class.
static G4int GetNewIntValue(const char *paramString)
void SetStepperType(G4int i)
virtual void SetNewValue(G4UIcommand *, G4String)
static G4double GetNewDoubleValue(const char *paramString)
virtual ~F03FieldMessenger()
G4GLOB_DLL std::ostream G4cout
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetMinStep(G4double s)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
void SetDefaultUnit(const char *defUnit)
#define G4endl
Definition: G4ios.hh:61
void SetDefaultValue(G4int defVal)
Definition of the F03FieldSetup class.
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
F03FieldMessenger(F03FieldSetup *)