Updated information
[u/mrichter/AliRoot.git] / EVE / alice-macros / MUON_displaySimu.C
CommitLineData
58e15fc1 1// $Id: MUON_display.C 24485 2008-03-13 15:27:38Z mtadel $
d810d0de 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
58e15fc1 21void MUON_displaySimu(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE)
f6ee486c 22{
58e15fc1 23 //
24 // display from simulated digits (or produced raw data)
25 // tracks: ESD, Refs, MC
26 //
27
51346b82 28 if (!AliMpSegmentation::Instance()) AliMpCDB::LoadMpSegmentation();
832dd5c9 29 if (!AliMpDDLStore::Instance()) AliMpCDB::LoadDDLStore();
30
83eb8a9e 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
f6ee486c 38 TTree* dt = 0;
39 TTree* ct = 0;
eadce74d 40 TTree* ht = 0;
f6ee486c 41
a15e6d7d 42 if (gAliEveEvent == 0) {
f6ee486c 43 printf("No alieve event: use alieve_init(...) \n");
44 return;
45 }
46
a15e6d7d 47 if (g_currentEvent == gAliEveEvent->GetEventId()) {
f6ee486c 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");
a15e6d7d 54 gAliEveEvent->GotoEvent(g_currentEvent);
f6ee486c 55 } else {
56 printf("Same event with raw.\n");
a15e6d7d 57 gAliEveEvent->GotoEvent(g_currentEvent);
f6ee486c 58 }
59 }
60 }
61
62 g_fromRaw = fromRaw;
63
a15e6d7d 64 TString dataPath = TString(gAliEveEvent->GetTitle());
eadce74d 65 dataPath.Append("/rawmuon.root");
f6ee486c 66
d810d0de 67 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
68 g_muon_data = new AliEveMUONData;
51346b82 69
f6ee486c 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 {
eadce74d 76 cout << "With aliroot digits!" << endl;
f6ee486c 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 {
eadce74d 83 cout << "With raw digits!" << endl;
f6ee486c 84 g_muon_data->LoadRaw(dataPath.Data());
85 }
86 }
51346b82 87
f6ee486c 88 rl->LoadRecPoints("MUON");
89 ct = rl->GetTreeR("MUON", false);
83eb8a9e 90
a15e6d7d 91 TString esdDataPath = TString(gAliEveEvent->GetTitle());
83eb8a9e 92 esdDataPath.Append("/AliESDs.root");
93 g_muon_data->LoadRecPointsFromESD(esdDataPath.Data());
58e15fc1 94
eadce74d 95 rl->LoadHits("MUON");
96 ht = rl->GetTreeH("MUON", false);
97 g_muon_data->LoadHits(ht);
58e15fc1 98
a15e6d7d 99 g_muon_last_event = gAliEveEvent;
51346b82 100
f6ee486c 101 g_currentEvent = g_muon_last_event->GetEventId();
51346b82 102
f6ee486c 103 gStyle->SetPalette(1, 0);
104
84aff7a4 105 gEve->DisableRedraw();
51346b82 106
84aff7a4 107 TEveElementList* l = new TEveElementList("MUONChambers");
f6ee486c 108 l->SetTitle("MUON chambers");
109 l->SetMainColor(Color_t(2));
84aff7a4 110 gEve->AddElement(l);
51346b82 111
cb4245bb 112 for (Int_t ic = 0; ic < 14; ic++)
113 {
d810d0de 114 AliEveMUONChamber* mucha = new AliEveMUONChamber(ic);
51346b82 115
f6ee486c 116 mucha->SetFrameColor(2);
117 mucha->SetChamberID(ic);
51346b82 118
f6ee486c 119 mucha->SetDataSource(g_muon_data);
120
84aff7a4 121 gEve->AddElement(mucha, l);
f6ee486c 122 }
123
eadce74d 124 if (showTracks) {
eadce74d 125 MUON_ESD_tracks();
126 MUON_Ref_tracks();
127 MUON_MC_tracks();
128 }
f6ee486c 129
84aff7a4 130 gEve->Redraw3D(kTRUE);
cb4245bb 131 gEve->EnableRedraw();
f6ee486c 132}
133
57ffa5fb 134//______________________________________________________________________________
cb4245bb 135void MUON_ESD_tracks()
136{
d810d0de 137 AliESDEvent* esd = AliEveEventManager::AssertESD();
f6ee486c 138
51346b82 139 TEveTrackList* lt = new TEveTrackList("ESD-Tracks");
eadce74d 140 lt->SetMainColor(Color_t(6));
141 //lt->SetMUON();
f6ee486c 142
84aff7a4 143 gEve->AddElement(lt);
eadce74d 144
145 AliESDMuonTrack *mt;
84aff7a4 146 TEveRecTrack rt;
eadce74d 147 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
58e15fc1 148 Int_t nTrack = 0;
cb4245bb 149 for (Int_t n = 0; n < nMuonTracks; n++)
150 {
eadce74d 151 mt = esd->GetMuonTrack(n);
152
58e15fc1 153 if (mt->GetNHit() == 0) continue;
154 nTrack++;
155
83eb8a9e 156 rt.fLabel = n;
eadce74d 157
d810d0de 158 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 159
160 track->MakeESDTrack(mt);
161
84aff7a4 162 gEve->AddElement(track, lt);
eadce74d 163 }
164
165}
166
57ffa5fb 167//______________________________________________________________________________
cb4245bb 168void MUON_Ref_tracks()
169{
a15e6d7d 170 TString dataPathESD = TString(gAliEveEvent->GetTitle());
83eb8a9e 171 dataPathESD.Append("/AliESDs.root");
a15e6d7d 172 TString dataPathSIM = TString(gAliEveEvent->GetTitle());
83eb8a9e 173 dataPathSIM.Append("/");
eadce74d 174
83eb8a9e 175 AliMUONRecoCheck recoCheck(dataPathESD.Data(),dataPathSIM.Data());
a15e6d7d 176 AliMUONVTrackStore* trackRefStore = recoCheck.ReconstructibleTracks(gAliEveEvent->GetEventId());
832dd5c9 177 TIter next(trackRefStore->CreateIterator());
178 AliMUONTrack* trackRef;
51346b82 179
180 TEveTrackList* lt = new TEveTrackList("Ref-Tracks");
eadce74d 181 lt->SetMainColor(Color_t(6));
eadce74d 182
84aff7a4 183 gEve->AddElement(lt);
eadce74d 184
84aff7a4 185 TEveRecTrack rt;
51346b82 186 Int_t i = 0;
cb4245bb 187 while ( ( trackRef = static_cast<AliMUONTrack*>(next()) ) )
188 {
83eb8a9e 189 rt.fLabel = i++;
eadce74d 190
d810d0de 191 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 192
832dd5c9 193 track->MakeRefTrack(trackRef);
eadce74d 194
84aff7a4 195 gEve->AddElement(track, lt);
eadce74d 196 }
197
198}
199
57ffa5fb 200//______________________________________________________________________________
cb4245bb 201void MUON_MC_tracks()
202{
eadce74d 203 Double_t RADDEG = 180.0/TMath::Pi();
204
d810d0de 205 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
eadce74d 206 rl->LoadKinematics();
207 AliStack* stack = rl->Stack();
208
209 Int_t nPrimary = stack->GetNprimary();
210 Int_t nTracks = stack->GetNtrack();
211
51346b82 212 TEveTrackList* lt = new TEveTrackList("MC-Tracks");
eadce74d 213 lt->SetMainColor(Color_t(6));
214 //lt->SetMUON();
215
84aff7a4 216 gEve->AddElement(lt);
eadce74d 217
218 Int_t pdgCode;
219 TParticle *part;
84aff7a4 220 TEveRecTrack rt;
eadce74d 221
222 Int_t nHitTracks = g_muon_data->GetNTrackList();
223 Int_t index;
cb4245bb 224 for (Int_t i = 0; i < nHitTracks; i++)
225 {
eadce74d 226 index = g_muon_data->GetTrack(i);
227 if (index >= nTracks) {
84aff7a4 228 cout << "TEveHit track index larger than number in stack!" << endl;
eadce74d 229 continue;
230 }
231
232 part = stack->Particle(index);
233 if (part->P() < 0.001) continue; // skip momenta < 1.0 MeV/c
83eb8a9e 234 rt.fLabel = i;
eadce74d 235
d810d0de 236 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 237
238 track->MakeMCTrack(part);
239
84aff7a4 240 gEve->AddElement(track, lt);
eadce74d 241 }
f6ee486c 242
832dd5c9 243 rl->UnloadKinematics();
f6ee486c 244}
245