Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
testoptical.C
Go to the documentation of this file.
1/// \file
2/// \ingroup tutorial_geom
3/// Tests importing/exporting optical surfaces from GDML
4///
5/// Optical surfaces, skin surfaces and border surfaces are imported in object arrays
6/// stored by TGeoManager class. Optical surfaces do not store property arrays but point
7/// to GDML matrices describing such properties. One can get the data for such property
8/// like:
9/// TGeoOpticalSurface *surf = geom->GetOpticalSurface("surf1");
10/// const char *property = surf=>GetPropertyRef("REFLECTIVITY");
11/// TGeoGDMLMatrix *m = geom->GetGDMLMatrix(property);
12/// Skin surfaces and border surfaces can be retrieved from the TGeoManager object by using:
13/// TObjArray *skin_array = geom->GetListOfSkinSurfaces();
14/// TObjArra8 *border_array = geom->GetListOfBorderSurfaces();
15/// Alternatively accessors by name can also be used: GetSkinSurface(name)/GetBorderSurface(name)
16///
17/// \author Andrei Gheata
18
19#include <cassert>
20#include <TObjArray.h>
21#include <TROOT.h>
22#include <TGeoOpticalSurface.h>
23#include <TGeoManager.h>
24
25double Checksum(TGeoManager *geom)
26{
27 double sum = 0.;
28 TIter next(geom->GetListOfOpticalSurfaces());
30 while ((surf = (TGeoOpticalSurface *)next())) {
31 sum += (double)surf->GetType() + (double)surf->GetModel() + (double)surf->GetFinish() + surf->GetValue();
32 TString name = surf->GetName();
33 sum += (double)name.Hash();
34 name = surf->GetTitle();
35 sum += (double)name.Hash();
36 }
37 return sum;
38}
39
40int testoptical()
41{
42 TString geofile = gROOT->GetTutorialDir() + "/visualisation/geom/gdml/opticalsurfaces.gdml";
43 geofile.ReplaceAll("\\", "/");
46 printf("=== Importing %s ...\n", geofile.Data());
48 printf("=== List of GDML matrices:\n");
49 geom->GetListOfGDMLMatrices()->Print();
50 printf("=== List of optical surfaces:\n");
51 geom->GetListOfOpticalSurfaces()->Print();
52 printf("=== List of skin surfaces:\n");
53 geom->GetListOfSkinSurfaces()->Print();
54 printf("=== List of border surfaces:\n");
55 geom->GetListOfBorderSurfaces()->Print();
56 // Compute some checksum for optical surfaces
57 double checksum1 = Checksum(geom);
58 printf("=== Exporting as .gdml, then importing back\n");
59 geom->Export("tmp.gdml");
60 geom = TGeoManager::Import("tmp.gdml");
61 double checksum2 = Checksum(geom);
62 assert((checksum2 == checksum1) && "Exporting/importing as .gdml not OK");
63 printf("=== Exporting as .root, then importing back\n");
64 geom->Export("tmp.root");
65 geom = TGeoManager::Import("tmp.root");
66 double checksum3 = Checksum(geom);
67 assert((checksum3 == checksum1) && "Exporting/importing as .root not OK");
68 printf("all OK\n");
69 return 0;
70}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
char name[80]
Definition TGX11.cxx:110
#define gROOT
Definition TROOT.h:406
The manager class for any TGeo geometry.
Definition TGeoManager.h:44
static void SetExportPrecision(UInt_t prec)
static TGeoManager * Import(const char *filename, const char *name="", Option_t *option="")
static function Import a geometry from a gdml or ROOT file
static void SetVerboseLevel(Int_t vl)
Return current verbosity level (static function).
This is a wrapper class to G4OpticalSurface.
Basic string class.
Definition TString.h:139
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2345