ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DetectorMessenger.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file DetectorMessenger.cc
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 //
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
32 
33 #include "DetectorMessenger.hh"
34 
35 #include <sstream>
36 #include <iostream>
37 
38 #include "G4OpticalSurface.hh"
39 
40 #include "DetectorConstruction.hh"
41 #include "G4UIdirectory.hh"
42 #include "G4UIcommand.hh"
43 #include "G4UIparameter.hh"
44 #include "G4UIcmdWithAString.hh"
45 #include "G4UIcmdWithADouble.hh"
46 #include "G4UIcmdWithAnInteger.hh"
49 
50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
51 
53 :G4UImessenger(),fDetector(Det)
54 {
55  fOpticalDir = new G4UIdirectory("/opnovice2/");
56  fOpticalDir->SetGuidance("Parameters for optical simulation.");
57 
58  fSurfaceTypeCmd = new G4UIcmdWithAString("/opnovice2/surfaceType", this);
59  fSurfaceTypeCmd->SetGuidance("Surface type.");
62 
63  fSurfaceFinishCmd = new G4UIcmdWithAString("/opnovice2/surfaceFinish", this);
64  fSurfaceFinishCmd->SetGuidance("Surface finish.");
67 
69  new G4UIcmdWithAString("/opnovice2/surfaceModel", this);
70  fSurfaceModelCmd->SetGuidance("surface model.");
73 
75  new G4UIcmdWithADouble("/opnovice2/surfaceSigmaAlpha", this);
76  fSurfaceSigmaAlphaCmd->SetGuidance("surface sigma alpha");
77  fSurfaceSigmaAlphaCmd->SetGuidance(" parameter.");
80 
82  new G4UIcmdWithADouble("/opnovice2/surfacePolish", this);
83  fSurfacePolishCmd->SetGuidance("surface polish");
84  fSurfacePolishCmd->SetGuidance(" parameter (for Glisur model).");
87 
89  new G4UIcmdWithAString("/opnovice2/surfaceProperty", this);
90  fSurfaceMatPropVectorCmd->SetGuidance("Set material property vector");
91  fSurfaceMatPropVectorCmd->SetGuidance(" for the surface.");
94 
96  new G4UIcmdWithAString("/opnovice2/surfaceConstProperty", this);
97  fSurfaceMatPropConstCmd->SetGuidance("Set material constant property");
98  fSurfaceMatPropConstCmd->SetGuidance(" for the surface.");
101 
103  new G4UIcmdWithAString("/opnovice2/boxProperty", this);
104  fTankMatPropVectorCmd->SetGuidance("Set material property vector for ");
105  fTankMatPropVectorCmd->SetGuidance("the box.");
108 
110  new G4UIcmdWithAString("/opnovice2/boxConstProperty", this);
111  fTankMatPropConstCmd->SetGuidance("Set material constant property ");
112  fTankMatPropConstCmd->SetGuidance("for the box.");
115 
116  fTankMaterialCmd = new G4UIcmdWithAString("/opnovice2/boxMaterial", this);
117  fTankMaterialCmd->SetGuidance("Set material of box.");
120 
122  new G4UIcmdWithAString("/opnovice2/worldProperty", this);
123  fWorldMatPropVectorCmd->SetGuidance("Set material property vector ");
124  fWorldMatPropVectorCmd->SetGuidance("for the world.");
127 
129  new G4UIcmdWithAString("/opnovice2/worldConstProperty", this);
130  fWorldMatPropConstCmd->SetGuidance("Set material constant property");
131  fWorldMatPropConstCmd->SetGuidance(" for the world.");
133  AvailableForStates(G4State_PreInit, G4State_Idle);
135 
136  fWorldMaterialCmd = new G4UIcmdWithAString("/opnovice2/worldMaterial", this);
137  fWorldMaterialCmd->SetGuidance("Set material of world.");
140 
141 }
142 
143 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
144 
146 {
147  delete fSurfaceFinishCmd;
148  delete fSurfaceTypeCmd;
149  delete fSurfaceModelCmd;
150  delete fSurfaceSigmaAlphaCmd;
151  delete fSurfacePolishCmd;
154  delete fTankMatPropVectorCmd;
155  delete fTankMatPropConstCmd;
156  delete fTankMaterialCmd;
157  delete fWorldMatPropVectorCmd;
158  delete fWorldMatPropConstCmd;
159  delete fWorldMaterialCmd;
160 }
161 
162 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
163 
165 {
166  // FINISH
167  if (command == fSurfaceFinishCmd) {
168  if (newValue == "polished") {
170  }
171  else if (newValue == "polishedfrontpainted") {
173  }
174  else if (newValue == "polishedbackpainted") {
176  }
177  else if (newValue == "ground") {
179  }
180  else if (newValue == "groundfrontpainted") {
182  }
183  else if (newValue == "groundbackpainted") {
185  }
186  else if (newValue == "polishedlumirrorair") {
188  }
189  else if (newValue == "polishedlumirrorglue") {
191  }
192  else if (newValue == "polishedair") {
194  }
195  else if (newValue == "polishedteflonair") {
197  }
198  else if (newValue == "polishedtioair") {
200  }
201  else if (newValue == "polishedtyvekair") {
203  }
204  else if (newValue == "polishedvm2000air") {
206  }
207  else if (newValue == "polishedvm2000glue") {
209  }
210  else if (newValue == "etchedlumirrorair") {
212  }
213  else if (newValue == "etchedlumirrorglue") {
215  }
216  else if (newValue == "etchedair") {
218  }
219  else if (newValue == "etchedteflonair") {
221  }
222  else if (newValue == "etchedtioair") {
224  }
225  else if (newValue == "etchedtyvekair") {
227  }
228  else if (newValue == "etchedvm2000air") {
230  }
231  else if (newValue == "etchedvm2000glue") {
233  }
234  else if (newValue == "groundlumirrorair") {
236  }
237  else if (newValue == "groundlumirrorglue") {
239  }
240  else if (newValue == "groundair") {
242  }
243  else if (newValue == "groundteflonair") {
245  }
246  else if (newValue == "groundtioair") {
248  }
249  else if (newValue == "groundtyvekair") {
251  }
252  else if (newValue == "groundvm2000air") {
254  }
255  else if (newValue == "groundvm2000glue") {
257  }
258  // for Davis model
259  else if (newValue == "Rough_LUT") {
261  }
262  else if (newValue == "RoughTeflon_LUT") {
264  }
265  else if (newValue == "RoughESR_LUT") {
267  }
268  else if (newValue == "RoughESRGrease_LUT") {
270  }
271  else if (newValue == "Polished_LUT") {
273  }
274  else if (newValue == "PolishedTeflon_LUT") {
276  }
277  else if (newValue == "PolishedESR_LUT") {
279  }
280  else if (newValue == "PolishedESRGrease_LUT") {
282  }
283  else if (newValue == "Detector_LUT") {
285  }
286  else {
288  ed << "Invalid surface finish: " << newValue;
289  G4Exception("DetectorMessenger", "OpNovice2_003", FatalException,ed);
290  }
291  }
292 
293  // MODEL
294  else if (command == fSurfaceModelCmd) {
295  if (newValue == "glisur") {
297  }
298  else if (newValue == "unified") {
300  }
301  else if (newValue == "LUT") {
303  }
304  else if (newValue == "DAVIS") {
306  }
307  else if (newValue == "dichroic") {
309  }
310  else {
312  ed << "Invalid surface model: " << newValue;
313  G4Exception("DetectorMessenger", "ONovice2_001",
314  FatalException,ed);
315  }
316  }
317 
318  // TYPE
319  else if (command == fSurfaceTypeCmd) {
320  if (newValue == "dielectric_metal") {
322  }
323  else if (newValue == "dielectric_dielectric") {
325  }
326  else if (newValue == "dielectric_LUT") {
328  }
329  else if (newValue == "dielectric_LUTDAVIS") {
331  }
332  else {
334  ed << "Invalid surface type: " << newValue;
335  G4Exception("DetectorMessenger", "OpNovice2_002", FatalException,ed);
336  }
337  }
338  else if (command == fSurfaceSigmaAlphaCmd) {
341  }
342  else if (command == fSurfacePolishCmd) {
345  }
346  else if (command == fTankMatPropVectorCmd) {
347  // got a string. need to convert it to physics vector.
348  // string format is property name, then pairs of energy, value
349  // specify units for each value, eg 3.0*eV
350  // space delimited
352  std::istringstream instring(newValue);
353  G4String prop;
354  instring >> prop;
355  while (instring) {
356  G4String tmp;
357  instring >> tmp;
358  if (tmp == "") { break; }
360  instring >> tmp;
361  G4double val;
362  val = G4UIcommand::ConvertToDouble(tmp);
363  mpv->InsertValues(en, val);
364  }
365  const char* c = prop.c_str();
366 
367  fDetector->AddTankMPV(c, mpv);
368  }
369  else if (command == fWorldMatPropVectorCmd) {
370  // Convert string to physics vector
371  // string format is property name, then pairs of energy, value
373  std::istringstream instring(newValue);
374  G4String prop;
375  instring >> prop;
376  while (instring) {
377  G4String tmp;
378  instring >> tmp;
379  if (tmp == "") { break; }
381  instring >> tmp;
382  G4double val;
383  val = G4UIcommand::ConvertToDouble(tmp);
384  mpv->InsertValues(en, val);
385  }
386  const char* c = prop.c_str();
387  fDetector->AddWorldMPV(c, mpv);
388  }
389  else if (command == fSurfaceMatPropVectorCmd) {
390  // Convert string to physics vector
391  // string format is property name, then pairs of energy, value
392  // space delimited
394  G4cout << newValue << G4endl;
395  std::istringstream instring(newValue);
396  G4String prop;
397  instring >> prop;
398  while (instring) {
399  G4String tmp;
400  instring >> tmp;
401  if (tmp == "") { break; }
403  instring >> tmp;
404  G4double val;
405  val = G4UIcommand::ConvertToDouble(tmp);
406  mpv->InsertValues(en, val);
407  }
408  const char* c = prop.c_str();
409  fDetector->AddSurfaceMPV(c, mpv);
410  }
411 
412  else if (command == fTankMatPropConstCmd) {
413  // Convert string to physics vector
414  // string format is property name, then value
415  // space delimited
416  std::istringstream instring(newValue);
417  G4String prop;
418  G4String tmp;
419  instring >> prop;
420  instring >> tmp;
422  const char* c = prop.c_str();
423  fDetector->AddTankMPC(c, val);
424  }
425  else if (command == fWorldMatPropConstCmd) {
426  // Convert string to physics vector
427  // string format is property name, then value
428  // space delimited
429  std::istringstream instring(newValue);
430  G4String prop;
431  G4String tmp;
432  instring >> prop;
433  instring >> tmp;
435  const char* c = prop.c_str();
436  fDetector->AddTankMPC(c, val);
437  }
438  else if (command == fSurfaceMatPropConstCmd) {
439  // Convert string to physics vector
440  // string format is property name, then value
441  // space delimited
442  std::istringstream instring(newValue);
443  G4String prop;
444  G4String tmp;
445  instring >> prop;
446  instring >> tmp;
448  const char* c = prop.c_str();
449  fDetector->AddSurfaceMPC(c, val);
450  }
451  else if (command == fWorldMaterialCmd) {
452  fDetector->SetWorldMaterial(newValue);
453  }
454  else if (command == fTankMaterialCmd) {
455  fDetector->SetTankMaterial(newValue);
456  }
457 }
458 
459 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......