projection_prescale.C

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: quad_test.C 25245 2008-08-25 21:44:09Z matevz $
00002 // Author: Matevz Tadel
00003 
00004 // Demonstates usage pre-scaling for automatic 2D projections.
00005 
00006 const char* esd_geom_file_name =
00007    "http://root.cern.ch/files/alice_ESDgeometry.root";
00008 
00009 void projection_prescale()
00010 {
00011    TFile::SetCacheFileDir(".");
00012    TEveManager::Create();
00013 
00014    TEveViewer *pev = gEve->SpawnNewViewer("Projections");
00015 
00016    // camera
00017    TEveScene* s = gEve->SpawnNewScene("Projected Geom");
00018    pev->AddScene(s);
00019 
00020    TGLViewer* pgv = pev->GetGLViewer();
00021    pgv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
00022    TGLOrthoCamera* cam = (TGLOrthoCamera*) pgv->CurrentCamera();
00023    cam->SetZoomMinMax(0.2, 20);
00024 
00025    // projections
00026    TEveProjectionManager* mng = new TEveProjectionManager();
00027    {
00028       mng->SetProjection(TEveProjection::kPT_RPhi);
00029       TEveProjection* p = mng->GetProjection();
00030       p->AddPreScaleEntry(0, 0,   4);    // r scale 4 from 0
00031       p->AddPreScaleEntry(0, 45,  1);    // r scale 1 from 45
00032       p->AddPreScaleEntry(0, 310, 0.5);
00033       p->SetUsePreScale(kTRUE);
00034    }
00035    {
00036       mng->SetProjection(TEveProjection::kPT_RhoZ);
00037       TEveProjection* p = mng->GetProjection();
00038       // Increase silicon tracker
00039       p->AddPreScaleEntry(0, 0, 4);     // rho scale 4 from 0
00040       p->AddPreScaleEntry(1, 0, 4);     // z   scale 4 from 0
00041       // Normal for TPC
00042       p->AddPreScaleEntry(0, 45,  1);   // rho scale 1 from 45
00043       p->AddPreScaleEntry(1, 110, 1);   // z   scale 1 from 110
00044       // Reduce the rest
00045       p->AddPreScaleEntry(0, 310, 0.5);
00046       p->AddPreScaleEntry(1, 250, 0.5);
00047       p->SetUsePreScale(kTRUE);
00048    }
00049    mng->SetProjection(TEveProjection::kPT_RPhi);
00050    s->AddElement(mng);
00051 
00052    TEveProjectionAxes* axes = new TEveProjectionAxes(mng);
00053    s->AddElement(axes);
00054    gEve->AddToListTree(axes, kTRUE);
00055    gEve->AddToListTree(mng, kTRUE);
00056 
00057    // Simple geometry
00058    TFile* geom = TFile::Open(esd_geom_file_name, "CACHEREAD");
00059    if (!geom)
00060       return;
00061 
00062    TEveGeoShapeExtract* gse = (TEveGeoShapeExtract*) geom->Get("Gentle");
00063    TEveGeoShape* gsre = TEveGeoShape::ImportShapeExtract(gse, 0);
00064    geom->Close();
00065    delete geom;
00066    gEve->AddGlobalElement(gsre);
00067    mng->ImportElements(gsre);
00068 
00069    TEveLine* line = new TEveLine;
00070    line->SetMainColor(kGreen);
00071    for (Int_t i=0; i<160; ++i)
00072       line->SetNextPoint(120*sin(0.2*i), 120*cos(0.2*i), 80-i);
00073    gEve->AddElement(line);
00074    mng->ImportElements(line);
00075    line->SetRnrSelf(kFALSE);
00076 
00077 
00078    //-------------------------------------------------------------------------
00079    // Scaled 3D "projection"
00080    //-------------------------------------------------------------------------
00081 
00082    TEveViewer *sev = gEve->SpawnNewViewer("Scaled 3D");
00083    TEveProjectionManager* smng =
00084       new TEveProjectionManager(TEveProjection::kPT_3D);
00085    TEveProjection* sp = smng->GetProjection();
00086    sp->SetUsePreScale(kTRUE);
00087    sp->AddPreScaleEntry(2,   0,  1);
00088    sp->AddPreScaleEntry(2, 100,  0.2);
00089 
00090    TEveScene* ss = gEve->SpawnNewScene("Scaled Geom");
00091    sev->AddScene(ss);
00092    ss->AddElement(smng);
00093 
00094    smng->ImportElements(gsre);
00095 
00096    //-------------------------------------------------------------------------
00097 
00098    gEve->GetBrowser()->GetTabRight()->SetTab(1);
00099 
00100    gEve->Redraw3D(kTRUE);
00101 }

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