Mods for CMake
[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
af2d8a68 21void MUON_displaySimu(Bool_t fromRaw = kFALSE, Bool_t showTracks = kTRUE, Bool_t clustersFromESD = 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
a15e6d7d 88 TString esdDataPath = TString(gAliEveEvent->GetTitle());
83eb8a9e 89 esdDataPath.Append("/AliESDs.root");
af2d8a68 90 if (clustersFromESD) {
91 g_muon_data->LoadRecPointsFromESD(esdDataPath.Data());
92 } else {
93 rl->LoadRecPoints("MUON");
94 ct = rl->GetTreeR("MUON", false);
95 g_muon_data->LoadRecPoints(ct);
96 }
58e15fc1 97
eadce74d 98 rl->LoadHits("MUON");
99 ht = rl->GetTreeH("MUON", false);
100 g_muon_data->LoadHits(ht);
58e15fc1 101
a15e6d7d 102 g_muon_last_event = gAliEveEvent;
51346b82 103
f6ee486c 104 g_currentEvent = g_muon_last_event->GetEventId();
51346b82 105
f6ee486c 106 gStyle->SetPalette(1, 0);
107
84aff7a4 108 gEve->DisableRedraw();
51346b82 109
84aff7a4 110 TEveElementList* l = new TEveElementList("MUONChambers");
f6ee486c 111 l->SetTitle("MUON chambers");
fbc350a3 112 l->SetMainColor(2);
84aff7a4 113 gEve->AddElement(l);
51346b82 114
cb4245bb 115 for (Int_t ic = 0; ic < 14; ic++)
116 {
d810d0de 117 AliEveMUONChamber* mucha = new AliEveMUONChamber(ic);
51346b82 118
f6ee486c 119 mucha->SetFrameColor(2);
120 mucha->SetChamberID(ic);
51346b82 121
f6ee486c 122 mucha->SetDataSource(g_muon_data);
123
84aff7a4 124 gEve->AddElement(mucha, l);
f6ee486c 125 }
126
eadce74d 127 if (showTracks) {
eadce74d 128 MUON_ESD_tracks();
129 MUON_Ref_tracks();
130 MUON_MC_tracks();
131 }
f6ee486c 132
84aff7a4 133 gEve->Redraw3D(kTRUE);
cb4245bb 134 gEve->EnableRedraw();
f6ee486c 135}
136
57ffa5fb 137//______________________________________________________________________________
cb4245bb 138void MUON_ESD_tracks()
139{
d810d0de 140 AliESDEvent* esd = AliEveEventManager::AssertESD();
f6ee486c 141
51346b82 142 TEveTrackList* lt = new TEveTrackList("ESD-Tracks");
fbc350a3 143 lt->SetMainColor(6);
eadce74d 144 //lt->SetMUON();
f6ee486c 145
84aff7a4 146 gEve->AddElement(lt);
eadce74d 147
148 AliESDMuonTrack *mt;
84aff7a4 149 TEveRecTrack rt;
eadce74d 150 Int_t nMuonTracks = esd->GetNumberOfMuonTracks();
58e15fc1 151 Int_t nTrack = 0;
cb4245bb 152 for (Int_t n = 0; n < nMuonTracks; n++)
153 {
eadce74d 154 mt = esd->GetMuonTrack(n);
155
58e15fc1 156 if (mt->GetNHit() == 0) continue;
157 nTrack++;
158
83eb8a9e 159 rt.fLabel = n;
eadce74d 160
d810d0de 161 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 162
163 track->MakeESDTrack(mt);
164
84aff7a4 165 gEve->AddElement(track, lt);
eadce74d 166 }
167
168}
169
57ffa5fb 170//______________________________________________________________________________
cb4245bb 171void MUON_Ref_tracks()
172{
a15e6d7d 173 TString dataPathESD = TString(gAliEveEvent->GetTitle());
83eb8a9e 174 dataPathESD.Append("/AliESDs.root");
a15e6d7d 175 TString dataPathSIM = TString(gAliEveEvent->GetTitle());
83eb8a9e 176 dataPathSIM.Append("/");
eadce74d 177
83eb8a9e 178 AliMUONRecoCheck recoCheck(dataPathESD.Data(),dataPathSIM.Data());
a15e6d7d 179 AliMUONVTrackStore* trackRefStore = recoCheck.ReconstructibleTracks(gAliEveEvent->GetEventId());
832dd5c9 180 TIter next(trackRefStore->CreateIterator());
181 AliMUONTrack* trackRef;
51346b82 182
183 TEveTrackList* lt = new TEveTrackList("Ref-Tracks");
fbc350a3 184 lt->SetMainColor(6);
eadce74d 185
84aff7a4 186 gEve->AddElement(lt);
eadce74d 187
84aff7a4 188 TEveRecTrack rt;
51346b82 189 Int_t i = 0;
cb4245bb 190 while ( ( trackRef = static_cast<AliMUONTrack*>(next()) ) )
191 {
83eb8a9e 192 rt.fLabel = i++;
eadce74d 193
d810d0de 194 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 195
832dd5c9 196 track->MakeRefTrack(trackRef);
eadce74d 197
84aff7a4 198 gEve->AddElement(track, lt);
eadce74d 199 }
200
201}
202
57ffa5fb 203//______________________________________________________________________________
cb4245bb 204void MUON_MC_tracks()
205{
eadce74d 206 Double_t RADDEG = 180.0/TMath::Pi();
207
d810d0de 208 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
eadce74d 209 rl->LoadKinematics();
210 AliStack* stack = rl->Stack();
211
212 Int_t nPrimary = stack->GetNprimary();
213 Int_t nTracks = stack->GetNtrack();
214
51346b82 215 TEveTrackList* lt = new TEveTrackList("MC-Tracks");
fbc350a3 216 lt->SetMainColor(6);
eadce74d 217 //lt->SetMUON();
218
84aff7a4 219 gEve->AddElement(lt);
eadce74d 220
221 Int_t pdgCode;
222 TParticle *part;
84aff7a4 223 TEveRecTrack rt;
eadce74d 224
225 Int_t nHitTracks = g_muon_data->GetNTrackList();
226 Int_t index;
cb4245bb 227 for (Int_t i = 0; i < nHitTracks; i++)
228 {
eadce74d 229 index = g_muon_data->GetTrack(i);
230 if (index >= nTracks) {
84aff7a4 231 cout << "TEveHit track index larger than number in stack!" << endl;
eadce74d 232 continue;
233 }
234
235 part = stack->Particle(index);
236 if (part->P() < 0.001) continue; // skip momenta < 1.0 MeV/c
83eb8a9e 237 rt.fLabel = i;
eadce74d 238
d810d0de 239 AliEveMUONTrack* track = new AliEveMUONTrack(&rt, lt->GetPropagator());
eadce74d 240
241 track->MakeMCTrack(part);
242
84aff7a4 243 gEve->AddElement(track, lt);
eadce74d 244 }
f6ee486c 245
832dd5c9 246 rl->UnloadKinematics();
f6ee486c 247}
248