Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/electromagnetic/TestEm16/src/DetectorMessenger.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 electromagnetic/TestEm16/src/DetectorMessenger.cc
27 /// \brief Implementation of the DetectorMessenger class
28 //
29 // $Id: DetectorMessenger.cc 68208 2013-03-18 18:17:16Z maire $
30 //
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
33 
34 #include "DetectorMessenger.hh"
35 
36 #include "DetectorConstruction.hh"
37 #include "G4UIdirectory.hh"
38 #include "G4UIcmdWithAString.hh"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 :G4UImessenger(),fDetector(Det),
46  fTestemDir(0),
47  fDetDir(0),
48  fTrackdir(0),
49  fMaterCmd(0),
50  fSizeCmd(0),
51  fMagFieldCmd(0),
52  fMaxStepCmd(0),
53  fMaxStepLength(0),
54  fUpdateCmd(0)
55 {
56  fTestemDir = new G4UIdirectory("/testem/");
57  fTestemDir->SetGuidance(" detector control.");
58 
59  fDetDir = new G4UIdirectory("/testem/det/");
60  fDetDir->SetGuidance("detector construction commands");
61 
62  fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
63  fMaterCmd->SetGuidance("Select material of the box.");
64  fMaterCmd->SetParameterName("choice",false);
66 
67  fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
68  fSizeCmd->SetGuidance("Set size of the box");
69  fSizeCmd->SetParameterName("Size",false);
70  fSizeCmd->SetRange("Size>0.");
71  fSizeCmd->SetUnitCategory("Length");
73 
74  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
75  fMagFieldCmd->SetGuidance("Define magnetic field.");
76  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
77  fMagFieldCmd->SetParameterName("Bz",false);
78  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
80 
81  fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
82  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
83  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
84  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
85  fUpdateCmd->AvailableForStates(G4State_Idle);
86 
87  fMaxStepCmd = new G4UIcmdWithADoubleAndUnit("/testem/tracking/stepMax",this);
88  fMaxStepCmd->SetGuidance("Set max allowed step size");
89  fMaxStepCmd->SetParameterName("Size",false);
90  fMaxStepCmd->SetRange("Size>0.");
91  fMaxStepCmd->SetUnitCategory("Length");
92  fMaxStepCmd->AvailableForStates(G4State_Idle);
93 
94  fTrackdir = new G4UIdirectory("/testem/tracking/");
95  fTrackdir->SetGuidance("step length");
96  fMaxStepLength= new G4UIcmdWithADoubleAndUnit("/testem/tracking/setMaxStepLength",this);
97  fMaxStepLength->SetGuidance("Set the maximum length of tracking step");
98  fMaxStepLength->SetGuidance("when integrating magnetic field line.");
99  fMaxStepLength->SetParameterName("Size",false);
100  fMaxStepLength->SetRange("Size>0.");
101  fMaxStepLength->SetUnitCategory("Length");
102  fMaxStepLength->AvailableForStates(G4State_Idle);
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  delete fMaterCmd;
110  delete fSizeCmd;
111  delete fMagFieldCmd;
112  delete fUpdateCmd;
113  delete fMaxStepCmd;
114  delete fMaxStepLength;
115  delete fDetDir;
116  delete fTestemDir;
117  delete fTrackdir;
118 }
119 
120 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
121 
123 {
124  if( command == fMaterCmd )
125  { fDetector->SetMaterial(newValue);}
126 
127  if( command == fSizeCmd )
128  { fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));}
129 
130  if( command == fMagFieldCmd )
131  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
132 
133  if( command == fUpdateCmd )
134  { fDetector->UpdateGeometry(); }
135 
136  if( command == fMaxStepCmd )
137  { fDetector->SetMaxStepSize(fMaxStepCmd->GetNewDoubleValue(newValue));}
138 
139  if( command == fMaxStepLength )
140  { fDetector->SetMaxStepLength(fMaxStepLength->GetNewDoubleValue(newValue));}
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)