Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr06/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 70755 2013-06-05 12:17:48Z ihrivnac $
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"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 :G4UImessenger(),
48  fDetector(Det), fTestemDir(0), fDetDir(0), fMaterCmd(0), fSizeCmd(0),
49  fIsotopeCmd(0)
50 {
51  fTestemDir = new G4UIdirectory("/testhadr/");
52  fTestemDir->SetGuidance("commands specific to this example");
53 
54  G4bool broadcast = false;
55  fDetDir = new G4UIdirectory("/testhadr/det/",broadcast);
56  fDetDir->SetGuidance("detector construction commands");
57 
58  fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat",this);
59  fMaterCmd->SetGuidance("Select material of the box.");
60  fMaterCmd->SetParameterName("choice",false);
62 
63  fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setRadius",this);
64  fSizeCmd->SetGuidance("Set size of the sphere");
65  fSizeCmd->SetParameterName("Size",false);
66  fSizeCmd->SetRange("Size>0.");
67  fSizeCmd->SetUnitCategory("Length");
69 
70  fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
71  fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
72  fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
73  //
74  G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
75  symbPrm->SetGuidance("isotope symbol");
76  fIsotopeCmd->SetParameter(symbPrm);
77  //
78  G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
79  ZPrm->SetGuidance("Z");
80  ZPrm->SetParameterRange("Z>0");
82  //
83  G4UIparameter* APrm = new G4UIparameter("A",'i',false);
84  APrm->SetGuidance("A");
85  APrm->SetParameterRange("A>0");
86  fIsotopeCmd->SetParameter(APrm);
87  //
88  G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
89  densityPrm->SetGuidance("density of material");
90  densityPrm->SetParameterRange("density>0.");
91  fIsotopeCmd->SetParameter(densityPrm);
92  //
93  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
94  unitPrm->SetGuidance("unit of density");
96  unitPrm->SetParameterCandidates(unitList);
97  fIsotopeCmd->SetParameter(unitPrm);
98  //
100 }
101 
102 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
103 
105 {
106  delete fMaterCmd;
107  delete fSizeCmd;
108  delete fIsotopeCmd;
109  delete fDetDir;
110  delete fTestemDir;
111 }
112 
113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
114 
116 {
117  if( command == fMaterCmd )
118  { fDetector->SetMaterial(newValue);}
119 
120  if( command == fSizeCmd )
122 
123  if (command == fIsotopeCmd)
124  {
125  G4int Z; G4int A; G4double dens;
126  G4String name, unt;
127  std::istringstream is(newValue);
128  is >> name >> Z >> A >> dens >> unt;
129  dens *= G4UIcommand::ValueOf(unt);
130  fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
131  fDetector->SetMaterial(name);
132  }
133 }
134 
135 //....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
const XML_Char * name
Definition: expat.h:151
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
Float_t Z
static G4double GetNewDoubleValue(const char *paramString)
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
void SetUnitCategory(const char *unitCategory)
double A(double temperature)
int G4int
Definition: G4Types.hh:78
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
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.
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)