1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
6 * Artur Szostak <artursz@iafrica.com> *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
17 // $Id: DisplaydHLTData.C 37070 2009-11-20 13:53:08Z aszostak $
21 * \file DisplaydHLTData.C
22 * \brief Macro for displaying rootified dHLT data generated with RunChain.C
24 * This macro is used to display the dHLT data generated by the RunChain.C macro
25 * with the "root" option for making the output data. Optionally the dHLTRawData.root
26 * file which is generated during a AliRoot offline reconstruction can also be
27 * displayed using this macro.
28 * After having generated the dHLT raw data file (called <i>output.root</i> for example)
29 * the following command can be executed in an alieve session to display both
32 * > gSystem->Load("libAliHLTMUON.so");
33 * > .L $ALICE_ROOT/EVE/macros/alieve_init.C
34 * > .L $ALICE_ROOT/EVE/alice-macros/event_goto.C
35 * > .L $ALICE_ROOT/EVE/alice-macros/MUON_displayData.C
36 * > .L $ALICE_ROOT/HLT/MUON/macros/DisplaydHLTData.C
37 * > alieve_init("OCDBpath","DataPath",EventNumber);
38 * > MUON_displayData(1,1,1);
39 * > DisplaydHLTData("output.root");
41 * Where <i>OCDBpath</i> should be replaced by the path to the OCDB database,
42 * <i>DataPath</i> should be the directory of the raw data or raw data root file and
43 * <i>EventNumber</i> is the event number to load.
45 * \author Artur Szostak <artursz@iafrica.com>
48 #if !defined(__CINT__) || defined(__MAKECINT__)
49 #include "AliEveEventManager.h"
50 #include "AliHLTMUONTriggerRecord.h"
51 #include "AliHLTMUONRecHit.h"
52 #include "AliHLTMUONMansoTrack.h"
53 #include "AliHLTMUONEvent.h"
54 #include "TEveManager.h"
55 #include "TEveElement.h"
56 #include "TEvePointSet.h"
57 #include "TEveStraightLineSet.h"
61 #include "TClassTable.h"
69 TFile* gDHLTFile = NULL;
71 void FillData(Int_t eventId);
74 void DisplaydHLTData(const char* dHLTfilename = "output.root")
78 if (gClassTable->GetID("AliHLTMUONEvent") < 0)
80 gSystem->Load("libAliHLTMUON.so");
83 if (AliEveEventManager::GetMaster() == NULL)
85 cerr << "ERROR: alieve event not initialised, use alieve_init(...)" << endl;
89 gEve->DisableRedraw();
91 TString filename = dHLTfilename;
92 TString tmpfilename = filename;
93 if (gSystem->FindFile("", tmpfilename) == NULL)
95 tmpfilename = filename;
96 if (gSystem->FindFile(".", tmpfilename) == NULL)
98 TString filename = TString(AliEveEventManager::GetMaster()->GetTitle());
100 filename += dHLTfilename;
103 if (gDHLTFile == NULL)
105 gDHLTFile = new TFile(filename.Data(), "READ");
107 else if (filename != gDHLTFile->GetName())
110 gDHLTFile = new TFile(filename.Data(), "READ");
113 FillData(AliEveEventManager::GetMaster()->GetEventId());
115 gEve->Redraw3D(kTRUE);
116 gEve->EnableRedraw();
120 void FillData(TEveElementList* list, const AliHLTMUONTriggerRecord* trigrec)
122 // Count the number of points in the trigger record.
123 Int_t pointCount = 0;
124 for (int i = 11; i <= 14; ++i)
126 if (trigrec->Hit(i) != TVector3(0,0,0)) ++pointCount;
129 // Create and fill the point set for the trigger record.
130 TEvePointSet* pointset = new TEvePointSet(pointCount);
131 pointset->SetName(Form("TriggerRecord%d", trigrec->Id()));
132 pointset->SetTitle(Form("dHLT trigger record ID = %d", trigrec->Id()));
133 pointset->SetMarkerStyle(28);
134 pointset->SetMarkerColor(kYellow);
135 pointset->SetMarkerSize(3);
137 for (int i = 11; i <= 14; ++i)
139 if (trigrec->Hit(i) == TVector3(0,0,0)) continue;
140 pointset->SetPoint(ipnt, trigrec->Hit(i).X(), trigrec->Hit(i).Y(), trigrec->Hit(i).Z());
144 list->AddElement(pointset);
148 void FillData(TEveElementList* list, const AliHLTMUONMansoTrack* track)
150 // Count the points in the track.
151 Int_t pointCount = 0;
152 for (int i = 7; i <= 10; ++i)
154 const AliHLTMUONRecHit* hit = track->Hit(i);
155 if (hit != NULL) ++pointCount;
157 const AliHLTMUONTriggerRecord* trigrec = track->TriggerRecord();
160 for (int i = 11; i <= 14; ++i)
162 if (trigrec->Hit(i) != TVector3(0,0,0)) ++pointCount;
166 // Create and fill the point set for the track.
167 TEvePointSet* pointset = new TEvePointSet(pointCount);
168 pointset->SetName(Form("Track%d", track->Id()));
169 pointset->SetTitle(Form("dHLT track ID = %d", track->Id()));
170 if (track->Id() != -1)
172 pointset->SetMarkerStyle(20);
173 pointset->SetMarkerColor(kGreen);
174 pointset->SetMarkerSize(1.5);
178 pointset->SetMarkerStyle(28);
179 pointset->SetMarkerColor(kYellow);
180 pointset->SetMarkerSize(3);
185 for (int i = 11; i <= 14; ++i)
187 if (trigrec->Hit(i) == TVector3(0,0,0)) continue;
188 pointset->SetPoint(ipnt, trigrec->Hit(i).X(), trigrec->Hit(i).Y(), trigrec->Hit(i).Z());
192 for (int j = 7; j <= 10; ++j)
194 const AliHLTMUONRecHit* hit = track->Hit(j);
195 if (hit == NULL) continue;
196 pointset->SetPoint(ipnt, hit->X(), hit->Y(), hit->Z());
200 for (int j = 7; j <= 10; ++j)
202 if (track->RoIRadius(j) == -1) continue;
203 TEveStraightLineSet* roi = new TEveStraightLineSet(
205 Form("Region of interest for chamber %d", j)
207 Float_t p0x = track->RoICentre(j).X() + track->RoIRadius(j);
208 Float_t p0y = track->RoICentre(j).Y();
209 Float_t p0z = track->RoICentre(j).Z();
213 for (int i = 0; i < 32; ++i)
215 Double_t t = Double_t(i) / 32. * 2. * TMath::Pi();
216 Float_t p2x = track->RoICentre(j).X() + track->RoIRadius(j)*cos(t);
217 Float_t p2y = track->RoICentre(j).Y() + track->RoIRadius(j)*sin(t);
218 Float_t p2z = track->RoICentre(j).Z();
219 roi->AddLine(p1x, p1y, p1z, p2x, p2y, p2z);
224 roi->AddLine(p1x, p1y, p1z, p0x, p0y, p0z);
225 pointset->AddElement(roi);
228 list->AddElement(pointset);
232 void FillData(Int_t eventId)
234 AliHLTMUONEvent* dhltEvent = dynamic_cast<AliHLTMUONEvent*>( gDHLTFile->Get(Form("AliHLTMUONEvent;%d", eventId+1)) );
235 if (dhltEvent == NULL)
237 cerr << "ERROR: Could not find dHLT data for event " << eventId << endl;
241 TEveElementList* list = new TEveElementList("dHLTData", "dHLT data");
242 gEve->AddElement(list);
245 for (int i = 0; i < dhltEvent->DataObjects().GetEntriesFast(); i++)
247 if (dhltEvent->DataObjects()[i]->IsA() == AliHLTMUONRecHit::Class())
249 const AliHLTMUONRecHit* hit = dynamic_cast<const AliHLTMUONRecHit*>( dhltEvent->DataObjects()[i] );
250 px.Set(px.GetSize()+1);
251 py.Set(py.GetSize()+1);
252 pz.Set(pz.GetSize()+1);
253 px[px.GetSize()-1] = hit->X();
254 py[py.GetSize()-1] = hit->Y();
255 pz[pz.GetSize()-1] = hit->Z();
258 else if (dhltEvent->DataObjects()[i]->IsA() == AliHLTMUONTriggerRecord::Class())
260 const AliHLTMUONTriggerRecord* trigrec = dynamic_cast<const AliHLTMUONTriggerRecord*>( dhltEvent->DataObjects()[i] );
261 FillData(list, trigrec);
263 else if (dhltEvent->DataObjects()[i]->IsA() == AliHLTMUONMansoTrack::Class())
265 const AliHLTMUONMansoTrack* track = dynamic_cast<const AliHLTMUONMansoTrack*>( dhltEvent->DataObjects()[i] );
266 FillData(list, track);
270 TEvePointSet* mps = new TEvePointSet(px.GetSize());
271 mps->SetName("RecHits");
272 mps->SetTitle("dHLT reconstructed hits");
273 mps->SetMarkerStyle(28);
274 mps->SetMarkerColor(kYellow);
275 mps->SetMarkerSize(3);
276 for (int i = 0; i < px.GetSize(); ++i)
278 mps->SetPoint(i, px[i], py[i], pz[i]);
280 list->AddElement(mps);