ACTARSim
ACTAR TPC Simulation Reference Guide
ActarSimDetectorMessenger.cc
Go to the documentation of this file.
1 // - AUTHOR: Hector Alvarez-Pol 11/2004
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 ActarSimDetectorMessenger
11 /// Messenger for the detector construction
12 /////////////////////////////////////////////////////////////////
13 
16 #include "G4UIdirectory.hh"
17 #include "G4UIcmdWithAString.hh"
18 #include "G4UIcmdWithAnInteger.hh"
19 #include "G4UIcmdWithADouble.hh"
20 #include "G4UIcmdWithADoubleAndUnit.hh"
21 #include "G4UIcmdWith3VectorAndUnit.hh"
22 #include "G4UIcmdWith3Vector.hh"
23 #include "G4UIcmdWithoutParameter.hh"
24 
25 //////////////////////////////////////////////////////////////////
26 /// Constructor
27 /// command included in this AnalysisMessenger:
28 /// - /ActarSim/det/MaikoGeoIncludedFlag
29 /// - /ActarSim/det/ACTARTPCDEMOGeoIncludedFlag
30 /// - /ActarSim/det/ACTARTPCGeoIncludedFlag
31 /// - /ActarSim/det/SpecMATGeoIncludedFlag
32 /// - /ActarSim/det/OthersGeoIncludedFlag
33 /// - /ActarSim/det/setWorldSizeX
34 /// - /ActarSim/det/setWorldSizeY
35 /// - /ActarSim/det/setWorldSizeZ
36 /// - /ActarSim/det/setXLengthGasChamber
37 /// - /ActarSim/det/setYLengthGasChamber
38 /// - /ActarSim/det/setZLengthGasChamber
39 /// - /ActarSim/det/setXCenterChamber
40 /// - /ActarSim/det/setYCenterChamber
41 /// - /ActarSim/det/setZCenterChamber
42 /// - /ActarSim/det/gasGeoIncludedFlag
43 /// - /ActarSim/det/silGeoIncludedFlag
44 /// - /ActarSim/det/sciGeoIncludedFlag
45 /// - /ActarSim/det/setMediumMat
46 /// - /ActarSim/det/setChamberMat
47 /// - /ActarSim/det/setEleField
48 /// - /ActarSim/det/setMagField
49 /// - /ActarSim/det/update
50 /// - /ActarSim/det/print
53  :ActarSimDetector(ActarSimDet) {
54 
55  ActarSimDir = new G4UIdirectory("/ActarSim/");
56  ActarSimDir->SetGuidance("UI commands of ActarSim program");
57 
58  detDir = new G4UIdirectory("/ActarSim/det/");
59  detDir->SetGuidance("Detector control");
60 
61  MaikoGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/MaikoGeoIncludedFlag",this);
62  MaikoGeoIncludedFlagCmd->SetGuidance("Includes the Maiko geometry in the simulation (default off).");
63  MaikoGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
64  MaikoGeoIncludedFlagCmd->SetParameterName("choice",true);
65  MaikoGeoIncludedFlagCmd->SetDefaultValue("off");
66  MaikoGeoIncludedFlagCmd->SetCandidates("on off");
67  MaikoGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
68 
69  ACTARTPCDEMOGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/ACTARTPCDEMOGeoIncludedFlag",this);
70  ACTARTPCDEMOGeoIncludedFlagCmd->SetGuidance("Includes the ACTARTPC Demonstrator geometry in the simulation (default off).");
71  ACTARTPCDEMOGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
72  ACTARTPCDEMOGeoIncludedFlagCmd->SetParameterName("choice",true);
73  ACTARTPCDEMOGeoIncludedFlagCmd->SetDefaultValue("off");
74  ACTARTPCDEMOGeoIncludedFlagCmd->SetCandidates("on off");
75  ACTARTPCDEMOGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
76 
77  ACTARTPCGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/ACTARTPCGeoIncludedFlag",this);
78  ACTARTPCGeoIncludedFlagCmd->SetGuidance("Includes the ACTARTPC geometry in the simulation (default off).");
79  ACTARTPCGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
80  ACTARTPCGeoIncludedFlagCmd->SetParameterName("choice",true);
81  ACTARTPCGeoIncludedFlagCmd->SetDefaultValue("off");
82  ACTARTPCGeoIncludedFlagCmd->SetCandidates("on off");
83  ACTARTPCGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
84 
85  SpecMATGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/SpecMATGeoIncludedFlag",this);
86  SpecMATGeoIncludedFlagCmd->SetGuidance("Includes the SpecMAT geometry in the simulation (default off).");
87  SpecMATGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
88  SpecMATGeoIncludedFlagCmd->SetParameterName("choice",true);
89  SpecMATGeoIncludedFlagCmd->SetDefaultValue("off");
90  SpecMATGeoIncludedFlagCmd->SetCandidates("on off");
91  SpecMATGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
92 
93  OthersGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/OthersGeoIncludedFlag",this);
94  OthersGeoIncludedFlagCmd->SetGuidance("Includes Other geometries in the simulation (default off).");
95  OthersGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
96  OthersGeoIncludedFlagCmd->SetParameterName("choice",true);
97  OthersGeoIncludedFlagCmd->SetDefaultValue("off");
98  OthersGeoIncludedFlagCmd->SetCandidates("on off");
99  OthersGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
100 
101  worldSizeXCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setWorldSizeX",this);
102  worldSizeXCmd->SetGuidance("Select the half-length X dimension of the World.");
103  worldSizeXCmd->SetParameterName("xWorld",false);
104  worldSizeXCmd->SetRange("xWorld>=0.");
105  worldSizeXCmd->SetUnitCategory("Length");
106  worldSizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
107 
108  worldSizeYCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setWorldSizeY",this);
109  worldSizeYCmd->SetGuidance("Select the half-length Y dimension of the World.");
110  worldSizeYCmd->SetParameterName("yWorld",false);
111  worldSizeYCmd->SetRange("yWorld>=0.");
112  worldSizeYCmd->SetUnitCategory("Length");
113  worldSizeYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
114 
115  worldSizeZCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setWorldSizeZ",this);
116  worldSizeZCmd->SetGuidance("Select the half-length Z dimension of the World.");
117  worldSizeZCmd->SetParameterName("zWorld",false);
118  worldSizeZCmd->SetRange("zWorld>=0.");
119  worldSizeZCmd->SetUnitCategory("Length");
120  worldSizeZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
121 
122  chamberSizeXCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setXLengthGasChamber",this);
123  chamberSizeXCmd->SetGuidance("Select the half-length X dimension of the Gas Chamber.");
124  chamberSizeXCmd->SetParameterName("xGasChamber",false);
125  chamberSizeXCmd->SetRange("xGasChamber>=0.");
126  chamberSizeXCmd->SetUnitCategory("Length");
127  chamberSizeXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
128 
129  chamberSizeYCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setYLengthGasChamber",this);
130  chamberSizeYCmd->SetGuidance("Select the half-length Y dimension of the Gas Chamber.");
131  chamberSizeYCmd->SetParameterName("yGasChamber",false);
132  chamberSizeYCmd->SetRange("yGasChamber>=0.");
133  chamberSizeYCmd->SetUnitCategory("Length");
134  chamberSizeYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
135 
136  chamberSizeZCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setZLengthGasChamber",this);
137  chamberSizeZCmd->SetGuidance("Select the half-length Z dimension of the Gas Chamber.");
138  chamberSizeZCmd->SetParameterName("zGasChamber",false);
139  chamberSizeZCmd->SetRange("zGasChamber>=0.");
140  chamberSizeZCmd->SetUnitCategory("Length");
141  chamberSizeZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
142 
143  chamberCenterXCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setXCenterChamber",this);
144  chamberCenterXCmd->SetGuidance("Select the X offset of the Chamber center.");
145  chamberCenterXCmd->SetParameterName("chamberCenterX",false);
146  chamberCenterXCmd->SetUnitCategory("Length");
147  chamberCenterXCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
148 
149  chamberCenterYCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setYCenterChamber",this);
150  chamberCenterYCmd->SetGuidance("Select the Y offset of the Chamber center.");
151  chamberCenterYCmd->SetParameterName("chamberCenterY",false);
152  chamberCenterYCmd->SetUnitCategory("Length");
153  chamberCenterYCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
154 
155  chamberCenterZCmd = new G4UIcmdWithADoubleAndUnit("/ActarSim/det/setZCenterChamber",this);
156  chamberCenterZCmd->SetGuidance("Select the Z offset of the Chamber center.");
157  chamberCenterZCmd->SetParameterName("chamberCenterZ",false);
158  chamberCenterZCmd->SetUnitCategory("Length");
159  chamberCenterZCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
160 
161  gasGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/gasGeoIncludedFlag",this);
162  gasGeoIncludedFlagCmd->SetGuidance("Includes the geometry of the gas volume in the simulation (default on).");
163  gasGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
164  gasGeoIncludedFlagCmd->SetParameterName("choice",true);
165  gasGeoIncludedFlagCmd->SetDefaultValue("off");
166  gasGeoIncludedFlagCmd->SetCandidates("on off");
167  gasGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
168 
169  silGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/silGeoIncludedFlag",this);
170  silGeoIncludedFlagCmd->SetGuidance("Includes the geometry of the silicons in the simulation (default off).");
171  silGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
172  silGeoIncludedFlagCmd->SetParameterName("choice",true);
173  silGeoIncludedFlagCmd->SetDefaultValue("off");
174  silGeoIncludedFlagCmd->SetCandidates("on off");
175  silGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
176 
177  sciGeoIncludedFlagCmd = new G4UIcmdWithAString("/ActarSim/det/sciGeoIncludedFlag",this);
178  sciGeoIncludedFlagCmd->SetGuidance("Includes the geometry of the scintillator in the simulation (default off).");
179  sciGeoIncludedFlagCmd->SetGuidance(" Choice : on, off(default)");
180  sciGeoIncludedFlagCmd->SetParameterName("choice",true);
181  sciGeoIncludedFlagCmd->SetDefaultValue("off");
182  sciGeoIncludedFlagCmd->SetCandidates("on off");
183  sciGeoIncludedFlagCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
184 
185  mediumMaterialCmd = new G4UIcmdWithAString("/ActarSim/det/setMediumMat",this);
186  mediumMaterialCmd->SetGuidance("Select Material outside the Chamber.");
187  mediumMaterialCmd->SetParameterName("mediumMat",false);
188  mediumMaterialCmd->SetDefaultValue("Air");
189  mediumMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
190 
191  chamberMaterialCmd = new G4UIcmdWithAString("/ActarSim/det/setChamberMat",this);
192  chamberMaterialCmd->SetGuidance("Select Material in the Chamber (but not in the gas!).");
193  chamberMaterialCmd->SetParameterName("chamberMat",false);
194  chamberMaterialCmd->SetDefaultValue("Air");
195  chamberMaterialCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
196 
197  eleFieldCmd = new G4UIcmdWith3Vector("/ActarSim/det/setEleField",this);
198  eleFieldCmd->SetGuidance("Define electric field.");
199  eleFieldCmd->SetGuidance("Usage: /ActarSim/det/setEleField Ex Ey Ez (in MV/mm)");
200  eleFieldCmd->SetGuidance("Use the command update after setting a field.");
201  eleFieldCmd->SetParameterName("Ex","Ey","Ez",false,false);
202  //eleFieldCmd->SetDefaultUnit("kV/cm");
203  //eleFieldCmd->SetUnitCategory("Electric field");
204  eleFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
205 
206  magFieldCmd = new G4UIcmdWith3VectorAndUnit("/ActarSim/det/setMagField",this);
207  magFieldCmd->SetGuidance("Define magnetic field.");
208  magFieldCmd->SetGuidance("Usage: /ActarSim/det/setMagField Bx By Bz unit");
209  magFieldCmd->SetGuidance("Use the command update after setting a field.");
210  magFieldCmd->SetParameterName("Bx","By","Bz",false,false);
211  magFieldCmd->SetUnitCategory("Magnetic flux density");
212  magFieldCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
213 
214  updateCmd = new G4UIcmdWithoutParameter("/ActarSim/det/update",this);
215  updateCmd->SetGuidance("Update geometry.");
216  updateCmd->SetGuidance("This command MUST be applied before \"beamOn\" ");
217  updateCmd->SetGuidance("if you changed geometrical value(s).");
218  updateCmd->AvailableForStates(G4State_Idle);
219 
220  printCmd = new G4UIcmdWithoutParameter("/ActarSim/det/print",this);
221  printCmd->SetGuidance("Prints geometry.");
222  printCmd->AvailableForStates(G4State_Idle);
223 }
224 
225 //////////////////////////////////////////////////////////////////
226 /// Destructor
228  delete ActarSimDir;
229  delete detDir;
235  delete worldSizeXCmd;
236  delete worldSizeYCmd;
237  delete worldSizeZCmd;
238  delete chamberSizeXCmd;
239  delete chamberSizeYCmd;
240  delete chamberSizeZCmd;
241  delete chamberCenterXCmd;
242  delete chamberCenterYCmd;
243  delete chamberCenterZCmd;
244  delete gasGeoIncludedFlagCmd;
245  delete silGeoIncludedFlagCmd;
246  delete sciGeoIncludedFlagCmd;
247  delete mediumMaterialCmd;
248  delete chamberMaterialCmd;
249  delete eleFieldCmd;
250  delete magFieldCmd;
251  delete updateCmd;
252  delete printCmd;
253 }
254 
255 //////////////////////////////////////////////////////////////////
256 /// Setting the values using the ActarSimDetectorConstruction interface
257 void ActarSimDetectorMessenger::SetNewValue(G4UIcommand* command,
258  G4String newValue) {
259  //G4cout<<"Processing command: "<<command->GetCommandName()<<" - New value: "<<newValue<<G4endl;
260 
261  if( command == MaikoGeoIncludedFlagCmd )
263 
264  if( command == ACTARTPCDEMOGeoIncludedFlagCmd )
266 
267  if( command == ACTARTPCGeoIncludedFlagCmd )
269 
270  if( command == SpecMATGeoIncludedFlagCmd )
272 
273  if( command == OthersGeoIncludedFlagCmd )
275 
276  if(command == worldSizeXCmd)
277  ActarSimDetector->SetWorldSizeX(worldSizeXCmd->GetNewDoubleValue(newValue));
278 
279  if(command == worldSizeYCmd)
280  ActarSimDetector->SetWorldSizeY(worldSizeYCmd->GetNewDoubleValue(newValue));
281 
282  if(command == worldSizeZCmd)
283  ActarSimDetector->SetWorldSizeZ(worldSizeZCmd->GetNewDoubleValue(newValue));
284 
285  if(command == chamberSizeXCmd)
286  ActarSimDetector->SetChamberSizeX(chamberSizeXCmd->GetNewDoubleValue(newValue));
287 
288  if(command == chamberSizeYCmd)
289  ActarSimDetector->SetChamberSizeY(chamberSizeYCmd->GetNewDoubleValue(newValue));
290 
291  if(command == chamberSizeZCmd)
292  ActarSimDetector->SetChamberSizeZ(chamberSizeZCmd->GetNewDoubleValue(newValue));
293 
294  //HAPOL NOW!!! TODO CORRECT IT! JUST TESTING
295  //if(command == chamberCenterXCmd) {
296  // ActarSimGasDetector->chamberCenterXCmd(gasBoxSizeXCmd->GetNewDoubleValue(newValue));
297  //}
298 
299  if( command == gasGeoIncludedFlagCmd )
301 
302  if( command == silGeoIncludedFlagCmd )
304 
305  if( command == sciGeoIncludedFlagCmd )
307 
308  if(command == mediumMaterialCmd)
310 
311  if(command == chamberMaterialCmd)
313 
314  if( command == eleFieldCmd )
315  ActarSimDetector->SetEleField(eleFieldCmd->GetNew3VectorValue(newValue));
316 
317  if( command == magFieldCmd )
318  ActarSimDetector->SetMagField(magFieldCmd->GetNew3VectorValue(newValue));
319 
320  if( command == updateCmd ) {
324  }
325 
326  if( command == printCmd )
328 }
void SetMagField(G4ThreeVector mVector)
Setting the uniform magnetic field vector.
G4UIcmdWithADoubleAndUnit * chamberCenterXCmd
Select the X offset of the Chamber center.
ActarSimDetectorConstruction * ActarSimDetector
Pointer to detector class.
G4UIcmdWithAString * chamberMaterialCmd
Select Material in the Chamber (but not in the gas!).
G4UIcmdWithAString * silGeoIncludedFlagCmd
Includes the geometry of the silicons in the simulation (default off).
void SetNewValue(G4UIcommand *, G4String)
Setting the values using the ActarSimDetectorConstruction interface.
ActarSimDetectorMessenger(ActarSimDetectorConstruction *)
G4UIcmdWithADoubleAndUnit * chamberSizeXCmd
Select the half-length X dimension of the Gas Chamber.
G4UIcmdWithAString * mediumMaterialCmd
Select Material outside the Chamber.
G4UIcmdWithAString * MaikoGeoIncludedFlagCmd
Includes the Maiko geometry in the simulation (default off).
G4UIcmdWithAString * SpecMATGeoIncludedFlagCmd
Includes the SpecMAT geometry in the simulation (default off).
G4UIcmdWith3VectorAndUnit * magFieldCmd
Define magnetic field.
G4UIcmdWithAString * sciGeoIncludedFlagCmd
Includes the geometry of the scintillator in the simulation (default off).
G4UIcmdWithADoubleAndUnit * chamberCenterZCmd
Select the Z offset of the Chamber center.
G4UIcmdWithADoubleAndUnit * chamberSizeYCmd
Select the half-length Y dimension of the Gas Chamber.
G4UIcmdWithADoubleAndUnit * worldSizeXCmd
Select the half-length X dimension of the World.
void SetChamberMaterial(G4String)
Sets the material the chamber is made of (the same as GasBox)
G4UIcmdWithAString * ACTARTPCGeoIncludedFlagCmd
Includes the ACTARTPC geometry in the simulation (default off).
G4UIcmdWith3Vector * eleFieldCmd
Define electric field.
G4UIcmdWithADoubleAndUnit * worldSizeYCmd
Select the half-length Y dimension of the World.
G4UIcmdWithADoubleAndUnit * chamberCenterYCmd
Select the Y offset of the Chamber center.
G4UIcmdWithADoubleAndUnit * chamberSizeZCmd
Select the half-length Z dimension of the Gas Chamber.
void UpdateGeometry()
Updates any change on the geometry of the detectors.
G4UIcmdWithoutParameter * updateCmd
Update geometry.
void SetMediumMaterial(G4String)
Sets the material the medium is made of.
G4UIcmdWithAString * ACTARTPCDEMOGeoIncludedFlagCmd
Includes the ACTARTPC Demonstrator geometry in the simulation (default off).
void PrintDetectorParameters()
Print current detector parameters.
G4UIcmdWithAString * OthersGeoIncludedFlagCmd
Includes Other geometries in the simulation (default off).
G4UIcmdWithADoubleAndUnit * worldSizeZCmd
Select the half-length Z dimension of the World.
G4UIcmdWithAString * gasGeoIncludedFlagCmd
Includes the geometry of the gas volume in the simulation (default on).
void UpdateEMField()
Setting the uniform EM field.
G4UIdirectory * ActarSimDir
Directory in messenger structure.
G4UIdirectory * detDir
Directory in messenger structure.
G4UIcmdWithoutParameter * printCmd
Prints geometry.