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 | // |
---|
27 | // $Id: ExN07DetectorMessenger.cc,v 1.6 2006/06/29 17:54:57 gunter Exp $ |
---|
28 | // GEANT4 tag $Name: $ |
---|
29 | // |
---|
30 | |
---|
31 | #include "ExN07DetectorMessenger.hh" |
---|
32 | |
---|
33 | #include "ExN07DetectorConstruction.hh" |
---|
34 | #include "G4UIdirectory.hh" |
---|
35 | #include "G4UIcmdWithAString.hh" |
---|
36 | #include "G4UIcmdWithABool.hh" |
---|
37 | #include "G4UIcmdWithAnInteger.hh" |
---|
38 | #include "G4Material.hh" |
---|
39 | |
---|
40 | ExN07DetectorMessenger::ExN07DetectorMessenger( |
---|
41 | ExN07DetectorConstruction* ExN07Det) |
---|
42 | :ExN07Detector(ExN07Det) |
---|
43 | { |
---|
44 | N07Dir = new G4UIdirectory("/N07/"); |
---|
45 | N07Dir->SetGuidance("UI commands of this example"); |
---|
46 | |
---|
47 | G4String matList; |
---|
48 | const G4MaterialTable* matTbl = G4Material::GetMaterialTable(); |
---|
49 | for(size_t i=0;i<G4Material::GetNumberOfMaterials();i++) |
---|
50 | { |
---|
51 | matList += (*matTbl)[i]->GetName(); |
---|
52 | matList += " "; |
---|
53 | } |
---|
54 | |
---|
55 | AbsMaterCmd = new G4UIcmdWithAString("/N07/setAbsMat",this); |
---|
56 | AbsMaterCmd->SetGuidance("Select Material of the Absorber."); |
---|
57 | AbsMaterCmd->SetParameterName("choice",false); |
---|
58 | AbsMaterCmd->AvailableForStates(G4State_Idle); |
---|
59 | AbsMaterCmd->SetCandidates(matList); |
---|
60 | |
---|
61 | GapMaterCmd = new G4UIcmdWithAString("/N07/setGapMat",this); |
---|
62 | GapMaterCmd->SetGuidance("Select Material of the Gap."); |
---|
63 | GapMaterCmd->SetParameterName("choice",false); |
---|
64 | GapMaterCmd->AvailableForStates(G4State_Idle); |
---|
65 | GapMaterCmd->SetCandidates(matList); |
---|
66 | |
---|
67 | numLayerCmd = new G4UIcmdWithAnInteger("/N07/numberOfLayers",this); |
---|
68 | numLayerCmd->SetGuidance("Set number of layers."); |
---|
69 | numLayerCmd->SetParameterName("nl",false); |
---|
70 | numLayerCmd->AvailableForStates(G4State_Idle); |
---|
71 | numLayerCmd->SetRange("nl>0"); |
---|
72 | |
---|
73 | SerialCmd = new G4UIcmdWithABool("/N07/serialGeometry",this); |
---|
74 | SerialCmd->SetGuidance("Select calorimeters to be placed in serial or parallel."); |
---|
75 | SerialCmd->SetParameterName("serialize",false); |
---|
76 | SerialCmd->AvailableForStates(G4State_Idle); |
---|
77 | |
---|
78 | verboseCmd = new G4UIcmdWithAnInteger("/N07/verbose",this); |
---|
79 | verboseCmd->SetGuidance("Set verbosity level"); |
---|
80 | verboseCmd->SetParameterName("verbose",false); |
---|
81 | verboseCmd->AvailableForStates(G4State_Idle); |
---|
82 | verboseCmd->SetRange("verbose>=0"); |
---|
83 | |
---|
84 | AddMatCmd = new G4UIcmdWithABool("/N07/AddMaterial",this); |
---|
85 | AddMatCmd->SetGuidance("Add materials "); |
---|
86 | AddMatCmd->SetParameterName("dummy",true); |
---|
87 | AddMatCmd->AvailableForStates(G4State_Idle); |
---|
88 | |
---|
89 | |
---|
90 | } |
---|
91 | |
---|
92 | ExN07DetectorMessenger::~ExN07DetectorMessenger() |
---|
93 | { |
---|
94 | delete AbsMaterCmd; |
---|
95 | delete GapMaterCmd; |
---|
96 | delete numLayerCmd; |
---|
97 | delete SerialCmd; |
---|
98 | delete N07Dir; |
---|
99 | } |
---|
100 | |
---|
101 | void ExN07DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue) |
---|
102 | { |
---|
103 | if( command == AbsMaterCmd ) { |
---|
104 | ExN07Detector->SetAbsorberMaterial(newValue); |
---|
105 | |
---|
106 | } else if( command == GapMaterCmd ){ |
---|
107 | ExN07Detector->SetGapMaterial(newValue); |
---|
108 | |
---|
109 | } else if( command == numLayerCmd ) { |
---|
110 | ExN07Detector->SetNumberOfLayers(numLayerCmd->GetNewIntValue(newValue)); |
---|
111 | |
---|
112 | } else if( command == SerialCmd ) { |
---|
113 | ExN07Detector->SetSerialGeometry(SerialCmd->GetNewBoolValue(newValue)); |
---|
114 | |
---|
115 | } else if( command == verboseCmd ) { |
---|
116 | ExN07Detector->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue)); |
---|
117 | |
---|
118 | } else if( command == AddMatCmd ) { |
---|
119 | ExN07Detector->AddMaterial(); |
---|
120 | UpdateMaterialList(); |
---|
121 | } |
---|
122 | } |
---|
123 | |
---|
124 | G4String ExN07DetectorMessenger::GetCurrentValue(G4UIcommand * command) |
---|
125 | { |
---|
126 | G4String ans; |
---|
127 | if( command == AbsMaterCmd ){ |
---|
128 | ans=ExN07Detector->GetAbsorberMaterial(); |
---|
129 | |
---|
130 | } else if( command == GapMaterCmd ){ |
---|
131 | ans=ExN07Detector->GetGapMaterial(); |
---|
132 | |
---|
133 | } else if( command == numLayerCmd ) { |
---|
134 | ans=numLayerCmd->ConvertToString(ExN07Detector->GetNumberOfLayers()); |
---|
135 | |
---|
136 | } else if( command == SerialCmd ){ |
---|
137 | ans=SerialCmd->ConvertToString(ExN07Detector->IsSerial()); |
---|
138 | |
---|
139 | } else if( command == SerialCmd ) { |
---|
140 | ans=SerialCmd->ConvertToString(ExN07Detector->IsSerial()); |
---|
141 | |
---|
142 | } else if( command == verboseCmd ) { |
---|
143 | ans=verboseCmd->ConvertToString(ExN07Detector->GetVerboseLevel()); |
---|
144 | |
---|
145 | } |
---|
146 | return ans; |
---|
147 | } |
---|
148 | |
---|
149 | void ExN07DetectorMessenger::UpdateMaterialList() |
---|
150 | { |
---|
151 | G4String matList; |
---|
152 | const G4MaterialTable* matTbl = G4Material::GetMaterialTable(); |
---|
153 | for(size_t i=0;i<G4Material::GetNumberOfMaterials();i++) |
---|
154 | { |
---|
155 | matList += (*matTbl)[i]->GetName(); |
---|
156 | matList += " "; |
---|
157 | } |
---|
158 | |
---|
159 | if(AbsMaterCmd !=0) { |
---|
160 | AbsMaterCmd->SetCandidates(matList); |
---|
161 | } |
---|
162 | if (GapMaterCmd !=0) { |
---|
163 | GapMaterCmd->SetCandidates(matList); |
---|
164 | } |
---|
165 | } |
---|
166 | |
---|
167 | |
---|