Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 //
28 //
29 // $Id$
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 :fDetector(Det)
47 {
48  fTestemDir = new G4UIdirectory("/testem/");
49  fTestemDir->SetGuidance("UI commands specific to this example.");
50 
51  fDetDir = new G4UIdirectory("/testem/det/");
52  fDetDir->SetGuidance("detector construction commands");
53 
54  fAbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat",this);
55  fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
56  fAbsMaterCmd->SetParameterName("choice",false);
58 
59  fWorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
60  fWorldMaterCmd->SetGuidance("Select Material of the World.");
61  fWorldMaterCmd->SetParameterName("wchoice",false);
63 
64  fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this);
65  fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
66  fAbsThickCmd->SetParameterName("SizeZ",false);
67  fAbsThickCmd->SetRange("SizeZ>0.");
68  fAbsThickCmd->SetUnitCategory("Length");
70 
71  fAbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this);
72  fAbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
73  fAbsSizYZCmd->SetParameterName("SizeYZ",false);
74  fAbsSizYZCmd->SetRange("SizeYZ>0.");
75  fAbsSizYZCmd->SetUnitCategory("Length");
77 
78  fAbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this);
79  fAbsXposCmd->SetGuidance("Set X pos. of the Absorber");
80  fAbsXposCmd->SetParameterName("Xpos",false);
81  fAbsXposCmd->SetUnitCategory("Length");
83 
84  fWorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this);
85  fWorldXCmd->SetGuidance("Set X size of the World");
86  fWorldXCmd->SetParameterName("WSizeX",false);
87  fWorldXCmd->SetRange("WSizeX>0.");
88  fWorldXCmd->SetUnitCategory("Length");
90 
91  fWorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this);
92  fWorldYZCmd->SetGuidance("Set sizeYZ of the World");
93  fWorldYZCmd->SetParameterName("WSizeYZ",false);
94  fWorldYZCmd->SetRange("WSizeYZ>0.");
95  fWorldYZCmd->SetUnitCategory("Length");
97 
98  fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
99  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
100  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
101  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
102  fUpdateCmd->AvailableForStates(G4State_Idle);
103 
104  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
105  fMagFieldCmd->SetGuidance("Define magnetic field.");
106  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
107  fMagFieldCmd->SetParameterName("Bz",false);
108  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
110 
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117  delete fAbsMaterCmd;
118  delete fAbsThickCmd;
119  delete fAbsSizYZCmd;
120  delete fAbsXposCmd;
121  delete fWorldMaterCmd;
122  delete fWorldXCmd;
123  delete fWorldYZCmd;
124  delete fUpdateCmd;
125  delete fMagFieldCmd;
126  delete fDetDir;
127  delete fTestemDir;
128 }
129 
130 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
131 
133 {
134  if ( command == fAbsMaterCmd )
135  {fDetector->SetAbsorberMaterial(newValue);}
136 
137  if ( command == fWorldMaterCmd )
138  {fDetector->SetWorldMaterial(newValue);}
139 
140  if ( command == fAbsThickCmd )
141  {fDetector->SetAbsorberThickness(fAbsThickCmd->GetNewDoubleValue(newValue));}
142 
143  if ( command == fAbsSizYZCmd )
144  {fDetector->SetAbsorberSizeYZ(fAbsSizYZCmd->GetNewDoubleValue(newValue));}
145 
146  if ( command == fAbsXposCmd )
147  {fDetector->SetAbsorberXpos(fAbsXposCmd->GetNewDoubleValue(newValue));}
148 
149  if ( command == fWorldXCmd )
150  {fDetector->SetWorldSizeX(fWorldXCmd->GetNewDoubleValue(newValue));}
151 
152  if ( command == fWorldYZCmd )
153  {fDetector->SetWorldSizeYZ(fWorldYZCmd->GetNewDoubleValue(newValue));}
154 
155  if ( command == fUpdateCmd )
156  {fDetector->UpdateGeometry(); }
157 
158  if( command == fMagFieldCmd )
159  {fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......