From Bogdan:
[u/mrichter/AliRoot.git] / EVE / alice-macros / MUON_displayData.C
CommitLineData
58e15fc1 1// $Id: MUON_display.C 24485 2008-03-13 15:27:38Z mtadel $
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
10class AliEveMUONData;
11class AliEveEventManager;
12
13AliEveMUONData *g_muon_data = 0;
14AliEveEventManager *g_muon_last_event = 0;
15
16Int_t g_currentEvent = -1;
17Bool_t g_fromRaw = kFALSE;
18
19AliMagFMaps *g_field = 0;
20
21void MUON_displayData(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE)
22{
23 //
24 // display from real data, eventually with recreated digits
25 // tracks: ESD
26 //
27
28 if (!AliMpSegmentation::Instance()) AliMpCDB::LoadMpSegmentation();
29 if (!AliMpDDLStore::Instance()) AliMpCDB::LoadDDLStore();
30
31 if (g_field == 0) {
32 printf("Loading field map...\n");
33 g_field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
34 AliTracker::SetFieldMap(g_field, kFALSE);
35 AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
36 }
37
38 TTree* dt = 0;
39 TTree* ct = 0;
40 TTree* ht = 0;
41
42 if (gAliEveEvent == 0) {
43 printf("No alieve event: use alieve_init(...) \n");
44 return;
45 }
46
47 if (g_currentEvent == gAliEveEvent->GetEventId()) {
48 if (g_fromRaw == fromRaw) {
49 printf("Same event... \n");
50 return;
51 } else {
52 if (g_fromRaw) {
53 printf("Same event with digits.\n");
54 gAliEveEvent->GotoEvent(g_currentEvent);
55 } else {
56 printf("Same event with raw.\n");
57 gAliEveEvent->GotoEvent(g_currentEvent);
58 }
59 }
60 }
61
62 g_fromRaw = fromRaw;
63
64 TString dataPath = TString(gAliEveEvent->GetTitle());
65 dataPath.Append("/rawmuon.root");
66
67 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
68 g_muon_data = new AliEveMUONData;
69
70 if (!fromRaw) {
71 rl->LoadDigits("MUON");
72 dt = rl->GetTreeD("MUON", false);
73 if (dt == 0) {
74 cout << "No digits produced!" << endl;
75 } else {
76 cout << "With aliroot digits!" << endl;
77 g_muon_data->LoadDigits(dt);
78 }
79 } else {
80 if (gSystem->AccessPathName(dataPath.Data(),kFileExists)) {
81 cout << "No raw data produced!" << endl;
82 } else {
83 cout << "With raw digits!" << endl;
84 g_muon_data->LoadRaw(dataPath.Data());
85 }
86 }
87
88 rl->LoadRecPoints("MUON");
89 ct = rl->GetTreeR("MUON", false);
90
91 TString esdDataPath = TString(gAliEveEvent->GetTitle());
92 esdDataPath.Append("/AliESDs.root");
93 g_muon_data->LoadRecPointsFromESD(esdDataPath.Data());
94
95 g_muon_last_event = gAliEveEvent;
96
97 g_currentEvent = g_muon_last_event->GetEventId();
98
99 gStyle->SetPalette(1, 0);
100
101 gEve->DisableRedraw();
102
103 TEveElementList* l = new TEveElementList("MUONChambers");
104 l->SetTitle("MUON chambers");
105 l->SetMainColor(Color_t(2));
106 gEve->AddElement(l);
107
108 for (Int_t ic = 0; ic < 14; ic++)
109 {
110 AliEveMUONChamber* mucha = new AliEveMUONChamber(ic);
111
112 mucha->SetFrameColor(2);
113 mucha->SetChamberID(ic);
114
115 mucha->SetDataSource(g_muon_data);
116
117 gEve->AddElement(mucha, l);
118 }
119
120 if (showTracks) {
121 MUON_ESD_tracks();
122 }
123
124 gEve->Redraw3D(kTRUE);
125 gEve->EnableRedraw();
126}
127
128//______________________________________________________________________________
129void MUON_ESD_tracks()
130{
131 AliESDEvent* esd = AliEveEventManager::AssertESD();
132
133 TEveTrackList* lt = new TEveTrackList("ESD-Tracks");
134 lt->SetMainColor(Color_t(6));
135 //lt->SetMUON();
136
137 gEve->AddElement(lt);
138
139 AliESDMuonTrack *mt;
140 TEveRecTrack rt;
141 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
142 Int_t nTrack = 0;
143 for (Int_t n = 0; n < nMuonTracks; n++)
144 {
145 mt = esd->GetMuonTrack(n);
146
147 if (mt->GetNHit() == 0) continue;
148 nTrack++;
149
150 rt.fLabel = n;
151
152 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
153
154 track->MakeESDTrack(mt);
155
156 gEve->AddElement(track, lt);
157 }
158
159}
160