]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/MUON_displayData.C
Change to support compilation when ALICE_INSTALL is not same as ALICE_ROOT
[u/mrichter/AliRoot.git] / EVE / alice-macros / MUON_displayData.C
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 /// \ingroup evemacros
11 /// \file MUON_displayData.C
12 ///
13 /// \author B. Vulpescu, LPC
14
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
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>
37 #endif
38
39 class AliEveMUONData;
40 class AliEveEventManager;
41
42 AliEveMUONData     *g_muon_data       = 0;
43
44 Int_t  g_currentEvent = -1;
45 Bool_t g_fromRaw      = kFALSE;
46
47 void MUON_ESD_tracks();
48
49 void MUON_displayData(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE, Bool_t clustersFromESD = kTRUE)
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
59   // set the magnetic field for track extrapolations
60   AliEveEventManager::AssertMagField();
61   AliMUONTrackExtrap::SetField();
62
63   TTree* dt = 0;
64   TTree* ct = 0;
65   TTree* ht = 0;
66
67   if (AliEveEventManager::GetMaster() == 0) {
68     printf("No alieve event: use alieve_init(...) \n");
69     return;
70   }
71
72   if (g_currentEvent == AliEveEventManager::GetMaster()->GetEventId()) {
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");
79         AliEveEventManager::GetMaster()->GotoEvent(g_currentEvent);
80       } else {
81         printf("Same event with raw.\n");
82         AliEveEventManager::GetMaster()->GotoEvent(g_currentEvent);
83       }
84     }
85   }
86
87   g_fromRaw = fromRaw;
88
89   TString dataPath = TString(AliEveEventManager::GetMaster()->GetTitle());
90   dataPath.Append("/raw.root");
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) {
99       cout << "No digits produced!" << endl;
100     } else {
101       cout << "With aliroot digits!" << endl;
102       g_muon_data->LoadDigits(dt);
103     }
104   } else {
105     if (gSystem->AccessPathName(dataPath.Data(),kFileExists)) {
106       cout << "No raw data produced!" << endl;
107     } else {
108       cout << "With raw digits!" << endl;
109       g_muon_data->LoadRaw(dataPath.Data());
110     }
111   }
112
113   TString esdDataPath = TString(AliEveEventManager::GetMaster()->GetTitle());
114   esdDataPath.Append("/AliESDs.root");
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   
123   g_currentEvent = AliEveEventManager::GetMaster()->GetEventId();
124
125   gStyle->SetPalette(1, 0);
126
127   gEve->DisableRedraw();
128
129   TEveElementList* l = new TEveElementList("MUONChambers");
130   l->SetTitle("MUON chambers");
131   l->SetMainColor(2);
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
143     l->AddElement(mucha);
144   }
145
146   if (showTracks) {
147     MUON_ESD_tracks();
148   }
149
150   gEve->Redraw3D(kTRUE);
151   gEve->EnableRedraw();
152 }
153
154 //______________________________________________________________________________
155 void MUON_ESD_tracks()
156 {
157   AliESDEvent* esd = AliEveEventManager::AssertESD();
158
159   // TEveTrackList* lt = new TEveTrackList("ESD-Tracks");
160   AliEveMUONTrackList* lt = new AliEveMUONTrackList("ESD-Tracks");
161   lt->SetMainColor(6);
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
183     lt->AddElement(track);
184   }
185   lt->HackMomentumLimits();
186 }
187