Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RE06DetectorMessenger.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 /// \file RE06/src/RE06DetectorMessenger.cc
27 /// \brief Implementation of the RE06DetectorMessenger class
28 //
29 // $Id: RE06DetectorMessenger.cc 68026 2013-03-13 13:45:22Z gcosmo $
30 //
31 
32 #include "RE06DetectorMessenger.hh"
33 
35 #include "G4UIdirectory.hh"
36 #include "G4UIcmdWithAString.hh"
37 #include "G4UIcmdWithABool.hh"
38 #include "G4UIcmdWithAnInteger.hh"
39 #include "G4Material.hh"
40 
41 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42 
44  : G4UImessenger(),
45  fDetector(det),
46  fDirectory(0),
47  fAbsMaterialCmd(0),
48  fGapMaterialCmd(0),
49  fNumLayerCmd(0),
50  fSerialCmd(0),
51  fVerboseCmd(0),
52  fAddMaterialCmd(0)
53 {
54  fDirectory = new G4UIdirectory("/RE06/");
55  fDirectory->SetGuidance("UI commands of this example");
56 
57  G4String matList;
59  for(size_t i=0;i<G4Material::GetNumberOfMaterials();i++)
60  {
61  matList += (*matTbl)[i]->GetName();
62  matList += " ";
63  }
64 
65  fAbsMaterialCmd = new G4UIcmdWithAString("/RE06/setAbsMat",this);
66  fAbsMaterialCmd->SetGuidance("Select Material of the Absorber.");
67  fAbsMaterialCmd->SetParameterName("choice",false);
68  fAbsMaterialCmd->AvailableForStates(G4State_Idle);
69  fAbsMaterialCmd->SetCandidates(matList);
70 
71  fGapMaterialCmd = new G4UIcmdWithAString("/RE06/setGapMat",this);
72  fGapMaterialCmd->SetGuidance("Select Material of the Gap.");
73  fGapMaterialCmd->SetParameterName("choice",false);
74  fGapMaterialCmd->AvailableForStates(G4State_Idle);
75  fGapMaterialCmd->SetCandidates(matList);
76 
77  fNumLayerCmd = new G4UIcmdWithAnInteger("/RE06/numberOfLayers",this);
78  fNumLayerCmd->SetGuidance("Set number of layers.");
79  fNumLayerCmd->SetParameterName("nl",false);
80  fNumLayerCmd->AvailableForStates(G4State_Idle);
81  fNumLayerCmd->SetRange("nl>0");
82 
83  fSerialCmd = new G4UIcmdWithABool("/RE06/serialGeometry",this);
84  fSerialCmd
85  ->SetGuidance("Select calorimeters to be placed in serial or parallel.");
86  fSerialCmd->SetParameterName("serialize",false);
87  fSerialCmd->AvailableForStates(G4State_Idle);
88 
89  fVerboseCmd = new G4UIcmdWithAnInteger("/RE06/verbose",this);
90  fVerboseCmd->SetGuidance("Set verbosity level");
91  fVerboseCmd->SetParameterName("verbose",false);
92  fVerboseCmd->AvailableForStates(G4State_Idle);
93  fVerboseCmd->SetRange("verbose>=0");
94 
95  fAddMaterialCmd = new G4UIcmdWithABool("/RE06/AddMaterial",this);
96  fAddMaterialCmd->SetGuidance("Add materials ");
97  fAddMaterialCmd->SetParameterName("dummy",true);
98  fAddMaterialCmd->AvailableForStates(G4State_Idle);
99 }
100 
101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
102 
104 {
105  delete fAbsMaterialCmd;
106  delete fGapMaterialCmd;
107  delete fNumLayerCmd;
108  delete fSerialCmd;
109  delete fDirectory;
110 }
111 
113 {
114  if( command == fAbsMaterialCmd ) {
115  fDetector->SetAbsorberMaterial(newValue);
116 
117  } else if( command == fGapMaterialCmd ){
118  fDetector->SetGapMaterial(newValue);
119 
120  } else if( command == fNumLayerCmd ) {
121  fDetector->SetNumberOfLayers(fNumLayerCmd->GetNewIntValue(newValue));
122 
123  } else if( command == fSerialCmd ) {
124  fDetector->SetSerialGeometry(fSerialCmd->GetNewBoolValue(newValue));
125 
126  } else if( command == fVerboseCmd ) {
127  fDetector->SetVerboseLevel(fVerboseCmd->GetNewIntValue(newValue));
128 
129  } else if( command == fAddMaterialCmd ) {
130  fDetector->AddMaterial();
131  UpdateMaterialList();
132  }
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
138 {
139  G4String ans;
140  if( command == fAbsMaterialCmd ){
141  ans=fDetector->GetAbsorberMaterial();
142 
143  } else if( command == fGapMaterialCmd ){
144  ans=fDetector->GetGapMaterial();
145 
146  } else if( command == fNumLayerCmd ) {
147  ans=fNumLayerCmd->ConvertToString(fDetector->GetNumberOfLayers());
148 
149  } else if( command == fSerialCmd ){
150  ans=fSerialCmd->ConvertToString(fDetector->IsSerial());
151 
152  } else if( command == fSerialCmd ) {
153  ans=fSerialCmd->ConvertToString(fDetector->IsSerial());
154 
155  } else if( command == fVerboseCmd ) {
156  ans=fVerboseCmd->ConvertToString(fDetector->GetVerboseLevel());
157 
158  }
159  return ans;
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 
164 void RE06DetectorMessenger::UpdateMaterialList()
165 {
166  G4String matList;
168  for(size_t i=0;i<G4Material::GetNumberOfMaterials();i++)
169  {
170  matList += (*matTbl)[i]->GetName();
171  matList += " ";
172  }
173 
174  if(fAbsMaterialCmd !=0) {
175  fAbsMaterialCmd->SetCandidates(matList);
176  }
177  if (fGapMaterialCmd !=0) {
178  fGapMaterialCmd->SetCandidates(matList);
179  }
180 }
181 
182 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual G4String GetCurrentValue(G4UIcommand *command)
Definition of the RE06DetectorMessenger class.
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
virtual void SetNewValue(G4UIcommand *, G4String)
static G4int GetNewIntValue(const char *paramString)
static G4MaterialTable * GetMaterialTable()
Definition: G4Material.cc:564
std::vector< G4Material * > G4MaterialTable
static G4String ConvertToString(G4bool boolVal)
Definition: G4UIcommand.cc:357
RE06DetectorMessenger(RE06DetectorConstruction *)
static G4bool GetNewBoolValue(const char *paramString)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
static size_t GetNumberOfMaterials()
Definition: G4Material.cc:571
void SetAbsorberMaterial(G4String materialChoice)
void SetCandidates(const char *candidateList)
Definition of the RE06DetectorConstruction class.
void SetGapMaterial(G4String materialChoice)