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: DetectorMessenger.cc 66994 2013-01-29 14:34:08Z 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  :fDetector(det)
47 {
48  fDetDir = new G4UIdirectory("/testex/det/");
49  fDetDir->SetGuidance("detector construction commands");
50 
51  fMaterCmd = new G4UIcmdWithAString("/testex/det/setMat",this);
52  fMaterCmd->SetGuidance("Select material of the box.");
53  fMaterCmd->SetParameterName("choice",false);
55 
56  fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeX",this);
57  fSizeXCmd->SetGuidance("Set sizeX of the absorber");
58  fSizeXCmd->SetParameterName("SizeX",false);
59  fSizeXCmd->SetRange("SizeX>0.");
60  fSizeXCmd->SetUnitCategory("Length");
62 
63  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setSizeYZ",this);
64  fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
65  fSizeYZCmd->SetParameterName("SizeYZ",false);
66  fSizeYZCmd->SetRange("SizeYZ>0.");
67  fSizeYZCmd->SetUnitCategory("Length");
69 
70  fStepSizeCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setStepSize",this);
71  fStepSizeCmd->SetGuidance("Set maxStepSize in the absorber");
72  fStepSizeCmd->SetParameterName("StepSize",false);
73  fStepSizeCmd->SetRange("StepSize>0.");
74  fStepSizeCmd->SetUnitCategory("Length");
76 
77 
78  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testex/det/setField",this);
79  fMagFieldCmd->SetGuidance("Define magnetic field.");
80  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
81  fMagFieldCmd->SetParameterName("Bz",false);
82  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
84 
85  fUpdateCmd = new G4UIcmdWithoutParameter("/testex/det/update",this);
86  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
87  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
88  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
89  fUpdateCmd->AvailableForStates(G4State_Idle);
90 }
91 
92 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
93 
95 {
96  delete fMaterCmd;
97  delete fSizeXCmd;
98  delete fSizeYZCmd;
99  delete fStepSizeCmd;
100  delete fMagFieldCmd;
101  delete fUpdateCmd;
102  delete fDetDir;
103 }
104 
105 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
106 
108 {
109  if( command == fMaterCmd )
110  { fDetector->SetMaterial(newValue);}
111 
112  if( command == fSizeXCmd )
113  { fDetector->SetSizeX(fSizeXCmd->GetNewDoubleValue(newValue));}
114 
115  if( command == fSizeYZCmd )
116  { fDetector->SetSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));}
117 
118  if( command == fMagFieldCmd )
119  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
120 
121  if( command == fStepSizeCmd )
122  { fDetector->SetMaxStepSize(fStepSizeCmd->GetNewDoubleValue(newValue));}
123 
124  if( command == fUpdateCmd )
125  { fDetector->UpdateGeometry();}
126 }
127 
128 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......