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