Saving an image of a TGeoManager geometry


I have a routine to draw a TGeoManager geometry object in the top pad of a canvas and an ordinary graph in the bottom pad. I want to save this canvas as a vector graphics file (i.e., PostScript or PDF) where the geometry object is rendered as a solid (that is, with colored, opaque surfaces, not just an arrangement of lines).

When I use the Raytrace() method to render the geometry object in solid form, the canvas will save correctly as a JPEG or other raster image. But when I try to save it as a PostScript or other vector image, the geometry object disappears from the saved file! (Everything else is still there.) I do not have this problem when I use Draw() instead of Raytrace(), but again, I’d like a solid form and not just the lines. I think maybe Raytrace() isn’t meant for what I’m trying to do, but I don’t know how else to make the geometry object appear as a solid. What can I do to get this canvas saved as a PostScript file that includes the geometry object rendered in solid form?

I’m running Root 5.12/00. To save the canvas, I’ve been using File->Save As… on the canvas’s dropdown menu. A simplified version of the code follows.


//Makes the canvas & pads
TCanvas *cmain = new TCanvas(“cmain”,“Sample Code”,0,0,250, 350);

//makes the geometry object on top
TGeoManager *manager = new TGeoManager(“Manager”,“Sample Manager”);
TGeoMaterial *mat = new TGeoMaterial(“generic”,0,0,0);
TGeoMedium *med = new TGeoMedium(“generic”,1,mat);
TGeoVolume *top = manager->MakeTube(“Top Volume”,med,0,1,1);

//Makes the graph below
TF1 f1(“func1”, “sin(x)”, 0, 10);

The postscript driver does not support the result of raytracing.
Instead of the ray tracing option, I recommend using the Gl viewer and save your picture with the GL canvas menu

file->saveas -> viewer.eps
To draw with Gl, simply replace

top->Raytrace(); by