Merge from EVE-dev to HEAD.
[u/mrichter/AliRoot.git] / EVE / alice-macros / tpc_digits.C
1 // $Id$
2
3 #include "TGLViewer.h"
4
5 namespace Alieve {
6 class TPCData;
7 class Event;
8 }
9
10 Alieve::TPCData* g_tpc_data = 0;
11 Alieve::Event*   g_tpc_last_event = 0;
12
13 void tpc_digits(Int_t mode=0)
14 {
15   if (g_tpc_data == 0 || g_tpc_last_event != Alieve::gEvent) {
16     AliRunLoader* rl =  Alieve::Event::AssertRunLoader();
17     rl->LoadDigits("TPC");
18     TTree* dt = rl->GetTreeD("TPC", false);
19
20     g_tpc_data = new Alieve::TPCData;
21     g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
22
23     g_tpc_last_event = Alieve::gEvent;
24   }
25
26   // Viewport limits.
27   /*
28   Float_t left, right, top, bottom;
29   right  = di->fOut2Seg.fNMaxPads* di->fOut2Seg.fPadWidth;
30   left   = -right;
31   bottom = di->fInnSeg.fRlow;
32   top    = bottom + di->fOut2Seg.fRlow +
33     di->fOut2Seg.fNRows*di->fOut2Seg.fPadLength - di->fInnSeg.fRlow;
34   */
35
36   gStyle->SetPalette(1, 0);
37   Color_t col = 36;
38
39   switch(mode) {
40
41   case 0: { // Display a single sector
42     Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
43     s->SetFrameColor(col);
44     s->SetDataSource(g_tpc_data);
45     gReve->AddRenderElement(s);
46     gReve->DrawRenderElement(s);
47
48     TGLViewer* cam = dynamic_cast<TGLViewer*>(gReve->GetCC()->GetViewer3D());
49     //cam->SetCurrentCamera(TGLViewer::kCameraOrthoXOY) ;
50     //cam->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, 2*left, 2*right, 2*top, bottom); 
51     //printf("%f %f %f %f\n", left, right, top, bottom);
52
53     break;
54   }
55
56   case 1: { // Display all sectors
57     gReve->DisableRedraw();
58     {
59       Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 1");
60       l->SetTitle("TPC Plate");
61       l->SetMainColor(Color_t(col));
62       TGListTreeItem *ti = gReve->AddRenderElement(l);
63       
64       for(Int_t i = 0; i<18; i++) {
65         Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
66         s->SetSectorID(i);
67         s->SetDataSource(g_tpc_data);
68         s->SetFrameColor(col);
69         s->SetTrans(true);
70         l->AddElement(s);
71         gReve->AddRenderElement(ti, s);
72       }
73       gReve->DrawRenderElement(l);
74     }
75     {
76       Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 2");
77       l->SetTitle("TPC Plate");
78       l->SetMainColor(Color_t(col));
79
80       TGListTreeItem *ti = gReve->AddRenderElement(l);
81       for(Int_t i = 18; i<36; i++) {
82         Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
83         s->SetSectorID(i);
84         s->SetDataSource(g_tpc_data);
85         s->SetFrameColor(col);
86         s->SetTrans(true);
87         l->AddElement(s);
88         gReve->AddRenderElement(ti, s);
89       }
90       gReve->DrawRenderElement(l);
91     }
92     gReve->EnableRedraw();
93
94     break;
95   }
96
97   case 2 : { // Display a single sector in 3D
98     Alieve::TPCSector3D* s = new Alieve::TPCSector3D();
99     s->SetFrameColor(col);
100     s->SetDataSource(g_tpc_data);
101     gReve->AddRenderElement(s);
102     gReve->DrawRenderElement(s);
103     break;
104   }
105
106   } // switch
107 }