]> git.uio.no Git - u/mrichter/AliRoot.git/blob - EVE/alice-macros/primary_vertex.C
SetSeed dummy implementations
[u/mrichter/AliRoot.git] / EVE / alice-macros / primary_vertex.C
1 // $Id$
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          *
7  * full copyright notice.                                                 *
8  **************************************************************************/
9
10 #if !defined(__CINT__) || defined(__MAKECINT__)
11 #include <TEveManager.h>
12 #include <TEveCompound.h>
13 #include <TEveStraightLineSet.h>
14
15 #include <AliESDEvent.h>
16 #include <AliESDVertex.h>
17 #include <AliEveEventManager.h>
18 #endif
19
20 //==============================================================================
21 // Utilities
22 //==============================================================================
23
24 TEveCompound* assert_vertex_parent(const TString& name, Color_t col)
25 {
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.
28
29   TEveCompound* parent = dynamic_cast<TEveCompound*>
30     (AliEveEventManager::GetCurrent()->FindChild(name));
31   if (parent == 0)
32   {
33     parent = new TEveCompound(name);
34     parent->OpenCompound();
35     parent->SetMainColor(col);
36     AliEveEventManager::GetMaster()->AddElement(parent);
37   }
38   return parent;
39 }
40
41
42 //==============================================================================
43 // Functions to make a cross / ellipse / box
44 //==============================================================================
45
46 TEveStraightLineSet*
47 make_vertex_cross(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
48 {
49   Double_t x[3], e[3];
50   v->GetXYZ(x); v->GetSigmaXYZ(e);
51
52   TEveStraightLineSet* ls = new TEveStraightLineSet("Cross");
53   TString title;
54   if (use_sigma)
55   {
56     e[0] *= fx; e[1] *= fy; e[2] *= fz;
57     title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f*sigma_z", fx, fy, fz);
58   }
59   else
60   {
61     e[0] = fx; e[1] = fy; e[2] = fz;
62     title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
63   }
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]);
66   ls->SetTitle(title);
67
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]);
71
72   ls->RefMainTrans().SetPos(x);
73   return ls;
74 }
75
76 TEveStraightLineSet*
77 make_vertex_ellipse(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
78 {
79   Double_t x[3], e[3];
80   v->GetXYZ(x); v->GetSigmaXYZ(e);
81
82   TEveStraightLineSet* ls = new TEveStraightLineSet("Ellipse");
83   TString title;
84   if (use_sigma)
85   {
86     e[0] *= fx; e[1] *= fy; e[2] *= fz;
87     title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f sigma_z", fx, fy, fz);
88   }
89   else
90   {
91     e[0] = fx; e[1] = fy; e[2] = fz;
92     title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
93   }
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]);
96   ls->SetTitle(title);
97
98   const Int_t   N = 32;
99   const Float_t S = 2*TMath::Pi()/N;
100
101   Float_t a = e[0], b = e[1];
102   for (Int_t i = 0; i<N; i++)
103     ls->AddLine(a*TMath::Cos(i*S)  , b*TMath::Sin(i*S)  , 0,
104                 a*TMath::Cos(i*S+S), b*TMath::Sin(i*S+S), 0);
105
106   a = e[0]; b = e[2];
107   for (Int_t i = 0; i<N; i++)
108     ls->AddLine(a*TMath::Cos(i*S)  , 0, b*TMath::Sin(i*S),
109                 a*TMath::Cos(i*S+S), 0, b*TMath::Sin(i*S+S));
110
111   a = e[1]; b = e[2];
112   for (Int_t i = 0; i<N; i++)
113     ls->AddLine(0, a*TMath::Cos(i*S)  ,  b*TMath::Sin(i*S),
114                 0, a*TMath::Cos(i*S+S),  b*TMath::Sin(i*S+S));
115
116   ls->RefMainTrans().SetPos(x);
117   return ls;
118 }
119
120 TEveStraightLineSet*
121 make_vertex_box(const AliESDVertex* v, Bool_t use_sigma, Float_t fx, Float_t fy, Float_t fz)
122 {
123   Double_t x[3], e[3];
124   v->GetXYZ(x); v->GetSigmaXYZ(e);
125
126   TEveStraightLineSet* ls = new TEveStraightLineSet("Box");
127   TString title;
128   if (use_sigma)
129   {
130     e[0] *= fx; e[1] *= fy; e[2] *= fz;
131     title += Form("+- %.1f*sigma_x, %.1f*sigma_y, %.1f*sigma_z", fx, fy, fz);
132   }
133   else
134   {
135     e[0] = fx; e[1] = fy; e[2] = fz;
136     title += Form("+- %.1f cm x %.1f cm x %.1f cm", fx, fy, fz);
137   }
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]);
140   ls->SetTitle(title);
141
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
167 TEveStraightLineSet*
168 primary_vertex(Bool_t use_sigma=kTRUE, Float_t fx=1, Float_t fy=1, Float_t fz=1)
169 {
170   AliESDEvent  *esd = AliEveEventManager::AssertESD();
171   const AliESDVertex *pv  = esd->GetPrimaryVertex();
172   if ( ! pv->GetStatus()) {
173     Info("primary_vertex", "Primary vertex not available.");
174     return 0;
175   }
176
177   TEveStraightLineSet* ls = make_vertex_cross(pv, use_sigma, fx, fy, fz);
178   ls->ApplyVizTag("REC PVTX");
179   assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
180   gEve->Redraw3D();
181   return ls;
182 }
183
184 TEveStraightLineSet*
185 primary_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();
188   const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
189   if ( ! spdv->GetStatus()) {
190     Info("primary_vertex_spd", "Primary vertex SPD not available.");
191     return 0;
192   }
193
194   TEveStraightLineSet* ls = make_vertex_cross(spdv, use_sigma, fx, fy, fz);
195   ls->ApplyVizTag("REC PVTX SPD");
196   assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
197   gEve->Redraw3D();
198   return ls;
199 }
200
201 TEveStraightLineSet*
202 primary_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();
205   const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
206   if ( ! tpcv->GetStatus()) {
207     Info("primary_vertex_tpc", "Primary vertex TPC not available.");
208     return 0;
209   }
210
211   TEveStraightLineSet* ls = make_vertex_cross(tpcv, use_sigma, fx, fy, fz);
212   ls->ApplyVizTag("REC PVTX TPC");
213   assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
214   gEve->Redraw3D();
215   return ls;
216 }
217
218 //------------------------------------------------------------------------------
219 // Ellipse
220 //------------------------------------------------------------------------------
221
222 TEveStraightLineSet*
223 primary_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();
226   const AliESDVertex *pv  = esd->GetPrimaryVertex();
227   if ( ! pv->GetStatus()) {
228     Info("primary_vertex_ellipse", "Primary vertex not available.");
229     return 0;
230   }
231
232   TEveStraightLineSet* ls = make_vertex_ellipse(pv, use_sigma, fx, fy, fz);
233   ls->ApplyVizTag("REC PVTX Ellipse");
234   assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
235   gEve->Redraw3D();
236   return ls;
237 }
238
239 TEveStraightLineSet*
240 primary_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();
243   const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
244   if ( ! spdv->GetStatus()) {
245     Info("primary_vertex_ellipse_spd", "Primary vertex SPD not available.");
246     return 0;
247   }
248
249   TEveStraightLineSet* ls = make_vertex_ellipse(spdv, use_sigma, fx, fy, fz);
250   ls->ApplyVizTag("REC PVTX Ellipse SPD");
251   assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
252   gEve->Redraw3D();
253   return ls;
254 }
255
256 TEveStraightLineSet*
257 primary_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();
260   const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
261   if ( ! tpcv->GetStatus()) {
262     Info("primary_vertex_ellipse_tpc", "Primary vertex TPC not available.");
263     return 0;
264   }
265
266   TEveStraightLineSet* ls = make_vertex_ellipse(tpcv, use_sigma, fx, fy, fz);
267   ls->ApplyVizTag("REC PVTX Ellipse TPC");
268   assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
269   gEve->Redraw3D();
270   return ls;
271 }
272
273 //------------------------------------------------------------------------------
274 // Box
275 //------------------------------------------------------------------------------
276
277 TEveStraightLineSet*
278 primary_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();
281   const AliESDVertex *pv  = esd->GetPrimaryVertex();
282   if ( ! pv->GetStatus()) {
283     Info("primary_vertex_box", "Primary vertex not available.");
284     return 0;
285   }
286
287   TEveStraightLineSet* ls = make_vertex_box(pv, use_sigma, fx, fy, fz);
288   ls->ApplyVizTag("REC PVTX Box");
289   assert_vertex_parent("Primary Vertex", 7)->AddElement(ls);
290   gEve->Redraw3D();
291   return ls;
292 }
293
294 TEveStraightLineSet*
295 primary_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();
298   const AliESDVertex *spdv = esd->GetPrimaryVertexSPD();
299   if ( ! spdv->GetStatus()) {
300     Info("primary_vertex_box_spd", "Primary vertex SPD not available.");
301     return 0;
302   }
303
304   TEveStraightLineSet* ls = make_vertex_box(spdv, use_sigma, fx, fy, fz);
305   ls->ApplyVizTag("REC PVTX Box SPD");
306   assert_vertex_parent("Primary Vertex SPD", 6)->AddElement(ls);
307   gEve->Redraw3D();
308   return ls;
309 }
310
311 TEveStraightLineSet*
312 primary_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();
315   const AliESDVertex *tpcv = esd->GetPrimaryVertexTPC();
316   if ( ! tpcv->GetStatus()) {
317     Info("primary_vertex_box_tpc", "Primary vertex TPC not available.");
318     return 0;
319   }
320
321   TEveStraightLineSet* ls = make_vertex_box(tpcv, use_sigma, fx, fy, fz);
322   ls->ApplyVizTag("REC PVTX Box TPC");
323   assert_vertex_parent("Primary Vertex TPC", 5)->AddElement(ls);
324   gEve->Redraw3D();
325   return ls;
326 }