Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/radioactivedecay/Activation/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(nullptr), fDetDir(nullptr), fMaterCmd(nullptr),
49  fThickCmd(nullptr), fSizeYZCmd(nullptr), fIsotopeCmd(nullptr)
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  fThickCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setThickness",this);
64  fThickCmd->SetGuidance("Set thickness of the absor");
65  fThickCmd->SetParameterName("Thickness",false);
66  fThickCmd->SetRange("Thickness>0.");
67  fThickCmd->SetUnitCategory("Length");
69 
70  fSizeYZCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/det/setSizeYZ",this);
71  fSizeYZCmd->SetGuidance("Set transverse size of the absor");
72  fSizeYZCmd->SetParameterName("Size",false);
73  fSizeYZCmd->SetRange("Size>0.");
74  fSizeYZCmd->SetUnitCategory("Length");
76 
77  fIsotopeCmd = new G4UIcommand("/testhadr/det/setIsotopeMat",this);
78  fIsotopeCmd->SetGuidance("Build and select a material with single isotope");
79  fIsotopeCmd->SetGuidance(" symbol of isotope, Z, A, density of material");
80  //
81  G4UIparameter* symbPrm = new G4UIparameter("isotope",'s',false);
82  symbPrm->SetGuidance("isotope symbol");
83  fIsotopeCmd->SetParameter(symbPrm);
84  //
85  G4UIparameter* ZPrm = new G4UIparameter("Z",'i',false);
86  ZPrm->SetGuidance("Z");
87  ZPrm->SetParameterRange("Z>0");
89  //
90  G4UIparameter* APrm = new G4UIparameter("A",'i',false);
91  APrm->SetGuidance("A");
92  APrm->SetParameterRange("A>0");
93  fIsotopeCmd->SetParameter(APrm);
94  //
95  G4UIparameter* densityPrm = new G4UIparameter("density",'d',false);
96  densityPrm->SetGuidance("density of material");
97  densityPrm->SetParameterRange("density>0.");
98  fIsotopeCmd->SetParameter(densityPrm);
99  //
100  G4UIparameter* unitPrm = new G4UIparameter("unit",'s',false);
101  unitPrm->SetGuidance("unit of density");
103  unitPrm->SetParameterCandidates(unitList);
104  fIsotopeCmd->SetParameter(unitPrm);
105  //
107 }
108 
109 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
110 
112 {
113  delete fMaterCmd;
114  delete fThickCmd;
115  delete fSizeYZCmd;
116  delete fIsotopeCmd;
117  delete fDetDir;
118  delete fTestemDir;
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 
124 {
125  if( command == fMaterCmd )
126  { fDetector->SetAbsorMaterial(newValue);}
127 
128  if( command == fThickCmd )
130 
131  if( command == fSizeYZCmd )
133 
134  if (command == fIsotopeCmd)
135  {
136  G4int Z; G4int A; G4double dens;
137  G4String name, unt;
138  std::istringstream is(newValue);
139  is >> name >> Z >> A >> dens >> unt;
140  dens *= G4UIcommand::ValueOf(unt);
141  fDetector->MaterialWithSingleIsotope (name,name,dens,Z,A);
142  fDetector->SetAbsorMaterial(name);
143  }
144 }
145 
146 //....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)