Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/electromagnetic/TestEm7/src/DetectorMessenger.cc
이 파일의 문서화 페이지로 가기
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: DetectorMessenger.cc 107330 2017-11-08 16:42:09Z gcosmo $
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 "G4UIcommand.hh"
39 #include "G4UIparameter.hh"
40 #include "G4UIcmdWithAString.hh"
41 #include "G4UIcmdWithAnInteger.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
48 :G4UImessenger(),fDetector(Det),
49  fTestemDir(nullptr),
50  fDetDir(nullptr),
51  fMaterCmd(nullptr),
52  fWMaterCmd(nullptr),
53  fSizeXCmd(nullptr),
54  fSizeYZCmd(nullptr),
55  fMagFieldCmd(nullptr),
56  fTalNbCmd(nullptr),
57  fTalDefCmd(nullptr),
58  fTalPosiCmd(nullptr)
59 {
60  fTestemDir = new G4UIdirectory("/testem/");
61  fTestemDir->SetGuidance(" detector control.");
62 
63  fDetDir = new G4UIdirectory("/testem/det/");
64  fDetDir->SetGuidance("detector construction commands");
65 
66  fMaterCmd = new G4UIcmdWithAString("/testem/det/setMat",this);
67  fMaterCmd->SetGuidance("Select material of the box.");
68  fMaterCmd->SetParameterName("choice",false);
70 
71  fWMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
72  fWMaterCmd->SetGuidance("Select material of the world.");
73  fWMaterCmd->SetParameterName("choice",false);
75 
76  fSizeXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeX",this);
77  fSizeXCmd->SetGuidance("Set sizeX of the absorber");
78  fSizeXCmd->SetParameterName("SizeX",false);
79  fSizeXCmd->SetRange("SizeX>0.");
80  fSizeXCmd->SetUnitCategory("Length");
82 
83  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setSizeYZ",this);
84  fSizeYZCmd->SetGuidance("Set sizeYZ of the absorber");
85  fSizeYZCmd->SetParameterName("SizeYZ",false);
86  fSizeYZCmd->SetRange("SizeYZ>0.");
87  fSizeYZCmd->SetUnitCategory("Length");
89 
90  fMagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this);
91  fMagFieldCmd->SetGuidance("Define magnetic field.");
92  fMagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
93  fMagFieldCmd->SetParameterName("Bz",false);
94  fMagFieldCmd->SetUnitCategory("Magnetic flux density");
96 
97  fTalNbCmd = new G4UIcmdWithAnInteger("/testem/det/tallyNumber",this);
98  fTalNbCmd->SetGuidance("Set number of fTallies.");
99  fTalNbCmd->SetParameterName("tallyNb",false);
100  fTalNbCmd->SetRange("tallyNb>=0");
102 
103  fTalDefCmd = new G4UIcommand("/testem/det/tallyDefinition",this);
104  fTalDefCmd->SetGuidance("Set tally nb, box dimensions.");
105  fTalDefCmd->SetGuidance(" tally number : from 0 to tallyNumber");
106  fTalDefCmd->SetGuidance(" material name");
107  fTalDefCmd->SetGuidance(" dimensions (3-vector with unit)");
108  //
109  G4UIparameter* fTalNbPrm = new G4UIparameter("tallyNb",'i',false);
110  fTalNbPrm->SetGuidance("tally number : from 0 to tallyNumber");
111  fTalNbPrm->SetParameterRange("tallyNb>=0");
112  fTalDefCmd->SetParameter(fTalNbPrm);
113  //
114  G4UIparameter* SizeXPrm = new G4UIparameter("sizeX",'d',false);
115  SizeXPrm->SetGuidance("sizeX");
116  SizeXPrm->SetParameterRange("sizeX>0.");
117  fTalDefCmd->SetParameter(SizeXPrm);
118  //
119  G4UIparameter* SizeYPrm = new G4UIparameter("sizeY",'d',false);
120  SizeYPrm->SetGuidance("sizeY");
121  SizeYPrm->SetParameterRange("sizeY>0.");
122  fTalDefCmd->SetParameter(SizeYPrm);
123  //
124  G4UIparameter* SizeZPrm = new G4UIparameter("sizeZ",'d',false);
125  SizeZPrm->SetGuidance("sizeZ");
126  SizeZPrm->SetParameterRange("sizeZ>0.");
127  fTalDefCmd->SetParameter(SizeZPrm);
128  //
129  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
130  unitPrm->SetGuidance("unit of dimensions");
132  unitPrm->SetParameterCandidates(unitList);
133  fTalDefCmd->SetParameter(unitPrm);
134  //
136 
137  fTalPosiCmd = new G4UIcommand("/testem/det/tallyPosition",this);
138  fTalPosiCmd->SetGuidance("Set tally nb, position");
139  fTalPosiCmd->SetGuidance(" tally number : from 0 to tallyNumber");
140  fTalPosiCmd->SetGuidance(" position (3-vector with unit)");
141  //
142  G4UIparameter* fTalNumPrm = new G4UIparameter("tallyNum",'i',false);
143  fTalNumPrm->SetGuidance("tally number : from 0 to tallyNumber");
144  fTalNumPrm->SetParameterRange("tallyNum>=0");
145  fTalPosiCmd->SetParameter(fTalNumPrm);
146  //
147  G4UIparameter* PosiXPrm = new G4UIparameter("posiX",'d',false);
148  PosiXPrm->SetGuidance("position X");
149  fTalPosiCmd->SetParameter(PosiXPrm);
150  //
151  G4UIparameter* PosiYPrm = new G4UIparameter("posiY",'d',false);
152  PosiYPrm->SetGuidance("position Y");
153  fTalPosiCmd->SetParameter(PosiYPrm);
154  //
155  G4UIparameter* PosiZPrm = new G4UIparameter("posiZ",'d',false);
156  PosiZPrm->SetGuidance("position Z");
157  fTalPosiCmd->SetParameter(PosiZPrm);
158  //
159  G4UIparameter* unitPr = new G4UIparameter("unit",'s',false);
160  unitPr->SetGuidance("unit of position");
161  unitPr->SetParameterCandidates(unitList);
162  fTalPosiCmd->SetParameter(unitPr);
163  //
165 
166 }
167 
168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
169 
171 {
172  delete fMaterCmd;
173  delete fWMaterCmd;
174  delete fSizeXCmd;
175  delete fSizeYZCmd;
176  delete fMagFieldCmd;
177  delete fTalNbCmd;
178  delete fTalDefCmd;
179  delete fTalPosiCmd;
180  delete fDetDir;
181  delete fTestemDir;
182 }
183 
184 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
185 
187 {
188  if( command == fMaterCmd )
189  { fDetector->SetMaterial(newValue);}
190 
191  if( command == fWMaterCmd )
192  { fDetector->SetWorldMaterial(newValue);}
193 
194  if( command == fSizeXCmd )
196 
197  if( command == fSizeYZCmd )
199 
200  if( command == fMagFieldCmd )
202 
203  if( command == fTalNbCmd )
205 
206  if (command == fTalDefCmd)
207  {
208  G4int num; G4double v1, v2, v3;
209  G4String unt;
210  std::istringstream is(newValue);
211  is >> num >> v1 >> v2 >> v3 >> unt;
212  G4ThreeVector vec(v1,v2,v3);
213  vec *= G4UIcommand::ValueOf(unt);
214  fDetector->SetTallySize(num,vec);
215  }
216 
217  if (command == fTalPosiCmd)
218  {
219  G4int num; G4double v1, v2, v3;
220  G4String unt;
221  std::istringstream is(newValue);
222  is >> num >> v1 >> v2 >> v3 >> unt;
223  G4ThreeVector vec(v1,v2,v3);
224  vec *= G4UIcommand::ValueOf(unt);
225  fDetector->SetTallyPosition(num,vec);
226  }
227 }
228 
229 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
static G4double ValueOf(const char *unitName)
Definition: G4UIcommand.cc:311
static G4String CategoryOf(const char *unitName)
Definition: G4UIcommand.cc:318
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *theGuidance)
void SetParameterRange(const char *theRange)
void SetParameter(G4UIparameter *const newParameter)
Definition: G4UIcommand.hh:152
void SetWorldMaterial(const G4String &materialName)
static G4double GetNewDoubleValue(const char *paramString)
double G4double
Definition: G4Types.hh:76
void SetUnitCategory(const char *unitCategory)
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
static G4int GetNewIntValue(const char *paramString)
static G4String UnitsList(const char *unitCategory)
Definition: G4UIcommand.cc:323
void SetParameterCandidates(const char *theString)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
Simple detector construction with a box volume placed in a world.