Geant4  10.00.p01
DetectorMessenger.cc
Go to the documentation of this file.
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 77255 2013-11-22 10:09:14Z 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("show inelastic and elastic cross sections");
117 
118  fVerbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this);
119  fVerbCmd->SetGuidance("Set verbose for ");
120  fVerbCmd->SetParameterName("verb",false);
122 }
123 
124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
125 
127 {
128  delete fMatCmd;
129  delete fMat1Cmd;
130  delete fRCmd;
131  delete fLCmd;
132  delete fBinCmd;
133  delete fNOfAbsCmd;
134  delete fTestDir;
135  delete fBeamCmd;
136  delete fVerbCmd;
137  delete fEdepCmd;
138 }
139 
140 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
141 
142 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
143 {
145  if( command == fMatCmd ) {
146  fDetector->SetTargetMaterial(newValue);
147  } else if( command == fMat1Cmd ) {
148  fDetector->SetWorldMaterial(newValue);
149  } else if( command == fRCmd ) {
151  } else if( command == fLCmd ) {
152  h->SetTargetLength(fLCmd->GetNewDoubleValue(newValue));
153  } else if( command == fNOfAbsCmd ) {
155  } else if( command == fBinCmd ) {
156  h->SetNumberOfBinsE(fBinCmd->GetNewIntValue(newValue));
157  } else if( command == fVerbCmd ) {
158  h->SetVerbose(fVerbCmd->GetNewIntValue(newValue));
159  } else if (command == fBeamCmd) {
161  } else if (command == fEdepCmd) {
163  }
164 }
165 
166 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
167 
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
void SetMaxEnergyDeposit(G4double val)
Definition: HistoManager.hh:98
void SetDefaultBeamPositionFlag(G4bool f)
Definition: HistoManager.hh:97
void SetNewValue(G4UIcommand *, G4String)
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithADoubleAndUnit * fEdepCmd
static G4int GetNewIntValue(const char *paramString)
void SetWorldMaterial(const G4String &)
void SetNumberOfBinsE(G4int val)
void SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
G4UIcmdWithAnInteger * fVerbCmd
G4UIdirectory * fTestDir
static G4bool GetNewBoolValue(const char *paramString)
G4UIcmdWithAString * fMatCmd
G4UIcmdWithAnInteger * fNOfAbsCmd
void SetRange(const char *rs)
Definition: G4UIcommand.hh:125
void SetGuidance(const char *aGuidance)
Definition: G4UIcommand.hh:161
void AvailableForStates(G4ApplicationState s1)
Definition: G4UIcommand.cc:225
void SetTargetMaterial(const G4String &)
G4UIcmdWithABool * fBeamCmd
void SetTargetRadius(G4double val)
void SetNumberOfSlices(G4int val)
Definition: HistoManager.hh:95
DetectorMessenger(DetectorConstruction *)
Detector construction class to demonstrate various ways of placement.
G4UIcmdWithADoubleAndUnit * fLCmd
static HistoManager * GetPointer()
Definition: HistoManager.cc:58
G4UIcmdWithAnInteger * fBinCmd
DetectorConstruction * fDetector
void SetVerbose(G4int value)
G4UIcmdWithADoubleAndUnit * fRCmd
void SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)
G4UIcmdWithAString * fMat1Cmd
void SetTargetLength(G4double val)
Definition: HistoManager.hh:94