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