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"
41 
42 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
43 
45 :fDetector(Det)
46 {
47  fTestemDir = new G4UIdirectory("/testem/");
48  fTestemDir->SetGuidance(" detector control.");
49 
50  fDetDir = new G4UIdirectory("/testem/det/");
51  fDetDir->SetGuidance("detector construction commands");
52 
53  fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
54  fMaterCmd->SetGuidance("Select material of the box.");
55  fMaterCmd->SetParameterName("choice",false);
57 
58  fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSize",this);
59  fSizeCmd->SetGuidance("Set size of the box");
60  fSizeCmd->SetParameterName("Size",false);
61  fSizeCmd->SetRange("Size>0.");
62  fSizeCmd->SetUnitCategory("Length");
64 
65  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
66  fMagFieldCmd->SetGuidance("Define magnetic field.");
67  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
68  fMagFieldCmd->SetParameterName("Bz",false);
69  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
71 
72  fUpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
73  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
74  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
75  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
76  fUpdateCmd->AvailableForStates(G4State_Idle);
77 
78  fMaxStepCmd = new G4UIcmdWithADoubleAndUnit("/testem/tracking/stepMax",this);
79  fMaxStepCmd->SetGuidance("Set max allowed step size");
80  fMaxStepCmd->SetParameterName("Size",false);
81  fMaxStepCmd->SetRange("Size>0.");
82  fMaxStepCmd->SetUnitCategory("Length");
83  fMaxStepCmd->AvailableForStates(G4State_Idle);
84 }
85 
86 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
87 
89 {
90  delete fMaterCmd;
91  delete fSizeCmd;
92  delete fMagFieldCmd;
93  delete fUpdateCmd;
94  delete fMaxStepCmd;
95  delete fDetDir;
96  delete fTestemDir;
97 }
98 
99 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
100 
102 {
103  if( command == fMaterCmd )
104  { fDetector->SetMaterial(newValue);}
105 
106  if( command == fSizeCmd )
107  { fDetector->SetSize(fSizeCmd->GetNewDoubleValue(newValue));}
108 
109  if( command == fMagFieldCmd )
110  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
111 
112  if( command == fUpdateCmd )
113  { fDetector->UpdateGeometry(); }
114 
115  if( command == fMaxStepCmd )
116  { fDetector->SetMaxStepSize(fMaxStepCmd->GetNewDoubleValue(newValue));}
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......