]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/its_clusters.C
From Pawel Debski.
[u/mrichter/AliRoot.git] / EVE / alice-macros / its_clusters.C
CommitLineData
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
32e219c2 9#ifdef __CINT__
d5e9edb3 10
84aff7a4 11class TEveElement;
12class TEvePointSet;
32e219c2 13
14#else
15
84aff7a4 16#include <TEveManager.h>
17#include <TEvePointSet.h>
ea5d9491 18#include <EveBase/AliEveEventManager.h>
32e219c2 19
20#include <AliRunLoader.h>
21#include <AliCluster.h>
22
23#include <TClonesArray.h>
24
25#endif
26
84aff7a4 27TEvePointSet* its_clusters(TEveElement* cont=0, Float_t maxR=50)
d5e9edb3 28{
d810d0de 29 AliEveEventManager::AssertGeometry();
d5e9edb3 30
d810d0de 31 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
d5e9edb3 32 rl->LoadRecPoints("ITS");
33
34 TTree *cTree = rl->GetTreeR("ITS", false);
8ebd7df4 35 if (cTree == 0)
36 return 0;
d5e9edb3 37
32e219c2 38 TClonesArray *cl = NULL;
39 TBranch *branch = cTree->GetBranch("ITSRecPoints");
d5e9edb3 40 branch->SetAddress(&cl);
41
8ebd7df4 42 TEvePointSet* clusters = new TEvePointSet(10000);
43 clusters->SetOwnIds(kTRUE);
44
5f8f3b6b 45 Int_t nentr = (Int_t) cTree->GetEntries();
46 for (Int_t i=0; i<nentr; i++)
47 {
d5e9edb3 48 if (!cTree->GetEvent(i)) continue;
49
5f8f3b6b 50 Int_t ncl = cl->GetEntriesFast();
d5e9edb3 51
ec357b01 52 Float_t maxRsqr = maxR*maxR;
5f8f3b6b 53 for (Int_t icl = 0; icl < ncl; ++icl)
54 {
55 AliCluster *c = (AliCluster*) cl->UncheckedAt(icl);
56 // This really should not happen, but did in online display once.
57 if (c == 0)
58 {
59 ::Warning("its_clusters", "Got NULL AliCluster*, idx=%d, N=%d.",
60 icl, ncl);
61 continue;
62 }
d5e9edb3 63 Float_t g[3]; //global coordinates
64 c->GetGlobalXYZ(g);
5f8f3b6b 65 if (g[0]*g[0] + g[1]*g[1] < maxRsqr)
ec357b01 66 {
67 clusters->SetNextPoint(g[0], g[1], g[2]);
68 AliCluster *atp = new AliCluster(*c);
69 clusters->SetPointId(atp);
70 }
d5e9edb3 71 }
72 }
73
78ab36c2 74 rl->UnloadRecPoints("ITS");
75
84aff7a4 76 if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
8ebd7df4 77 Warning("its_clusters.C", "No ITS clusters");
d5e9edb3 78 delete clusters;
79 return 0;
80 }
81
30650838 82 clusters->SetName("ITS Clusters");
d5e9edb3 83
9dcd42ea 84 clusters->SetTitle(Form("N=%d", clusters->Size()));
f6afd0e1 85
9dcd42ea 86 const TString viz_tag("REC Clusters ITS");
30650838 87
68ca2fe7 88 clusters->ApplyVizTag(viz_tag, "Clusters");
f6afd0e1 89
84aff7a4 90 gEve->AddElement(clusters, cont);
f6afd0e1 91
84aff7a4 92 gEve->Redraw3D();
d5e9edb3 93
94 return clusters;
95}