Throw exception if a track does not have a valid index.
[u/mrichter/AliRoot.git] / EVE / alice-macros / clusters_from_index.C
CommitLineData
cdd1f390 1// $Id$
2
3Reve::PointSet* clusters_from_index(Int_t index=0)
4{
5 AliESD* esd = Alieve::Event::AssertESD();
6
0e0a00ee 7 if (index < 0) {
8 Warning("clusters_from_index", "index not set.");
9 return 0;
10 }
11
12 if (index >= esd->GetNumberOfTracks()) {
13 Warning("clusters_from_index", "index out of range");
cdd1f390 14 return 0;
15 }
16
17 Reve::PointSet* clusters = new Reve::PointSet(64);
18 clusters->SetOwnIds(kTRUE);
19
20 AliESDtrack* at = esd->GetTrack(index);
21 const AliTrackPointArray* pArr = at->GetTrackPointArray();
22 if (pArr == 0) {
23 Warning("clusters_from_index", "TrackPointArray not stored with ESD track.");
24 continue;
25 }
26 Int_t np = pArr->GetNPoints();
27 const Float_t* x = pArr->GetX();
28 const Float_t* y = pArr->GetY();
29 const Float_t* z = pArr->GetZ();
30 for (Int_t i=0; i<np; ++i) {
31 clusters->SetNextPoint(x[i], y[i], z[i]);
32 AliTrackPoint *atp = new AliTrackPoint;
33 pArr->GetPoint(*atp, i);
34 clusters->SetPointId(atp); }
35
36 clusters->SetMarkerStyle(2);
37 clusters->SetMarkerSize(0.5);
38 clusters->SetMarkerColor(4);
39
40 //PH The line below is replaced waiting for a fix in Root
41 //PH which permits to use variable siza arguments in CINT
42 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
43 //PH clusters->SetName(Form("Clusters idx=%d", index));
44 char form[1000];
45 sprintf(form,"Clusters idx=%d", index);
46 clusters->SetName(form);
47
48 using namespace Reve;
49 gReve->AddRenderElement(clusters);
50 gReve->Redraw3D();
51
52 return clusters;
53}