Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr03/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 98265 2016-07-04 17:47:54Z 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"
43 
44 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
45 
47 :G4UImessenger(),
48  fDetector(Det), fTesthadDir(0), fDetDir(0), fMaterCmd(0), fSizeCmd(0),
49  fIsotopeCmd(0)
50 {
51  fTesthadDir = new G4UIdirectory("/testhadr/");
52  fTesthadDir->SetGuidance("commands specific to this example");
53 
54  fDetDir = new G4UIdirectory("/testhadr/det/");
55  fDetDir->SetGuidance("detector construction commands");
56 
57  fMaterCmd = new G4UIcmdWithAString("/testhadr/det/setMat",this);
58  fMaterCmd->SetGuidance("Select material of the box.");
59  fMaterCmd->SetParameterName("choice",false);
62 
63  fSizeCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSize",this);
64  fSizeCmd->SetGuidance("Set size of the box");
65  fSizeCmd->SetParameterName("Size",false);
66  fSizeCmd->SetRange("Size>0.");
67  fSizeCmd->SetUnitCategory("Length");
70 
71  fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
72  fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
73  fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
74  //
75  G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
76  symbPrm->SetGuidance("isotope symbol");
77  fIsotopeCmd->SetParameter(symbPrm);
78  //
79  G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
80  ZPrm->SetGuidance("Z");
81  ZPrm->SetParameterRange("Z>0");
83  //
84  G4UIparameter* APrm = new G4UIparameter("A",'i',false);
85  APrm->SetGuidance("A");
86  APrm->SetParameterRange("A>0");
87  fIsotopeCmd->SetParameter(APrm);
88  //
89  G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
90  densityPrm->SetGuidance("density of material");
91  densityPrm->SetParameterRange("density>0.");
92  fIsotopeCmd->SetParameter(densityPrm);
93  //
94  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
95  unitPrm->SetGuidance("unit of density");
97  unitPrm->SetParameterCandidates(unitList);
98  fIsotopeCmd->SetParameter(unitPrm);
99  //
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105 
107 {
108  delete fMaterCmd;
109  delete fSizeCmd;
110  delete fIsotopeCmd;
111  delete fDetDir;
112  delete fTesthadDir;
113 }
114 
115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
116 
118 {
119  if( command == fMaterCmd )
120  { fDetector->SetMaterial(newValue);}
121 
122  if( command == fSizeCmd )
124 
125  if (command == fIsotopeCmd)
126  {
127  G4int Z; G4int A; G4double dens;
128  G4String name, unt;
129  std::istringstream is(newValue);
130  is >> name >> Z >> A >> dens >> unt;
131  dens *= G4UIcommand::ValueOf(unt);
132  fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
133  fDetector->SetMaterial(name);
134  }
135 }
136 
137 //....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
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.
void SetToBeBroadcasted(G4bool val)
Definition: G4UIcommand.hh:184
G4Material * MaterialWithSingleIsotope(G4String, G4String, G4double, G4int, G4int)