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