geom_alice_its.C

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: geom_alice_its.C 32880 2010-04-02 20:11:22Z matevz $
00002 // Author: Matevz Tadel
00003 
00004 // Shows geometry of ALICE ITS.
00005 
00006 #include "TEveManager.h"
00007 #include "TEveGeoNode.h"
00008 
00009 #include "TGeoManager.h"
00010 #include "TGeoNode.h"
00011 #include "TGeoVolume.h"
00012 #include "TGeoMedium.h"
00013 
00014 #include "TString.h"
00015 
00016 void geom_alice_its()
00017 {
00018    TEveManager::Create();
00019 
00020    gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
00021 
00022    TGeoNode* node = gGeoManager->GetTopVolume()->FindNode("ITSV_1");
00023    TEveGeoTopNode* its = new TEveGeoTopNode(gGeoManager, node);
00024    gEve->AddGlobalElement(its);
00025 
00026    gEve->Redraw3D(kTRUE);
00027 }
00028 
00029 
00030 //==============================================================================
00031 // Demonstrate extraction of volumes matching certain criteria.
00032 //==============================================================================
00033 
00034 // Should be run in compiled mode -- CINT has issues with recursion.
00035 //
00036 // 1. Creation:
00037 //    root
00038 //      .L geom_alice_its.C+
00039 //      extract_ssd_modules()
00040 //      .q
00041 //    This creates file "test-extract.root" in current dir.
00042 //
00043 // 2. Viewing:
00044 //    root
00045 //      .x show_extract.C("test-extract.root")
00046 
00047 TEveGeoNode* descend_extract(TGeoNode* node)
00048 {
00049    // We only return something if:
00050    // - this is a node of interest;
00051    // - one of the daughters returns something of interest.
00052 
00053    const TString material("ITS_SI$");
00054 
00055    TEveGeoNode *res = 0;
00056 
00057    TGeoMedium *medium = node->GetVolume()->GetMedium();
00058    if (medium && material == medium->GetName())
00059    {
00060       // Node of interest - instantiate eve representation and return.
00061       res = new TEveGeoNode(node);
00062       return res;
00063    }
00064 
00065    Int_t nd = node->GetNdaughters();
00066    for (Int_t i = 0; i < nd; ++i)
00067    {
00068       TEveGeoNode *ed = descend_extract(node->GetDaughter(i));
00069 
00070       if (ed)
00071       {
00072          if (res == 0) res = new TEveGeoNode(node);
00073          res->AddElement(ed);
00074       }
00075    }
00076 
00077    return res;
00078 }
00079 
00080 void extract_ssd_modules()
00081 {
00082    const TString kEH("extract_ssd_modules");
00083 
00084    TEveManager::Create();
00085 
00086    gGeoManager = gEve->GetGeometry("http://root.cern.ch/files/alice.root");
00087 
00088    Bool_t s = gGeoManager->cd("/ITSV_1/ITSD_1/IT56_1");
00089    if (!s) {
00090       Error(kEH, "Start node not found.");
00091       return;
00092    }
00093 
00094    TGeoNode *node = gGeoManager->GetCurrentNode();
00095 
00096    TEveGeoNode *egn = descend_extract(node);
00097 
00098    if (egn == 0)
00099    {
00100       Warning(kEH, "No matching nodes found.");
00101       return;
00102    }
00103 
00104    egn->SaveExtract("test-extract.root", "AliSDD", kTRUE);
00105 }

Generated on Tue Jul 5 15:43:50 2011 for ROOT_528-00b_version by  doxygen 1.5.1