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