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