Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/electromagnetic/TestEm12/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/TestEm12/src/DetectorMessenger.cc
27 /// \brief Implementation of the DetectorMessenger class
28 //
29 // $Id: DetectorMessenger.cc 67268 2013-02-13 11:38:40Z ihrivnac $
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"
39 #include "G4UIcmdWithAnInteger.hh"
42 
43 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
44 
46 :G4UImessenger(),fDetector(Det),
47  fTestemDir(0),
48  fDetDir(0),
49  fMaterCmd(0),
50  fRadiusCmd(0),
51  fNbLayersCmd(0),
52  fMagFieldCmd(0),
53  fUpdateCmd(0)
54 {
55  fTestemDir = new G4UIdirectory("/testem/");
56  fTestemDir->SetGuidance(" detector control.");
57 
58  fDetDir = new G4UIdirectory("/testem/det/");
59  fDetDir->SetGuidance("detector construction commands");
60 
61  fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
62  fMaterCmd->SetGuidance("Select material of the box.");
63  fMaterCmd->SetParameterName("choice",false);
65 
66  fRadiusCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setRadius",this);
67  fRadiusCmd->SetGuidance("Set radius of the absorber");
68  fRadiusCmd->SetParameterName("Radius",false);
69  fRadiusCmd->SetRange("Radius>0.");
70  fRadiusCmd->SetUnitCategory("Length");
72 
73  fNbLayersCmd = new G4UIcmdWithAnInteger("/testem/det/setNbOfLayers",this);
74  fNbLayersCmd->SetGuidance("Set number of layers");
75  fNbLayersCmd->SetParameterName("NbLayers",false);
76  fNbLayersCmd->SetRange("NbLayers>0");
78 
79  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
80  fMagFieldCmd->SetGuidance("Define magnetic field.");
81  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
82  fMagFieldCmd->SetParameterName("Bz",false);
83  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
85 
86  fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
87  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
88  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
89  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
90  fUpdateCmd->AvailableForStates(G4State_Idle);
91 }
92 
93 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
94 
96 {
97  delete fMaterCmd;
98  delete fRadiusCmd;
99  delete fNbLayersCmd;
100  delete fMagFieldCmd;
101  delete fUpdateCmd;
102  delete fDetDir;
103  delete fTestemDir;
104 }
105 
106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
107 
109 {
110  if( command == fMaterCmd )
111  { fDetector->SetMaterial(newValue);}
112 
113  if( command == fRadiusCmd )
114  { fDetector->SetRadius(fRadiusCmd->GetNewDoubleValue(newValue));}
115 
116  if( command == fNbLayersCmd )
117  { fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));}
118 
119  if( command == fMagFieldCmd )
120  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
121 
122  if( command == fUpdateCmd )
123  { fDetector->UpdateGeometry();}
124 }
125 
126 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
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)