]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EVE/alice-macros/tpc_digits.C
From Mario: minor change according to the new ID volumes (now go from 0 to 59).
[u/mrichter/AliRoot.git] / EVE / alice-macros / tpc_digits.C
index 90214d6a89ba2a7af9da29f3315be48bfa7f95e3..a2666314cd34489159ac2d28b596457a8663ab56 100644 (file)
@@ -1,37 +1,25 @@
 // $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
 
-#include "TGLViewer.h"
-
-namespace Alieve {
-class TPCData;
-class Event;
-}
-
-Alieve::TPCData* g_tpc_data = 0;
-Alieve::Event*   g_tpc_last_event = 0;
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
 
 void tpc_digits(Int_t mode=1)
 {
-  if (g_tpc_data == 0 || g_tpc_last_event != Alieve::gEvent) {
-    AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
-    rl->LoadDigits("TPC");
-    TTree* dt = rl->GetTreeD("TPC", false);
-
-    g_tpc_data = new Alieve::TPCData;
-    g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
-
-    g_tpc_last_event = Alieve::gEvent;
+  AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
+  rl->LoadDigits("TPC");
+  TTree* dt = rl->GetTreeD("TPC", false);
+  if (dt == 0)
+  {
+    throw TEveException("tpc_digits Can not access digits tree.");
   }
 
-  // Viewport limits.
-  /*
-  Float_t left, right, top, bottom;
-  right  = di->fOut2Seg.fNMaxPads* di->fOut2Seg.fPadWidth;
-  left   = -right;
-  bottom = di->fInnSeg.fRlow;
-  top    = bottom + di->fOut2Seg.fRlow +
-    di->fOut2Seg.fNRows*di->fOut2Seg.fPadLength - di->fInnSeg.fRlow;
-  */
+  AliEveTPCData *x = new AliEveTPCData;
+
+  x->LoadDigits(dt, kTRUE); // Create all present sectors.
 
   gStyle->SetPalette(1, 0);
   Color_t col = 36;
@@ -39,99 +27,103 @@ void tpc_digits(Int_t mode=1)
   switch(mode) {
 
   case 0: { // Display a single sector
-    Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
+    AliEveTPCSector2D* s = new AliEveTPCSector2D();
     s->SetFrameColor(col);
-    s->SetDataSource(g_tpc_data);
-    gReve->AddRenderElement(s);
-    gReve->Redraw3D();
+    s->SetDataSource(x);
+    gEve->AddElement(s);
+    gEve->Redraw3D();
 
-    //TGLViewer* cam = gReve->GetGLViewer();
+    //TGLViewer* cam = gEve->GetDefaultGLViewer();
     //cam->SetCurrentCamera(TGLViewer::kCameraOrthoXOY) ;
-    //cam->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, 2*left, 2*right, 2*top, bottom); 
+    //cam->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, 2*left, 2*right, 2*top, bottom);
     //printf("%f %f %f %f\n", left, right, top, bottom);
 
     break;
   }
 
   case 1: { // Display all sectors
-    gReve->DisableRedraw();
+    gEve->DisableRedraw();
     {
-      Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 1");
+      TEveElementList* l = new TEveElementList("TPC plate 1");
       l->SetTitle("TPC Plate");
-      l->SetMainColor(Color_t(col));
-      gReve->AddRenderElement(l);
-      
-      for(Int_t i = 0; i<18; i++) {
-       Alieve::TPCSector2D* s = new Alieve::TPCSector2D(Form("TPCSector2D %d", i));
+      l->SetMainColor(col);
+      gEve->AddElement(l);
+
+      for (Int_t i = 0; i<18; i++)
+      {
+       AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("AliEveTPCSector2D %d", i));
        s->SetSectorID(i);
-       s->SetDataSource(g_tpc_data);
+       s->SetDataSource(x);
        s->SetFrameColor(col);
        s->SetAutoTrans(kTRUE);
-       gReve->AddRenderElement(s, l);
+       l->AddElement(s);
       }
     }
     {
-      Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 2");
+      TEveElementList* l = new TEveElementList("TPC plate 2");
       l->SetTitle("TPC Plate");
-      l->SetMainColor(Color_t(col));
+      l->SetMainColor(col);
 
-      gReve->AddRenderElement(l);
-      for(Int_t i = 18; i<36; i++) {
-       Alieve::TPCSector2D* s = new Alieve::TPCSector2D(Form("TPCSector2D %d", i));
+      gEve->AddElement(l);
+      for (Int_t i = 18; i<36; i++)
+      {
+       AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("AliEveTPCSector2D %d", i));
        s->SetSectorID(i);
-       s->SetDataSource(g_tpc_data);
+       s->SetDataSource(x);
        s->SetFrameColor(col);
        s->SetAutoTrans(kTRUE);
-       gReve->AddRenderElement(s, l);
+       l->AddElement(s);
       }
     }
-    gReve->EnableRedraw();
+    gEve->EnableRedraw();
 
     break;
   }
 
   case 2 : { // Display a single sector in 3D
-    Alieve::TPCSector3D* s = new Alieve::TPCSector3D();
+    AliEveTPCSector3D* s = new AliEveTPCSector3D();
     s->SetFrameColor(col);
-    s->SetDataSource(g_tpc_data);
-    gReve->AddRenderElement(s);
-    gReve->Redraw3D();
+    s->SetDataSource(x);
+    gEve->AddElement(s);
+    gEve->Redraw3D();
     break;
   }
 
   case 3: { // Display all sectors in 3D
-    gReve->DisableRedraw();
+    gEve->DisableRedraw();
     {
-      Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 1");
+      TEveElementList* l = new TEveElementList("TPC plate 1");
       l->SetTitle("TPC Plate");
-      l->SetMainColor(Color_t(col));
-      gReve->AddRenderElement(l);
-      
-      for(Int_t i = 0; i<18; i++) {
-       Alieve::TPCSector3D* s = new Alieve::TPCSector3D(Form("TPCSector3D %d", i));
+      l->SetMainColor(col);
+      gEve->AddElement(l);
+
+      for (Int_t i = 0; i<18; i++)
+      {
+       AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("AliEveTPCSector3D %d", i));
        s->SetSectorID(i);
-       s->SetDataSource(g_tpc_data);
+       s->SetDataSource(x);
        s->SetFrameColor(col);
        s->SetAutoTrans(kTRUE);
-       gReve->AddRenderElement(s, l);
+       l->AddElement(s);
       }
     }
     {
-      Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 2");
+      TEveElementList* l = new TEveElementList("TPC plate 2");
       l->SetTitle("TPC Plate");
-      l->SetMainColor(Color_t(col));
+      l->SetMainColor(col);
 
-      gReve->AddRenderElement(l);
-      for(Int_t i = 18; i<36; i++) {
-       Alieve::TPCSector3D* s = new Alieve::TPCSector3D(Form("TPCSector3D %d", i));
+      gEve->AddElement(l);
+      for (Int_t i = 18; i<36; i++)
+      {
+       AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("AliEveTPCSector3D %d", i));
        s->SetSectorID(i);
-       s->SetDataSource(g_tpc_data);
+       s->SetDataSource(x);
        s->SetFrameColor(col);
        s->SetAutoTrans(kTRUE);
-       gReve->AddRenderElement(s, l);
+       l->AddElement(s);
       }
     }
-    gReve->EnableRedraw();
+    gEve->EnableRedraw();
 
     break;
   }
@@ -145,34 +137,36 @@ void tpc_digits_2drange(Int_t start, Int_t end)
   if (start <  0)  start = 0;
   if (end   > 35)  end   = 35;
 
-  if (g_tpc_data == 0 || g_tpc_last_event != Alieve::gEvent) {
-    AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
-    rl->LoadDigits("TPC");
-    TTree* dt = rl->GetTreeD("TPC", false);
+  AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
+  rl->LoadDigits("TPC");
+  TTree* dt = rl->GetTreeD("TPC", false);
+  if (dt == 0)
+  {
+    throw TEveException("tpc_digits Can not access digits tree.");
+  }
 
-    g_tpc_data = new Alieve::TPCData;
-    g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
+  AliEveTPCData *x = new AliEveTPCData;
 
-    g_tpc_last_event = Alieve::gEvent;
-  }
+  x->LoadDigits(dt, kTRUE); // Create all present sectors.
 
   gStyle->SetPalette(1, 0);
   Color_t col = 36;
 
-  gReve->DisableRedraw();
+  gEve->DisableRedraw();
   {
-    Reve::RenderElementList* l = new Reve::RenderElementList("TPC sectors");
-    l->SetMainColor(Color_t(col));
-    gReve->AddRenderElement(l);
-      
-    for(Int_t i=start; i<=end; i++) {
-      Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
+    TEveElementList* l = new TEveElementList("TPC sectors");
+    l->SetMainColor(col);
+    gEve->AddElement(l);
+
+    for (Int_t i=start; i<=end; i++)
+    {
+      AliEveTPCSector2D* s = new AliEveTPCSector2D();
       s->SetSectorID(i);
-      s->SetDataSource(g_tpc_data);
+      s->SetDataSource(x);
       s->SetFrameColor(col);
       s->SetAutoTrans(kTRUE);
-      gReve->AddRenderElement(s, l);
+      gEve->AddElement(s, l);
     }
   }
-  gReve->EnableRedraw();
+  gEve->EnableRedraw();
 }