]> 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 a6f1599eaacd6913d76c5a598f50a06365453e78..a2666314cd34489159ac2d28b596457a8663ab56 100644 (file)
@@ -1,37 +1,25 @@
 // $Id$
+// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
 
-#include "TGLViewer.h"
+/**************************************************************************
+ * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
+ * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
+ * full copyright notice.                                                 *
+ **************************************************************************/
 
-namespace Alieve {
-class TPCData;
-class Event;
-}
-
-Alieve::TPCData* g_tpc_data = 0;
-Alieve::Event*   g_tpc_last_event = 0;
-
-void tpc_digits(Int_t mode=0)
+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,102 +27,146 @@ void tpc_digits(Int_t mode=0)
   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 = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D());
+    //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();
+      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(l, s);
+       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();
+      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(l, s);
+       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();
+      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(l, s);
+       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();
+      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(l, s);
+       l->AddElement(s);
       }
     }
-    gReve->EnableRedraw();
+    gEve->EnableRedraw();
 
     break;
   }
 
   } // switch
 }
+
+
+void tpc_digits_2drange(Int_t start, Int_t end)
+{
+  if (start <  0)  start = 0;
+  if (end   > 35)  end   = 35;
+
+  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.");
+  }
+
+  AliEveTPCData *x = new AliEveTPCData;
+
+  x->LoadDigits(dt, kTRUE); // Create all present sectors.
+
+  gStyle->SetPalette(1, 0);
+  Color_t col = 36;
+
+  gEve->DisableRedraw();
+  {
+    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(x);
+      s->SetFrameColor(col);
+      s->SetAutoTrans(kTRUE);
+      gEve->AddElement(s, l);
+    }
+  }
+  gEve->EnableRedraw();
+}