Revert "Another histos for lumi"
[u/mrichter/AliRoot.git] / EVE / alice-macros / esd_tracks.C
CommitLineData
0d644216 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 **************************************************************************/
5a5a1232 9
e9ece5b4 10#if !defined(__CINT__) || defined(__MAKECINT__)
15c12442 11#include <TString.h>
12#include <TSystem.h>
13#include <TROOT.h>
14#include <TMath.h>
15#include <TGListTree.h>
15c12442 16#include <TEveVSDStructs.h>
17#include <TEveManager.h>
18#include <TEveTrackPropagator.h>
19
6c49a8e1 20#include <AliESDtrackCuts.h>
21#include <AliPWG0Helper.h>
22#include <AliESDEvent.h>
23#include <AliESDfriend.h>
24#include <AliESDtrack.h>
25#include <AliESDfriendTrack.h>
26#include <AliExternalTrackParam.h>
27#include <AliEveTrack.h>
28#include <AliEveTrackCounter.h>
29#include <AliEveMagField.h>
30#include <AliEveEventManager.h>
e9ece5b4 31#endif
32
33
29207369 34// Use inner-tpc track params when its refit failed.
35Bool_t g_esd_tracks_use_ip_on_failed_its_refit = kFALSE;
36
6336e5d7 37// Use magnetic-field as retrieved from GRP.
38Bool_t g_esd_tracks_true_field = kTRUE;
39
40// Use Runge-Kutta track stepper.
41Bool_t g_esd_tracks_rk_stepper = kFALSE;
42
43
44//==============================================================================
45
46void esd_track_propagator_setup(TEveTrackPropagator* trkProp,
47 Float_t magF, Float_t maxR)
48{
49 if (g_esd_tracks_true_field)
50 {
51 trkProp->SetMagFieldObj(new AliEveMagField);
52 }
53 else
54 {
55 trkProp->SetMagField(magF);
56 }
57 if (g_esd_tracks_rk_stepper)
58 {
59 trkProp->SetStepper(TEveTrackPropagator::kRungeKutta);
60 }
61 trkProp->SetMaxR(maxR);
62}
63
64//==============================================================================
65
29207369 66TString esd_track_title(AliESDtrack* t)
ad5abc55 67{
68 TString s;
29207369 69
70 Int_t label = t->GetLabel(), index = t->GetID();
71 TString idx(index == kMinInt ? "<undef>" : Form("%d", index));
72 TString lbl(label == kMinInt ? "<undef>" : Form("%d", label));
73
74 Double_t p[3], v[3];
75 t->GetXYZ(v);
76 t->GetPxPyPz(p);
d6962cc4 77 Double_t pt = t->Pt();
78 Double_t ptsig = TMath::Sqrt(t->GetSigma1Pt2());
79 Double_t ptsq = pt*pt;
80 Double_t ptm = pt / (1.0 + pt*ptsig);
81 Double_t ptM = pt / (1.0 - pt*ptsig);
29207369 82
83 s = Form("Index=%s, Label=%s\nChg=%d, Pdg=%d\n"
d6962cc4 84 "pT = %.3f + %.3f - %.3f [%.3f]\n"
85 "P = (%.3f, %.3f, %.3f)\n"
86 "V = (%.3f, %.3f, %.3f)\n",
29207369 87 idx.Data(), lbl.Data(), t->Charge(), 0,
d6962cc4 88 pt, ptM - pt, pt - ptm, ptsig*ptsq,
89 p[0], p[1], p[2],
90 v[0], v[1], v[2]);
29207369 91
ad5abc55 92 Int_t o;
d6962cc4 93 s += "Det (in,out,refit,pid):\n";
ad5abc55 94 o = AliESDtrack::kITSin;
6b7fd3a4 95 s += Form("ITS (%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
ad5abc55 96 o = AliESDtrack::kTPCin;
6b7fd3a4 97 s += Form("TPC(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
ad5abc55 98 o = AliESDtrack::kTRDin;
6b7fd3a4 99 s += Form("TRD(%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
ad5abc55 100 o = AliESDtrack::kTOFin;
6b7fd3a4 101 s += Form("TOF(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3));
ad5abc55 102 o = AliESDtrack::kHMPIDout;
6b7fd3a4 103 s += Form("HMPID(out=%d,pid=%d)\n", t->IsOn(o), t->IsOn(o<<1));
ad5abc55 104 s += Form("ESD pid=%d", t->IsOn(AliESDtrack::kESDpid));
86f12f78 105
29207369 106 if (t->IsOn(AliESDtrack::kESDpid))
107 {
108 Double_t pid[5];
109 t->GetESDpid(pid);
110 s += Form("\n[%.2f %.2f %.2f %.2f %.2f]", pid[0], pid[1], pid[2], pid[3], pid[4]);
111 }
51346b82 112
29207369 113 return s;
86f12f78 114}
115
6336e5d7 116//==============================================================================
117
e9ece5b4 118void esd_track_add_param(AliEveTrack* track, const AliExternalTrackParam* tp)
c222eb1d 119{
29207369 120 // Add additional track parameters as a path-mark to track.
121
c222eb1d 122 if (tp == 0)
123 return;
124
29207369 125 Double_t pbuf[3], vbuf[3];
c222eb1d 126 tp->GetXYZ(vbuf);
127 tp->GetPxPyPz(pbuf);
128
a15e6d7d 129 TEvePathMark pm(TEvePathMark::kReference);
130 pm.fV.Set(vbuf);
131 pm.fP.Set(pbuf);
c222eb1d 132 track->AddPathMark(pm);
133}
134
6336e5d7 135//==============================================================================
136
8e37954c 137AliEveTrack* esd_make_track_TPC(AliESDtrack *at, AliESDfriendTrack* aft, TEveTrackList* cont)
138{
139 // Make a TPC track representation and put it into given container.
140
141 AliEveTrack* track = new AliEveTrack(at, cont->GetPropagator());
142 track->SetAttLineAttMarker(cont);
143 track->SetName(Form("AliEveTrack %d", at->GetID()));
144 track->SetElementTitle(esd_track_title(at));
145 track->SetSourceObject(at);
146
147 // Add inner/outer track parameters as start point and pathmark.
148 if (at->GetInnerParam()) track->SetStartParams(at->GetInnerParam());
149 else return NULL;
150 if (aft->GetTPCOut()) esd_track_add_param(track, aft->GetTPCOut());
151 else return NULL;
152
153 return track;
154}
155
7b4a06f8 156AliEveTrack* esd_make_track_ITS_standalone(AliESDtrack *at, AliESDfriendTrack* aft, TEveTrackList* cont)
157{
158 // Make a ITS standalone track representation and put it into given container.
159
160 if ( !(!at->IsOn(AliESDtrack::kTPCin) &&
161 at->IsOn(AliESDtrack::kITSout)) ) return NULL; //only ITS standalone
162 AliEveTrack* track = new AliEveTrack(at, cont->GetPropagator());
163 track->SetAttLineAttMarker(cont);
164 track->SetName(Form("AliEveTrack %d", at->GetID()));
165 track->SetElementTitle(esd_track_title(at));
166 track->SetSourceObject(at);
167
168 // Add inner/outer track parameters as path-marks.
169 if (aft->GetITSOut())
170 {
171 esd_track_add_param(track, aft->GetITSOut());
172 }
173 else return NULL;
174
175 return track;
176}
177
8e37954c 178AliEveTrack* esd_make_track_ITS(AliESDtrack *at, AliESDfriendTrack* aft, TEveTrackList* cont)
179{
180 // Make a ITS track representation and put it into given container.
181
7b4a06f8 182 if ( (!at->IsOn(AliESDtrack::kTPCin) &&
183 at->IsOn(AliESDtrack::kITSout)) ) return NULL; //ignore ITS standalone
8e37954c 184 AliEveTrack* track = new AliEveTrack(at, cont->GetPropagator());
185 track->SetAttLineAttMarker(cont);
186 track->SetName(Form("AliEveTrack %d", at->GetID()));
187 track->SetElementTitle(esd_track_title(at));
188 track->SetSourceObject(at);
189
190 // Add inner/outer track parameters as path-marks.
191 if (aft->GetITSOut())
192 {
8e37954c 193 esd_track_add_param(track, aft->GetITSOut());
194 }
195 else return NULL;
196
197 return track;
198}
199
e9ece5b4 200AliEveTrack* esd_make_track(AliESDtrack *at, TEveTrackList* cont)
29207369 201{
202 // Make a standard track representation and put it into given container.
203
204 // Choose which parameters to use a track's starting point.
205 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
206 // if ITS refit failed, take track parameters at inner TPC radius.
e9ece5b4 207
208 const AliExternalTrackParam* tp = at;
29207369 209
210 Bool_t innerTaken = kFALSE;
211 if ( ! at->IsOn(AliESDtrack::kITSrefit) && g_esd_tracks_use_ip_on_failed_its_refit)
212 {
213 tp = at->GetInnerParam();
214 innerTaken = kTRUE;
215 }
216
50ac85c6 217 AliEveTrack* track = new AliEveTrack(at, cont->GetPropagator());
29207369 218 track->SetAttLineAttMarker(cont);
0e33c639 219 track->SetName(Form("AliEveTrack %d", at->GetID()));
29207369 220 track->SetElementTitle(esd_track_title(at));
9b6216c0 221 track->SetSourceObject(at);
29207369 222
223 // Add inner/outer track parameters as path-marks.
224 if (at->IsOn(AliESDtrack::kTPCrefit))
225 {
226 if ( ! innerTaken)
227 {
228 esd_track_add_param(track, at->GetInnerParam());
229 }
230 esd_track_add_param(track, at->GetOuterParam());
231 }
a15e6d7d 232
29207369 233 return track;
234}
86f12f78 235
6336e5d7 236
237//==============================================================================
238// esd_tracks()
239//==============================================================================
240
8e37954c 241TEveTrackList* esd_tracks_TPC()
242{
243 AliESDEvent* esd = AliEveEventManager::AssertESD();
244 AliESDfriend* esd_friend = AliEveEventManager::AssertESDfriend();
245
246 TEveTrackList* cont = new TEveTrackList("TPC Tracks");
7b4a06f8 247 cont->SetMainColor(kMagenta);
8e37954c 248
249 esd_track_propagator_setup(cont->GetPropagator(),
250 0.1*esd->GetMagneticField(), 520);
251
252 gEve->AddElement(cont);
253
254 Int_t count = 0;
255 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
256 {
257 ++count;
258 if (!esd->GetTrack(n)) continue;
259 if (!esd_friend->GetTrack(n)) continue;
260 AliEveTrack* track = esd_make_track_TPC(esd->GetTrack(n), esd_friend->GetTrack(n), cont);
261 if (!track) continue;
262
263 cont->AddElement(track);
264 }
265 cont->SetTitle(Form("N=%d", count));
266 cont->MakeTracks();
267
268 gEve->Redraw3D();
269
270 return cont;
271}
272
273TEveTrackList* esd_tracks_ITS()
274{
275 AliESDEvent* esd = AliEveEventManager::AssertESD();
276 AliESDfriend* esd_friend = AliEveEventManager::AssertESDfriend();
277
278 TEveTrackList* cont = new TEveTrackList("ITS Tracks");
7b4a06f8 279 cont->SetMainColor(kMagenta+3);
8e37954c 280
281 esd_track_propagator_setup(cont->GetPropagator(),
282 0.1*esd->GetMagneticField(), 520);
283 cont->GetPropagator()->SetMaxR(85.0);
284 cont->SetLineWidth(1);
285
286 gEve->AddElement(cont);
287
288 Int_t count = 0;
289 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
290 {
291 ++count;
292 if (!esd->GetTrack(n)) continue;
293 if (!esd_friend->GetTrack(n)) continue;
294 AliEveTrack* track = esd_make_track_ITS(esd->GetTrack(n), esd_friend->GetTrack(n), cont);
295 if (!track) continue;
296
297 cont->AddElement(track);
298 }
299 cont->SetTitle(Form("N=%d", count));
300 cont->MakeTracks();
301
7b4a06f8 302 gEve->Redraw3D();
303
304 return cont;
305}
306
307TEveTrackList* esd_tracks_ITS_standalone()
308{
309 AliESDEvent* esd = AliEveEventManager::AssertESD();
310 AliESDfriend* esd_friend = AliEveEventManager::AssertESDfriend();
311
312 TEveTrackList* cont = new TEveTrackList("ITS Standalone Tracks");
313 cont->SetMainColor(kBlue);
314
315 esd_track_propagator_setup(cont->GetPropagator(),
316 0.1*esd->GetMagneticField(), 520);
317 cont->GetPropagator()->SetMaxR(85.0);
318 cont->SetLineWidth(1);
319
320 gEve->AddElement(cont);
321
322 Int_t count = 0;
323 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
324 {
325 ++count;
326 if (!esd->GetTrack(n)) continue;
327 if (!esd_friend->GetTrack(n)) continue;
328 AliEveTrack* track = esd_make_track_ITS_standalone(esd->GetTrack(n), esd_friend->GetTrack(n), cont);
329 if (!track) continue;
330
331 cont->AddElement(track);
332 }
333 cont->SetTitle(Form("N=%d", count));
334 cont->MakeTracks();
335
8e37954c 336 gEve->Redraw3D();
337
338 return cont;
339}
340
29207369 341TEveTrackList* esd_tracks()
5a5a1232 342{
d810d0de 343 AliESDEvent* esd = AliEveEventManager::AssertESD();
5a5a1232 344
51346b82 345 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
fbc350a3 346 cont->SetMainColor(6);
6336e5d7 347
348 esd_track_propagator_setup(cont->GetPropagator(),
2633d322 349 0.1*esd->GetMagneticField(), 520);
5a5a1232 350
84aff7a4 351 gEve->AddElement(cont);
5a5a1232 352
29207369 353 Int_t count = 0;
354 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
d31ac39d 355 {
29207369 356 ++count;
0e33c639 357 AliEveTrack* track = esd_make_track(esd->GetTrack(n), cont);
5a5a1232 358
29207369 359 cont->AddElement(track);
360 }
361 cont->SetTitle(Form("N=%d", count));
362 cont->MakeTracks();
5a5a1232 363
29207369 364 gEve->Redraw3D();
5a5a1232 365
29207369 366 return cont;
367}
5a5a1232 368
06219f85 369TEveTrackList* esd_tracks_MI()
29207369 370{
371 AliESDEvent* esd = AliEveEventManager::AssertESD();
c222eb1d 372
06219f85 373 TEveTrackList* cont = new TEveTrackList("ESD Tracks MI");
374 cont->SetLineColor(5);
29207369 375 gEve->AddElement(cont);
c222eb1d 376
29207369 377 Int_t count = 0;
378 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
379 {
380 ++count;
381 AliESDtrack* at = esd->GetTrack(n);
06219f85 382 AliEveTrack* l = new AliEveTrack(at, cont->GetPropagator());
29207369 383 l->SetName(Form("ESDTrackMI %d", at->GetID()));
384 l->SetElementTitle(esd_track_title(at));
06219f85 385 l->SetAttLineAttMarker(cont);
9b6216c0 386 l->SetSourceObject(at);
c222eb1d 387
06219f85 388 at->FillPolymarker(l, esd->GetMagneticField(), 0, 250, 5);
389
390 l->SetLockPoints(kTRUE);
29207369 391 cont->AddElement(l);
5a5a1232 392 }
29207369 393 cont->SetTitle(Form("N=%d", count));
32e219c2 394
84aff7a4 395 gEve->Redraw3D();
5a5a1232 396
397 return cont;
398}
399
6336e5d7 400
401//==============================================================================
a8600b56 402// esd_tracks_from_array()
6336e5d7 403//==============================================================================
a8600b56 404
84aff7a4 405TEveTrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
5a5a1232 406{
407 // Retrieves AliESDTrack's from collection.
408 // See example usage with AliAnalysisTrackCuts in the next function.
409
d810d0de 410 if (esd == 0) esd = AliEveEventManager::AssertESD();
86f12f78 411
51346b82 412 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
fbc350a3 413 cont->SetMainColor(6);
6336e5d7 414
415 esd_track_propagator_setup(cont->GetPropagator(),
416 0.1*esd->GetMagneticField(), 520);
5a5a1232 417
84aff7a4 418 gEve->AddElement(cont);
5a5a1232 419
5a5a1232 420 Int_t count = 0;
421 TIter next(col);
422 TObject *obj;
84aff7a4 423 while ((obj = next()) != 0)
d31ac39d 424 {
29207369 425 if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE)
426 {
427 Warning("esd_tracks_from_array", "Object '%s', '%s' is not an AliESDtrack.",
5a5a1232 428 obj->GetName(), obj->GetTitle());
429 continue;
430 }
431
432 ++count;
e9ece5b4 433 AliESDtrack* at = reinterpret_cast<AliESDtrack*>(obj);
5a5a1232 434
0e33c639 435 AliEveTrack* track = esd_make_track(at, cont);
29207369 436 cont->AddElement(track);
5a5a1232 437 }
6b7fd3a4 438 cont->SetTitle(Form("N=%d", count));
5a5a1232 439 cont->MakeTracks();
32e219c2 440
84aff7a4 441 gEve->Redraw3D();
5a5a1232 442
443 return cont;
444}
445
446void esd_tracks_alianalcuts_demo()
447{
d810d0de 448 AliESDEvent* esd = AliEveEventManager::AssertESD();
5a5a1232 449
fcfc8b01 450 AliESDtrackCuts atc;
5a5a1232 451 atc.SetPtRange(0.1, 5);
452 atc.SetRapRange(-1, 1);
453
fcfc8b01 454 esd_tracks_from_array(atc.GetAcceptedTracks(esd), esd);
5a5a1232 455}
a8600b56 456
6336e5d7 457
458//==============================================================================
29207369 459// esd_tracks_by_category
6336e5d7 460//==============================================================================
a8600b56 461
462Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
463{
464 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
465 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
466
467 Float_t b[2];
468 Float_t bRes[2];
469 Float_t bCov[3];
470 esdTrack->GetImpactParameters(b,bCov);
29207369 471 if (bCov[0] <= 0 || bCov[2] <= 0)
472 {
d31ac39d 473 printf("Estimated b resolution lower or equal zero!\n");
29207369 474 bCov[0] = bCov[2] = 0;
a8600b56 475 }
476 bRes[0] = TMath::Sqrt(bCov[0]);
477 bRes[1] = TMath::Sqrt(bCov[2]);
478
479 // -----------------------------------
480 // How to get to a n-sigma cut?
481 //
482 // The accumulated statistics from 0 to d is
483 //
484 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
485 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
486 //
487 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
488 // Can this be expressed in a different way?
489
29207369 490 if (bRes[0] == 0 || bRes[1] == 0)
a8600b56 491 return -1;
492
493 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
494
495 // stupid rounding problem screws up everything:
496 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
497 if (TMath::Exp(-d * d / 2) < 1e-10)
498 return 1000;
499
500 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
501 return d;
502}
503
29207369 504TEveElementList* esd_tracks_by_category()
a8600b56 505{
440a8bc6 506 // Import ESD tracks, separate them into several containers
507 // according to primary-vertex cut and ITS&TPC refit status.
508
509 AliESDEvent* esd = AliEveEventManager::AssertESD();
510
511 TEveElementList* cont = new TEveElementList("ESD Tracks by category");
512 gEve->AddElement(cont);
513
514 const Int_t nCont = 9;
515 const Float_t maxR = 520;
516 const Float_t magF = 0.1*esd->GetMagneticField();
517
518 TEveTrackList *tl[nCont];
519 Int_t tc[nCont];
520 Int_t count = 0;
521
522 tl[0] = new TEveTrackList("Sigma < 3");
523 tc[0] = 0;
524 esd_track_propagator_setup(tl[0]->GetPropagator(), magF, maxR);
525 tl[0]->SetMainColor(3);
526 cont->AddElement(tl[0]);
527
528 tl[1] = new TEveTrackList("3 < Sigma < 5");
529 tc[1] = 0;
530 esd_track_propagator_setup(tl[1]->GetPropagator(), magF, maxR);
531 tl[1]->SetMainColor(7);
532 cont->AddElement(tl[1]);
533
534 tl[2] = new TEveTrackList("5 < Sigma");
535 tc[2] = 0;
536 esd_track_propagator_setup(tl[2]->GetPropagator(), magF, maxR);
537 tl[2]->SetMainColor(46);
538 cont->AddElement(tl[2]);
539
540 tl[3] = new TEveTrackList("no ITS refit; Sigma < 5");
541 tc[3] = 0;
542 esd_track_propagator_setup(tl[3]->GetPropagator(), magF, maxR);
543 tl[3]->SetMainColor(41);
544 cont->AddElement(tl[3]);
545
546 tl[4] = new TEveTrackList("no ITS refit; Sigma > 5");
547 tc[4] = 0;
548 esd_track_propagator_setup(tl[4]->GetPropagator(), magF, maxR);
549 tl[4]->SetMainColor(48);
550 cont->AddElement(tl[4]);
551
552 tl[5] = new TEveTrackList("no TPC refit");
553 tc[5] = 0;
554 esd_track_propagator_setup(tl[5]->GetPropagator(), magF, maxR);
555 tl[5]->SetMainColor(kRed);
556 cont->AddElement(tl[5]);
557
558 tl[6] = new TEveTrackList("ITS ncl>=3 & SPD Inner");
559 tc[6] = 0;
560 esd_track_propagator_setup(tl[6]->GetPropagator(), magF, maxR);
561 tl[6]->SetMainColor(kGreen);
562 cont->AddElement(tl[6]);
563
564 tl[7] = new TEveTrackList("ITS ncl>=3 & b<3 cm");
565 tc[7] = 0;
566 esd_track_propagator_setup(tl[7]->GetPropagator(), magF, maxR);
567 tl[7]->SetMainColor(kMagenta - 9);
568 cont->AddElement(tl[7]);
569
570 tl[8] = new TEveTrackList("ITS others");
571 tc[8] = 0;
572 esd_track_propagator_setup(tl[8]->GetPropagator(), magF, maxR);
573 tl[8]->SetMainColor(kRed + 2);
574 cont->AddElement(tl[8]);
575
576 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
577 {
578 AliESDtrack* at = esd->GetTrack(n);
579
580 Float_t s = get_sigma_to_vertex(at);
581 Int_t ti;
582 if (s < 3) ti = 0;
583 else if (s <= 5) ti = 1;
584 else ti = 2;
585
586 Int_t nclits;
587 Double_t dtobeam;
588
589 if (at->IsOn(AliESDtrack::kITSin) && ! at->IsOn(AliESDtrack::kTPCin))
590 {
591 UChar_t itsclmap = at->GetITSClusterMap();
592 Bool_t spdinner = (itsclmap & 3) != 0;
593
594 nclits = 0;
595 for (Int_t iter = 0; iter < 6; ++iter)
596 if (itsclmap & (1 << iter)) nclits ++;
597
598 Double_t xyz[3];
599 at->GetXYZ(xyz);
600 dtobeam = TMath::Hypot(xyz[0], xyz[1]);
601
602 if ((nclits >= 3) && (spdinner))
603 ti = 6;
604 else if ((nclits >= 3) && (dtobeam < 3.0))
605 ti = 7;
606 else
607 ti = 8;
608 }
609 else if (at->IsOn(AliESDtrack::kTPCin) && ! at->IsOn(AliESDtrack::kTPCrefit))
610 {
611 ti = 5;
612 }
613 else if ( ! at->IsOn(AliESDtrack::kITSrefit))
614 {
615 ti = (ti == 2) ? 4 : 3;
616 }
617
618 TEveTrackList* tlist = tl[ti];
619 ++tc[ti];
620 ++count;
621
622 AliEveTrack* track = esd_make_track(at, tlist);
623 if (ti<6)
624 track->SetName(Form("ESD Track idx=%d, sigma=%5.3f", at->GetID(), s));
625 else
626 track->SetName(Form("ESD Track idx=%d, dxy=%5.3f cl=%i", at->GetID(), dtobeam, nclits));
627 tlist->AddElement(track);
628 }
629
630 for (Int_t ti = 0; ti < nCont; ++ti)
631 {
632 TEveTrackList* tlist = tl[ti];
633 tlist->SetName(Form("%s [%d]", tlist->GetName(), tlist->NumChildren()));
634 tlist->SetTitle(Form("N tracks=%d", tc[ti]));
635
636 tlist->MakeTracks();
637
638 // Bool_t good_cont = ti <= 1;
639 Bool_t good_cont = ((ti == 6) || (ti == 7));
640 if (AliEveTrackCounter::IsActive())
641 {
642 AliEveTrackCounter::fgInstance->RegisterTracks(tlist, good_cont);
643 }
644 else
645 {
646 if ( ! good_cont)
647 tlist->SetLineStyle(6);
648 }
649 }
650 cont->SetTitle(Form("N all tracks = %d", count));
651 // ??? The following does not always work:
652 cont->FindListTreeItem(gEve->GetListTree())->SetOpen(kTRUE);
653
654 gEve->Redraw3D();
655
656 return cont;
a8600b56 657}
5320a363 658
659
660//==============================================================================
661// esd_tracks_by_anal_cuts
662//==============================================================================
663
664AliESDtrackCuts* g_esd_tracks_anal_cuts = 0;
665
666TEveElementList* esd_tracks_by_anal_cuts()
667{
668 AliESDEvent* esd = AliEveEventManager::AssertESD();
669
670 if (g_esd_tracks_anal_cuts == 0)
671 {
b118e3ec 672 gSystem->Load("libPWGUDbase");
673 gROOT->ProcessLine(".L $ALICE_ROOT/PWGUD/CreateStandardCuts.C");
5065a65b 674 Int_t mode = AliPWG0Helper::kTPC;
5320a363 675 if (TMath::Abs(esd->GetMagneticField()) > 0.01)
676 mode |= AliPWG0Helper::kFieldOn;
15c12442 677 gROOT->ProcessLine(Form("g_esd_tracks_anal_cuts = CreateTrackCuts(%d, kFALSE)", mode));
5320a363 678 }
679
680 TEveElementList* cont = new TEveElementList("ESD Tracks by Analysis Cuts");
681 gEve->AddElement(cont);
682
683 const Int_t nCont = 2;
684 const Float_t maxR = 520;
685 const Float_t magF = 0.1*esd->GetMagneticField();
686
687 TEveTrackList *tl[nCont];
688 Int_t tc[nCont];
689 Int_t count = 0;
690
691 tl[0] = new TEveTrackList("Passed");
692 tc[0] = 0;
693 esd_track_propagator_setup(tl[0]->GetPropagator(), magF, maxR);
694 tl[0]->SetMainColor(3);
695 cont->AddElement(tl[0]);
696
697 tl[1] = new TEveTrackList("Rejected");
698 tc[1] = 0;
699 esd_track_propagator_setup(tl[1]->GetPropagator(), magF, maxR);
700 tl[1]->SetMainColor(kRed);
701 cont->AddElement(tl[1]);
702
703 for (Int_t n = 0; n < esd->GetNumberOfTracks(); ++n)
704 {
705 AliESDtrack* at = esd->GetTrack(n);
706
707 Float_t s = get_sigma_to_vertex(at);
708 Int_t ti = (g_esd_tracks_anal_cuts->AcceptTrack(at)) ? 0 : 1;
709
710 TEveTrackList* tlist = tl[ti];
711 ++tc[ti];
712 ++count;
713
714 AliEveTrack* track = esd_make_track(at, tlist);
715 track->SetName(Form("ESD Track idx=%d, sigma=%5.3f", at->GetID(), s));
716 tlist->AddElement(track);
717 }
718
719 for (Int_t ti = 0; ti < nCont; ++ti)
720 {
721 TEveTrackList* tlist = tl[ti];
722 tlist->SetName(Form("%s [%d]", tlist->GetName(), tlist->NumChildren()));
723 tlist->SetTitle(Form("N tracks=%d", tc[ti]));
724
725 tlist->MakeTracks();
726
727 Bool_t good_cont = ti < 1;
728 if (AliEveTrackCounter::IsActive())
729 {
730 AliEveTrackCounter::fgInstance->RegisterTracks(tlist, good_cont);
731 }
732 else
733 {
734 if ( ! good_cont)
735 tlist->SetLineStyle(6);
736 }
737 }
738 cont->SetTitle(Form("N all tracks = %d", count));
739 // ??? The following does not always work:
740 cont->FindListTreeItem(gEve->GetListTree())->SetOpen(kTRUE);
741
742 gEve->Redraw3D();
743
744 return cont;
745}