Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
TGeoOpticalSurface.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Andrei Gheata 05/12/18
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 
13 /** \class TGeoMedium
14 \ingroup Geometry_classes
15 
16 This is a wrapper class to G4OpticalSurface
17 */
18 
19 #include "TGeoOpticalSurface.h"
20 
21 #include <string>
22 
23 #include "TGeoManager.h"
24 #include "TGeoVolume.h"
25 #include "TGeoNode.h"
26 #include "TGDMLMatrix.h"
27 
28 ClassImp(TGeoOpticalSurface)
29 ClassImp(TGeoSkinSurface)
30 ClassImp(TGeoBorderSurface)
31 
32 //_____________________________________________________________________________
33 TGeoOpticalSurface::TGeoOpticalSurface(const char *name, ESurfaceModel model, ESurfaceFinish finish,
34  ESurfaceType type, Double_t value)
35  : TNamed(name, ""), fType(type), fModel(model), fFinish(finish), fValue(value)
36 {
37  // Constructor
38  fProperties.SetOwner();
39  if (model == kMglisur) {
40  fPolish = value;
41  fSigmaAlpha = 0.0;
42  } else if (model == kMunified || model == kMLUT || model == kMdichroic || model == kMDAVIS) {
43  fSigmaAlpha = value;
44  fPolish = 0.0;
45  } else {
46  Fatal("TGeoOpticalSurface::TGeoOpticalSurface()", "Constructor called with INVALID model.");
47  }
48 }
49 
50 //_____________________________________________________________________________
51 TGeoOpticalSurface::ESurfaceType TGeoOpticalSurface::StringToType(const char *name)
52 {
53  // Convert string to optical surface type
54  ESurfaceType type;
55  TString stype(name);
56  if ((stype == "dielectric_metal") || (stype == "0")) {
57  type = kTdielectric_metal;
58  } else if ((stype == "dielectric_dielectric") || (stype == "1")) {
59  type = kTdielectric_dielectric;
60  } else if ((stype == "dielectric_LUT") || (stype == "2")) {
61  type = kTdielectric_LUT;
62  } else if ((stype == "dielectric_dichroic") || (stype == "3")) {
63  type = kTdielectric_dichroic;
64  } else if ((stype == "firsov") || (stype == "4")) {
65  type = kTfirsov;
66  } else {
67  type = kTx_ray;
68  }
69  return type;
70 }
71 
72 //_____________________________________________________________________________
73 const char *TGeoOpticalSurface::TypeToString(ESurfaceType type)
74 {
75  // Convert surface type to string
76  switch (type) {
77  case kTdielectric_metal: return "dielectric_metal";
78  case kTdielectric_dielectric: return "dielectric_dielectric";
79  case kTdielectric_LUT: return "dielectric_LUT";
80  case kTdielectric_dichroic: return "dielectric_dichroic";
81  case kTfirsov: return "firsov";
82  case kTx_ray: return "x_ray";
83  case kTdielectric_LUTDAVIS:;
84  }
85 
86  return "unhandled surface type";
87 }
88 
89 //_____________________________________________________________________________
90 TGeoOpticalSurface::ESurfaceModel TGeoOpticalSurface::StringToModel(const char *name)
91 {
92 
93  // Convert string to optical surface type
94  TString smodel(name);
95  ESurfaceModel model;
96  if ((smodel == "glisur") || (smodel == "0")) {
97  model = kMglisur;
98  } else if ((smodel == "unified") || (smodel == "1")) {
99  model = kMunified;
100  } else if ((smodel == "LUT") || (smodel == "2")) {
101  model = kMLUT;
102  } else {
103  model = kMdichroic;
104  }
105  return model;
106 }
107 
108 //_____________________________________________________________________________
109 const char *TGeoOpticalSurface::ModelToString(ESurfaceModel model)
110 {
111  // Convert optical surface model to string
112  switch (model) {
113  case kMglisur: return "glisur";
114  case kMunified: return "unified";
115  case kMLUT: return "LUT";
116  case kMdichroic: return "dichoic";
117  case kMDAVIS:;
118  }
119 
120  return "unhandled model type";
121 }
122 
123 //_____________________________________________________________________________
124 TGeoOpticalSurface::ESurfaceFinish TGeoOpticalSurface::StringToFinish(const char *name)
125 {
126  // Convert surface finish to string
127  TString sfinish(name);
128  ESurfaceFinish finish;
129  if ((sfinish == "polished") || (sfinish == "0")) {
130  finish = kFpolished;
131  } else if ((sfinish == "polishedfrontpainted") || (sfinish == "1")) {
132  finish = kFpolishedfrontpainted;
133  } else if ((sfinish == "polishedbackpainted") || (sfinish == "2")) {
134  finish = kFpolishedbackpainted;
135  } else if ((sfinish == "ground") || (sfinish == "3")) {
136  finish = kFground;
137  } else if ((sfinish == "groundfrontpainted") || (sfinish == "4")) {
138  finish = kFgroundfrontpainted;
139  } else if ((sfinish == "groundbackpainted") || (sfinish == "5")) {
140  finish = kFgroundbackpainted;
141  } else if ((sfinish == "polishedlumirrorair") || (sfinish == "6")) {
142  finish = kFpolishedlumirrorair;
143  } else if ((sfinish == "polishedlumirrorglue") || (sfinish == "7")) {
144  finish = kFpolishedlumirrorglue;
145  } else if ((sfinish == "polishedair") || (sfinish == "8")) {
146  finish = kFpolishedair;
147  } else if ((sfinish == "polishedteflonair") || (sfinish == "9")) {
148  finish = kFpolishedteflonair;
149  } else if ((sfinish == "polishedtioair") || (sfinish == "10")) {
150  finish = kFpolishedtioair;
151  } else if ((sfinish == "polishedtyvekair") || (sfinish == "11")) {
152  finish = kFpolishedtyvekair;
153  } else if ((sfinish == "polishedvm2000air") || (sfinish == "12")) {
154  finish = kFpolishedvm2000air;
155  } else if ((sfinish == "polishedvm2000glue") || (sfinish == "13")) {
156  finish = kFpolishedvm2000glue;
157  } else if ((sfinish == "etchedlumirrorair") || (sfinish == "14")) {
158  finish = kFetchedlumirrorair;
159  } else if ((sfinish == "etchedlumirrorglue") || (sfinish == "15")) {
160  finish = kFetchedlumirrorglue;
161  } else if ((sfinish == "etchedair") || (sfinish == "16")) {
162  finish = kFetchedair;
163  } else if ((sfinish == "etchedteflonair") || (sfinish == "17")) {
164  finish = kFetchedteflonair;
165  } else if ((sfinish == "etchedtioair") || (sfinish == "18")) {
166  finish = kFetchedtioair;
167  } else if ((sfinish == "etchedtyvekair") || (sfinish == "19")) {
168  finish = kFetchedtyvekair;
169  } else if ((sfinish == "etchedvm2000air") || (sfinish == "20")) {
170  finish = kFetchedvm2000air;
171  } else if ((sfinish == "etchedvm2000glue") || (sfinish == "21")) {
172  finish = kFetchedvm2000glue;
173  } else if ((sfinish == "groundlumirrorair") || (sfinish == "22")) {
174  finish = kFgroundlumirrorair;
175  } else if ((sfinish == "groundlumirrorglue") || (sfinish == "23")) {
176  finish = kFgroundlumirrorglue;
177  } else if ((sfinish == "groundair") || (sfinish == "24")) {
178  finish = kFgroundair;
179  } else if ((sfinish == "groundteflonair") || (sfinish == "25")) {
180  finish = kFgroundteflonair;
181  } else if ((sfinish == "groundtioair") || (sfinish == "26")) {
182  finish = kFgroundtioair;
183  } else if ((sfinish == "groundtyvekair") || (sfinish == "27")) {
184  finish = kFgroundtyvekair;
185  } else if ((sfinish == "groundvm2000air") || (sfinish == "28")) {
186  finish = kFgroundvm2000air;
187  } else {
188  finish = kFgroundvm2000glue;
189  }
190 
191  return finish;
192 }
193 
194 //_____________________________________________________________________________
195 const char *TGeoOpticalSurface::FinishToString(ESurfaceFinish finish)
196 {
197  switch (finish) {
198  case kFpolished: return "polished";
199  case kFpolishedfrontpainted: return "polishedfrontpainted";
200  case kFpolishedbackpainted: return "polishedbackpainted";
201 
202  case kFground: return "ground";
203  case kFgroundfrontpainted: return "groundfrontpainted";
204  case kFgroundbackpainted: return "groundbackpainted";
205 
206  case kFpolishedlumirrorair: return "polishedlumirrorair";
207  case kFpolishedlumirrorglue: return "polishedlumirrorglue";
208  case kFpolishedair: return "polishedair";
209  case kFpolishedteflonair: return "polishedteflonair";
210  case kFpolishedtioair: return "polishedtioair";
211  case kFpolishedtyvekair: return "polishedtyvekair";
212  case kFpolishedvm2000air: return "polishedvm2000air";
213  case kFpolishedvm2000glue: return "polishedvm2000glue";
214 
215  case kFetchedlumirrorair: return "etchedlumirrorair";
216  case kFetchedlumirrorglue: return "etchedlumirrorglue";
217  case kFetchedair: return "etchedair";
218  case kFetchedteflonair: return "etchedteflonair";
219  case kFetchedtioair: return "etchedtioair";
220  case kFetchedtyvekair: return "etchedtyvekair";
221  case kFetchedvm2000air: return "etchedvm2000air";
222  case kFetchedvm2000glue: return "etchedvm2000glue";
223 
224  case kFgroundlumirrorair: return "groundlumirrorair";
225  case kFgroundlumirrorglue: return "groundlumirrorglue";
226  case kFgroundair: return "groundair";
227  case kFgroundteflonair: return "groundteflonair";
228  case kFgroundtioair: return "groundtioair";
229  case kFgroundtyvekair: return "groundtyvekair";
230  case kFgroundvm2000air: return "groundvm2000air";
231  case kFgroundvm2000glue: return "groundvm2000glue";
232  case kFRough_LUT:
233  case kFRoughTeflon_LUT:
234  case kFRoughESR_LUT:
235  case kFRoughESRGrease_LUT:
236  case kFPolished_LUT:
237  case kFPolishedTeflon_LUT:
238  case kFPolishedESR_LUT:
239  case kFPolishedESRGrease_LUT:
240  case kFDetector_LUT:;
241  }
242 
243  return "unhandled model finish";
244 }
245 
246 //_____________________________________________________________________________
247 const char *TGeoOpticalSurface::GetPropertyRef(const char *property)
248 {
249  // Find reference for a given property
250  TNamed *prop = (TNamed *)fProperties.FindObject(property);
251  return (prop) ? prop->GetTitle() : nullptr;
252 }
253 
254 //_____________________________________________________________________________
255 TGDMLMatrix *TGeoOpticalSurface::GetProperty(const char *property) const
256 {
257  // Find reference for a given property
258  TNamed *prop = (TNamed*)fProperties.FindObject(property);
259  if ( !prop ) return nullptr;
260  return gGeoManager->GetGDMLMatrix(prop->GetTitle());
261 }
262 
263 //_____________________________________________________________________________
264 TGDMLMatrix *TGeoOpticalSurface::GetProperty(Int_t i) const
265 {
266  // Find reference for a given property
267  TNamed *prop = (TNamed*)fProperties.At(i);
268  if ( !prop ) return nullptr;
269  return gGeoManager->GetGDMLMatrix(prop->GetTitle());
270 }
271 
272 //_____________________________________________________________________________
273 bool TGeoOpticalSurface::AddProperty(const char *property, const char *ref)
274 {
275  fProperties.SetOwner();
276  if (GetPropertyRef(property)) {
277  Error("AddProperty", "Property %s already added to optical surface %s", property, GetName());
278  return false;
279  }
280  fProperties.Add(new TNamed(property, ref));
281  return true;
282 }
283 
284 //_____________________________________________________________________________
285 void TGeoOpticalSurface::Print(Option_t *) const
286 {
287  // Print info about this optical surface
288  printf("*** opticalsurface: %s type: %s model: %s finish: %s value = %g\n", GetName(),
289  TGeoOpticalSurface::TypeToString(fType), TGeoOpticalSurface::ModelToString(fModel),
290  TGeoOpticalSurface::FinishToString(fFinish), fValue);
291  if (fProperties.GetSize()) {
292  TIter next(&fProperties);
293  TNamed *property;
294  while ((property = (TNamed *)next()))
295  printf(" property: %s ref: %s\n", property->GetName(), property->GetTitle());
296  }
297 }
298 
299 //_____________________________________________________________________________
300 void TGeoSkinSurface::Print(Option_t *) const
301 {
302  // Print info about this optical surface
303  if (!fVolume) {
304  Error("Print", "Skin surface %s: volume not set", GetName());
305  return;
306  }
307  printf("*** skinsurface: %s surfaceproperty: %s volumeref: %s \n", GetName(), GetTitle(), fVolume->GetName());
308 }
309 
310 //_____________________________________________________________________________
311 void TGeoBorderSurface::Print(Option_t *) const
312 {
313  // Print info about this optical surface
314  if (!fNode1 || !fNode2) {
315  Error("Print", "Border surface %s: nodes not set", GetName());
316  return;
317  }
318  printf("*** bordersurface: %s surfaceproperty: %s physvolref: %s %s \n", GetName(), GetTitle(),
319  fNode1->GetName(), fNode2->GetName());
320 }