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
16This 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//_____________________________________________________________________________
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);
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//_____________________________________________________________________________
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:
234 case kFRoughESR_LUT:
236 case kFPolished_LUT:
240 case kFDetector_LUT:;
241 }
242
243 return "unhandled model finish";
244}
245
246//_____________________________________________________________________________
247const 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//_____________________________________________________________________________
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//_____________________________________________________________________________
273bool 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(),
320}
PyObject * fValue
PyObject * fType
int Int_t
Definition: RtypesCore.h:41
double Double_t
Definition: RtypesCore.h:55
const char Option_t
Definition: RtypesCore.h:62
#define ClassImp(name)
Definition: Rtypes.h:365
void Fatal(const char *location, const char *msgfmt,...)
char name[80]
Definition: TGX11.cxx:109
int type
Definition: TGX11.cxx:120
R__EXTERN TGeoManager * gGeoManager
Definition: TGeoManager.h:601
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
This class is used in the process of reading and writing the GDML "matrix" tag.
Definition: TGDMLMatrix.h:34
TGeoNode const * fNode2
TGeoNode const * fNode1
void Print(Option_t *option="") const
Print TNamed name and title.
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
static ESurfaceType StringToType(const char *type)
bool AddProperty(const char *property, const char *ref)
static const char * ModelToString(ESurfaceModel model)
static const char * TypeToString(ESurfaceType type)
static ESurfaceFinish StringToFinish(const char *finish)
TGDMLMatrix * GetProperty(const char *name) const
static const char * FinishToString(ESurfaceFinish finish)
void Print(Option_t *option="") const
Print TNamed name and title.
static ESurfaceModel StringToModel(const char *model)
ESurfaceFinish fFinish
const char * GetPropertyRef(const char *property)
TGeoVolume const * fVolume
void Print(Option_t *option="") const
Print TNamed name and title.
virtual void Add(TObject *obj)
Definition: TList.h:87
virtual TObject * FindObject(const char *name) const
Find an object in this list using its name.
Definition: TList.cxx:575
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:354
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
TNamed()
Definition: TNamed.h:36
virtual const char * GetTitle() const
Returns title of object.
Definition: TNamed.h:48
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition: TObject.cxx:880
Basic string class.
Definition: TString.h:131