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