]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/phos_clusters.C
Adding ALICE specific implementation of Eve
[u/mrichter/AliRoot.git] / EVE / alice-macros / phos_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 <TObjArray.h>
12 #include <TBranch.h>
13 #include <TTree.h>
14 #include <TString.h>
15 #include <TEveManager.h>
16 #include <TEveElement.h>
17 #include <TEvePointSet.h>
18
19 #include <AliCluster.h>
20 #include <AliRunLoader.h>
21 #include <AliEveEventManager.h>
22 #endif
23
24 TEvePointSet* phos_clusters(TEveElement* cont=0)
25 {
26   AliEveEventManager::AssertGeometry();
27
28   AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
29   rl->LoadRecPoints("PHOS");
30
31   TTree *cTree = rl->GetTreeR("PHOS", false);
32
33         if(!cTree) return 0;
34
35   TEvePointSet* clusters = new TEvePointSet(10000);
36   clusters->SetOwnIds(kTRUE);
37
38   TObjArray *arr=NULL;
39   TBranch *branch=cTree->GetBranch("PHOSEmcRP");
40   branch->SetAddress(&arr);
41
42   Int_t nentr=(Int_t)branch->GetEntries();
43   for (Int_t i=0; i<nentr; i++) {
44     if (!branch->GetEvent(i)) continue;
45
46     Int_t ncl=arr->GetEntriesFast();
47     while (ncl--) {
48       AliCluster *cl=(AliCluster*)arr->UncheckedAt(ncl);
49
50       Float_t g[3]; //global coordinates
51       cl->GetGlobalXYZ(g);
52
53       AliCluster *atp = new AliCluster(*cl);
54       clusters->SetNextPoint(g[0], g[1], g[2]);
55       clusters->SetPointId(atp);
56     }
57   }
58
59   Warning("phos_clusters"," %d", clusters->Size());
60
61   if(clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
62     Warning("phos_clusters", "No PHOS clusters");
63     delete clusters;
64     return 0;
65   }
66
67   clusters->SetMarkerStyle(2);
68   clusters->SetMarkerSize(0.5);
69   clusters->SetMarkerColor(4);
70
71   clusters->SetName("PHOS Clusters");
72
73   clusters->SetTitle(Form("N=%d", clusters->Size()));
74
75   const TString viz_tag("REC Clusters PHOS");
76
77   clusters->ApplyVizTag(viz_tag, "Clusters");
78
79   gEve->AddElement(clusters);
80
81   gEve->Redraw3D();
82
83   return clusters;
84 }