Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
examples/extended/hadronic/Hadr01/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 109185 2018-04-03 07:20:46Z gcosmo $
30 //
32 //
33 // DetectorMessenger
34 //
35 // Created: 31.01.03 V.Ivanchenko
36 //
37 // Modified:
38 // 04.06.2006 Adoptation of Hadr01 (V.Ivanchenko)
39 // 16.11.2006 Add beamCmd (V.Ivanchenko)
40 //
42 //
43 
44 #include "DetectorMessenger.hh"
45 
46 #include "DetectorConstruction.hh"
47 #include "G4UIdirectory.hh"
48 #include "G4UIcmdWithABool.hh"
49 #include "G4UIcmdWithAString.hh"
50 #include "G4UIcmdWithAnInteger.hh"
51 #include "G4UIcmdWith3Vector.hh"
54 #include "HistoManager.hh"
55 
56 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57 
59 : G4UImessenger(), fDetector(Det),
60  fTestDir(0),
61  fMatCmd(0),
62  fMat1Cmd(0),
63  fRCmd(0),
64  fLCmd(0),
65  fEdepCmd(0),
66  fBinCmd(0),
67  fNOfAbsCmd(0),
68  fVerbCmd(0),
69  fBeamCmd(0)
70 {
71  fTestDir = new G4UIdirectory("/testhadr/");
72  fTestDir->SetGuidance(" Hadronic Extended Example.");
73 
74  fMatCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this);
75  fMatCmd->SetGuidance("Select Material for the target");
76  fMatCmd->SetParameterName("tMaterial",false);
78 
79  fMat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this);
80  fMat1Cmd->SetGuidance("Select Material for world");
81  fMat1Cmd->SetParameterName("wMaterial",false);
83 
84  fRCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this);
85  fRCmd->SetGuidance("Set radius of the target");
86  fRCmd->SetParameterName("radius",false);
87  fRCmd->SetUnitCategory("Length");
88  fRCmd->SetRange("radius>0");
90 
91  fLCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this);
92  fLCmd->SetGuidance("Set length of the target");
93  fLCmd->SetParameterName("length",false);
94  fLCmd->SetUnitCategory("Length");
95  fLCmd->SetRange("length>0");
97 
98  fBinCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE",this);
99  fBinCmd->SetGuidance("Set number of bins for Energy");
100  fBinCmd->SetParameterName("NEbins",false);
102 
103  fNOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ",this);
104  fNOfAbsCmd->SetGuidance("Set number of slices");
105  fNOfAbsCmd->SetParameterName("NZ",false);
107 
108  fEdepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep",this);
109  fEdepCmd->SetGuidance("Set max energy in histogram");
110  fEdepCmd->SetParameterName("edep",false);
111  fEdepCmd->SetUnitCategory("Energy");
112  fEdepCmd->SetRange("edep>0");
114 
115  fBeamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition",this);
116  fBeamCmd->SetGuidance("Use default beam position");
118 
119  fVerbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this);
120  fVerbCmd->SetGuidance("Set verbose for ");
121  fVerbCmd->SetParameterName("verb",false);
123 }
124 
125 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
126 
128 {
129  delete fMatCmd;
130  delete fMat1Cmd;
131  delete fRCmd;
132  delete fLCmd;
133  delete fBinCmd;
134  delete fNOfAbsCmd;
135  delete fTestDir;
136  delete fBeamCmd;
137  delete fVerbCmd;
138  delete fEdepCmd;
139 }
140 
141 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
142 
143 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
144 {
146  if( command == fMatCmd ) {
147  fDetector->SetTargetMaterial(newValue);
148  } else if( command == fMat1Cmd ) {
149  fDetector->SetWorldMaterial(newValue);
150  } else if( command == fRCmd ) {
152  } else if( command == fLCmd ) {
153  h->SetTargetLength(fLCmd->GetNewDoubleValue(newValue));
154  } else if( command == fNOfAbsCmd ) {
156  } else if( command == fBinCmd ) {
157  h->SetNumberOfBinsE(fBinCmd->GetNewIntValue(newValue));
158  } else if( command == fVerbCmd ) {
159  h->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
160  } else if (command == fBeamCmd) {
162  } else if (command == fEdepCmd) {
164  }
165 }
166 
167 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
168 
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
static G4bool GetNewBoolValue(const char *paramString)
void SetWorldMaterial(const G4String &materialName)
static G4double GetNewDoubleValue(const char *paramString)
void SetUnitCategory(const char *unitCategory)
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)
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:242
Simple detector construction with a box volume placed in a world.