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