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