New macro for visualization of the HMPID clusters (Jouri)
[u/mrichter/AliRoot.git] / EVE / alice-macros / hmpid_clusters.C
1 #ifdef __CINT__
2
3 namespace Reve
4 {
5 class RenderElement;
6 class PointSet;
7 }
8
9 #else
10
11 #include <Reve/Reve.h>
12 #include <Reve/ReveManager.h>
13 #include <Reve/PointSet.h>
14 #include <Alieve/EventAlieve.h>
15
16 #include <AliRunLoader.h>
17 #include <AliCluster3D.h>
18
19 #include <TClonesArray.h>
20
21 #endif
22
23 Reve::PointSet* hmpid_clusters(Reve::RenderElement* cont=0, Float_t maxR=1000)
24 {
25   const Int_t nCh=7;
26   TClonesArray *cl[nCh] = {0,0,0,0,0,0,0};
27   Char_t *name[nCh]={
28     "HMPID0",
29     "HMPID1",
30     "HMPID2",
31     "HMPID3",
32     "HMPID4",
33     "HMPID5",
34     "HMPID6"
35   };
36
37
38   Reve::PointSet* clusters = new Reve::PointSet(10000);
39   clusters->SetOwnIds(kTRUE);
40
41   Alieve::Event::AssertGeometry();
42   
43   AliRunLoader* rl = Alieve::Event::AssertRunLoader();
44   rl->LoadRecPoints("HMPID");
45
46   TTree *cTree = rl->GetTreeR("HMPID", false);
47   if (!cTree) return 0;
48
49   for (Int_t k=0; k<nCh; k++) {
50      TBranch *br=cTree->GetBranch(name[k]);
51      if (!br) return 0;
52      br->SetAddress(&(cl[k]));
53   } 
54
55   if (!cTree->GetEvent(0)) return 0;
56
57
58   for (Int_t i=0; i<nCh; i++) {
59     TClonesArray *arr=cl[i];
60     Int_t ncl=arr->GetEntriesFast();
61
62     Float_t maxRsqr = maxR*maxR;
63     while (ncl--) {
64       AliCluster3D *c=(AliCluster3D*)arr->UncheckedAt(ncl);
65       Float_t g[3]; //global coordinates
66       c->GetGlobalXYZ(g);
67       if (g[0]*g[0]+g[1]*g[1] < maxRsqr)
68       {
69         clusters->SetNextPoint(g[0], g[1], g[2]);
70         AliCluster3D *atp = new AliCluster3D(*c);
71         clusters->SetPointId(atp);
72       }
73     }
74   }
75
76   if(clusters->Size() == 0 && gReve->GetKeepEmptyCont() == kFALSE) {
77     Warning("hmpid_clusters", "No HMPID clusters");
78     delete clusters;
79     return 0;
80   }
81
82   clusters->SetMarkerStyle(2);
83   clusters->SetMarkerSize(0.2);
84   clusters->SetMarkerColor(4);
85
86   char form[1000];
87   sprintf(form,"HMPID Clusters");
88   clusters->SetName(form);
89
90   char tip[1000];
91   sprintf(tip,"N=%d", clusters->Size());
92   clusters->SetTitle(tip);
93
94   using namespace Reve;
95   gReve->AddRenderElement(clusters, cont);
96   gReve->Redraw3D();
97
98   return clusters;
99 }