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