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