]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/its_clusters.C
- rename macro to display TRD digits
[u/mrichter/AliRoot.git] / EVE / alice-macros / its_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 #ifdef __CINT__
10
11 class TEveElement;
12 class TEvePointSet;
13
14 #else
15
16 #include <TEveManager.h>
17 #include <TEvePointSet.h>
18 #include <EveBase/AliEveEventManager.h>
19
20 #include <AliRunLoader.h>
21 #include <AliCluster.h>
22
23 #include <TClonesArray.h>
24
25 #endif
26
27 TEvePointSet* its_clusters(TEveElement* cont=0, Float_t maxR=50)
28 {
29   AliEveEventManager::AssertGeometry();
30
31   AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
32   rl->LoadRecPoints("ITS");
33
34   TTree *cTree = rl->GetTreeR("ITS", false);
35   if (cTree == 0)
36     return 0;
37
38   TClonesArray *cl = NULL;
39   TBranch *branch  = cTree->GetBranch("ITSRecPoints");
40   branch->SetAddress(&cl);
41
42   TEvePointSet* clusters = new TEvePointSet(10000);
43   clusters->SetOwnIds(kTRUE);
44
45   Int_t nentr = (Int_t) cTree->GetEntries();
46   for (Int_t i=0; i<nentr; i++)
47   {
48     if (!cTree->GetEvent(i)) continue;
49
50     Int_t ncl = cl->GetEntriesFast();
51
52     Float_t maxRsqr = maxR*maxR;
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       }
63       Float_t g[3]; //global coordinates
64       c->GetGlobalXYZ(g);
65       if (g[0]*g[0] + g[1]*g[1] < maxRsqr)
66       {
67         clusters->SetNextPoint(g[0], g[1], g[2]);
68         AliCluster *atp = new AliCluster(*c);
69         clusters->SetPointId(atp);
70       }
71     }
72   }
73
74   rl->UnloadRecPoints("ITS");
75
76   if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
77     Warning("its_clusters.C", "No ITS clusters");
78     delete clusters;
79     return 0;
80   }
81
82   clusters->SetName("ITS Clusters");
83
84   clusters->SetTitle(Form("N=%d", clusters->Size()));
85
86   const TString viz_tag("REC Clusters ITS");
87
88   clusters->ApplyVizTag(viz_tag, "Clusters");
89
90   gEve->AddElement(clusters, cont);
91
92   gEve->Redraw3D();
93
94   return clusters;
95 }