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