Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/exoticphysics/monopole/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 exoticphysics/monopole/src/DetectorMessenger.cc
27 /// \brief Implementation of the DetectorMessenger class
28 //
29 // $Id: DetectorMessenger.cc 68036 2013-03-13 14:13:45Z gcosmo $
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"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
46  :G4UImessenger(),
47  fDetector(det),
48  fDetDir(0),
49  fMaterCmd(0),
50  fSizeXCmd(0),
51  fSizeYZCmd(0),
52  fStepSizeCmd(0),
53  fMagFieldCmd(0)
54 
55 {
56  fDetDir = new G4UIdirectory("/testex/det/");
57  fDetDir->SetGuidance("detector construction commands");
58 
59  fMaterCmd = new G4UIcmdWithAString("/testex/det/setMat",this);
60  fMaterCmd->SetGuidance("Select material of the box.");
61  fMaterCmd->SetParameterName("choice",false);
63 
64  fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeX",this);
65  fSizeXCmd->SetGuidance("Set sizeX of the absorber");
66  fSizeXCmd->SetParameterName("SizeX",false);
67  fSizeXCmd->SetRange("SizeX>0.");
68  fSizeXCmd->SetUnitCategory("Length");
70 
71  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeYZ",this);
72  fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
73  fSizeYZCmd->SetParameterName("SizeYZ",false);
74  fSizeYZCmd->SetRange("SizeYZ>0.");
75  fSizeYZCmd->SetUnitCategory("Length");
77 
78  fStepSizeCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setStepSize",this);
79  fStepSizeCmd->SetGuidance("Set maxStepSize in the absorber");
80  fStepSizeCmd->SetParameterName("StepSize",false);
81  fStepSizeCmd->SetRange("StepSize>0.");
82  fStepSizeCmd->SetUnitCategory("Length");
84 
85 
86  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setField",this);
87  fMagFieldCmd->SetGuidance("Define magnetic field.");
88  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
89  fMagFieldCmd->SetParameterName("Bz",false);
90  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
92 
93  fUpdateCmd = new G4UIcmdWithoutParameter("/testex/det/update",this);
94  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
95  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
96  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
97  fUpdateCmd->AvailableForStates(G4State_Idle);
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
101 
103 {
104  delete fMaterCmd;
105  delete fSizeXCmd;
106  delete fSizeYZCmd;
107  delete fStepSizeCmd;
108  delete fMagFieldCmd;
109  delete fUpdateCmd;
110  delete fDetDir;
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117  if( command == fMaterCmd )
118  { fDetector->SetMaterial(newValue);}
119 
120  if( command == fSizeXCmd )
121  { fDetector->SetSizeX(fSizeXCmd->GetNewDoubleValue(newValue));}
122 
123  if( command == fSizeYZCmd )
124  { fDetector->SetSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));}
125 
126  if( command == fMagFieldCmd )
127  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
128 
129  if( command == fStepSizeCmd )
130  { fDetector->SetMaxStepSize(fStepSizeCmd->GetNewDoubleValue(newValue));}
131 
132  if( command == fUpdateCmd )
133  { fDetector->UpdateGeometry();}
134 }
135 
136 //....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)