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 | // $Id: DetectorMessenger.cc,v 1.7 2007/05/16 11:43:30 vnivanch Exp $ |
---|
27 | // GEANT4 tag $Name: $ |
---|
28 | // |
---|
29 | ///////////////////////////////////////////////////////////////////////// |
---|
30 | // |
---|
31 | // DetectorMessenger |
---|
32 | // |
---|
33 | // Created: 31.01.03 V.Ivanchenko |
---|
34 | // |
---|
35 | // Modified: |
---|
36 | // 04.06.2006 Adoptation of hadr01 (V.Ivanchenko) |
---|
37 | // 16.11.2006 Add beamCmd (V.Ivanchenko) |
---|
38 | // |
---|
39 | //////////////////////////////////////////////////////////////////////// |
---|
40 | // |
---|
41 | |
---|
42 | #include "DetectorMessenger.hh" |
---|
43 | |
---|
44 | #include "DetectorConstruction.hh" |
---|
45 | #include "G4UIdirectory.hh" |
---|
46 | #include "G4UIcmdWithABool.hh" |
---|
47 | #include "G4UIcmdWithAString.hh" |
---|
48 | #include "G4UIcmdWithAnInteger.hh" |
---|
49 | #include "G4UIcmdWith3Vector.hh" |
---|
50 | #include "G4UIcmdWithADoubleAndUnit.hh" |
---|
51 | #include "G4UIcmdWithoutParameter.hh" |
---|
52 | #include "HistoManager.hh" |
---|
53 | |
---|
54 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
55 | |
---|
56 | DetectorMessenger::DetectorMessenger(DetectorConstruction * Det) |
---|
57 | :Detector(Det) |
---|
58 | { |
---|
59 | testDir = new G4UIdirectory("/testhadr/"); |
---|
60 | testDir->SetGuidance(" Hadronic Extended Example."); |
---|
61 | |
---|
62 | matCmd = new G4UIcmdWithAString("/testhadr/TargetMat",this); |
---|
63 | matCmd->SetGuidance("Select Material for the target"); |
---|
64 | matCmd->SetParameterName("tMaterial",false); |
---|
65 | matCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
66 | |
---|
67 | mat1Cmd = new G4UIcmdWithAString("/testhadr/WorldMat",this); |
---|
68 | mat1Cmd->SetGuidance("Select Material for world"); |
---|
69 | mat1Cmd->SetParameterName("wMaterial",false); |
---|
70 | mat1Cmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
71 | |
---|
72 | rCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetRadius",this); |
---|
73 | rCmd->SetGuidance("Set radius of the target"); |
---|
74 | rCmd->SetParameterName("radius",false); |
---|
75 | rCmd->SetUnitCategory("Length"); |
---|
76 | rCmd->SetRange("radius>0"); |
---|
77 | rCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
78 | |
---|
79 | lCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/TargetLength",this); |
---|
80 | lCmd->SetGuidance("Set length of the target"); |
---|
81 | lCmd->SetParameterName("length",false); |
---|
82 | lCmd->SetUnitCategory("Length"); |
---|
83 | lCmd->SetRange("length>0"); |
---|
84 | lCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
85 | |
---|
86 | binCmd = new G4UIcmdWithAnInteger("/testhadr/NumberOfBinsE",this); |
---|
87 | binCmd->SetGuidance("Set number of bins for Energy"); |
---|
88 | binCmd->SetParameterName("NEbins",false); |
---|
89 | binCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
90 | |
---|
91 | nOfAbsCmd = new G4UIcmdWithAnInteger("/testhadr/NumberDivZ",this); |
---|
92 | nOfAbsCmd->SetGuidance("Set number of slices"); |
---|
93 | nOfAbsCmd->SetParameterName("NZ",false); |
---|
94 | nOfAbsCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
95 | |
---|
96 | edepCmd = new G4UIcmdWithADoubleAndUnit("/testhadr/MaxEdep",this); |
---|
97 | edepCmd->SetGuidance("Set max energy in histogram"); |
---|
98 | edepCmd->SetParameterName("edep",false); |
---|
99 | edepCmd->SetUnitCategory("Energy"); |
---|
100 | edepCmd->SetRange("edep>0"); |
---|
101 | edepCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
102 | |
---|
103 | updateCmd = new G4UIcmdWithoutParameter("/testhadr/Update",this); |
---|
104 | updateCmd->SetGuidance("Update geometry."); |
---|
105 | updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" "); |
---|
106 | updateCmd->SetGuidance("if you changed geometrical value(s)"); |
---|
107 | updateCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
108 | |
---|
109 | beamCmd = new G4UIcmdWithABool("/testhadr/DefaultBeamPosition",this); |
---|
110 | beamCmd->SetGuidance("show inelastic and elastic cross sections"); |
---|
111 | |
---|
112 | verbCmd = new G4UIcmdWithAnInteger("/testhadr/Verbose",this); |
---|
113 | verbCmd->SetGuidance("Set verbose for "); |
---|
114 | verbCmd->SetParameterName("verb",false); |
---|
115 | verbCmd->AvailableForStates(G4State_PreInit,G4State_Idle); |
---|
116 | } |
---|
117 | |
---|
118 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
119 | |
---|
120 | DetectorMessenger::~DetectorMessenger() |
---|
121 | { |
---|
122 | delete matCmd; |
---|
123 | delete mat1Cmd; |
---|
124 | delete rCmd; |
---|
125 | delete lCmd; |
---|
126 | delete nOfAbsCmd; |
---|
127 | delete updateCmd; |
---|
128 | delete testDir; |
---|
129 | delete beamCmd; |
---|
130 | delete verbCmd; |
---|
131 | delete edepCmd; |
---|
132 | } |
---|
133 | |
---|
134 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
135 | |
---|
136 | void DetectorMessenger::SetNewValue(G4UIcommand* command, G4String newValue) |
---|
137 | { |
---|
138 | HistoManager* h = HistoManager::GetPointer(); |
---|
139 | if( command == matCmd ) |
---|
140 | Detector->SetTargetMaterial(newValue); |
---|
141 | else if( command == mat1Cmd ) |
---|
142 | Detector->SetWorldMaterial(newValue); |
---|
143 | else if( command == rCmd ) |
---|
144 | Detector->SetTargetRadius(rCmd->GetNewDoubleValue(newValue)); |
---|
145 | else if( command == lCmd ) |
---|
146 | h->SetTargetLength(lCmd->GetNewDoubleValue(newValue)); |
---|
147 | else if( command == nOfAbsCmd ) |
---|
148 | h->SetNumberOfSlices(nOfAbsCmd->GetNewIntValue(newValue)); |
---|
149 | else if( command == binCmd ) |
---|
150 | h->SetNumberOfBinsE(binCmd->GetNewIntValue(newValue)); |
---|
151 | else if( command == verbCmd ) |
---|
152 | h->SetVerbose(verbCmd->GetNewIntValue(newValue)); |
---|
153 | else if (command == beamCmd) |
---|
154 | h->SetDefaultBeamPositionFlag(beamCmd->GetNewBoolValue(newValue)); |
---|
155 | else if (command == edepCmd) |
---|
156 | h->SetMaxEnergyDeposit(edepCmd->GetNewDoubleValue(newValue)); |
---|
157 | else if( command == updateCmd ) |
---|
158 | Detector->UpdateGeometry(); |
---|
159 | } |
---|
160 | |
---|
161 | //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... |
---|
162 | |
---|