]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/tpc_digits.C
Put all classes in Alieve/ sub-module out of the Alieve namespace and
[u/mrichter/AliRoot.git] / EVE / alice-macros / tpc_digits.C
1 // $Id$
2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
3
4 /**************************************************************************
5  * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6  * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for          *
7  * full copyright notice.                                                 * 
8  **************************************************************************/
9
10 #include "TGLViewer.h"
11
12 namespace Alieve {
13 class AliEveTPCData;
14 class AliEveEventManager;
15 }
16
17 AliEveTPCData* g_tpc_data = 0;
18 AliEveEventManager*   g_tpc_last_event = 0;
19
20 void tpc_digits(Int_t mode=1)
21 {
22   if (g_tpc_data == 0 || g_tpc_last_event != gEvent) {
23     AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
24     rl->LoadDigits("TPC");
25     TTree* dt = rl->GetTreeD("TPC", false);
26
27     g_tpc_data = new AliEveTPCData;
28     g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
29
30     g_tpc_last_event = gEvent;
31   }
32
33   // Viewport limits.
34   /*
35   Float_t left, right, top, bottom;
36   right  = di->fOut2Seg.fNMaxPads* di->fOut2Seg.fPadWidth;
37   left   = -right;
38   bottom = di->fInnSeg.fRlow;
39   top    = bottom + di->fOut2Seg.fRlow +
40     di->fOut2Seg.fNRows*di->fOut2Seg.fPadLength - di->fInnSeg.fRlow;
41   */
42
43   gStyle->SetPalette(1, 0);
44   Color_t col = 36;
45
46   switch(mode) {
47
48   case 0: { // Display a single sector
49     AliEveTPCSector2D* s = new AliEveTPCSector2D();
50     s->SetFrameColor(col);
51     s->SetDataSource(g_tpc_data);
52     gEve->AddElement(s);
53     gEve->Redraw3D();
54
55     //TGLViewer* cam = gEve->GetGLViewer();
56     //cam->SetCurrentCamera(TGLViewer::kCameraOrthoXOY) ;
57     //cam->SetOrthoCamera(TGLViewer::kCameraOrthoXOY, 2*left, 2*right, 2*top, bottom); 
58     //printf("%f %f %f %f\n", left, right, top, bottom);
59
60     break;
61   }
62
63   case 1: { // Display all sectors
64     gEve->DisableRedraw();
65     {
66       TEveElementList* l = new TEveElementList("TPC plate 1");
67       l->SetTitle("TPC Plate");
68       l->SetMainColor(Color_t(col));
69       gEve->AddElement(l);
70       
71       for(Int_t i = 0; i<18; i++) {
72         AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("AliEveTPCSector2D %d", i));
73         s->SetSectorID(i);
74         s->SetDataSource(g_tpc_data);
75         s->SetFrameColor(col);
76         s->SetAutoTrans(kTRUE);
77         gEve->AddElement(s, l);
78       }
79     }
80     {
81       TEveElementList* l = new TEveElementList("TPC plate 2");
82       l->SetTitle("TPC Plate");
83       l->SetMainColor(Color_t(col));
84
85       gEve->AddElement(l);
86       for(Int_t i = 18; i<36; i++) {
87         AliEveTPCSector2D* s = new AliEveTPCSector2D(Form("AliEveTPCSector2D %d", i));
88         s->SetSectorID(i);
89         s->SetDataSource(g_tpc_data);
90         s->SetFrameColor(col);
91         s->SetAutoTrans(kTRUE);
92         gEve->AddElement(s, l);
93       }
94     }
95     gEve->EnableRedraw();
96
97     break;
98   }
99
100   case 2 : { // Display a single sector in 3D
101     AliEveTPCSector3D* s = new AliEveTPCSector3D();
102     s->SetFrameColor(col);
103     s->SetDataSource(g_tpc_data);
104     gEve->AddElement(s);
105     gEve->Redraw3D();
106     break;
107   }
108
109   case 3: { // Display all sectors in 3D
110     gEve->DisableRedraw();
111     {
112       TEveElementList* l = new TEveElementList("TPC plate 1");
113       l->SetTitle("TPC Plate");
114       l->SetMainColor(Color_t(col));
115       gEve->AddElement(l);
116       
117       for(Int_t i = 0; i<18; i++) {
118         AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("AliEveTPCSector3D %d", i));
119         s->SetSectorID(i);
120         s->SetDataSource(g_tpc_data);
121         s->SetFrameColor(col);
122         s->SetAutoTrans(kTRUE);
123         gEve->AddElement(s, l);
124       }
125     }
126     {
127       TEveElementList* l = new TEveElementList("TPC plate 2");
128       l->SetTitle("TPC Plate");
129       l->SetMainColor(Color_t(col));
130
131       gEve->AddElement(l);
132       for(Int_t i = 18; i<36; i++) {
133         AliEveTPCSector3D* s = new AliEveTPCSector3D(Form("AliEveTPCSector3D %d", i));
134         s->SetSectorID(i);
135         s->SetDataSource(g_tpc_data);
136         s->SetFrameColor(col);
137         s->SetAutoTrans(kTRUE);
138         gEve->AddElement(s, l);
139       }
140     }
141     gEve->EnableRedraw();
142
143     break;
144   }
145
146   } // switch
147 }
148
149
150 void tpc_digits_2drange(Int_t start, Int_t end)
151 {
152   if (start <  0)  start = 0;
153   if (end   > 35)  end   = 35;
154
155   if (g_tpc_data == 0 || g_tpc_last_event != gEvent) {
156     AliRunLoader* rl =  AliEveEventManager::AssertRunLoader();
157     rl->LoadDigits("TPC");
158     TTree* dt = rl->GetTreeD("TPC", false);
159
160     g_tpc_data = new AliEveTPCData;
161     g_tpc_data->LoadDigits(dt, kTRUE); // Create all present sectors.
162
163     g_tpc_last_event = gEvent;
164   }
165
166   gStyle->SetPalette(1, 0);
167   Color_t col = 36;
168
169   gEve->DisableRedraw();
170   {
171     TEveElementList* l = new TEveElementList("TPC sectors");
172     l->SetMainColor(Color_t(col));
173     gEve->AddElement(l);
174       
175     for(Int_t i=start; i<=end; i++) {
176       AliEveTPCSector2D* s = new AliEveTPCSector2D();
177       s->SetSectorID(i);
178       s->SetDataSource(g_tpc_data);
179       s->SetFrameColor(col);
180       s->SetAutoTrans(kTRUE);
181       gEve->AddElement(s, l);
182     }
183   }
184   gEve->EnableRedraw();
185 }