Changes accompanying migration to usage of ZTrans in TPCSectorViz.
[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->Redraw3D();
47
48     TGLViewer* cam = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->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       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->SetAutoTrans(kTRUE);
70         gReve->AddRenderElement(l, s);
71       }
72     }
73     {
74       Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 2");
75       l->SetTitle("TPC Plate");
76       l->SetMainColor(Color_t(col));
77
78       gReve->AddRenderElement(l);
79       for(Int_t i = 18; i<36; i++) {
80         Alieve::TPCSector2D* s = new Alieve::TPCSector2D();
81         s->SetSectorID(i);
82         s->SetDataSource(g_tpc_data);
83         s->SetFrameColor(col);
84         s->SetAutoTrans(kTRUE);
85         gReve->AddRenderElement(l, s);
86       }
87     }
88     gReve->EnableRedraw();
89
90     break;
91   }
92
93   case 2 : { // Display a single sector in 3D
94     Alieve::TPCSector3D* s = new Alieve::TPCSector3D();
95     s->SetFrameColor(col);
96     s->SetDataSource(g_tpc_data);
97     gReve->AddRenderElement(s);
98     gReve->Redraw3D();
99     break;
100   }
101
102   case 3: { // Display all sectors in 3D
103     gReve->DisableRedraw();
104     {
105       Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 1");
106       l->SetTitle("TPC Plate");
107       l->SetMainColor(Color_t(col));
108       gReve->AddRenderElement(l);
109       
110       for(Int_t i = 0; i<18; i++) {
111         Alieve::TPCSector3D* s = new Alieve::TPCSector3D();
112         s->SetSectorID(i);
113         s->SetDataSource(g_tpc_data);
114         s->SetFrameColor(col);
115         s->SetAutoTrans(kTRUE);
116         gReve->AddRenderElement(l, s);
117       }
118     }
119     {
120       Reve::RenderElementList* l = new Reve::RenderElementList("TPC plate 2");
121       l->SetTitle("TPC Plate");
122       l->SetMainColor(Color_t(col));
123
124       gReve->AddRenderElement(l);
125       for(Int_t i = 18; i<36; i++) {
126         Alieve::TPCSector3D* s = new Alieve::TPCSector3D();
127         s->SetSectorID(i);
128         s->SetDataSource(g_tpc_data);
129         s->SetFrameColor(col);
130         s->SetAutoTrans(kTRUE);
131         gReve->AddRenderElement(l, s);
132       }
133     }
134     gReve->EnableRedraw();
135
136     break;
137   }
138
139   } // switch
140 }