Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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$
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 :Detector(Det)
60 {
61  testDir = new G4UIdirectory("/testhadr/");
62  testDir->SetGuidance(" Hadronic Extended Example.");
63 
64  matCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this);
65  matCmd->SetGuidance("Select Material for the target");
66  matCmd->SetParameterName("tMaterial",false);
68 
69  mat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this);
70  mat1Cmd->SetGuidance("Select Material for world");
71  mat1Cmd->SetParameterName("wMaterial",false);
73 
74  ionCmd = new G4UIcmdWithAString("/testhadr/ionPhysics",this);
75  ionCmd->SetGuidance("Select ion Physics");
76  ionCmd->SetParameterName("DPMJET",false);
78 
79  rCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this);
80  rCmd->SetGuidance("Set radius of the target");
81  rCmd->SetParameterName("radius",false);
82  rCmd->SetUnitCategory("Length");
83  rCmd->SetRange("radius>0");
85 
86  lCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this);
87  lCmd->SetGuidance("Set length of the target");
88  lCmd->SetParameterName("length",false);
89  lCmd->SetUnitCategory("Length");
90  lCmd->SetRange("length>0");
92 
93  binCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE",this);
94  binCmd->SetGuidance("Set number of bins for Energy");
95  binCmd->SetParameterName("NEbins",false);
97 
98  nOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ",this);
99  nOfAbsCmd->SetGuidance("Set number of slices");
100  nOfAbsCmd->SetParameterName("NZ",false);
102 
103  edepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep",this);
104  edepCmd->SetGuidance("Set max energy in histogram");
105  edepCmd->SetParameterName("edep",false);
106  edepCmd->SetUnitCategory("Energy");
107  edepCmd->SetRange("edep>0");
109 
110  beamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition",this);
111  beamCmd->SetGuidance("show inelastic and elastic cross sections");
112 
113  verbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this);
114  verbCmd->SetGuidance("Set verbose for ");
115  verbCmd->SetParameterName("verb",false);
117 }
118 
119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
120 
122 {
123  delete matCmd;
124  delete mat1Cmd;
125  delete ionCmd;
126  delete rCmd;
127  delete lCmd;
128  delete nOfAbsCmd;
129  delete testDir;
130  delete beamCmd;
131  delete verbCmd;
132  delete edepCmd;
133 }
134 
135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
136 
137 void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
138 {
140  if( command == matCmd ) {
141  Detector->SetTargetMaterial(newValue);
142  } else if( command == mat1Cmd ) {
143  Detector->SetWorldMaterial(newValue);
144  } else if( command == ionCmd ) {
145  h->SetIonPhysics(newValue);
146  } else if( command == rCmd ) {
147  Detector->SetTargetRadius(rCmd->GetNewDoubleValue(newValue));
148  } else if( command == lCmd ) {
149  h->SetTargetLength(lCmd->GetNewDoubleValue(newValue));
150  } else if( command == nOfAbsCmd ) {
151  h->SetNumberOfSlices(nOfAbsCmd->GetNewIntValue(newValue));
152  } else if( command == binCmd ) {
153  h->SetNumberOfBinsE(binCmd->GetNewIntValue(newValue));
154  } else if( command == verbCmd ) {
155  h->SetVerbose(verbCmd->GetNewIntValue(newValue));
156  } else if (command == beamCmd) {
157  h->SetDefaultBeamPositionFlag(beamCmd->GetNewBoolValue(newValue));
158  } else if (command == edepCmd) {
159  h->SetMaxEnergyDeposit(edepCmd->GetNewDoubleValue(newValue));
160  }
161 }
162 
163 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
164