]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/clusters_from_index.C
mistake - use AliInfoGeneral, not AliInfo
[u/mrichter/AliRoot.git] / EVE / alice-macros / clusters_from_index.C
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9 #if !defined(__CINT__) || defined(__MAKECINT__)
10 #include <TEveManager.h>
11 #include <TEveElement.h>
12 #include <TEvePointSet.h>
13
14 #include <AliESDEvent.h>
15 #include <AliTrackPointArray.h>
16 #include <AliEveEventManager.h>
17 #include <AliEveMultiView.h>
18 #endif
19
20 TEvePointSet* clusters_from_index(Int_t index=0, TEveElement* cont=0)
21 {
22   AliESDEvent* esd = AliEveEventManager::AssertESD();
23
24   if (index < 0) {
25     Warning("clusters_from_index", "index not set.");
26     return 0;
27   }
28
29   if (index >= esd->GetNumberOfTracks()) {
30     Warning("clusters_from_index", "index out of range");
31     return 0;
32   }
33
34   TEvePointSet* clusters = new TEvePointSet(64);
35   clusters->SetOwnIds(kTRUE);
36
37   AliESDtrack* at = esd->GetTrack(index);
38   const AliTrackPointArray* pArr = at->GetTrackPointArray();
39   if (pArr == 0) {
40     Warning("clusters_from_index", "TrackPointArray not stored with ESD track.");
41   }
42   
43   Int_t np =  pArr->GetNPoints();
44   const Float_t* x = pArr->GetX();
45   const Float_t* y = pArr->GetY();
46   const Float_t* z = pArr->GetZ();
47   for (Int_t i=0; i<np; ++i) {
48     clusters->SetNextPoint(x[i], y[i], z[i]);
49     AliTrackPoint *atp = new AliTrackPoint;
50     pArr->GetPoint(*atp, i);
51     clusters->SetPointId(atp);    }
52
53
54   if(clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
55     Warning("clusters_from_index", "No clusters for index '%d'", index);
56     delete clusters;
57     return 0;
58   }
59
60   clusters->SetMarkerStyle(2);
61   clusters->SetMarkerSize(2);
62   clusters->SetMarkerColor(4);
63
64   clusters->SetName(Form("Clusters idx=%d", index));
65   clusters->SetTitle(Form("N=%d", clusters->Size()));
66
67   gEve->AddElement(clusters);
68
69   if (AliEveMultiView::Instance())
70   {
71     AliEveMultiView::Instance()->ImportEventRPhi(clusters);
72     AliEveMultiView::Instance()->ImportEventRhoZ(clusters);
73   }
74
75   gEve->Redraw3D();
76
77   return clusters;
78 }