2 // Main authors: Adam Jacholkowski & Matevz Tadel: 2009
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 **************************************************************************/
12 #include <TGLViewer.h>
13 #include <TGLCameraOverlay.h>
15 #include <TEveManager.h>
16 #include <TEveBrowser.h>
17 #include <TEveViewer.h>
18 #include <TEveScene.h>
19 #include <TEvePointSet.h>
21 #include <EveBase/AliEveEventManager.h>
23 #include <AliESDEvent.h>
24 #include <AliESDVertex.h>
26 #include <AliRunLoader.h>
27 #include <AliCluster.h>
28 #include <TPC/AliTPCClustersRow.h>
32 TEveViewer *gVPTPCView = 0;
33 TEveScene *gVPTPCScene = 0;
35 TEvePointSet* vplot_tpc(TEveElement* cont=0, Float_t maxR=270)
39 TEveWindowSlot *slot = 0;
40 TEveBrowser *browser = gEve->GetBrowser();
42 slot = TEveWindow::CreateWindowInTab(browser->GetTabRight());
44 gVPTPCView = gEve->SpawnNewViewer("V-Plot", "");
45 gVPTPCScene = gEve->SpawnNewScene("V-Plot", "Scene holding elements for the V-Plot TPC.");
46 gVPTPCView->AddScene(gVPTPCScene);
48 TGLViewer *glv = gVPTPCView->GetGLViewer();
49 glv->SetCurrentCamera(TGLViewer::kCameraOrthoXOY);
50 glv->ResetCamerasAfterNextUpdate();
52 TGLCameraOverlay* co = glv->GetCameraOverlay();
53 co->SetShowOrthographic(true); //(false);
54 co->SetOrthographicMode(TGLCameraOverlay::kAxis); // ::kPlaneIntersect or ::kBar
57 const Int_t kMaxCl=100*160;
59 AliEveEventManager::AssertGeometry();
61 Double_t pvert[3] = { 0, 0, 0 };
62 if (AliEveEventManager::HasESD())
64 AliESDEvent *esd = AliEveEventManager::AssertESD();
65 const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
66 if (tpcv->GetStatus())
69 Info("vplot_tpc", "Primary vertex TPC not available, using 0.");
73 Info("vplot_tpc", "ESD not available, using 0 for primary vertex.");
76 AliRunLoader* rl = AliEveEventManager::AssertRunLoader();
77 rl->LoadRecPoints("TPC");
79 TTree *cTree = rl->GetTreeR("TPC", false);
83 AliTPCClustersRow *clrow = new AliTPCClustersRow();
84 clrow->SetClass("AliTPCclusterMI");
85 clrow->SetArray(kMaxCl);
86 cTree->SetBranchAddress("Segment", &clrow);
88 TEvePointSet* vplot = new TEvePointSet(kMaxCl);
89 vplot->SetOwnIds(kTRUE);
91 const Float_t phimin = -3.15;
92 const Float_t phimax = 3.15;
93 const Float_t etamin = -1.2;
94 const Float_t etamax = 1.2;
95 const Float_t vconst = 0.0003;
97 Float_t rhomax = 246.6;
98 Float_t rholim, rhoup;
100 Float_t rho, eta, phi, theta;
101 Float_t r3d, r3dmax, r3d1, r3d2;
103 Float_t maxRsqr = maxR*maxR;
105 Int_t nentr = (Int_t) cTree->GetEntries();
106 for (Int_t i = 0; i < nentr; ++i)
108 if (!cTree->GetEvent(i)) continue;
110 TClonesArray *cl = clrow->GetArray();
111 Int_t ncl = cl->GetEntriesFast();
115 AliCluster *c = (AliCluster*) cl->UncheckedAt(ncl);
116 Float_t g[3]; //global coordinates
121 if (g[0]*g[0] + g[1]*g[1] < maxRsqr)
123 phi = TMath::ATan2(g[1], g[0]);
124 rho = TMath::Sqrt(g[0]*g[0] + g[1]*g[1]);
125 theta = TMath::ATan2(rho, g[2]);
126 eta = -1.0*TMath::Log(TMath::Tan(0.5*theta));
127 rhoup = zmax*rho / TMath::Abs(g[2]);
128 rholim = TMath::Min(rhoup,rhomax);
129 // a version using rather r3d
130 r3d = TMath::Sqrt(rho*rho + g[2]*g[2]);
131 r3d1 = rhomax / TMath::Sin(theta);
132 r3d2 = TMath::Abs(zmax/TMath::Cos(theta));
133 r3dmax = TMath::Min(r3d1, r3d2);
135 if (eta>etamin && eta<etamax && phi>phimin && phi<phimax)
137 Float_t deta = vconst*(r3dmax - r3d);
139 vplot->SetNextPoint(eta + deta, phi, 0);
140 vplot->SetNextPoint(eta - deta, phi, 0);
149 rl->UnloadRecPoints("TPC");
151 if (vplot->Size() == 0 && gEve->GetKeepEmptyCont() == kFALSE)
153 Warning("vplot_tpc.C", "No TPC clusters were found.");
158 vplot->SetName("V=Plot TPC");
159 vplot->SetTitle(Form("N=%d", vplot->Size() / 2));
161 vplot->SetMainColor (kOrange);
162 vplot->SetMarkerSize(0.2);
163 vplot->SetMarkerStyle(1);
164 // vplot->ApplyVizTag("V-Plot TPC", "V-Plot");
168 cont->AddElement(vplot);
172 gVPTPCScene->AddElement(vplot);
174 AliEveEventManager::RegisterTransient(vplot);