ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimGasDetectorMessenger.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 04/2008
2 /******************************************************************
3  * Copyright (C) 2005-2016, Hector Alvarez-Pol *
4  * All rights reserved. *
5  * *
6  * License according to GNU LESSER GPL (see lgpl-3.0.txt). *
7  * For the list of contributors see CREDITS. *
8  ******************************************************************/
9 //////////////////////////////////////////////////////////////////
10 /// \class ActarSimGasDetectorMessenger
11 /// Messenger of the Gas ACTAR detector
12 /////////////////////////////////////////////////////////////////
13 
15 
16 #include "G4RunManager.hh"
17 
21 
22 #include "G4UIcommand.hh"
23 #include "G4UIdirectory.hh"
24 #include "G4UIcmdWithAString.hh"
25 #include "G4UIcmdWithAnInteger.hh"
26 #include "G4UIcmdWithADoubleAndUnit.hh"
27 #include "G4UIcmdWith3VectorAndUnit.hh"
28 #include "G4UIcmdWithoutParameter.hh"
29 #include "G4Tokenizer.hh"
30 
31 
32 //////////////////////////////////////////////////////////////////
33 /// Constructor
34 /// command included in this AnalysisMessenger:
35 /// - /ActarSim/det/gas/setGasMat
36 /// - /ActarSim/det/gas/setGasPressure
37 /// - /ActarSim/det/gas/setGasTemperature
38 /// - /ActarSim/det/gas/setBeamShieldMat
39 /// - /ActarSim/det/gas/setDetectorGeometry
40 /// - /ActarSim/det/gas/setBeamShield
41 /// - /ActarSim/det/gas/setXLengthGasBox
42 /// - /ActarSim/det/gas/setYLengthGasBox
43 /// - /ActarSim/det/gas/setZLengthGasBox
44 /// - /ActarSim/det/gas/setXCenterGasBox
45 /// - /ActarSim/det/gas/setYCenterGasBox
46 /// - /ActarSim/det/gas/setZCenterGasBox
47 /// - /ActarSim/det/gas/setRadiusGasTub
48 /// - /ActarSim/det/gas/setLengthGasTub
49 /// - /ActarSim/det/gas/setInnerRadiusBeamShieldTub
50 /// - /ActarSim/det/gas/setRadiusBeamShieldTub
51 /// - /ActarSim/det/gas/setLengthBeamShieldTub
52 /// - /ActarSim/det/gas/print
53 /// - /ActarSim/det/gas/mixture/
54 /// - /ActarSim/det/gas/mixture/GasMixture
55 /// - /ActarSim/det/gas/mixture/setGasMix
58  :ActarSimDetector(ActarSimDet), ActarSimGasDetector(ActarSimGasDet){
59 
61  ; //avoid compiler warning message
62 
63  detDir = new G4UIdirectory("/ActarSim/det/gas/");
64  detDir->SetGuidance("gas detector control");
65 
66  gasMaterCmd = new G4UIcmdWithAString("/ActarSim/det/gas/setGasMat",this);
67  gasMaterCmd->SetGuidance("Select Material of the Gas (for the Gas box and the Chamber).");
68  gasMaterCmd->SetParameterName("gasMat",false);
69  gasMaterCmd->SetDefaultValue("D2");
70  gasMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
71 
72  gasPresCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setGasPressure",this);
73  gasPresCmd->SetGuidance("Select the Gas Pressure (for the Gas box and the Chamber).");
74  gasPresCmd->SetParameterName("gasPressure",false);
75  gasPresCmd->SetRange("gasPressure>=0.");
76  gasPresCmd->SetUnitCategory("Pressure");
77  gasPresCmd->SetDefaultUnit("bar");
78  gasPresCmd->SetDefaultValue(1.01325);
79  gasPresCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
80 
81  gasTempCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setGasTemperature",this);
82  gasTempCmd->SetGuidance("Select the Gas Temperature (for the Gas box and the Chamber).");
83  gasTempCmd->SetParameterName("gasTemperature",false);
84  gasTempCmd->SetRange("gasTemperature>=0.");
85  gasTempCmd->SetUnitCategory("Temperature");
86  gasTempCmd->SetDefaultUnit("kelvin");
87  gasTempCmd->SetDefaultValue(293.15);
88  gasTempCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
89 
90  beamShieldMaterCmd = new G4UIcmdWithAString("/ActarSim/det/gas/setBeamShieldMat",this);
91  beamShieldMaterCmd->SetGuidance("Select Material of the beam shield.");
92  beamShieldMaterCmd->SetParameterName("gasMat",false);
93  beamShieldMaterCmd->SetDefaultValue("iC4H10");
94  beamShieldMaterCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
95 
96  detectorGeometryCmd = new G4UIcmdWithAString("/ActarSim/det/gas/setDetectorGeometry",this);
97  detectorGeometryCmd->SetGuidance("Select the geometry of the detector.");
98  detectorGeometryCmd->SetGuidance("Choice : box(default), tube.");
99  detectorGeometryCmd->SetParameterName("choice",false);
100  detectorGeometryCmd->SetDefaultValue("box");
101  detectorGeometryCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
102 
103  setBeamShieldCmd = new G4UIcmdWithAString("/ActarSim/det/gas/setBeamShield",this);
104  setBeamShieldCmd->SetGuidance("Sets a beam shield and selects the geometry.");
105  setBeamShieldCmd->SetGuidance("Choice : tube, off.");
106  setBeamShieldCmd->SetParameterName("choice",false);
107  setBeamShieldCmd->SetDefaultValue("tube");
108  setBeamShieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
109 
110  gasBoxSizeXCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setXLengthGasBox",this);
111  gasBoxSizeXCmd->SetGuidance("Select the half-length X dimension of the Gas Box.");
112  gasBoxSizeXCmd->SetParameterName("gasBoxSizeX",false);
113  gasBoxSizeXCmd->SetRange("gasBoxSizeX>=0.");
114  gasBoxSizeXCmd->SetUnitCategory("Length");
115  gasBoxSizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
116 
117  gasBoxSizeYCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setYLengthGasBox",this);
118  gasBoxSizeYCmd->SetGuidance("Select the half-length Y dimension of the Gas Box.");
119  gasBoxSizeYCmd->SetParameterName("gasBoxSizeY",false);
120  gasBoxSizeYCmd->SetRange("gasBoxSizeY>=0.");
121  gasBoxSizeYCmd->SetUnitCategory("Length");
122  gasBoxSizeYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
123 
124  gasBoxSizeZCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setZLengthGasBox",this);
125  gasBoxSizeZCmd->SetGuidance("Select the half-length Z dimension of the Gas Box.");
126  gasBoxSizeZCmd->SetParameterName("gasBoxSizeZ",false);
127  gasBoxSizeZCmd->SetRange("gasBoxSizeZ>=0.");
128  gasBoxSizeZCmd->SetUnitCategory("Length");
129  gasBoxSizeZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
130 
131  gasBoxCenterXCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setXCenterGasBox",this);
132  gasBoxCenterXCmd->SetGuidance("Select the X offset of the Gas Box center.");
133  gasBoxCenterXCmd->SetParameterName("gasBoxCenterX",false);
134  gasBoxCenterXCmd->SetUnitCategory("Length");
135  gasBoxCenterXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
136 
137  gasBoxCenterYCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setYCenterGasBox",this);
138  gasBoxCenterYCmd->SetGuidance("Select the Y offset of the Gas Box center.");
139  gasBoxCenterYCmd->SetParameterName("gasBoxCenterY",false);
140  gasBoxCenterYCmd->SetUnitCategory("Length");
141  gasBoxCenterYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
142 
143  gasBoxCenterZCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setZCenterGasBox",this);
144  gasBoxCenterZCmd->SetGuidance("Select the Z offset of the Gas Box center.");
145  gasBoxCenterZCmd->SetParameterName("gasBoxCenterZ",false);
146  gasBoxCenterZCmd->SetUnitCategory("Length");
147  gasBoxCenterZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
148 
149  radiusGasTubCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setRadiusGasTub",this);
150  radiusGasTubCmd->SetGuidance("Select the external radius of the Gas Tube.");
151  radiusGasTubCmd->SetParameterName("radiusGasTub",false);
152  radiusGasTubCmd->SetRange("radiusGasTub>=0.");
153  radiusGasTubCmd->SetUnitCategory("Length");
154  radiusGasTubCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
155 
156  lengthGasTubCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setLengthGasTub",this);
157  lengthGasTubCmd->SetGuidance("Select the half-length of the Gas Tube.");
158  lengthGasTubCmd->SetParameterName("lengthGasTub",false);
159  lengthGasTubCmd->SetRange("lengthGasTub>=0.");
160  lengthGasTubCmd->SetUnitCategory("Length");
161  lengthGasTubCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
162 
163  innerRadiusBeamShieldTubCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setInnerRadiusBeamShieldTub",this);
164  innerRadiusBeamShieldTubCmd->SetGuidance("Select the internal radius of the Gas Tube.");
165  innerRadiusBeamShieldTubCmd->SetParameterName("innerRadiusBeamShieldTub",false);
166  innerRadiusBeamShieldTubCmd->SetRange("innerRadiusBeamShieldTub>=0.");
167  innerRadiusBeamShieldTubCmd->SetUnitCategory("Length");
168  innerRadiusBeamShieldTubCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
169 
170  outerRadiusBeamShieldTubCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setRadiusBeamShieldTub",this);
171  outerRadiusBeamShieldTubCmd->SetGuidance("Select the external radius of the Gas Tube.");
172  outerRadiusBeamShieldTubCmd->SetParameterName("outerRadiusBeamShieldTub",false);
173  outerRadiusBeamShieldTubCmd->SetRange("outerRadiusBeamShieldTub>=0.");
174  outerRadiusBeamShieldTubCmd->SetUnitCategory("Length");
175  outerRadiusBeamShieldTubCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
176 
177  lengthBeamShieldTubCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/gas/setLengthBeamShieldTub",this);
178  lengthBeamShieldTubCmd->SetGuidance("Select the half-length of the Gas Tube.");
179  lengthBeamShieldTubCmd->SetParameterName("lengthBeamShieldTub",false);
180  lengthBeamShieldTubCmd->SetRange("lengthBeamShieldTub>=0.");
181  lengthBeamShieldTubCmd->SetUnitCategory("Length");
182  lengthBeamShieldTubCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
183 
184  printCmd = new G4UIcmdWithoutParameter("/ActarSim/det/gas/print",this);
185  printCmd->SetGuidance("Prints geometry.");
186  printCmd->AvailableForStates(G4State_Idle);
187 
188  detDirMix = new G4UIdirectory("/ActarSim/det/gas/mixture/");
189  detDirMix->SetGuidance("gas mixture control");
190 
191  gasMixtureFlagCmd = new G4UIcmdWithAnInteger("/ActarSim/det/gas/mixture/GasMixture",this);
192  gasMixtureFlagCmd->SetGuidance("Set a Gas Mixture with N number of elements (default 0).");
193  gasMixtureFlagCmd->SetGuidance(" Choice : 0 (default) to 10");
194  //gasMixtureFlagCmd->SetParameterName("GasNumber",false);
195  gasMixtureFlagCmd->SetParameterName("N",true,true);
196  gasMixtureFlagCmd->SetRange("N>0");
197  gasMixtureFlagCmd->SetDefaultValue(2);
198  //gasMixtureFlagCmd->SetCandidates("2 3 4 5 6 7 8 9 10");
199  //gasMixtureFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
200 
201  gasMixtureCmd = new G4UIcommand("/ActarSim/det/gas/mixture/setGasMix",this);
202  gasMixtureCmd->SetGuidance("Set a Gas Mixture (for the Gas box and the Chamber).");
203  gasMixtureCmd->SetGuidance("[usage] /ActarSim/det/gas/setGasMix GasNum GasMat GasRatio");
204  gasMixtureCmd->SetGuidance(" GasNum:(int) GasNumber (from 1 to 7)");
205  gasMixtureCmd->SetGuidance(" GasMat:(string) Gas Material from the list");
206  gasMixtureCmd->SetGuidance(" GasRatio:(double) Gas Ratio in Mixture (from 0 to 1)");
207 
208  G4UIparameter* gasMixtureParam;
209  gasMixtureParam = new G4UIparameter("GasNum",'i',false);
210  gasMixtureParam->SetDefaultValue("1");
211  gasMixtureParam->SetParameterRange("GasNum>0");
212  gasMixtureParam->SetParameterRange("GasNum<10");
213  gasMixtureCmd->SetParameter(gasMixtureParam);
214  gasMixtureParam = new G4UIparameter("GasMat",'s',false);
215  gasMixtureParam->SetDefaultValue("D2");
216  gasMixtureParam->SetParameterCandidates("H2 D2 He Ar CF4 CH4 iC4H10");
217  gasMixtureCmd->SetParameter(gasMixtureParam);
218  gasMixtureParam = new G4UIparameter("GasRatio",'d',false);
219  gasMixtureParam->SetDefaultValue("0");
220  gasMixtureParam->SetParameterRange("GasRatio>=0.");
221  gasMixtureParam->SetParameterRange("GasRatio<=1.");
222  gasMixtureCmd->SetParameter(gasMixtureParam);
223 }
224 
225 //////////////////////////////////////////////////////////////////
226 /// Destructor
228  delete detDir;
229  delete detDirMix;
230  delete gasMaterCmd;
231  delete gasMixtureFlagCmd;
232  delete gasMixtureCmd;
233  delete gasPresCmd;
234  delete gasTempCmd;
235  delete beamShieldMaterCmd;
236  delete detectorGeometryCmd;
237  delete setBeamShieldCmd;
238  delete gasBoxSizeXCmd;
239  delete gasBoxSizeYCmd;
240  delete gasBoxSizeZCmd;
241  delete gasBoxCenterXCmd;
242  delete gasBoxCenterYCmd;
243  delete gasBoxCenterZCmd;
244  delete radiusGasTubCmd;
245  delete lengthGasTubCmd;
248  delete lengthBeamShieldTubCmd;
249  delete printCmd;
250 }
251 
252 //////////////////////////////////////////////////////////////////
253 /// Setting the new values and connecting to actions
255  G4String newValue) {
256 
257  if(command == gasMaterCmd) {
258  //ActarSimGasDetector->DefineGas();
260  //ActarSimDetector->SetChamberMaterial(newValue);
261  //ActarSimDetector->UpdateGeometry();
262  //ActarSimDetector->PrintDetectorParameters();
263  }
264 
265  if(command == gasMixtureFlagCmd)
266  ActarSimGasDetector->SetGasMixture(gasMixtureFlagCmd->GetNewIntValue(newValue));
267 
268  if(command == gasMixtureCmd)
269  GasMixtureCommand(newValue);
270 
271  if(command == gasTempCmd)
272  ActarSimGasDetector->SetGasTemperature(gasTempCmd->GetNewDoubleValue(newValue));
273 
274  if(command == gasPresCmd)
275  ActarSimGasDetector->SetGasPressure(gasPresCmd->GetNewDoubleValue(newValue));
276 
277  if(command == beamShieldMaterCmd)
279 
280  if(command == detectorGeometryCmd)
282 
283  if(command == setBeamShieldCmd)
285 
286  if(command == gasBoxSizeXCmd)
287  ActarSimGasDetector->SetGasBoxSizeX(gasBoxSizeXCmd->GetNewDoubleValue(newValue));
288 
289  if(command == gasBoxSizeYCmd)
290  ActarSimGasDetector->SetGasBoxSizeY(gasBoxSizeYCmd->GetNewDoubleValue(newValue));
291 
292  if(command == gasBoxSizeZCmd)
293  ActarSimGasDetector->SetGasBoxSizeZ(gasBoxSizeZCmd->GetNewDoubleValue(newValue));
294 
295  if(command == gasBoxCenterXCmd)
296  ActarSimGasDetector->SetGasBoxCenterY(gasBoxCenterXCmd->GetNewDoubleValue(newValue));
297 
298  if(command == gasBoxCenterYCmd)
299  ActarSimGasDetector->SetGasBoxCenterY(gasBoxCenterYCmd->GetNewDoubleValue(newValue));
300 
301  if(command == gasBoxCenterZCmd)
302  ActarSimGasDetector->SetGasBoxCenterZ(gasBoxCenterZCmd->GetNewDoubleValue(newValue));
303 
304  if(command == radiusGasTubCmd)
305  ActarSimGasDetector->SetRadiusGasTub(radiusGasTubCmd->GetNewDoubleValue(newValue));
306 
307  if(command == lengthGasTubCmd)
308  ActarSimGasDetector->SetLengthGasTub(lengthGasTubCmd->GetNewDoubleValue(newValue));
309 
310  if(command == innerRadiusBeamShieldTubCmd)
312 
313  if(command == outerRadiusBeamShieldTubCmd)
315 
316  if(command == lengthBeamShieldTubCmd)
318 
319  if( command == printCmd )
321 }
322 
323 //////////////////////////////////////////////////////////////////
324 /// Selection of the mixture gases.
326 
327  G4Tokenizer next( newValues );
328  // check argument
329  fGasNumber = StoI(next());
330  fGasMaterial = next();
331  fGasRatio = StoD(next());
332 
333  //G4cout << " fGasNumber "<<fGasNumber<< " fGasMaterial "<<fGasMaterial<< " fGasRatio "<<fGasRatio<< G4endl;
334 
336 }
G4UIcmdWithADoubleAndUnit * gasBoxCenterZCmd
Select the Z offset of the Gas Box center.
G4UIcmdWithADoubleAndUnit * gasBoxCenterYCmd
Select the Y offset of the Gas Box center.
ActarSimGasDetectorMessenger(ActarSimDetectorConstruction *, ActarSimGasDetectorConstruction *)
G4UIcmdWithAString * detectorGeometryCmd
Select the geometry of the detector.
void SetBeamShieldMaterial(G4String)
Sets the material the medium is made of.
G4UIcmdWithADoubleAndUnit * lengthGasTubCmd
Select the half-length of the Gas Tube.
void GasMixtureCommand(G4String newValues)
Selection of the mixture gases.
void PrintDetectorParameters()
Prints Gas volume detector parameters.
G4UIcmdWithoutParameter * printCmd
Prints geometry.
G4UIcmdWithADoubleAndUnit * gasBoxSizeXCmd
Select the half-length X dimension of the Gas Box.
G4UIcmdWithADoubleAndUnit * radiusGasTubCmd
Select the external radius of the Gas Tube.
void SetBeamShieldGeometry(G4String)
Sets the geometry of the detector (box or tube)
G4int fGasNumber
Gas mixture parameters: number.
G4UIcmdWithAnInteger * gasMixtureFlagCmd
Set a Gas Mixture with N number of elements (default 0).
G4UIcmdWithADoubleAndUnit * gasBoxSizeYCmd
Select the half-length Y dimension of the Gas Box.
G4UIcmdWithAString * beamShieldMaterCmd
Select Material of the beam shield.
G4UIcmdWithADoubleAndUnit * gasBoxCenterXCmd
Select the X offset of the Gas Box center.
G4double fGasRatio
Gas mixture parameters: ratio.
void SetDetectorGeometry(G4String)
Sets the geometry of the detector (box or tube)
G4UIcmdWithADoubleAndUnit * gasTempCmd
Select the Gas Temperature (for the Gas box and the Chamber).
void SetNewValue(G4UIcommand *, G4String)
Setting the new values and connecting to actions.
G4UIcmdWithAString * setBeamShieldCmd
Sets a beam shield and selects the geometry.
G4UIcmdWithAString * gasMaterCmd
Select Material of the Gas (for the Gas box and the Chamber).
G4UIcmdWithADoubleAndUnit * gasBoxSizeZCmd
Select the half-length Z dimension of the Gas Box.
G4UIcmdWithADoubleAndUnit * outerRadiusBeamShieldTubCmd
Select the external radius of the Gas Tube.
G4UIcmdWithADoubleAndUnit * gasPresCmd
Select the Gas Pressure (for the Gas box and the Chamber).
G4UIcmdWithADoubleAndUnit * lengthBeamShieldTubCmd
Select the half-length of the Gas Tube.
ActarSimDetectorConstruction * ActarSimDetector
Pointer to main detector geometry class.
ActarSimGasDetectorConstruction * ActarSimGasDetector
Pointer to main gas detector geometry class.
G4UIcommand * gasMixtureCmd
Set a Gas Mixture (for the Gas box and the Chamber).
void SetGasMixMaterial(G4int GasNum, G4String GasMat, G4double GasRatio)
G4String fGasMaterial
Gas mixture parameters: material.
G4UIdirectory * detDirMix
Directory for gas mix.
G4UIcmdWithADoubleAndUnit * innerRadiusBeamShieldTubCmd
Select the internal radius of the Gas Tube.