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