AliInfo displays better than std::cout
[u/mrichter/AliRoot.git] / EVE / alice-macros / MUON_displayData.C
CommitLineData
20dae051 1// $Id$
58e15fc1 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
25b4bdb2 10/// \ingroup evemacros
11/// \file MUON_displayData.C
12///
13/// \author B. Vulpescu, LPC
14
ba978640 15#if !defined(__CINT__) || defined(__MAKECINT__)
16#include <Riostream.h>
17#include <Rtypes.h>
18#include <TTree.h>
19#include <TStyle.h>
20#include <TString.h>
21#include <TSystem.h>
22#include <TEveManager.h>
23#include <TEveElement.h>
24#include <TEveTrack.h>
25
6c49a8e1 26#include <AliMpSegmentation.h>
27#include <AliMpDDLStore.h>
28#include <AliMpCDB.h>
29#include <AliMUONTrackExtrap.h>
30#include <AliRunLoader.h>
31#include <AliESDEvent.h>
32#include <AliESDMuonTrack.h>
33#include <AliEveEventManager.h>
34#include <AliEveMUONData.h>
35#include <AliEveMUONChamber.h>
36#include <AliEveMUONTrack.h>
ba978640 37#endif
38
58e15fc1 39class AliEveMUONData;
40class AliEveEventManager;
41
42AliEveMUONData *g_muon_data = 0;
58e15fc1 43
44Int_t g_currentEvent = -1;
45Bool_t g_fromRaw = kFALSE;
46
ba978640 47void MUON_ESD_tracks();
48
af2d8a68 49void MUON_displayData(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE, Bool_t clustersFromESD = kTRUE)
58e15fc1 50{
51 //
52 // display from real data, eventually with recreated digits
53 // tracks: ESD
54 //
55
56 if (!AliMpSegmentation::Instance()) AliMpCDB::LoadMpSegmentation();
57 if (!AliMpDDLStore::Instance()) AliMpCDB::LoadDDLStore();
58
f7a1cc68 59 // set the magnetic field for track extrapolations
e383efce 60 AliEveEventManager::AssertMagField();
f7a1cc68 61 AliMUONTrackExtrap::SetField();
58e15fc1 62
63 TTree* dt = 0;
64 TTree* ct = 0;
65 TTree* ht = 0;
66
4d62585e 67 if (AliEveEventManager::GetMaster() == 0) {
58e15fc1 68 printf("No alieve event: use alieve_init(...) \n");
69 return;
70 }
71
4d62585e 72 if (g_currentEvent == AliEveEventManager::GetMaster()->GetEventId()) {
58e15fc1 73 if (g_fromRaw == fromRaw) {
74 printf("Same event... \n");
75 return;
76 } else {
77 if (g_fromRaw) {
78 printf("Same event with digits.\n");
4d62585e 79 AliEveEventManager::GetMaster()->GotoEvent(g_currentEvent);
58e15fc1 80 } else {
81 printf("Same event with raw.\n");
4d62585e 82 AliEveEventManager::GetMaster()->GotoEvent(g_currentEvent);
58e15fc1 83 }
84 }
85 }
86
87 g_fromRaw = fromRaw;
88
4d62585e 89 TString dataPath = TString(AliEveEventManager::GetMaster()->GetTitle());
20dae051 90 dataPath.Append("/raw.root");
58e15fc1 91
92 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
93 g_muon_data = new AliEveMUONData;
94
95 if (!fromRaw) {
96 rl->LoadDigits("MUON");
97 dt = rl->GetTreeD("MUON", false);
98 if (dt == 0) {
1cec595f 99 AliInfo("No digits produced!");
58e15fc1 100 } else {
1cec595f 101 AliInfo("With aliroot digits!");
58e15fc1 102 g_muon_data->LoadDigits(dt);
103 }
104 } else {
105 if (gSystem->AccessPathName(dataPath.Data(),kFileExists)) {
1cec595f 106 AliInfo("No raw data produced!");
58e15fc1 107 } else {
1cec595f 108 AliInfo("With raw digits!");
58e15fc1 109 g_muon_data->LoadRaw(dataPath.Data());
110 }
111 }
112
4d62585e 113 TString esdDataPath = TString(AliEveEventManager::GetMaster()->GetTitle());
58e15fc1 114 esdDataPath.Append("/AliESDs.root");
af2d8a68 115 if (clustersFromESD) {
116 g_muon_data->LoadRecPointsFromESD(esdDataPath.Data());
117 } else {
118 rl->LoadRecPoints("MUON");
119 ct = rl->GetTreeR("MUON", false);
120 g_muon_data->LoadRecPoints(ct);
121 }
122
4d62585e 123 g_currentEvent = AliEveEventManager::GetMaster()->GetEventId();
58e15fc1 124
125 gStyle->SetPalette(1, 0);
126
127 gEve->DisableRedraw();
128
129 TEveElementList* l = new TEveElementList("MUONChambers");
130 l->SetTitle("MUON chambers");
fbc350a3 131 l->SetMainColor(2);
58e15fc1 132 gEve->AddElement(l);
133
134 for (Int_t ic = 0; ic < 14; ic++)
135 {
136 AliEveMUONChamber* mucha = new AliEveMUONChamber(ic);
137
138 mucha->SetFrameColor(2);
139 mucha->SetChamberID(ic);
140
141 mucha->SetDataSource(g_muon_data);
142
98d99a29 143 l->AddElement(mucha);
58e15fc1 144 }
145
146 if (showTracks) {
147 MUON_ESD_tracks();
148 }
149
150 gEve->Redraw3D(kTRUE);
151 gEve->EnableRedraw();
152}
153
154//______________________________________________________________________________
155void MUON_ESD_tracks()
156{
157 AliESDEvent* esd = AliEveEventManager::AssertESD();
158
98d99a29 159 // TEveTrackList* lt = new TEveTrackList("ESD-Tracks");
ba978640 160 AliEveMUONTrackList* lt = new AliEveMUONTrackList("ESD-Tracks");
fbc350a3 161 lt->SetMainColor(6);
58e15fc1 162 //lt->SetMUON();
163
164 gEve->AddElement(lt);
165
166 AliESDMuonTrack *mt;
167 TEveRecTrack rt;
168 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
169 Int_t nTrack = 0;
170 for (Int_t n = 0; n < nMuonTracks; n++)
171 {
172 mt = esd->GetMuonTrack(n);
173
174 if (mt->GetNHit() == 0) continue;
175 nTrack++;
176
177 rt.fLabel = n;
178
179 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
180
181 track->MakeESDTrack(mt);
182
98d99a29 183 lt->AddElement(track);
58e15fc1 184 }
98d99a29 185 lt->HackMomentumLimits();
58e15fc1 186}
187