Geometry for MFT (Brigitte)
[u/mrichter/AliRoot.git] / EVE / alice-macros / set_momentum_vectors.C
CommitLineData
76dc7e0e 1/**************************************************************************
2 * Copyright(c) 1998-2009, ALICE Experiment at CERN, all rights reserved. *
3 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
4 * full copyright notice. *
5 **************************************************************************/
6
7// Author: Pawel Debski 2010
8
ba978640 9#if !defined(__CINT__) || defined(__MAKECINT__)
10#include <TPolyMarker3D.h>
11#include <TString.h>
12#include <TEveLine.h>
13#include <TEveManager.h>
14#include <TEveEventManager.h>
15#include <TEveElement.h>
16#include <TEveUtil.h>
17
6c49a8e1 18#include <AliESDtrack.h>
19#include <AliEveTrack.h>
20#include <AliEveMultiView.h>
ba978640 21#endif
76dc7e0e 22
23void set_momentum_vectors()
6aafad45 24{
25
ba978640 26 TString str1;
27 TString str2;
6aafad45 28
29 Bool_t draw = kFALSE;
30
31 TEveElement::List_i i = gEve->GetEventScene()->FirstChild()->BeginChildren();
32 TEveElement::List_i j = gEve->GetEventScene()->FirstChild()->EndChildren();
33 TEveElement::List_i k;
34
35 TEveElementList* momentumVectorList = new TEveElementList("Momentum Vectors");
36
37 Double_t maxMomentum = 0;
38 Double_t vectorLength = 600.0;
39
40 Double_t x1 = 0;
41 Double_t y1 = 0;
42 Double_t z1 = 0;
43
44 Double_t x2 = 0;
45 Double_t y2 = 0;
46 Double_t z2 = 0;
47
48 //==============================================
49 // find highest momentum (to normalize)
50 //==============================================
51
52 for(k = i; k != j; k++)
53 {
54 TEveElement* element = (TEveElement*) *k;
55
56 str1 = element->GetElementName();
57
58 if(str1.Contains("Tracks") || str1.Contains("tracks"))
59 {
60
61 TEveElement::List_i m = element->BeginChildren();
62 TEveElement::List_i n = element->EndChildren();
63 TEveElement::List_i l;
64
65 for(l = m; l != n; l++)
66 {
67 TEveElement* trackType = (TEveElement*) *l;
68 str2 = trackType->GetElementName();
69
70 if(str2.Contains("Sigma < 3"))
71 {
72 if(trackType->HasChildren())
73 {
74
75 TEveElement::List_i x = trackType->BeginChildren();
76 TEveElement::List_i y = trackType->EndChildren();
77 TEveElement::List_i z;
78
79 for(z = x; z != y; z++)
80 {
81
82 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
83
84 if(trackSingle1->GetESDTrack()->P() > maxMomentum)
85 maxMomentum = trackSingle1->GetESDTrack()->P();
86
87 }
88 }
89 }
90
91
92 if(str2.Contains("3 < Sigma < 5"))
93 {
94
95 if(trackType->HasChildren())
96 {
97
98 TEveElement::List_i x = trackType->BeginChildren();
99 TEveElement::List_i y = trackType->EndChildren();
100 TEveElement::List_i z;
101
102 for(z = x; z != y; z++)
103 {
104
105 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
106
107 if(trackSingle1->GetESDTrack()->P() > maxMomentum)
108 maxMomentum = trackSingle1->GetESDTrack()->P();
109
110 }
111 }
112 }
113
114 if(str2.Contains("5 < Sigma"))
115 {
116
117 if(trackType->HasChildren())
118 {
119
120 TEveElement::List_i x = trackType->BeginChildren();
121 TEveElement::List_i y = trackType->EndChildren();
122 TEveElement::List_i z;
123
124 for(z = x; z != y; z++)
125 {
126
127 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
128
129 if(trackSingle1->GetESDTrack()->P() > maxMomentum)
130 maxMomentum = trackSingle1->GetESDTrack()->P();
131
132
133 }
134 }
135 }
136 }
137 }
138 }
139
140 //==============================================
141 // clean the display
142 //==============================================
143/*
144 if(!drawWithTracks)
145
146 for(k = i; k != j; k++)
147 {
148 TEveElement* element = (TEveElement*) *k;
149
150 str1 = element->GetElementName();
151
152 element->SetRnrSelf(kFALSE);
153
154 if(element->HasChildren())
155 element->SetRnrChildren(kFALSE);
156
157 }
158
159 }
160*/
161 //==============================================
162 // draw momentum vectors
163 //==============================================
164
165 if(maxMomentum)
166 vectorLength = vectorLength/maxMomentum;
167// vectorLength = vectorLength/TMath::Log(maxMomentum);
168
169 for(k = i; k != j; k++)
170 {
171 TEveElement* element = (TEveElement*) *k;
172
173 str1 = element->GetElementName();
174
175 if(str1.Contains("Tracks") || str1.Contains("tracks"))
176 {
177
178 TEveElement::List_i m = element->BeginChildren();
179 TEveElement::List_i n = element->EndChildren();
180 TEveElement::List_i l;
181
182 for(l = m; l != n; l++)
183 {
184 TEveElement* trackType = (TEveElement*) *l;
185 str2 = trackType->GetElementName();
186
187 trackType->SetRnrSelf(kFALSE);
188
189 if(trackType->HasChildren())
190 trackType->SetRnrChildren(kFALSE);
191
192 if(str2.Contains("Sigma < 3"))
193 {
194
195 if(trackType->HasChildren())
196 {
197
198 TEveElementList* momentumVectorList1 = new TEveElementList("sigma < 3");
199
200 TEveElement::List_i x = trackType->BeginChildren();
201 TEveElement::List_i y = trackType->EndChildren();
202 TEveElement::List_i z;
203
204 for(z = x; z != y; z++)
205 {
206
207 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
208
209 TEveLine* momentumVector = new TEveLine(TString::Format("Momentum Vector"));
210
211 x1 = trackSingle1->GetESDTrack()->Xv();
212 y1 = trackSingle1->GetESDTrack()->Yv();
213 z1 = trackSingle1->GetESDTrack()->Zv();
214
215 momentumVector->SetPoint(0, x1, y1, z1);
216
217 x2 = x1+vectorLength*trackSingle1->GetESDTrack()->Px();
218 y2 = y1+vectorLength*trackSingle1->GetESDTrack()->Py();
219 z2 = z1+vectorLength*trackSingle1->GetESDTrack()->Pz();
220
221 momentumVector->SetPoint(1, x2, y2, z2);
222
223/*
224 if(trackSingle1->GetESDTrack()->Charge() == -1)
225 momentumVector->SetLineColor(kGreen);
226 else
227 momentumVector->SetLineColor(kRed);
228*/
229 momentumVector->SetLineColor(kRed);
230
231 momentumVector->SetLineWidth(1);
232 momentumVector->SetLineStyle(0);
233 momentumVector->SetTitle(Form("%f GeV/c", trackSingle1->GetESDTrack()->P()));
234
235 momentumVectorList1->AddElement(momentumVector);
236
237 }
238
239// gEve->AddElement(momentumVectorList1);
240 momentumVectorList->AddElement(momentumVectorList1);
241
242 draw = kTRUE;
243
244 }
245 }
246
247
248 if(str2.Contains("3 < Sigma < 5"))
249 {
250
251 if(trackType->HasChildren())
252 {
253
254 TEveElement::List_i x = trackType->BeginChildren();
255 TEveElement::List_i y = trackType->EndChildren();
256 TEveElement::List_i z;
257
258 TEveElementList* momentumVectorList2 = new TEveElementList("3 < sigma < 5");
259
260 for(z = x; z != y; z++)
261 {
262
263 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
264
265 TEveLine* momentumVector = new TEveLine(TString::Format("Momentum Vector"));
266
267 x1 = trackSingle1->GetESDTrack()->Xv();
268 y1 = trackSingle1->GetESDTrack()->Yv();
269 z1 = trackSingle1->GetESDTrack()->Zv();
270
271 momentumVector->SetPoint(0, x1, y1, z1);
272
273 x2 = x1+vectorLength*trackSingle1->GetESDTrack()->Px();
274 y2 = y1+vectorLength*trackSingle1->GetESDTrack()->Py();
275 z2 = z1+vectorLength*trackSingle1->GetESDTrack()->Pz();
276
277 momentumVector->SetPoint(1, x2, y2, z2);
278/*
279 if(trackSingle1->GetESDTrack()->Charge() == -1)
280 momentumVector->SetLineColor(kGreen+2);
281 else
282 momentumVector->SetLineColor(kRed+2);
283*/
284 momentumVector->SetLineColor(kRed+2);
285
286 momentumVector->SetLineWidth(1);
287 momentumVector->SetLineStyle(0);
288 momentumVector->SetTitle(Form("%f GeV/c", trackSingle1->GetESDTrack()->P()));
289
290 momentumVectorList2->AddElement(momentumVector);
291
292 }
293
294// gEve->AddElement(momentumVectorList2);
295 momentumVectorList->AddElement(momentumVectorList2);
296
297 draw = kTRUE;
298
299 }
300 }
301
302 if(str2.Contains("5 < Sigma"))
303 {
304
305 if(trackType->HasChildren())
306 {
307
308 TEveElementList* momentumVectorList3 = new TEveElementList("5 < sigma");
309
310 TEveElement::List_i x = trackType->BeginChildren();
311 TEveElement::List_i y = trackType->EndChildren();
312 TEveElement::List_i z;
313
314 for(z = x; z != y; z++)
315 {
316
317 AliEveTrack* trackSingle1 = dynamic_cast<AliEveTrack*>((TEveElement*) *z);
318
319 TEveLine* momentumVector = new TEveLine(TString::Format("Momentum Vector"));
320
321 x1 = trackSingle1->GetESDTrack()->Xv();
322 y1 = trackSingle1->GetESDTrack()->Yv();
323 z1 = trackSingle1->GetESDTrack()->Zv();
324
325 momentumVector->SetPoint(0, x1, y1, z1);
326
327 x2 = x1+vectorLength*trackSingle1->GetESDTrack()->Px();
328 y2 = y1+vectorLength*trackSingle1->GetESDTrack()->Py();
329 z2 = z1+vectorLength*trackSingle1->GetESDTrack()->Pz();
330
331 momentumVector->SetPoint(1, x2, y2, z2);
332/*
333 if(trackSingle1->GetESDTrack()->Charge() == -1)
334 momentumVector->SetLineColor(kGreen+3);
335 else
336 momentumVector->SetLineColor(kRed+3);
337*/
338 momentumVector->SetLineColor(kRed+3);
339
340 momentumVector->SetLineWidth(1);
341 momentumVector->SetLineStyle(0);
342 momentumVector->SetTitle(Form("%f GeV/c", trackSingle1->GetESDTrack()->P()));
343
344 momentumVectorList3->AddElement(momentumVector);
345
346 }
347
348 //gEve->AddElement(momentumVectorList3);
349 momentumVectorList->AddElement(momentumVectorList3);
350
351 draw = kTRUE;
352
353 }
354 }
355 }
356 }
357 }
358
359 gEve->AddElement(momentumVectorList);
360
361 TEveElement* top = gEve->GetCurrentEvent();
362
363 AliEveMultiView *mv = AliEveMultiView::Instance();
364
365 mv->DestroyEventRPhi();
366 mv->DestroyEventRhoZ();
367
368 mv->ImportEventRPhi(top);
369 mv->ImportEventRhoZ(top);
370
371 gEve->FullRedraw3D(kFALSE, kTRUE);
372
373}