Re: Problem drawing a geometry

From: Christian Holm Christensen <cholm_at_nbi.dk>
Date: Fri, 31 Mar 2006 16:21:23 +0200


Hi Rene et al,

On Fri, 2006-03-31 at 08:51 +0200, Rene Brun wrote:
> You are using the wrong classes to read the geometry.
> See an example below to draw the Alice geometry.
>
> Rene Brun
>
> {
> TGeoManager::Import("alice.root");

What's actually stored in the file `alice.geom' attached to Jochens mail, is _not_ a `TGeoManager' object, but a `TGeometry' object:

        root [0] TFile* f = TFile::Open("alice.geom")
        root [1] f->ls()
        TFile**         alice.geom
         TFile*         alice.geom
          KEY: TGeometry        AliceGeom;1     Galice Geometry for Hits
        root [2] TGeoManager::Import("alice.geom")
        Info: TGeoManager::Import : Reading geometry from file
        (class TGeoManager*)0x0
        

Perhaps what you want is something like

        void
        SetAtt(TNode* n)
        {
          std::cout << "Processing " << n->GetName() << std::endl;
          Color_t c = (n->GetName()[0] == 'L' ? 2 : 4);
          n->SetLineColor(c);
          n->SetFillColor(c);
          n->SetFillStyle(3001);
          n->SetVisibility(kTRUE);
          TList* l = n->GetListOfNodes();
          TIter next(l);
          TNode* nn = 0;
          while ((nn = static_cast<TNode*>(next()))) SetAtt(nn);
        }
          
        void
        geom()
        {
          TCanvas* c = new TCanvas("C", "C");
          c->SetFillColor(1);
        
          TFile*     f  = TFile::Open("alice.geom");
          TGeometry* g  = static_cast<TGeometry*>(f->Get("AliceGeom"));
          TList*     l  = g->GetListOfNodes();
          TNode*     nn = 0;
          TIter      next(l);
          while ((nn = static_cast<TNode*>(next()))) SetAtt(nn);
          g->Draw();
          g->ls();
        }
        

Yours,

-- 
 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:   cholm_at_nbi.dk               Web:    www.nbi.dk/~cholm
 | |
Received on Fri Mar 31 2006 - 16:21:24 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:31:58 MET