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