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 //
30 // $Id$
31 //
32 //
33 
34 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
35 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
36 
37 #include "DetectorMessenger.hh"
38 
39 #include "DetectorConstruction.hh"
40 #include "G4UIdirectory.hh"
41 #include "G4UIcmdWithAString.hh"
42 #include "G4UIcmdWithAnInteger.hh"
45 
46 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
47 
50 :fDetector(det)
51 {
52  fN03Dir = new G4UIdirectory("/N03/");
53  fN03Dir->SetGuidance("UI commands of this example");
54 
55  fDetDir = new G4UIdirectory("/N03/det/");
56  fDetDir->SetGuidance("detector control");
57 
58  fAbsMaterCmd = new G4UIcmdWithAString("/N03/det/setAbsMat",this);
59  fAbsMaterCmd->SetGuidance("Select Material of the Absorber.");
60  fAbsMaterCmd->SetParameterName("choice",false);
62 
63  fGapMaterCmd = new G4UIcmdWithAString("/N03/det/setGapMat",this);
64  fGapMaterCmd->SetGuidance("Select Material of the Gap.");
65  fGapMaterCmd->SetParameterName("choice",false);
67 
68  fAbsThickCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setAbsThick",this);
69  fAbsThickCmd->SetGuidance("Set Thickness of the Absorber");
70  fAbsThickCmd->SetParameterName("Size",false);
71  fAbsThickCmd->SetRange("Size>=0.");
72  fAbsThickCmd->SetUnitCategory("Length");
74 
75  fGapThickCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setGapThick",this);
76  fGapThickCmd->SetGuidance("Set Thickness of the Gap");
77  fGapThickCmd->SetParameterName("Size",false);
78  fGapThickCmd->SetRange("Size>=0.");
79  fGapThickCmd->SetUnitCategory("Length");
81 
82  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setSizeYZ",this);
83  fSizeYZCmd->SetGuidance("Set tranverse size of the calorimeter");
84  fSizeYZCmd->SetParameterName("Size",false);
85  fSizeYZCmd->SetRange("Size>0.");
86  fSizeYZCmd->SetUnitCategory("Length");
88 
89  fNbLayersCmd = new G4UIcmdWithAnInteger("/N03/det/setNbOfLayers",this);
90  fNbLayersCmd->SetGuidance("Set number of layers.");
91  fNbLayersCmd->SetParameterName("NbLayers",false);
92  fNbLayersCmd->SetRange("NbLayers>0 && NbLayers<500");
94 
95  fUpdateCmd = new G4UIcmdWithoutParameter("/N03/det/update",this);
96  fUpdateCmd->SetGuidance("Update calorimeter geometry.");
97  fUpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
98  fUpdateCmd->SetGuidance("if you changed geometrical value(s).");
99  fUpdateCmd->AvailableForStates(G4State_Idle);
100 
101  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/N03/det/setField",this);
102  fMagFieldCmd->SetGuidance("Define magnetic field.");
103  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
104  fMagFieldCmd->SetParameterName("Bz",false);
105  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
112 {
113  delete fNbLayersCmd;
114  delete fAbsMaterCmd; delete fGapMaterCmd;
115  delete fAbsThickCmd; delete fGapThickCmd;
116  delete fSizeYZCmd; delete fUpdateCmd;
117  delete fMagFieldCmd;
118  delete fDetDir;
119  delete fN03Dir;
120 }
121 
122 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
123 
125 {
126  if( command == fAbsMaterCmd )
127  { fDetector->SetAbsorberMaterial(newValue);}
128 
129  if( command == fGapMaterCmd )
130  { fDetector->SetGapMaterial(newValue);}
131 
132  if( command == fAbsThickCmd )
133  { fDetector->SetAbsorberThickness(fAbsThickCmd
134  ->GetNewDoubleValue(newValue));}
135 
136  if( command == fGapThickCmd )
137  { fDetector->SetGapThickness(fGapThickCmd->GetNewDoubleValue(newValue));}
138 
139  if( command == fSizeYZCmd )
140  { fDetector->SetCalorSizeYZ(fSizeYZCmd->GetNewDoubleValue(newValue));}
141 
142  if( command == fNbLayersCmd )
143  { fDetector->SetNbOfLayers(fNbLayersCmd->GetNewIntValue(newValue));}
144 
145  if( command == fUpdateCmd )
146  { fDetector->UpdateGeometry(); }
147 
148  if( command == fMagFieldCmd )
149  { fDetector->SetMagField(fMagFieldCmd->GetNewDoubleValue(newValue));}
150 }
151 
152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......