source: trunk/examples/extended/electromagnetic/TestEm5/src/DetectorMessenger.cc @ 1279

Last change on this file since 1279 was 1230, checked in by garnier, 14 years ago

update to geant4.9.3

File size: 6.7 KB
Line 
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.4 2006/06/29 16:55:32 gunter Exp $
27// GEANT4 tag $Name: geant4-09-03-cand-01 $
28//
29//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31
32#include "DetectorMessenger.hh"
33
34#include "DetectorConstruction.hh"
35#include "G4UIdirectory.hh"
36#include "G4UIcmdWithAString.hh"
37#include "G4UIcmdWithAnInteger.hh"
38#include "G4UIcmdWithADoubleAndUnit.hh"
39#include "G4UIcmdWithoutParameter.hh"
40
41//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
42
43DetectorMessenger::DetectorMessenger(DetectorConstruction * Det)
44:Detector(Det)
45{ 
46  testemDir = new G4UIdirectory("/testem/");
47  testemDir->SetGuidance("UI commands specific to this example.");
48 
49  detDir = new G4UIdirectory("/testem/det/");
50  detDir->SetGuidance("detector construction commands");
51     
52  AbsMaterCmd = new G4UIcmdWithAString("/testem/det/setAbsMat",this);
53  AbsMaterCmd->SetGuidance("Select Material of the Absorber.");
54  AbsMaterCmd->SetParameterName("choice",false);
55  AbsMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
56 
57  WorldMaterCmd = new G4UIcmdWithAString("/testem/det/setWorldMat",this);
58  WorldMaterCmd->SetGuidance("Select Material of the World.");
59  WorldMaterCmd->SetParameterName("wchoice",false);
60  WorldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
61 
62  AbsThickCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsThick",this);
63  AbsThickCmd->SetGuidance("Set Thickness of the Absorber");
64  AbsThickCmd->SetParameterName("SizeZ",false); 
65  AbsThickCmd->SetRange("SizeZ>0.");
66  AbsThickCmd->SetUnitCategory("Length"); 
67  AbsThickCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
68 
69  AbsSizYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsYZ",this);
70  AbsSizYZCmd->SetGuidance("Set sizeYZ of the Absorber");
71  AbsSizYZCmd->SetParameterName("SizeYZ",false);
72  AbsSizYZCmd->SetRange("SizeYZ>0.");
73  AbsSizYZCmd->SetUnitCategory("Length");
74  AbsSizYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
75 
76  AbsXposCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setAbsXpos",this);
77  AbsXposCmd->SetGuidance("Set X pos. of the Absorber");
78  AbsXposCmd->SetParameterName("Xpos",false);
79  AbsXposCmd->SetUnitCategory("Length");
80  AbsXposCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
81 
82  WorldXCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldX",this);
83  WorldXCmd->SetGuidance("Set X size of the World");
84  WorldXCmd->SetParameterName("WSizeX",false);
85  WorldXCmd->SetRange("WSizeX>0.");
86  WorldXCmd->SetUnitCategory("Length");
87  WorldXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
88 
89  WorldYZCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setWorldYZ",this);
90  WorldYZCmd->SetGuidance("Set sizeYZ of the World");
91  WorldYZCmd->SetParameterName("WSizeYZ",false);
92  WorldYZCmd->SetRange("WSizeYZ>0.");
93  WorldYZCmd->SetUnitCategory("Length");
94  WorldYZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
95 
96  UpdateCmd = new G4UIcmdWithoutParameter("/testem/det/update",this);
97  UpdateCmd->SetGuidance("Update calorimeter geometry.");
98  UpdateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
99  UpdateCmd->SetGuidance("if you changed geometrical value(s).");
100  UpdateCmd->AvailableForStates(G4State_Idle);
101     
102  MagFieldCmd = new G4UIcmdWithADoubleAndUnit("/testem/det/setField",this); 
103  MagFieldCmd->SetGuidance("Define magnetic field.");
104  MagFieldCmd->SetGuidance("Magnetic field will be in Z direction.");
105  MagFieldCmd->SetParameterName("Bz",false);
106  MagFieldCmd->SetUnitCategory("Magnetic flux density");
107  MagFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle); 
108
109}
110
111//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
112
113DetectorMessenger::~DetectorMessenger()
114{
115  delete AbsMaterCmd; 
116  delete AbsThickCmd; 
117  delete AbsSizYZCmd; 
118  delete AbsXposCmd; 
119  delete WorldMaterCmd;
120  delete WorldXCmd;
121  delete WorldYZCmd;
122  delete UpdateCmd;
123  delete MagFieldCmd;
124  delete detDir; 
125  delete testemDir;
126}
127
128//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
129
130void DetectorMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
131{ 
132  if ( command == AbsMaterCmd )
133   {Detector->SetAbsorberMaterial(newValue);}
134   
135  if ( command == WorldMaterCmd )
136   {Detector->SetWorldMaterial(newValue);}
137   
138  if ( command == AbsThickCmd )
139  {Detector->SetAbsorberThickness(AbsThickCmd->GetNewDoubleValue(newValue));}
140   
141  if ( command == AbsSizYZCmd )
142   {Detector->SetAbsorberSizeYZ(AbsSizYZCmd->GetNewDoubleValue(newValue));}
143   
144  if ( command == AbsXposCmd )
145   {Detector->SetAbsorberXpos(AbsXposCmd->GetNewDoubleValue(newValue));}
146   
147  if ( command == WorldXCmd )
148   {Detector->SetWorldSizeX(WorldXCmd->GetNewDoubleValue(newValue));}
149   
150  if ( command == WorldYZCmd )
151   {Detector->SetWorldSizeYZ(WorldYZCmd->GetNewDoubleValue(newValue));}
152   
153  if  ( command == UpdateCmd )
154   {Detector->UpdateGeometry(); }
155
156  if( command == MagFieldCmd )
157   {Detector->SetMagField(MagFieldCmd->GetNewDoubleValue(newValue));}
158}
159
160//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Note: See TracBrowser for help on using the repository browser.