]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/phos_clusters.C
get beam type
[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   TEvePointSet* clusters = new TEvePointSet(10000);
34   clusters->SetOwnIds(kTRUE);
35
36   TObjArray *arr=NULL;
37   TBranch *branch=cTree->GetBranch("PHOSEmcRP");
38   branch->SetAddress(&arr);
39
40   Int_t nentr=(Int_t)branch->GetEntries();
41   for (Int_t i=0; i<nentr; i++) {
42     if (!branch->GetEvent(i)) continue;
43
44     Int_t ncl=arr->GetEntriesFast();
45     while (ncl--) {
46       AliCluster *cl=(AliCluster*)arr->UncheckedAt(ncl);
47
48       Float_t g[3]; //global coordinates
49       cl->GetGlobalXYZ(g);
50
51       AliCluster *atp = new AliCluster(*cl);
52       clusters->SetNextPoint(g[0], g[1], g[2]);
53       clusters->SetPointId(atp);
54     }
55   }
56
57   Warning("phos_clusters"," %d", clusters->Size());
58
59   if(clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
60     Warning("phos_clusters", "No PHOS clusters");
61     delete clusters;
62     return 0;
63   }
64
65   clusters->SetMarkerStyle(2);
66   clusters->SetMarkerSize(0.5);
67   clusters->SetMarkerColor(4);
68
69   clusters->SetName("PHOS Clusters");
70
71   clusters->SetTitle(Form("N=%d", clusters->Size()));
72
73   const TString viz_tag("REC Clusters PHOS");
74
75   clusters->ApplyVizTag(viz_tag, "Clusters");
76
77   gEve->AddElement(clusters);
78
79   gEve->Redraw3D();
80
81   return clusters;
82 }