Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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/** \class TGeoOpticalSurface
13\ingroup Geometry_classes
14
15This is a wrapper class to G4OpticalSurface
16*/
17
18#include "TGeoOpticalSurface.h"
19
20#include <string>
21
22#include "TGeoManager.h"
23#include "TGeoVolume.h"
24#include "TGeoNode.h"
25#include "TGDMLMatrix.h"
26
28
29//_____________________________________________________________________________
32 : TNamed(name, ""), fType(type), fModel(model), fFinish(finish), fValue(value)
33{
34 // Constructor
36 if (model == kMglisur) {
37 fPolish = value;
38 fSigmaAlpha = 0.0;
39 } else if (model == kMunified || model == kMLUT || model == kMdichroic || model == kMDAVIS) {
41 fPolish = 0.0;
42 } else {
43 Fatal("TGeoOpticalSurface::TGeoOpticalSurface()", "Constructor called with INVALID model.");
44 }
45}
46
47//_____________________________________________________________________________
49{
50 // Convert string to optical surface type
52 TString stype(name);
53 if ((stype == "dielectric_metal") || (stype == "0")) {
55 } else if ((stype == "dielectric_dielectric") || (stype == "1")) {
57 } else if ((stype == "dielectric_LUT") || (stype == "2")) {
59 } else if ((stype == "dielectric_dichroic") || (stype == "3")) {
61 } else if ((stype == "firsov") || (stype == "4")) {
62 type = kTfirsov;
63 } else {
64 type = kTx_ray;
65 }
66 return type;
67}
68
69//_____________________________________________________________________________
71{
72 // Convert surface type to string
73 switch (type) {
74 case kTdielectric_metal: return "dielectric_metal";
75 case kTdielectric_dielectric: return "dielectric_dielectric";
76 case kTdielectric_LUT: return "dielectric_LUT";
77 case kTdielectric_dichroic: return "dielectric_dichroic";
78 case kTfirsov: return "firsov";
79 case kTx_ray: return "x_ray";
81 }
82
83 return "unhandled surface type";
84}
85
86//_____________________________________________________________________________
88{
89
90 // Convert string to optical surface type
91 TString smodel(name);
92 ESurfaceModel model;
93 if ((smodel == "glisur") || (smodel == "0")) {
94 model = kMglisur;
95 } else if ((smodel == "unified") || (smodel == "1")) {
96 model = kMunified;
97 } else if ((smodel == "LUT") || (smodel == "2")) {
98 model = kMLUT;
99 } else {
100 model = kMdichroic;
101 }
102 return model;
103}
104
105//_____________________________________________________________________________
107{
108 // Convert optical surface model to string
109 switch (model) {
110 case kMglisur: return "glisur";
111 case kMunified: return "unified";
112 case kMLUT: return "LUT";
113 case kMdichroic: return "dichoic";
114 case kMDAVIS:;
115 }
116
117 return "unhandled model type";
118}
119
120//_____________________________________________________________________________
122{
123 // Convert surface finish to string
124 TString sfinish(name);
125 ESurfaceFinish finish;
126 if ((sfinish == "polished") || (sfinish == "0")) {
127 finish = kFpolished;
128 } else if ((sfinish == "polishedfrontpainted") || (sfinish == "1")) {
129 finish = kFpolishedfrontpainted;
130 } else if ((sfinish == "polishedbackpainted") || (sfinish == "2")) {
131 finish = kFpolishedbackpainted;
132 } else if ((sfinish == "ground") || (sfinish == "3")) {
133 finish = kFground;
134 } else if ((sfinish == "groundfrontpainted") || (sfinish == "4")) {
135 finish = kFgroundfrontpainted;
136 } else if ((sfinish == "groundbackpainted") || (sfinish == "5")) {
137 finish = kFgroundbackpainted;
138 } else if ((sfinish == "polishedlumirrorair") || (sfinish == "6")) {
139 finish = kFpolishedlumirrorair;
140 } else if ((sfinish == "polishedlumirrorglue") || (sfinish == "7")) {
141 finish = kFpolishedlumirrorglue;
142 } else if ((sfinish == "polishedair") || (sfinish == "8")) {
143 finish = kFpolishedair;
144 } else if ((sfinish == "polishedteflonair") || (sfinish == "9")) {
145 finish = kFpolishedteflonair;
146 } else if ((sfinish == "polishedtioair") || (sfinish == "10")) {
147 finish = kFpolishedtioair;
148 } else if ((sfinish == "polishedtyvekair") || (sfinish == "11")) {
149 finish = kFpolishedtyvekair;
150 } else if ((sfinish == "polishedvm2000air") || (sfinish == "12")) {
151 finish = kFpolishedvm2000air;
152 } else if ((sfinish == "polishedvm2000glue") || (sfinish == "13")) {
153 finish = kFpolishedvm2000glue;
154 } else if ((sfinish == "etchedlumirrorair") || (sfinish == "14")) {
155 finish = kFetchedlumirrorair;
156 } else if ((sfinish == "etchedlumirrorglue") || (sfinish == "15")) {
157 finish = kFetchedlumirrorglue;
158 } else if ((sfinish == "etchedair") || (sfinish == "16")) {
159 finish = kFetchedair;
160 } else if ((sfinish == "etchedteflonair") || (sfinish == "17")) {
161 finish = kFetchedteflonair;
162 } else if ((sfinish == "etchedtioair") || (sfinish == "18")) {
163 finish = kFetchedtioair;
164 } else if ((sfinish == "etchedtyvekair") || (sfinish == "19")) {
165 finish = kFetchedtyvekair;
166 } else if ((sfinish == "etchedvm2000air") || (sfinish == "20")) {
167 finish = kFetchedvm2000air;
168 } else if ((sfinish == "etchedvm2000glue") || (sfinish == "21")) {
169 finish = kFetchedvm2000glue;
170 } else if ((sfinish == "groundlumirrorair") || (sfinish == "22")) {
171 finish = kFgroundlumirrorair;
172 } else if ((sfinish == "groundlumirrorglue") || (sfinish == "23")) {
173 finish = kFgroundlumirrorglue;
174 } else if ((sfinish == "groundair") || (sfinish == "24")) {
175 finish = kFgroundair;
176 } else if ((sfinish == "groundteflonair") || (sfinish == "25")) {
177 finish = kFgroundteflonair;
178 } else if ((sfinish == "groundtioair") || (sfinish == "26")) {
179 finish = kFgroundtioair;
180 } else if ((sfinish == "groundtyvekair") || (sfinish == "27")) {
181 finish = kFgroundtyvekair;
182 } else if ((sfinish == "groundvm2000air") || (sfinish == "28")) {
183 finish = kFgroundvm2000air;
184 } else {
185 finish = kFgroundvm2000glue;
186 }
187
188 return finish;
189}
190
191//_____________________________________________________________________________
193{
194 switch (finish) {
195 case kFpolished: return "polished";
196 case kFpolishedfrontpainted: return "polishedfrontpainted";
197 case kFpolishedbackpainted: return "polishedbackpainted";
198
199 case kFground: return "ground";
200 case kFgroundfrontpainted: return "groundfrontpainted";
201 case kFgroundbackpainted: return "groundbackpainted";
202
203 case kFpolishedlumirrorair: return "polishedlumirrorair";
204 case kFpolishedlumirrorglue: return "polishedlumirrorglue";
205 case kFpolishedair: return "polishedair";
206 case kFpolishedteflonair: return "polishedteflonair";
207 case kFpolishedtioair: return "polishedtioair";
208 case kFpolishedtyvekair: return "polishedtyvekair";
209 case kFpolishedvm2000air: return "polishedvm2000air";
210 case kFpolishedvm2000glue: return "polishedvm2000glue";
211
212 case kFetchedlumirrorair: return "etchedlumirrorair";
213 case kFetchedlumirrorglue: return "etchedlumirrorglue";
214 case kFetchedair: return "etchedair";
215 case kFetchedteflonair: return "etchedteflonair";
216 case kFetchedtioair: return "etchedtioair";
217 case kFetchedtyvekair: return "etchedtyvekair";
218 case kFetchedvm2000air: return "etchedvm2000air";
219 case kFetchedvm2000glue: return "etchedvm2000glue";
220
221 case kFgroundlumirrorair: return "groundlumirrorair";
222 case kFgroundlumirrorglue: return "groundlumirrorglue";
223 case kFgroundair: return "groundair";
224 case kFgroundteflonair: return "groundteflonair";
225 case kFgroundtioair: return "groundtioair";
226 case kFgroundtyvekair: return "groundtyvekair";
227 case kFgroundvm2000air: return "groundvm2000air";
228 case kFgroundvm2000glue: return "groundvm2000glue";
229 case kFRough_LUT:
231 case kFRoughESR_LUT:
233 case kFPolished_LUT:
237 case kFDetector_LUT:;
238 }
239
240 return "unhandled model finish";
241}
242
243//_____________________________________________________________________________
245{
246 // Find reference for a given property
248 return (prop) ? prop->GetTitle() : nullptr;
249}
250
251//_____________________________________________________________________________
253{
254 // Find reference for a given property
256 if (!prop)
257 return nullptr;
258 return gGeoManager->GetGDMLMatrix(prop->GetTitle());
259}
260
261//_____________________________________________________________________________
263{
264 // Find reference for a given property
266 if (!prop)
267 return nullptr;
268 return gGeoManager->GetGDMLMatrix(prop->GetTitle());
269}
270
271//_____________________________________________________________________________
273{
274 // Find reference for a given constant property
276 return (prop) ? prop->GetTitle() : nullptr;
277}
278
279//_____________________________________________________________________________
281{
282 // Find reference for a given constant property
284 if (!prop) {
285 if (err)
286 *err = kTRUE;
287 return 0.;
288 }
289 return gGeoManager->GetProperty(prop->GetTitle(), err);
290}
291
292//_____________________________________________________________________________
294{
295 // Find reference for a given constant property
297 if (!prop) {
298 if (err)
299 *err = kTRUE;
300 return 0.;
301 }
302 return gGeoManager->GetProperty(prop->GetTitle(), err);
303}
304
305//_____________________________________________________________________________
306bool TGeoOpticalSurface::AddProperty(const char *property, const char *ref)
307{
310 Error("AddProperty", "Property %s already added to optical surface %s", property, GetName());
311 return false;
312 }
313 fProperties.Add(new TNamed(property, ref));
314 return true;
315}
316
317//_____________________________________________________________________________
318bool TGeoOpticalSurface::AddConstProperty(const char *property, const char *ref)
319{
322 Error("AddConstProperty", "Constant property %s already added to material %s", property, GetName());
323 return false;
324 }
326 return true;
327}
328
329//_____________________________________________________________________________
331{
332 // Print info about this optical surface
333 printf("*** opticalsurface: %s type: %s model: %s finish: %s value = %g\n", GetName(),
336 if (fProperties.GetSize()) {
337 TIter next(&fProperties);
339 while ((property = (TNamed *)next()))
340 printf(" property: %s ref: %s\n", property->GetName(), property->GetTitle());
341 }
343 TIter next(&fConstProperties);
345 Bool_t err;
346 while ((property = (TNamed *)next())) {
347 Double_t value = this->GetConstProperty(property->GetName(), &err);
348 printf(" constant: %s ref: %s value: %g\n",
349 property->GetName(), property->GetTitle(), value);
350 }
351 }
352}
353
355
356//_____________________________________________________________________________
358{
359 // Print info about this optical surface
360 if (!fVolume) {
361 Error("Print", "Skin surface %s: volume not set", GetName());
362 return;
363 }
364 printf("*** skinsurface: %s surfaceproperty: %s volumeref: %s \n", GetName(), GetTitle(), fVolume->GetName());
365}
366
368
369//_____________________________________________________________________________
371{
372 // Print info about this optical surface
373 if (!fNode1 || !fNode2) {
374 Error("Print", "Border surface %s: nodes not set", GetName());
375 return;
376 }
377 printf("*** bordersurface: %s surfaceproperty: %s physvolref: %s %s \n", GetName(), GetTitle(),
379}
constexpr Bool_t kTRUE
Definition RtypesCore.h:93
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h prop
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t property
char name[80]
Definition TGX11.cxx:110
R__EXTERN TGeoManager * gGeoManager
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.
This class is used in the process of reading and writing the GDML "matrix" tag.
Definition TGDMLMatrix.h:33
TGeoNode const * fNode2
TGeoNode const * fNode1
void Print(Option_t *option="") const override
This method must be overridden when a class wants to print itself.
Double_t GetProperty(const char *name, Bool_t *error=nullptr) const
Get a user-defined property.
TGDMLMatrix * GetGDMLMatrix(const char *name) const
Get GDML matrix with a given name;.
This is a wrapper class to G4OpticalSurface.
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)
const char * GetConstPropertyRef(const char *property) const
static ESurfaceFinish StringToFinish(const char *finish)
TGDMLMatrix * GetProperty(const char *name) const
static const char * FinishToString(ESurfaceFinish finish)
void Print(Option_t *option="") const override
This method must be overridden when a class wants to print itself.
bool AddConstProperty(const char *property, const char *ref)
Double_t GetConstProperty(const char *property, Bool_t *error=nullptr) const
static ESurfaceModel StringToModel(const char *model)
const char * GetPropertyRef(const char *property)
TGeoVolume const * fVolume
void Print(Option_t *option="") const override
This method must be overridden when a class wants to print itself.
TObject * FindObject(const char *name) const override
Find an object in this list using its name.
Definition TList.cxx:576
void Add(TObject *obj) override
Definition TList.h:83
TObject * At(Int_t idx) const override
Returns the object at position idx. Returns 0 if idx is out of range.
Definition TList.cxx:355
The TNamed class is the base class for all named ROOT classes.
Definition TNamed.h:29
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
TNamed()
Definition TNamed.h:36
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
Definition TObject.cxx:993
virtual void Fatal(const char *method, const char *msgfmt,...) const
Issue fatal error message.
Definition TObject.cxx:1021
Basic string class.
Definition TString.h:139