IO test for Interpolator
[u/mrichter/AliRoot.git] / EVE / alice-macros / MUON_display.C
CommitLineData
f6ee486c 1#include "TGLViewer.h"
2
3namespace Alieve {
4class MUONData;
5class Event;
6}
7
8Alieve::MUONData* g_muon_data = 0;
9Alieve::Event* g_muon_last_event = 0;
10
11Int_t g_currentEvent = -1;
12Bool_t g_fromRaw = kFALSE;
13
14void MUON_display(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE)
15{
16
17 TTree* dt = 0;
18 TTree* ct = 0;
eadce74d 19 TTree* ht = 0;
f6ee486c 20
21 if (Alieve::gEvent == 0) {
22 printf("No alieve event: use alieve_init(...) \n");
23 return;
24 }
25
26 if (g_currentEvent == Alieve::gEvent->GetEventId()) {
27 if (g_fromRaw == fromRaw) {
28 printf("Same event... \n");
29 return;
30 } else {
31 if (g_fromRaw) {
32 printf("Same event with digits.\n");
33 Alieve::gEvent->GotoEvent(g_currentEvent);
34 } else {
35 printf("Same event with raw.\n");
36 Alieve::gEvent->GotoEvent(g_currentEvent);
37 }
38 }
39 }
40
41 g_fromRaw = fromRaw;
42
43 TString dataPath = TString(Alieve::gEvent->GetTitle());
eadce74d 44 dataPath.Append("/rawmuon.root");
f6ee486c 45
46 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
47 g_muon_data = new Alieve::MUONData;
eadce74d 48
f6ee486c 49 if (!fromRaw) {
50 rl->LoadDigits("MUON");
51 dt = rl->GetTreeD("MUON", false);
52 if (dt == 0) {
53 cout << "No digits produced!" << endl;
54 } else {
eadce74d 55 cout << "With aliroot digits!" << endl;
f6ee486c 56 g_muon_data->LoadDigits(dt);
57 }
58 } else {
59 if (gSystem->AccessPathName(dataPath.Data(),kFileExists)) {
60 cout << "No raw data produced!" << endl;
61 } else {
eadce74d 62 cout << "With raw digits!" << endl;
f6ee486c 63 g_muon_data->LoadRaw(dataPath.Data());
64 }
65 }
eadce74d 66
f6ee486c 67 rl->LoadRecPoints("MUON");
68 ct = rl->GetTreeR("MUON", false);
69 g_muon_data->LoadRecPoints(ct);
eadce74d 70
71 rl->LoadHits("MUON");
72 ht = rl->GetTreeH("MUON", false);
73 g_muon_data->LoadHits(ht);
74
f6ee486c 75 g_muon_last_event = Alieve::gEvent;
76
77 g_currentEvent = g_muon_last_event->GetEventId();
78
79 gStyle->SetPalette(1, 0);
80
81 gReve->DisableRedraw();
eadce74d 82
f6ee486c 83 Reve::RenderElementList* l = new Reve::RenderElementList("MUONChambers");
84 l->SetTitle("MUON chambers");
85 l->SetMainColor(Color_t(2));
86 gReve->AddRenderElement(l);
eadce74d 87
f6ee486c 88 for (Int_t ic = 0; ic < 14; ic++) {
89
eadce74d 90 Alieve::MUONChamber* mucha = new Alieve::MUONChamber(ic);
f6ee486c 91
92 mucha->SetFrameColor(2);
93 mucha->SetChamberID(ic);
eadce74d 94
f6ee486c 95 mucha->SetDataSource(g_muon_data);
96
97 gReve->AddRenderElement(l,mucha);
98
99 }
100
eadce74d 101 if (showTracks) {
102 MUON_tracks();
103 MUON_trigger_tracks();
104 MUON_ESD_tracks();
105 MUON_Ref_tracks();
106 MUON_MC_tracks();
107 }
f6ee486c 108
109 gReve->EnableRedraw();
110 gReve->Redraw3D(kTRUE);
eadce74d 111
f6ee486c 112 /*
113 TGLViewer* view = dynamic_cast<TGLViewer*>(gReve->GetGLCanvas()->GetViewer3D());
114 view->ResetCamerasAfterNextUpdate();
115 gReve->GetGLCanvas()->Modified();
116 gReve->GetGLCanvas()->Update();
117 */
118}
119
120//_____________________________________________________________________________
121void MUON_tracks() {
122
123 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
124 rl->LoadTracks("MUON");
125 TTree* tt = rl->GetTreeT("MUON", false);
126
f6ee486c 127 TClonesArray *tracks = 0;
128 tt->SetBranchAddress("MUONTrack",&tracks);
129 tt->GetEntry(0);
130
131 Int_t ntracks = tracks->GetEntriesFast();
132 //printf("Found %d tracks. \n",ntracks);
133
134 Reve::TrackList* lt = new Reve::TrackList("M-Tracks");
135 lt->SetMainColor(Color_t(6));
eadce74d 136 //lt->SetMUON();
137
f6ee486c 138 gReve->AddRenderElement(lt);
139
140 TMatrixD smatrix(2,2);
141 TMatrixD sums(2,1);
142 TMatrixD res(2,1);
143
144 Float_t xRec, xRec0;
145 Float_t yRec, yRec0;
146 Float_t zRec, zRec0;
147
148 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
149
150 AliMUONTrack *mt;
151 Reve::RecTrack rt;
152 Int_t count;
153 for (Int_t n = 0; n < ntracks; n++) {
154
155 count = 0;
156
157 mt = (AliMUONTrack*) tracks->At(n);
158
f6ee486c 159 rt.label = n;
160
161 Alieve::MUONTrack* track = new Alieve::MUONTrack(&rt, lt->GetRnrStyle());
162
eadce74d 163 track->MakeMUONTrack(mt);
f6ee486c 164
165 gReve->AddRenderElement(lt, track);
166
eadce74d 167 }
f6ee486c 168
eadce74d 169}
f6ee486c 170
eadce74d 171//_____________________________________________________________________________
172void MUON_trigger_tracks() {
f6ee486c 173
eadce74d 174 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
175 rl->LoadTracks("MUON");
176 TTree* tt = rl->GetTreeT("MUON", false);
f6ee486c 177
eadce74d 178 TClonesArray *tracks = 0;
179 tt->SetBranchAddress("MUONTriggerTrack",&tracks);
180 tt->GetEntry(0);
f6ee486c 181
eadce74d 182 Int_t ntracks = tracks->GetEntriesFast();
183 //printf("Found %d tracks. \n",ntracks);
184
185 Reve::TrackList* lt = new Reve::TrackList("MT-Tracks");
186 lt->SetMainColor(Color_t(4));
187 //lt->SetMUON();
188
189 gReve->AddRenderElement(lt);
190
191 TMatrixD smatrix(2,2);
192 TMatrixD sums(2,1);
193 TMatrixD res(2,1);
194
195 Float_t xRec, xRec0;
196 Float_t yRec, yRec0;
197 Float_t zRec, zRec0;
198
199 Float_t zg[4] = { -1603.5, -1620.5, -1703.5, -1720.5 };
200
201 AliMUONTriggerTrack *mt;
202 Reve::RecTrack rt;
203 Int_t count;
204 for (Int_t n = 0; n < ntracks; n++) {
f6ee486c 205
eadce74d 206 count = 0;
f6ee486c 207
eadce74d 208 mt = (AliMUONTriggerTrack*) tracks->At(n);
f6ee486c 209
eadce74d 210 rt.label = n;
f6ee486c 211
eadce74d 212 Alieve::MUONTrack* track = new Alieve::MUONTrack(&rt, lt->GetRnrStyle());
f6ee486c 213
eadce74d 214 track->MakeMUONTriggerTrack(mt);
f6ee486c 215
eadce74d 216 gReve->AddRenderElement(lt, track);
f6ee486c 217
eadce74d 218 }
f6ee486c 219
eadce74d 220}
f6ee486c 221
eadce74d 222//_____________________________________________________________________________
223void MUON_ESD_tracks() {
224
225 AliESD* esd = Alieve::Event::AssertESD();
f6ee486c 226
eadce74d 227 Reve::TrackList* lt = new Reve::TrackList("ESD-Tracks");
228 lt->SetMainColor(Color_t(6));
229 //lt->SetMUON();
f6ee486c 230
eadce74d 231 gReve->AddRenderElement(lt);
232
233 AliESDMuonTrack *mt;
234 Reve::RecTrack rt;
235 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
236 for (Int_t n = 0; n < nMuonTracks; n++) {
237
238 mt = esd->GetMuonTrack(n);
239
240 rt.label = n;
241
242 Alieve::MUONTrack* track = new Alieve::MUONTrack(&rt, lt->GetRnrStyle());
243
244 track->MakeESDTrack(mt);
245
246 gReve->AddRenderElement(lt, track);
247
248 }
249
250}
251
252//_____________________________________________________________________________
253void MUON_Ref_tracks() {
254
255 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
256
257 AliLoader * ml = rl->GetLoader("MUONLoader");
258 AliMUONData * mdata = new AliMUONData(ml,"MUON","MUON");
259
260 rl->LoadKinematics("READ");
261 rl->LoadTrackRefs("READ");
262
263 AliMUONRecoCheck rc(rl,mdata);
264
265 rc.ResetTracks();
266 rc.MakeTrackRef();
267
268 Reve::TrackList* lt = new Reve::TrackList("Ref-Tracks");
269 lt->SetMainColor(Color_t(6));
270 //lt->SetMUON();
271
272 gReve->AddRenderElement(lt);
273
274 AliMUONTrack *mt;
275 Reve::RecTrack rt;
276 TClonesArray * trackRefArray = rc.GetMuonTrackRef();
277 Int_t nTrackRef = trackRefArray->GetEntriesFast();
278
279 for (Int_t i = 0; i < nTrackRef; i++) {
280
281 mt = (AliMUONTrack *)trackRefArray->At(i);
282
283 rt.label = i;
284
285 Alieve::MUONTrack* track = new Alieve::MUONTrack(&rt, lt->GetRnrStyle());
286
287 track->MakeRefTrack(mt);
288
289 gReve->AddRenderElement(lt, track);
290
291 }
292
293}
294
295//_____________________________________________________________________________
296void MUON_MC_tracks() {
297
298 Double_t RADDEG = 180.0/TMath::Pi();
299
300 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
301 rl->LoadKinematics();
302 AliStack* stack = rl->Stack();
303
304 Int_t nPrimary = stack->GetNprimary();
305 Int_t nTracks = stack->GetNtrack();
306
307 Reve::TrackList* lt = new Reve::TrackList("MC-Tracks");
308 lt->SetMainColor(Color_t(6));
309 //lt->SetMUON();
310
311 gReve->AddRenderElement(lt);
312
313 Int_t pdgCode;
314 TParticle *part;
315 Reve::RecTrack rt;
316
317 Int_t nHitTracks = g_muon_data->GetNTrackList();
318 Int_t index;
319 for (Int_t i = 0; i < nHitTracks; i++) {
320
321 index = g_muon_data->GetTrack(i);
322 if (index >= nTracks) {
323 cout << "Hit track index larger than number in stack!" << endl;
324 continue;
325 }
326
327 part = stack->Particle(index);
328 if (part->P() < 0.001) continue; // skip momenta < 1.0 MeV/c
329 rt.label = i;
330
331 Alieve::MUONTrack* track = new Alieve::MUONTrack(&rt, lt->GetRnrStyle());
332
333 track->MakeMCTrack(part);
334
335 gReve->AddRenderElement(lt, track);
336
337 }
f6ee486c 338
339}
340