]> git.uio.no Git - u/mrichter/AliRoot.git/blame - EVE/alice-macros/tof_clusters.C
Bug fixed into equipmentID-volume correspondence
[u/mrichter/AliRoot.git] / EVE / alice-macros / tof_clusters.C
CommitLineData
455b87be 1// Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
2
3/**************************************************************************
4 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
5 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
6 * full copyright notice. *
7 **************************************************************************/
455b87be 8#ifdef __CINT__
9
a172375c 10class TEveElement;
11class TEvePointSet;
455b87be 12
13#else
14
a172375c 15#include <TEveManager.h>
16#include <TEvePointSet.h>
17#include <EveBase/AliEveEventManager.h>
455b87be 18
19#include <AliRunLoader.h>
20#include <AliCluster.h>
21
455b87be 22#endif
23
24TEvePointSet* tof_clusters(TEveElement* cont=0, Float_t maxR=390)
25{
455b87be 26 AliEveEventManager::AssertGeometry();
27
28 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
29 rl->LoadRecPoints("TOF");
30
31 TTree *cTree = rl->GetTreeR("TOF", false);
a172375c 32 if (cTree == 0)
33 return 0;
455b87be 34
02000333 35 TObjArray *cl = 0x0;
36 cTree->SetBranchAddress("TOF", &cl);
455b87be 37
a172375c 38 TEvePointSet* clusters = new TEvePointSet(10000);
39 clusters->SetOwnIds(kTRUE);
40
02000333 41 Float_t maxRsqr = maxR*maxR;
42
455b87be 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 cout<<" ncl = "<<ncl<<endl;
455b87be 49 while (ncl--) {
455b87be 50 AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
455b87be 51 Float_t g[3]; //global coordinates
52 c->GetGlobalXYZ(g);
02000333 53
54 if (g[0]*g[0]+g[1]*g[1] < maxRsqr) {
455b87be 55 clusters->SetNextPoint(g[0], g[1], g[2]);
56 AliCluster *atp = new AliCluster(*c);
455b87be 57 clusters->SetPointId(atp);
a172375c 58 }
02000333 59
60 }
61 }
62
63 if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
64 Warning("tof_clusters.C", "No TOF clusters");
65 delete clusters;
66 return 0;
67 }
68
69 clusters->SetMarkerStyle(2);
70 clusters->SetMarkerSize(0.2);
71 clusters->SetMarkerColor(4);
72
73 char form[1000];
74 sprintf(form,"TOF Clusters");
75 clusters->SetName(form);
76
77 char tip[1000];
78 sprintf(tip,"N=%d", clusters->Size());
79 clusters->SetTitle(tip);
80 gEve->AddElement(clusters, cont);
81 gEve->Redraw3D();
82
83 return clusters;
84}
85
86TEvePointSet* tof_clusters(Int_t selectedSector=-1,
87 TEveElement* cont=0, Float_t maxR=390)
88{
89 AliEveEventManager::AssertGeometry();
90
91 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
92 rl->LoadRecPoints("TOF");
93
94 TTree *cTree = rl->GetTreeR("TOF", false);
95 if (cTree == 0)
96 return 0;
97
98 TObjArray *cl = 0x0;
99 cTree->SetBranchAddress("TOF", &cl);
100
101 TEvePointSet* clusters = new TEvePointSet(10000);
102 clusters->SetOwnIds(kTRUE);
103
104 Float_t maxRsqr = maxR*maxR;
105 Double_t phiAngle = maxR*maxR;
106
107 Int_t nentr=(Int_t)cTree->GetEntries();
108 for (Int_t i=0; i<nentr; i++) {
109 if (!cTree->GetEvent(i)) continue;
110
111 Int_t ncl=cl->GetEntriesFast();
112 cout<<" ncl = "<<ncl<<endl;
113 while (ncl--) {
114 AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
115 Float_t g[3]; //global coordinates
116 c->GetGlobalXYZ(g);
117
118 phiAngle = 180./TMath::Pi()*(TMath::ATan2(-g[1],-g[0])+TMath::Pi());
119
120 if (g[0]*g[0]+g[1]*g[1] < maxRsqr) {
121 if (
122 (selectedSector!=-1 &&
123 phiAngle>=selectedSector*20. && phiAngle<(selectedSector+1)*20.)
124 ||
125 selectedSector==-1)
126 {
127 clusters->SetNextPoint(g[0], g[1], g[2]);
128 AliCluster *atp = new AliCluster(*c);
129 clusters->SetPointId(atp);
130 }
131 }
132
455b87be 133 }
134 }
135
a172375c 136 if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
137 Warning("tof_clusters.C", "No TOF clusters");
455b87be 138 delete clusters;
139 return 0;
140 }
141
142 clusters->SetMarkerStyle(2);
143 clusters->SetMarkerSize(0.2);
144 clusters->SetMarkerColor(4);
145
146 char form[1000];
147 sprintf(form,"TOF Clusters");
148 clusters->SetName(form);
149
150 char tip[1000];
151 sprintf(tip,"N=%d", clusters->Size());
152 clusters->SetTitle(tip);
455b87be 153 gEve->AddElement(clusters, cont);
154 gEve->Redraw3D();
155
156 return clusters;
157}