Geometry for MFT (Brigitte)
[u/mrichter/AliRoot.git] / EVE / alice-macros / primary_vertex.C
CommitLineData
84aff7a4 1// $Id$
d810d0de 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 *
51346b82 7 * full copyright notice. *
d810d0de 8 **************************************************************************/
3c1a4392 9
15c12442 10#if !defined(__CINT__) || defined(__MAKECINT__)
11#include <TEveManager.h>
12#include <TEveCompound.h>
13#include <TEveStraightLineSet.h>
14
6c49a8e1 15#include <AliESDEvent.h>
16#include <AliESDVertex.h>
17#include <AliEveEventManager.h>
15c12442 18#endif
c37f91e9 19
ad5abc55 20//==============================================================================
21// Utilities
22//==============================================================================
c37f91e9 23
ad5abc55 24TEveCompound* assert_vertex_parent(const TString& name, Color_t col)
3c1a4392 25{
ad5abc55 26 // !!! TEveCompound should have viz-db support ... add in root, then fix here,
27 // that is, remove the color var and pass viz-db tag.
3c1a4392 28
4d62585e 29 TEveCompound* parent = dynamic_cast<TEveCompound*>
30 (AliEveEventManager::GetCurrent()->FindChild(name));
ad5abc55 31 if (parent == 0)
32 {
33 parent = new TEveCompound(name);
34 parent->OpenCompound();
35 parent->SetMainColor(col);
4d62585e 36 AliEveEventManager::GetMaster()->AddElement(parent);
3c1a4392 37 }
ad5abc55 38 return parent;
3c1a4392 39}
32e219c2 40
32e219c2 41
ad5abc55 42//==============================================================================
43// Functions to make a cross / ellipse / box
44//==============================================================================
45
46TEveStraightLineSet*
15c12442 47make_vertex_cross(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
51346b82 48{
32e219c2 49 Double_t x[3], e[3];
50 v->GetXYZ(x); v->GetSigmaXYZ(e);
32e219c2 51
ad5abc55 52 TEveStraightLineSet* ls = new TEveStraightLineSet("Cross");
b1916ff9 53 TString title;
ad5abc55 54 if (use_sigma)
55 {
56 e[0] *= fx; e[1] *= fy; e[2] *= fz;
b1916ff9 57 title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f*sigma_z", fx, fy, fz);
ad5abc55 58 }
59 else
60 {
61 e[0] = fx; e[1] = fy; e[2] = fz;
b1916ff9 62 title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
ad5abc55 63 }
b1916ff9 64 title += Form("\nx=%.5f, y=%.5f, z=%.5f\nsx=%.5f, sy=%.5f, sz=%.5f",
65 x[0], x[1], x[2], e[0], e[1], e[2]);
8661a211 66 ls->SetTitle(title);
b1916ff9 67
2be943d0 68 ls->AddLine(e[0], 0, 0, -e[0], 0, 0);
69 ls->AddLine(0, e[1], 0, 0, -e[1], 0);
70 ls->AddLine(0, 0, e[2], 0, 0, -e[2]);
32e219c2 71
a15e6d7d 72 ls->RefMainTrans().SetPos(x);
51346b82 73 return ls;
32e219c2 74}
75
ad5abc55 76TEveStraightLineSet*
15c12442 77make_vertex_ellipse(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
32e219c2 78{
32e219c2 79 Double_t x[3], e[3];
80 v->GetXYZ(x); v->GetSigmaXYZ(e);
81
ad5abc55 82 TEveStraightLineSet* ls = new TEveStraightLineSet("Ellipse");
b1916ff9 83 TString title;
ad5abc55 84 if (use_sigma)
32e219c2 85 {
ad5abc55 86 e[0] *= fx; e[1] *= fy; e[2] *= fz;
b1916ff9 87 title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f sigma_z", fx, fy, fz);
32e219c2 88 }
89 else
90 {
ad5abc55 91 e[0] = fx; e[1] = fy; e[2] = fz;
b1916ff9 92 title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
32e219c2 93 }
b1916ff9 94 title += Form("\nx=%.5f, y=%.5f, z=%.5f\nsx=%.5f, sy=%.5f, sz=%.5f",
95 x[0], x[1], x[2], e[0], e[1], e[2]);
8661a211 96 ls->SetTitle(title);
2be943d0 97
ad5abc55 98 const Int_t N = 32;
99 const Float_t S = 2*TMath::Pi()/N;
32e219c2 100
ad5abc55 101 Float_t a = e[0], b = e[1];
84aff7a4 102 for (Int_t i = 0; i<N; i++)
51346b82 103 ls->AddLine(a*TMath::Cos(i*S) , b*TMath::Sin(i*S) , 0,
32e219c2 104 a*TMath::Cos(i*S+S), b*TMath::Sin(i*S+S), 0);
105
106 a = e[0]; b = e[2];
84aff7a4 107 for (Int_t i = 0; i<N; i++)
51346b82 108 ls->AddLine(a*TMath::Cos(i*S) , 0, b*TMath::Sin(i*S),
32e219c2 109 a*TMath::Cos(i*S+S), 0, b*TMath::Sin(i*S+S));
110
111 a = e[1]; b = e[2];
84aff7a4 112 for (Int_t i = 0; i<N; i++)
51346b82 113 ls->AddLine(0, a*TMath::Cos(i*S) , b*TMath::Sin(i*S),
32e219c2 114 0, a*TMath::Cos(i*S+S), b*TMath::Sin(i*S+S));
ad5abc55 115
116 ls->RefMainTrans().SetPos(x);
117 return ls;
32e219c2 118}
119
ad5abc55 120TEveStraightLineSet*
15c12442 121make_vertex_box(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
51346b82 122{
ad5abc55 123 Double_t x[3], e[3];
124 v->GetXYZ(x); v->GetSigmaXYZ(e);
32e219c2 125
ad5abc55 126 TEveStraightLineSet* ls = new TEveStraightLineSet("Box");
b1916ff9 127 TString title;
ad5abc55 128 if (use_sigma)
129 {
130 e[0] *= fx; e[1] *= fy; e[2] *= fz;
b1916ff9 131 title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f*sigma_z", fx, fy, fz);
ad5abc55 132 }
133 else
32e219c2 134 {
ad5abc55 135 e[0] = fx; e[1] = fy; e[2] = fz;
b1916ff9 136 title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
32e219c2 137 }
b1916ff9 138 title += Form("\nx=%.5f, y=%.5f, z=%.5f\nsx=%.5f, sy=%.5f, sz=%.5f",
139 x[0], x[1], x[2], e[0], e[1], e[2]);
8661a211 140 ls->SetTitle(title);
b1916ff9 141
ad5abc55 142 // pos z
143 ls->AddLine( e[0], e[1], e[2], e[0], -e[1], e[2]);
144 ls->AddLine( e[0], -e[1], e[2], -e[0], -e[1], e[2]);
145 ls->AddLine(-e[0], -e[1], e[2], -e[0], e[1], e[2]);
146 ls->AddLine(-e[0], e[1], e[2], e[0], e[1], e[2]);
147 // lines along z
148 ls->AddLine( e[0], e[1], e[2], e[0], e[1], -e[2]);
149 ls->AddLine( e[0], -e[1], e[2], e[0], -e[1], -e[2]);
150 ls->AddLine(-e[0], -e[1], e[2], -e[0], -e[1], -e[2]);
151 ls->AddLine(-e[0], e[1], e[2], -e[0], e[1], -e[2]);
152 // neg z
153 ls->AddLine( e[0], e[1], -e[2], e[0], -e[1], -e[2]);
154 ls->AddLine( e[0], -e[1], -e[2], -e[0], -e[1], -e[2]);
155 ls->AddLine(-e[0], -e[1], -e[2], -e[0], e[1], -e[2]);
156 ls->AddLine(-e[0], e[1], -e[2], e[0], e[1], -e[2]);
157
158 ls->RefMainTrans().SetPos(x);
159 return ls;
160}
161
162
163//==============================================================================
164// Element making functions
165//==============================================================================
166
167TEveStraightLineSet*
168primary_vertex(Bool_t use_sigma=kTRUE, Float_t fx=1, Float_t fy=1, Float_t fz=1)
169{
170 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 171 const AliESDVertex *pv = esd->GetPrimaryVertex();
b3b7b8d3 172 if ( ! pv->GetStatus()) {
173 Info("primary_vertex", "Primary vertex not available.");
174 return 0;
175 }
ad5abc55 176
177 TEveStraightLineSet* ls = make_vertex_cross(pv, use_sigma, fx, fy, fz);
3aff0c2e 178 ls->ApplyVizTag("REC PVTX");
ad5abc55 179 assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
180 gEve->Redraw3D();
181 return ls;
182}
183
184TEveStraightLineSet*
185primary_vertex_spd(Bool_t use_sigma=kTRUE, Float_t fx=1, Float_t fy=1, Float_t fz=1)
186{
187 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 188 const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
b3b7b8d3 189 if ( ! spdv->GetStatus()) {
190 Info("primary_vertex_spd", "Primary vertex SPD not available.");
191 return 0;
192 }
ad5abc55 193
194 TEveStraightLineSet* ls = make_vertex_cross(spdv, use_sigma, fx, fy, fz);
3aff0c2e 195 ls->ApplyVizTag("REC PVTX SPD");
ad5abc55 196 assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
197 gEve->Redraw3D();
198 return ls;
199}
200
201TEveStraightLineSet*
202primary_vertex_tpc(Bool_t use_sigma=kTRUE, Float_t fx=1, Float_t fy=1, Float_t fz=1)
203{
204 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 205 const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
b1916ff9 206 if ( ! tpcv->GetStatus()) {
b3b7b8d3 207 Info("primary_vertex_tpc", "Primary vertex TPC not available.");
208 return 0;
209 }
ad5abc55 210
211 TEveStraightLineSet* ls = make_vertex_cross(tpcv, use_sigma, fx, fy, fz);
3aff0c2e 212 ls->ApplyVizTag("REC PVTX TPC");
ad5abc55 213 assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
214 gEve->Redraw3D();
215 return ls;
216}
217
218//------------------------------------------------------------------------------
219// Ellipse
220//------------------------------------------------------------------------------
221
222TEveStraightLineSet*
223primary_vertex_ellipse(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
224{
225 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 226 const AliESDVertex *pv = esd->GetPrimaryVertex();
b3b7b8d3 227 if ( ! pv->GetStatus()) {
228 Info("primary_vertex_ellipse", "Primary vertex not available.");
229 return 0;
230 }
ad5abc55 231
232 TEveStraightLineSet* ls = make_vertex_ellipse(pv, use_sigma, fx, fy, fz);
3aff0c2e 233 ls->ApplyVizTag("REC PVTX Ellipse");
ad5abc55 234 assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
235 gEve->Redraw3D();
236 return ls;
237}
238
239TEveStraightLineSet*
240primary_vertex_ellipse_spd(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
241{
242 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 243 const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
b3b7b8d3 244 if ( ! spdv->GetStatus()) {
245 Info("primary_vertex_ellipse_spd", "Primary vertex SPD not available.");
246 return 0;
247 }
ad5abc55 248
249 TEveStraightLineSet* ls = make_vertex_ellipse(spdv, use_sigma, fx, fy, fz);
3aff0c2e 250 ls->ApplyVizTag("REC PVTX Ellipse SPD");
ad5abc55 251 assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
252 gEve->Redraw3D();
253 return ls;
254}
255
256TEveStraightLineSet*
257primary_vertex_ellipse_tpc(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
258{
259 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 260 const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
b1916ff9 261 if ( ! tpcv->GetStatus()) {
b3b7b8d3 262 Info("primary_vertex_ellipse_tpc", "Primary vertex TPC not available.");
263 return 0;
264 }
ad5abc55 265
266 TEveStraightLineSet* ls = make_vertex_ellipse(tpcv, use_sigma, fx, fy, fz);
3aff0c2e 267 ls->ApplyVizTag("REC PVTX Ellipse TPC");
ad5abc55 268 assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
269 gEve->Redraw3D();
270 return ls;
271}
272
273//------------------------------------------------------------------------------
274// Box
275//------------------------------------------------------------------------------
276
277TEveStraightLineSet*
278primary_vertex_box(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
279{
280 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 281 const AliESDVertex *pv = esd->GetPrimaryVertex();
b3b7b8d3 282 if ( ! pv->GetStatus()) {
283 Info("primary_vertex_box", "Primary vertex not available.");
284 return 0;
285 }
ad5abc55 286
287 TEveStraightLineSet* ls = make_vertex_box(pv, use_sigma, fx, fy, fz);
3aff0c2e 288 ls->ApplyVizTag("REC PVTX Box");
ad5abc55 289 assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
290 gEve->Redraw3D();
291 return ls;
292}
293
294TEveStraightLineSet*
295primary_vertex_box_spd(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
296{
297 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 298 const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
b3b7b8d3 299 if ( ! spdv->GetStatus()) {
300 Info("primary_vertex_box_spd", "Primary vertex SPD not available.");
301 return 0;
302 }
ad5abc55 303
304 TEveStraightLineSet* ls = make_vertex_box(spdv, use_sigma, fx, fy, fz);
3aff0c2e 305 ls->ApplyVizTag("REC PVTX Box SPD");
ad5abc55 306 assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
307 gEve->Redraw3D();
308 return ls;
309}
310
311TEveStraightLineSet*
312primary_vertex_box_tpc(Bool_t use_sigma=kTRUE, Float_t fx=30, Float_t fy=30, Float_t fz=10)
313{
314 AliESDEvent *esd = AliEveEventManager::AssertESD();
15c12442 315 const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
b1916ff9 316 if ( ! tpcv->GetStatus()) {
b3b7b8d3 317 Info("primary_vertex_box_tpc", "Primary vertex TPC not available.");
318 return 0;
319 }
ad5abc55 320
321 TEveStraightLineSet* ls = make_vertex_box(tpcv, use_sigma, fx, fy, fz);
3aff0c2e 322 ls->ApplyVizTag("REC PVTX Box TPC");
ad5abc55 323 assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
324 gEve->Redraw3D();
325 return ls;
32e219c2 326}