]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/tof_clusters.C
just make it work
[u/mrichter/AliRoot.git] / EVE / alice-macros / tof_clusters.C
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  **************************************************************************/
8 #ifdef __CINT__
9
10 class TEveElement;
11 class TEvePointSet;
12
13 #else
14
15 #include <TEveManager.h>
16 #include <TEvePointSet.h>
17 #include <EveBase/AliEveEventManager.h>
18
19 #include <AliRunLoader.h>
20 #include <AliCluster.h>
21
22 #endif
23
24 TEvePointSet* tof_clusters(TEveElement* cont=0, Float_t maxR=390)
25 {
26   AliEveEventManager::AssertGeometry();
27
28   AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
29   rl->LoadRecPoints("TOF");
30
31   TTree *cTree = rl->GetTreeR("TOF", false);
32   if (cTree == 0)
33     return 0;
34
35   TObjArray *cl = 0x0;
36   cTree->SetBranchAddress("TOF", &cl);
37
38   TEvePointSet* clusters = new TEvePointSet(10000);
39   clusters->SetOwnIds(kTRUE);
40
41   Float_t maxRsqr = maxR*maxR;
42
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     while (ncl--) {
49       AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
50       Float_t g[3]; //global coordinates
51       c->GetGlobalXYZ(g);
52
53       if (g[0]*g[0]+g[1]*g[1] < maxRsqr) {
54         clusters->SetNextPoint(g[0], g[1], g[2]);
55         AliCluster *atp = new AliCluster(*c);
56         clusters->SetPointId(atp);
57       }
58
59     }
60   }
61
62   if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
63     Warning("tof_clusters.C", "No TOF clusters");
64     delete clusters;
65     return 0;
66   }
67
68   char form[1000];
69   sprintf(form,"TOF Clusters");
70   clusters->SetName(form);
71
72   char tip[1000];
73   sprintf(tip,"N=%d", clusters->Size());
74   clusters->SetTitle(tip);
75
76   const TString viz_tag("TOF Clusters");
77   clusters->ApplyVizTag(viz_tag, "Clusters");
78
79   gEve->AddElement(clusters, cont);
80
81   gEve->Redraw3D();
82
83   return clusters;
84 }
85
86 TEvePointSet* tof_clusters_sec(Int_t selectedSector,
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     while (ncl--) {
113       AliCluster *c=(AliCluster*)cl->UncheckedAt(ncl);
114       Float_t g[3]; //global coordinates
115       c->GetGlobalXYZ(g);
116
117       phiAngle = 180./TMath::Pi()*(TMath::ATan2(-g[1],-g[0])+TMath::Pi());
118
119       if (g[0]*g[0]+g[1]*g[1] < maxRsqr) {
120         if (
121             (selectedSector!=-1 &&
122              phiAngle>=selectedSector*20. && phiAngle<(selectedSector+1)*20.)
123             ||
124             selectedSector==-1)
125           {
126             clusters->SetNextPoint(g[0], g[1], g[2]);
127             AliCluster *atp = new AliCluster(*c);
128             clusters->SetPointId(atp);
129           }
130       }
131
132     }
133   }
134
135   if (clusters->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE) {
136     Warning("tof_clusters.C", "No TOF clusters");
137     delete clusters;
138     return 0;
139   }
140
141   char form[1000];
142   sprintf(form,"TOF Clusters");
143   clusters->SetName(form);
144
145   char tip[1000];
146   sprintf(tip,"N=%d", clusters->Size());
147   clusters->SetTitle(tip);
148
149   const TString viz_tag("TOF Clusters");
150   // when going to new root call:
151   // clusters->ApplyVizTag(viz_tag, "Clusters");
152   clusters->ApplyVizTag(viz_tag);
153
154   gEve->AddElement(clusters, cont);
155
156   gEve->Redraw3D();
157
158   return clusters;
159 }