Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
testoptical.C File Reference

Detailed Description

Tests importing/exporting optical surfaces from GDML.

Optical surfaces, skin surfaces and border surfaces are imported in object arrays stored by TGeoManager class. Optical surfaces do not store property arrays but point to GDML matrices describing such properties. One can get the data for such property like:

TGeoOpticalSurface *surf = geom->GetOpticalSurface("surf1");
const char *property = surf=>GetPropertyRef("REFLECTIVITY");
TGeoGDMLMatrix *m = geom->GetGDMLMatrix(property);
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
This is a wrapper class to G4OpticalSurface.
TMarker m
Definition textangle.C:8

Skin surfaces and border surfaces can be retrieved from the TGeoManager object by using:

TObjArray *skin_array = geom->GetListOfSkinSurfaces();
TObjArra8 *border_array = geom->GetListOfBorderSurfaces();
An array of TObjects.
Definition TObjArray.h:31

Alternatively accessors by name can also be used: GetSkinSurface(name)/GetBorderSurface(name)

#include <cassert>
#include <TObjArray.h>
#include <TROOT.h>
#include <TGeoManager.h>
double Checksum(TGeoManager *geom)
{
double sum = 0.;
TIter next(geom->GetListOfOpticalSurfaces());
while ((surf = (TGeoOpticalSurface *)next())) {
sum += (double)surf->GetType() + (double)surf->GetModel() + (double)surf->GetFinish() + surf->GetValue();
TString name = surf->GetName();
sum += (double)name.Hash();
name = surf->GetTitle();
sum += (double)name.Hash();
}
return sum;
}
{
TString geofile = gROOT->GetTutorialDir() + "/visualisation/geom/gdml/opticalsurfaces.gdml";
geofile.ReplaceAll("\\", "/");
printf("=== Importing %s ...\n", geofile.Data());
printf("=== List of GDML matrices:\n");
geom->GetListOfGDMLMatrices()->Print();
printf("=== List of optical surfaces:\n");
geom->GetListOfOpticalSurfaces()->Print();
printf("=== List of skin surfaces:\n");
geom->GetListOfSkinSurfaces()->Print();
printf("=== List of border surfaces:\n");
geom->GetListOfBorderSurfaces()->Print();
// Compute some checksum for optical surfaces
double checksum1 = Checksum(geom);
printf("=== Exporting as .gdml, then importing back\n");
geom->Export("tmp.gdml");
geom = TGeoManager::Import("tmp.gdml");
double checksum2 = Checksum(geom);
assert((checksum2 == checksum1) && "Exporting/importing as .gdml not OK");
printf("=== Exporting as .root, then importing back\n");
geom->Export("tmp.root");
geom = TGeoManager::Import("tmp.root");
double checksum3 = Checksum(geom);
assert((checksum3 == checksum1) && "Exporting/importing as .root not OK");
printf("all OK\n");
return 0;
}
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:148
#define gROOT
Definition TROOT.h:417
The manager class for any TGeo geometry.
Definition TGeoManager.h:46
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).
Basic string class.
Definition TString.h:138
static uint64_t sum(uint64_t i)
Definition Factory.cxx:2335
Author
Andrei Gheata

Definition in file testoptical.C.