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