Logo ROOT  
Reference Guide
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 
31 
32 //_____________________________________________________________________________
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 //_____________________________________________________________________________
52 {
53  // Convert string to optical surface type
55  TString stype(name);
56  if ((stype == "dielectric_metal") || (stype == "0")) {
58  } else if ((stype == "dielectric_dielectric") || (stype == "1")) {
60  } else if ((stype == "dielectric_LUT") || (stype == "2")) {
62  } else if ((stype == "dielectric_dichroic") || (stype == "3")) {
64  } else if ((stype == "firsov") || (stype == "4")) {
65  type = kTfirsov;
66  } else {
67  type = kTx_ray;
68  }
69  return type;
70 }
71 
72 //_____________________________________________________________________________
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";
84  }
85 
86  return "unhandled surface type";
87 }
88 
89 //_____________________________________________________________________________
91 {
92 
93  // Convert string to optical surface type
94  TString smodel(name);
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 //_____________________________________________________________________________
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 //_____________________________________________________________________________
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 //_____________________________________________________________________________
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:
236  case kFPolished_LUT:
238  case kFPolishedESR_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 //_____________________________________________________________________________
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 {
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 //_____________________________________________________________________________
286 {
287  // Print info about this optical surface
288  printf("*** opticalsurface: %s type: %s model: %s finish: %s value = %g\n", GetName(),
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 //_____________________________________________________________________________
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 //_____________________________________________________________________________
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 }
TGeoOpticalSurface::kFpolishedfrontpainted
@ kFpolishedfrontpainted
Definition: TGeoOpticalSurface.h:31
TGeoOpticalSurface::kFPolishedESR_LUT
@ kFPolishedESR_LUT
Definition: TGeoOpticalSurface.h:72
TGeoSkinSurface::fVolume
TGeoVolume const * fVolume
Definition: TGeoOpticalSurface.h:165
TGeoOpticalSurface::kFetchedvm2000glue
@ kFetchedvm2000glue
Definition: TGeoOpticalSurface.h:54
TGeoOpticalSurface::kFpolishedbackpainted
@ kFpolishedbackpainted
Definition: TGeoOpticalSurface.h:32
TGeoOpticalSurface::kMunified
@ kMunified
Definition: TGeoOpticalSurface.h:79
TGeoOpticalSurface::GetPropertyRef
const char * GetPropertyRef(const char *property)
Definition: TGeoOpticalSurface.cxx:247
TGeoOpticalSurface::kFgroundvm2000air
@ kFgroundvm2000air
Definition: TGeoOpticalSurface.h:62
Option_t
const char Option_t
Definition: RtypesCore.h:66
TGeoOpticalSurface::kFetchedlumirrorglue
@ kFetchedlumirrorglue
Definition: TGeoOpticalSurface.h:48
TGeoOpticalSurface::kTdielectric_LUTDAVIS
@ kTdielectric_LUTDAVIS
Definition: TGeoOpticalSurface.h:89
TGeoOpticalSurface::kFpolishedlumirrorair
@ kFpolishedlumirrorair
Definition: TGeoOpticalSurface.h:38
TGeoBorderSurface::Print
void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TGeoOpticalSurface.cxx:311
gGeoManager
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:602
TList::FindObject
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:578
TGeoOpticalSurface::StringToFinish
static ESurfaceFinish StringToFinish(const char *finish)
Definition: TGeoOpticalSurface.cxx:124
TGeoOpticalSurface::kFRoughTeflon_LUT
@ kFRoughTeflon_LUT
Definition: TGeoOpticalSurface.h:67
TGeoOpticalSurface::kFgroundtioair
@ kFgroundtioair
Definition: TGeoOpticalSurface.h:60
ClassImp
#define ClassImp(name)
Definition: Rtypes.h:364
TNamed::GetTitle
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
TGeoOpticalSurface::kFgroundlumirrorair
@ kFgroundlumirrorair
Definition: TGeoOpticalSurface.h:56
TGeoOpticalSurface::kFetchedteflonair
@ kFetchedteflonair
Definition: TGeoOpticalSurface.h:50
TGeoOpticalSurface::kFpolishedtyvekair
@ kFpolishedtyvekair
Definition: TGeoOpticalSurface.h:43
TObject::Error
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:893
TCollection::SetOwner
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
Definition: TCollection.cxx:746
TGeoVolume.h
TGeoOpticalSurface::kFpolishedvm2000glue
@ kFpolishedvm2000glue
Definition: TGeoOpticalSurface.h:45
TGeoOpticalSurface::GetProperty
TGDMLMatrix * GetProperty(const char *name) const
Definition: TGeoOpticalSurface.cxx:255
TGeoOpticalSurface::ESurfaceFinish
ESurfaceFinish
Definition: TGeoOpticalSurface.h:29
TGeoOpticalSurface::kTdielectric_metal
@ kTdielectric_metal
Definition: TGeoOpticalSurface.h:86
TGeoOpticalSurface::ESurfaceType
ESurfaceType
Definition: TGeoOpticalSurface.h:85
TGeoOpticalSurface::Print
void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TGeoOpticalSurface.cxx:285
TGeoOpticalSurface::kMglisur
@ kMglisur
Definition: TGeoOpticalSurface.h:78
TString
Basic string class.
Definition: TString.h:136
TGeoOpticalSurface::fModel
ESurfaceModel fModel
Definition: TGeoOpticalSurface.h:98
TGeoOpticalSurface::kFground
@ kFground
Definition: TGeoOpticalSurface.h:34
TGeoOpticalSurface::kFPolishedESRGrease_LUT
@ kFPolishedESRGrease_LUT
Definition: TGeoOpticalSurface.h:73
TGeoOpticalSurface::kFgroundbackpainted
@ kFgroundbackpainted
Definition: TGeoOpticalSurface.h:36
TGeoSkinSurface::Print
void Print(Option_t *option="") const
Print TNamed name and title.
Definition: TGeoOpticalSurface.cxx:300
TGeoBorderSurface::fNode2
TGeoNode const * fNode2
Definition: TGeoOpticalSurface.h:195
TGeoOpticalSurface::AddProperty
bool AddProperty(const char *property, const char *ref)
Definition: TGeoOpticalSurface.cxx:273
TList::At
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:357
TGeoOpticalSurface::kFDetector_LUT
@ kFDetector_LUT
Definition: TGeoOpticalSurface.h:74
TGeoOpticalSurface::fFinish
ESurfaceFinish fFinish
Definition: TGeoOpticalSurface.h:99
TGeoOpticalSurface::kTdielectric_dichroic
@ kTdielectric_dichroic
Definition: TGeoOpticalSurface.h:90
TGeoOpticalSurface::ModelToString
static const char * ModelToString(ESurfaceModel model)
Definition: TGeoOpticalSurface.cxx:109
TGeoOpticalSurface::kFRough_LUT
@ kFRough_LUT
Definition: TGeoOpticalSurface.h:66
TGeoOpticalSurface.h
TGeoOpticalSurface::kFpolishedteflonair
@ kFpolishedteflonair
Definition: TGeoOpticalSurface.h:41
TGeoOpticalSurface::kFPolished_LUT
@ kFPolished_LUT
Definition: TGeoOpticalSurface.h:70
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TGeoOpticalSurface::fType
ESurfaceType fType
Definition: TGeoOpticalSurface.h:97
Fatal
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
Definition: TError.cxx:245
TGeoOpticalSurface::kFpolishedvm2000air
@ kFpolishedvm2000air
Definition: TGeoOpticalSurface.h:44
TNamed::TNamed
TNamed()
Definition: TNamed.h:36
TGeoOpticalSurface::kMdichroic
@ kMdichroic
Definition: TGeoOpticalSurface.h:82
TGeoOpticalSurface::kFgroundlumirrorglue
@ kFgroundlumirrorglue
Definition: TGeoOpticalSurface.h:57
TGeoOpticalSurface::kFgroundair
@ kFgroundair
Definition: TGeoOpticalSurface.h:58
TGeoOpticalSurface::kTfirsov
@ kTfirsov
Definition: TGeoOpticalSurface.h:91
TGeoOpticalSurface::kFpolishedtioair
@ kFpolishedtioair
Definition: TGeoOpticalSurface.h:42
TGeoOpticalSurface::kFpolishedlumirrorglue
@ kFpolishedlumirrorglue
Definition: TGeoOpticalSurface.h:39
TGeoOpticalSurface::StringToType
static ESurfaceType StringToType(const char *type)
Definition: TGeoOpticalSurface.cxx:51
TGeoOpticalSurface::kFgroundtyvekair
@ kFgroundtyvekair
Definition: TGeoOpticalSurface.h:61
TGeoOpticalSurface::kTdielectric_LUT
@ kTdielectric_LUT
Definition: TGeoOpticalSurface.h:88
TGDMLMatrix
This class is used in the process of reading and writing the GDML "matrix" tag.
Definition: TGDMLMatrix.h:34
TGeoOpticalSurface::kFetchedlumirrorair
@ kFetchedlumirrorair
Definition: TGeoOpticalSurface.h:47
TGeoOpticalSurface::kMDAVIS
@ kMDAVIS
Definition: TGeoOpticalSurface.h:81
TGeoManager.h
TGeoOpticalSurface::kMLUT
@ kMLUT
Definition: TGeoOpticalSurface.h:80
Double_t
double Double_t
Definition: RtypesCore.h:59
TGeoBorderSurface
Definition: TGeoOpticalSurface.h:191
TGeoOpticalSurface::kFgroundvm2000glue
@ kFgroundvm2000glue
Definition: TGeoOpticalSurface.h:63
TGeoOpticalSurface::kFRoughESR_LUT
@ kFRoughESR_LUT
Definition: TGeoOpticalSurface.h:68
TGeoOpticalSurface::StringToModel
static ESurfaceModel StringToModel(const char *model)
Definition: TGeoOpticalSurface.cxx:90
TCollection::GetSize
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TGeoOpticalSurface::kFRoughESRGrease_LUT
@ kFRoughESRGrease_LUT
Definition: TGeoOpticalSurface.h:69
TList::Add
virtual void Add(TObject *obj)
Definition: TList.h:87
TGeoOpticalSurface::kFetchedvm2000air
@ kFetchedvm2000air
Definition: TGeoOpticalSurface.h:53
TGeoOpticalSurface::kFetchedtioair
@ kFetchedtioair
Definition: TGeoOpticalSurface.h:51
name
char name[80]
Definition: TGX11.cxx:110
TGeoOpticalSurface::kFpolishedair
@ kFpolishedair
Definition: TGeoOpticalSurface.h:40
TGeoOpticalSurface::kFgroundteflonair
@ kFgroundteflonair
Definition: TGeoOpticalSurface.h:59
TIter
Definition: TCollection.h:233
make_cnn_model.model
model
Definition: make_cnn_model.py:6
TGeoOpticalSurface::kTdielectric_dielectric
@ kTdielectric_dielectric
Definition: TGeoOpticalSurface.h:87
TGDMLMatrix.h
TNamed::GetName
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
TGeoOpticalSurface::TypeToString
static const char * TypeToString(ESurfaceType type)
Definition: TGeoOpticalSurface.cxx:73
type
int type
Definition: TGX11.cxx:121
TGeoOpticalSurface::kFetchedair
@ kFetchedair
Definition: TGeoOpticalSurface.h:49
TGeoOpticalSurface::fProperties
TList fProperties
Definition: TGeoOpticalSurface.h:105
TGeoOpticalSurface
Definition: TGeoOpticalSurface.h:27
TGeoOpticalSurface::kFPolishedTeflon_LUT
@ kFPolishedTeflon_LUT
Definition: TGeoOpticalSurface.h:71
TGeoNode.h
TGeoOpticalSurface::ESurfaceModel
ESurfaceModel
Definition: TGeoOpticalSurface.h:77
TGeoOpticalSurface::FinishToString
static const char * FinishToString(ESurfaceFinish finish)
Definition: TGeoOpticalSurface.cxx:195
TGeoOpticalSurface::kFetchedtyvekair
@ kFetchedtyvekair
Definition: TGeoOpticalSurface.h:52
TGeoOpticalSurface::kTx_ray
@ kTx_ray
Definition: TGeoOpticalSurface.h:92
TGeoManager::GetGDMLMatrix
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
Definition: TGeoManager.cxx:1829
TGeoBorderSurface::fNode1
TGeoNode const * fNode1
Definition: TGeoOpticalSurface.h:194
TGeoOpticalSurface::kFgroundfrontpainted
@ kFgroundfrontpainted
Definition: TGeoOpticalSurface.h:35
int
TGeoSkinSurface
Definition: TGeoOpticalSurface.h:162
TGeoOpticalSurface::kFpolished
@ kFpolished
Definition: TGeoOpticalSurface.h:30
TGeoOpticalSurface::fValue
Double_t fValue
Definition: TGeoOpticalSurface.h:101