First big commit of the mchview program and its accompanying library,
[u/mrichter/AliRoot.git] / EVE / alice-macros / tpc_clusters.C
CommitLineData
32e219c2 1#ifdef __CINT__
ae1afd97 2
32e219c2 3namespace Reve
4{
5class RenderElement;
6class PointSet;
7}
8
9#else
10
11#include <Reve/Reve.h>
12#include <Reve/ReveManager.h>
13#include <Reve/PointSet.h>
14#include <Alieve/EventAlieve.h>
15
16#include <AliRunLoader.h>
17#include <AliCluster.h>
18#include <TPC/AliTPCClustersRow.h>
19
20#endif
21
22Reve::PointSet* tpc_clusters(Reve::RenderElement* cont=0, Float_t maxR=270)
ae1afd97 23{
24 const Int_t kMaxCl=100*160;
25
26 Alieve::Event::AssertGeometry();
27
28 Reve::PointSet* clusters = new Reve::PointSet(kMaxCl);
29 clusters->SetOwnIds(kTRUE);
30
31 AliRunLoader* rl = Alieve::Event::AssertRunLoader();
32 rl->LoadRecPoints("TPC");
33
34 AliTPCClustersRow *clrow=new AliTPCClustersRow();
35 clrow->SetClass("AliTPCclusterMI");
36 clrow->SetArray(kMaxCl);
37
38 TTree *cTree = rl->GetTreeR("TPC", false);
32e219c2 39 cTree->SetBranchAddress("Segment", &clrow);
ae1afd97 40
41 Float_t maxRsqr = maxR*maxR;
42 TClonesArray *cl=clrow->GetArray();
43 Int_t nentr=(Int_t)cTree->GetEntries();
44 for (Int_t i=0; i<nentr; i++) {
45 if (!cTree->GetEvent(i)) continue;
46
47 Int_t ncl=cl->GetEntriesFast();
48
49 while (ncl--) {
50 AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
51 Float_t g[3]; //global coordinates
52 c->GetGlobalXYZ(g);
53 if (g[0]*g[0]+g[1]*g[1] < maxRsqr)
54 {
55 clusters->SetNextPoint(g[0], g[1], g[2]);
56 AliCluster *atp = new AliCluster(*c);
57 clusters->SetPointId(atp);
58 }
59 }
60 cl->Clear();
61 }
62
63 delete clrow;
64
65 if(clusters->Size() == 0 && gReve->GetKeepEmptyCont() == kFALSE) {
66 Warning("tpc_clusters", "No TPC clusters");
67 delete clusters;
68 return 0;
69 }
70
71 clusters->SetMarkerStyle(2);
72 clusters->SetMarkerSize(0.2);
73 clusters->SetMarkerColor(4);
74
75 char form[1000];
76 sprintf(form,"TPC Clusters");
77 clusters->SetName(form);
78
79 char tip[1000];
80 sprintf(tip,"N=%d", clusters->Size());
81 clusters->SetTitle(tip);
82
83 using namespace Reve;
32e219c2 84 gReve->AddRenderElement(clusters, cont);
ae1afd97 85 gReve->Redraw3D();
86
87 return clusters;
88}