Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
examples/extended/hadronic/Hadr02/src/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 //
26 /// \file hadronic/Hadr02/src/DetectorMessenger.cc
27 /// \brief Implementation of the DetectorMessenger class
28 //
29 // $Id: DetectorMessenger.cc 77519 2013-11-25 10:54:57Z gcosmo $
30 //
31 /////////////////////////////////////////////////////////////////////////
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 //
41 ////////////////////////////////////////////////////////////////////////
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 #include "G4PhysicalConstants.hh"
56 #include "G4SystemOfUnits.hh"
57 
58 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
59 
61 :Detector(Det)
62 {
63  testDir = new G4UIdirectory("/testhadr/");
64  testDir->SetGuidance(" Hadronic Extended Example.");
65 
66  matCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this);
67  matCmd->SetGuidance("Select Material for the target");
68  matCmd->SetParameterName("tMaterial",false);
70 
71  mat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this);
72  mat1Cmd->SetGuidance("Select Material for world");
73  mat1Cmd->SetParameterName("wMaterial",false);
75 
76  ionCmd = new G4UIcmdWithAString("/testhadr/ionPhysics",this);
77  ionCmd->SetGuidance("Select ion Physics");
78  ionCmd->SetParameterName("DPMJET",false);
80 
81  rCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this);
82  rCmd->SetGuidance("Set radius of the target");
83  rCmd->SetParameterName("radius",false);
84  rCmd->SetUnitCategory("Length");
85  rCmd->SetRange("radius>0");
87 
88  lCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this);
89  lCmd->SetGuidance("Set length of the target");
90  lCmd->SetParameterName("length",false);
91  lCmd->SetUnitCategory("Length");
92  lCmd->SetRange("length>0");
94 
95  binCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE",this);
96  binCmd->SetGuidance("Set number of bins for Energy");
97  binCmd->SetParameterName("NEbins",false);
99 
100  nOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ",this);
101  nOfAbsCmd->SetGuidance("Set number of slices");
102  nOfAbsCmd->SetParameterName("NZ",false);
104 
105  edepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep",this);
106  edepCmd->SetGuidance("Set max energy in histogram");
107  edepCmd->SetParameterName("edep",false);
108  edepCmd->SetUnitCategory("Energy");
109  edepCmd->SetRange("edep>0");
111 
112  beamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition",this);
113  beamCmd->SetGuidance("show inelastic and elastic cross sections");
114 
115  verbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this);
116  verbCmd->SetGuidance("Set verbose for ");
117  verbCmd->SetParameterName("verb",false);
119 }
120 
121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
122 
124 {
125  delete matCmd;
126  delete mat1Cmd;
127  delete ionCmd;
128  delete rCmd;
129  delete lCmd;
130  delete nOfAbsCmd;
131  delete testDir;
132  delete beamCmd;
133  delete verbCmd;
134  delete edepCmd;
135 }
136 
137 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
138 
139 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
140 {
142  if( command == matCmd ) {
143  Detector->SetTargetMaterial(newValue);
144  } else if( command == mat1Cmd ) {
145  Detector->SetWorldMaterial(newValue);
146  } else if( command == ionCmd ) {
147  h->SetIonPhysics(newValue);
148  } else if( command == rCmd ) {
149  Detector->SetTargetRadius(rCmd->GetNewDoubleValue(newValue));
150  } else if( command == lCmd ) {
151  h->SetTargetLength(lCmd->GetNewDoubleValue(newValue));
152  } else if( command == nOfAbsCmd ) {
153  h->SetNumberOfSlices(nOfAbsCmd->GetNewIntValue(newValue));
154  } else if( command == binCmd ) {
155  h->SetNumberOfBinsE(binCmd->GetNewIntValue(newValue));
156  } else if( command == verbCmd ) {
157  h->SetVerbose(verbCmd->GetNewIntValue(newValue));
158  } else if (command == beamCmd) {
159  h->SetDefaultBeamPositionFlag(beamCmd->GetNewBoolValue(newValue));
160  } else if (command == edepCmd) {
161  h->SetMaxEnergyDeposit(edepCmd->GetNewDoubleValue(newValue));
162  }
163 }
164 
165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
166 
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 SetUnitCategory(const char *unitCategory)
static G4double GetNewDoubleValue(const char *paramString)
static G4bool GetNewBoolValue(const char *paramString)
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 SetParameterName(const char *theName, G4bool omittable, G4bool currentAsDefault=false)