]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 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 | |
ad5abc55 | 10 | TString esd_track_flags(AliESDtrack* t) |
11 | { | |
12 | TString s; | |
13 | Int_t o; | |
14 | s += "det(in,out,refit,pid):\n"; | |
15 | o = AliESDtrack::kITSin; | |
16 | s += Form("its(%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3)); | |
17 | o = AliESDtrack::kTPCin; | |
18 | s += Form("tpc(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3)); | |
19 | o = AliESDtrack::kTRDin; | |
20 | s += Form("trd(%d,%d,%d,%d) ", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3)); | |
21 | o = AliESDtrack::kTOFin; | |
22 | s += Form("tof(%d,%d,%d,%d)\n", t->IsOn(o), t->IsOn(o<<1), t->IsOn(o<<2), t->IsOn(o<<3)); | |
23 | o = AliESDtrack::kHMPIDout; | |
24 | s += Form("hmpid(out=%d,pid=%d)\n", t->IsOn(o), t->IsOn(o<<1)); | |
25 | s += Form("ESD pid=%d", t->IsOn(AliESDtrack::kESDpid)); | |
26 | return s; | |
27 | } | |
28 | ||
a6337352 | 29 | TEveTrack* esd_make_track(TEveTrackPropagator* trkProp, |
a15e6d7d | 30 | Int_t index, |
31 | AliESDtrack* at, | |
32 | AliExternalTrackParam* tp=0) | |
86f12f78 | 33 | { |
a8600b56 | 34 | // Helper function |
84aff7a4 | 35 | Double_t pbuf[3], vbuf[3]; |
36 | TEveRecTrack rt; | |
86f12f78 | 37 | |
38 | if(tp == 0) tp = at; | |
39 | ||
84aff7a4 | 40 | rt.fLabel = at->GetLabel(); |
41 | rt.fIndex = index; | |
42 | rt.fStatus = (Int_t) at->GetStatus(); | |
43 | rt.fSign = tp->GetSign(); | |
86f12f78 | 44 | tp->GetXYZ(vbuf); |
84aff7a4 | 45 | rt.fV.Set(vbuf); |
86f12f78 | 46 | tp->GetPxPyPz(pbuf); |
84aff7a4 | 47 | rt.fP.Set(pbuf); |
86f12f78 | 48 | Double_t ep = at->GetP(), mc = at->GetMass(); |
84aff7a4 | 49 | rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc); |
51346b82 | 50 | |
a6337352 | 51 | TEveTrack* track = new TEveTrack(&rt, trkProp); |
7be1e8cd | 52 | //PH The line below is replaced waiting for a fix in Root |
53 | //PH which permits to use variable siza arguments in CINT | |
54 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
84aff7a4 | 55 | //PH track->SetName(Form("ESDTrack %d", rt.fLabel)); |
7be1e8cd | 56 | //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)", |
84aff7a4 | 57 | //PH rt.fSign*TMath::Hypot(rt.fP.fX, rt.fP.fY), rt.fP.fZ, |
58 | //PH rt.fV.fX, rt.fV.fY, rt.fV.fZ)); | |
7be1e8cd | 59 | char form[1000]; |
84aff7a4 | 60 | sprintf(form,"TEveTrack %d", rt.fIndex); |
7be1e8cd | 61 | track->SetName(form); |
fc9514f5 | 62 | track->SetStdTitle(); |
ad5abc55 | 63 | track->SetElementTitle(Form("%s\n%s", track->GetElementTitle(), esd_track_flags(at).Data())); |
86f12f78 | 64 | return track; |
65 | } | |
66 | ||
c222eb1d | 67 | void esd_track_add_param(TEveTrack* track, AliExternalTrackParam* tp) |
68 | { | |
69 | if (tp == 0) | |
70 | return; | |
71 | ||
72 | Double_t pbuf[3], vbuf[3]; | |
73 | tp->GetXYZ(vbuf); | |
74 | tp->GetPxPyPz(pbuf); | |
75 | ||
a15e6d7d | 76 | TEvePathMark pm(TEvePathMark::kReference); |
77 | pm.fV.Set(vbuf); | |
78 | pm.fP.Set(pbuf); | |
c222eb1d | 79 | track->AddPathMark(pm); |
80 | } | |
81 | ||
a15e6d7d | 82 | // Use inner-tpc track params when its refit failed. |
c222eb1d | 83 | Bool_t gkFixFailedITSExtr = kFALSE; |
a15e6d7d | 84 | |
85 | // Also show lines as generated by AliESDtrack. | |
86 | Bool_t gkMakeTrackParamLines = kFALSE; | |
86f12f78 | 87 | |
a6337352 | 88 | TEveTrackList* esd_tracks(Double_t min_pt=0, Double_t max_pt=10000) |
5a5a1232 | 89 | { |
d810d0de | 90 | AliESDEvent* esd = AliEveEventManager::AssertESD(); |
5a5a1232 | 91 | |
92 | Double_t minptsq = min_pt*min_pt; | |
93 | Double_t maxptsq = max_pt*max_pt; | |
94 | Double_t ptsq; | |
95 | ||
51346b82 | 96 | TEveTrackList* cont = new TEveTrackList("ESD Tracks"); |
fbc350a3 | 97 | cont->SetMainColor(6); |
a6337352 | 98 | TEveTrackPropagator* trkProp = cont->GetPropagator(); |
99 | trkProp->SetMagField( 0.1*esd->GetMagneticField() ); | |
100 | trkProp->SetMaxR ( 520 ); | |
5a5a1232 | 101 | |
84aff7a4 | 102 | gEve->AddElement(cont); |
5a5a1232 | 103 | |
c222eb1d | 104 | TEveElementList* contLines = 0; |
105 | if (gkMakeTrackParamLines) | |
106 | { | |
107 | contLines = new TEveElementList("MyTracks"); | |
108 | gEve->AddElement(contLines); | |
109 | } | |
110 | ||
86f12f78 | 111 | Int_t count = 0; |
112 | Double_t pbuf[3]; | |
d31ac39d | 113 | for (Int_t n=0; n<esd->GetNumberOfTracks(); n++) |
114 | { | |
86f12f78 | 115 | AliESDtrack* at = esd->GetTrack(n); |
5a5a1232 | 116 | |
117 | // Here would be sweet to have TObjectFormula. | |
118 | at->GetPxPyPz(pbuf); | |
119 | ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1]; | |
120 | if(ptsq < minptsq || ptsq > maxptsq) | |
121 | continue; | |
122 | ||
123 | ++count; | |
124 | ||
a8600b56 | 125 | // If gkFixFailedITSExtr is TRUE (FALSE by default) and |
126 | // if ITS refit failed, take track parameters at inner TPC radius. | |
c222eb1d | 127 | Bool_t innerTaken = kFALSE; |
86f12f78 | 128 | AliExternalTrackParam* tp = at; |
129 | if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) { | |
c222eb1d | 130 | tp = at->GetInnerParam(); |
131 | innerTaken = kTRUE; | |
86f12f78 | 132 | } |
5a5a1232 | 133 | |
a6337352 | 134 | TEveTrack* track = esd_make_track(trkProp, n, at, tp); |
32e219c2 | 135 | track->SetAttLineAttMarker(cont); |
c222eb1d | 136 | |
a15e6d7d | 137 | if (!innerTaken) { |
138 | esd_track_add_param(track, at->GetInnerParam()); | |
139 | } | |
c222eb1d | 140 | // esd_track_add_param(track, at->GetOuterParam()); |
141 | ||
84aff7a4 | 142 | gEve->AddElement(track, cont); |
c222eb1d | 143 | |
144 | if (gkMakeTrackParamLines) { | |
145 | TEveLine* l = new TEveLine; | |
146 | l->SetName(Form("Track%d", count)); | |
fbc350a3 | 147 | l->SetLineColor(5); |
c222eb1d | 148 | at->FillPolymarker(l, esd->GetMagneticField(), 0, 250, 5); |
149 | contLines->AddElement(l); | |
150 | } | |
5a5a1232 | 151 | } |
152 | ||
7be1e8cd | 153 | //PH The line below is replaced waiting for a fix in Root |
154 | //PH which permits to use variable siza arguments in CINT | |
155 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
156 | //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count); | |
157 | char tooltip[1000]; | |
158 | sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count); | |
5a5a1232 | 159 | cont->SetTitle(tooltip); // Not broadcasted automatically ... |
5a5a1232 | 160 | |
161 | cont->MakeTracks(); | |
32e219c2 | 162 | |
84aff7a4 | 163 | gEve->Redraw3D(); |
5a5a1232 | 164 | |
165 | return cont; | |
166 | } | |
167 | ||
57ffa5fb | 168 | /******************************************************************************/ |
a8600b56 | 169 | // esd_tracks_from_array() |
57ffa5fb | 170 | /******************************************************************************/ |
a8600b56 | 171 | |
84aff7a4 | 172 | TEveTrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0) |
5a5a1232 | 173 | { |
174 | // Retrieves AliESDTrack's from collection. | |
175 | // See example usage with AliAnalysisTrackCuts in the next function. | |
176 | ||
d810d0de | 177 | if (esd == 0) esd = AliEveEventManager::AssertESD(); |
86f12f78 | 178 | |
51346b82 | 179 | TEveTrackList* cont = new TEveTrackList("ESD Tracks"); |
fbc350a3 | 180 | cont->SetMainColor(6); |
a6337352 | 181 | TEveTrackPropagator* trkProp = cont->GetPropagator(); |
182 | trkProp->SetMagField( 0.1*esd->GetMagneticField() ); | |
183 | trkProp->SetMaxR ( 520 ); | |
5a5a1232 | 184 | |
84aff7a4 | 185 | gEve->AddElement(cont); |
5a5a1232 | 186 | |
5a5a1232 | 187 | Int_t count = 0; |
188 | TIter next(col); | |
189 | TObject *obj; | |
84aff7a4 | 190 | while ((obj = next()) != 0) |
d31ac39d | 191 | { |
84aff7a4 | 192 | if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) { |
5a5a1232 | 193 | Warning("Object '%s', '%s' is not an AliESDtrack.", |
194 | obj->GetName(), obj->GetTitle()); | |
195 | continue; | |
196 | } | |
197 | ||
198 | ++count; | |
86f12f78 | 199 | AliESDtrack* at = (AliESDtrack*) obj; |
5a5a1232 | 200 | |
a6337352 | 201 | TEveTrack* track = esd_make_track(trkProp, count, at); |
32e219c2 | 202 | track->SetAttLineAttMarker(cont); |
84aff7a4 | 203 | gEve->AddElement(track, cont); |
5a5a1232 | 204 | } |
205 | ||
7be1e8cd | 206 | //PH The line below is replaced waiting for a fix in Root |
207 | //PH which permits to use variable siza arguments in CINT | |
208 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
209 | //PH const Text_t* tooltip = Form("N=%d", count); | |
210 | const tooltip[1000]; | |
211 | sprintf(tooltip,"N=%d", count); | |
5a5a1232 | 212 | cont->SetTitle(tooltip); // Not broadcasted automatically ... |
5a5a1232 | 213 | |
214 | cont->MakeTracks(); | |
32e219c2 | 215 | |
84aff7a4 | 216 | gEve->Redraw3D(); |
5a5a1232 | 217 | |
218 | return cont; | |
219 | } | |
220 | ||
221 | void esd_tracks_alianalcuts_demo() | |
222 | { | |
d810d0de | 223 | AliESDEvent* esd = AliEveEventManager::AssertESD(); |
86f12f78 | 224 | gSystem->Load("libANALYSIS"); |
5a5a1232 | 225 | |
226 | AliAnalysisTrackCuts atc; | |
227 | atc.SetPtRange(0.1, 5); | |
228 | atc.SetRapRange(-1, 1); | |
229 | ||
86f12f78 | 230 | esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd); |
5a5a1232 | 231 | } |
a8600b56 | 232 | |
57ffa5fb | 233 | /******************************************************************************/ |
a8600b56 | 234 | // esd_tracks_vertex_cut |
57ffa5fb | 235 | /******************************************************************************/ |
a8600b56 | 236 | |
237 | Float_t get_sigma_to_vertex(AliESDtrack* esdTrack) | |
238 | { | |
239 | // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx | |
240 | // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack) | |
241 | ||
242 | Float_t b[2]; | |
243 | Float_t bRes[2]; | |
244 | Float_t bCov[3]; | |
245 | esdTrack->GetImpactParameters(b,bCov); | |
246 | if (bCov[0]<=0 || bCov[2]<=0) { | |
d31ac39d | 247 | printf("Estimated b resolution lower or equal zero!\n"); |
a8600b56 | 248 | bCov[0]=0; bCov[2]=0; |
249 | } | |
250 | bRes[0] = TMath::Sqrt(bCov[0]); | |
251 | bRes[1] = TMath::Sqrt(bCov[2]); | |
252 | ||
253 | // ----------------------------------- | |
254 | // How to get to a n-sigma cut? | |
255 | // | |
256 | // The accumulated statistics from 0 to d is | |
257 | // | |
258 | // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma) | |
259 | // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma) | |
260 | // | |
261 | // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2) | |
262 | // Can this be expressed in a different way? | |
263 | ||
264 | if (bRes[0] == 0 || bRes[1] ==0) | |
265 | return -1; | |
266 | ||
267 | Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2)); | |
268 | ||
269 | // stupid rounding problem screws up everything: | |
270 | // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :( | |
271 | if (TMath::Exp(-d * d / 2) < 1e-10) | |
272 | return 1000; | |
273 | ||
274 | d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2); | |
275 | return d; | |
276 | } | |
277 | ||
84aff7a4 | 278 | TEveElementList* esd_tracks_vertex_cut() |
a8600b56 | 279 | { |
f206464b | 280 | // Import ESD tracks, separate them into five containers according to |
281 | // primary-vertex cut and ITS refit status. | |
a8600b56 | 282 | |
d810d0de | 283 | AliESDEvent* esd = AliEveEventManager::AssertESD(); |
a8600b56 | 284 | |
ca49b003 | 285 | TEveElementList* cont = new TEveElementList("ESD Tracks"); |
286 | ||
84aff7a4 | 287 | gEve->AddElement(cont); |
288 | TEveTrackList *tl[5]; | |
f206464b | 289 | Int_t tc[5]; |
a8600b56 | 290 | Int_t count = 0; |
291 | ||
84aff7a4 | 292 | tl[0] = new TEveTrackList("Sigma < 3"); |
a8600b56 | 293 | tc[0] = 0; |
daaa6c4d | 294 | tl[0]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() ); |
a6337352 | 295 | tl[0]->GetPropagator()->SetMaxR ( 520 ); |
fbc350a3 | 296 | tl[0]->SetMainColor(3); |
84aff7a4 | 297 | gEve->AddElement(tl[0], cont); |
a8600b56 | 298 | |
84aff7a4 | 299 | tl[1] = new TEveTrackList("3 < Sigma < 5"); |
a8600b56 | 300 | tc[1] = 0; |
daaa6c4d | 301 | tl[1]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() ); |
a6337352 | 302 | tl[1]->GetPropagator()->SetMaxR ( 520 ); |
fbc350a3 | 303 | tl[1]->SetMainColor(7); |
84aff7a4 | 304 | gEve->AddElement(tl[1], cont); |
a8600b56 | 305 | |
84aff7a4 | 306 | tl[2] = new TEveTrackList("5 < Sigma"); |
a8600b56 | 307 | tc[2] = 0; |
daaa6c4d | 308 | tl[2]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() ); |
a6337352 | 309 | tl[2]->GetPropagator()->SetMaxR ( 520 ); |
fbc350a3 | 310 | tl[2]->SetMainColor(46); |
84aff7a4 | 311 | gEve->AddElement(tl[2], cont); |
a8600b56 | 312 | |
84aff7a4 | 313 | tl[3] = new TEveTrackList("no ITS refit; Sigma < 5"); |
a8600b56 | 314 | tc[3] = 0; |
daaa6c4d | 315 | tl[3]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() ); |
a6337352 | 316 | tl[3]->GetPropagator()->SetMaxR ( 520 ); |
fbc350a3 | 317 | tl[3]->SetMainColor(41); |
84aff7a4 | 318 | gEve->AddElement(tl[3], cont); |
a8600b56 | 319 | |
84aff7a4 | 320 | tl[4] = new TEveTrackList("no ITS refit; Sigma > 5"); |
f206464b | 321 | tc[4] = 0; |
daaa6c4d | 322 | tl[4]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() ); |
a6337352 | 323 | tl[4]->GetPropagator()->SetMaxR ( 520 ); |
fbc350a3 | 324 | tl[4]->SetMainColor(48); |
84aff7a4 | 325 | gEve->AddElement(tl[4], cont); |
f206464b | 326 | |
d31ac39d | 327 | for (Int_t n=0; n<esd->GetNumberOfTracks(); n++) |
328 | { | |
a8600b56 | 329 | AliESDtrack* at = esd->GetTrack(n); |
330 | ||
331 | Float_t s = get_sigma_to_vertex(at); | |
332 | Int_t ti; | |
333 | if (s < 3) ti = 0; | |
334 | else if (s <= 5) ti = 1; | |
335 | else ti = 2; | |
336 | ||
337 | AliExternalTrackParam* tp = at; | |
f206464b | 338 | // If ITS refit failed, optionally take track parameters at inner |
339 | // TPC radius and put track in a special container. | |
a8600b56 | 340 | // This ignores state of gkFixFailedITSExtr (used in esd_tracks()). |
341 | // Use BOTH functions to compare results. | |
342 | if (!at->IsOn(AliESDtrack::kITSrefit)) { | |
f206464b | 343 | // tp = at->GetInnerParam(); |
344 | ti = (ti == 2) ? 4 : 3; | |
a8600b56 | 345 | } |
346 | ||
84aff7a4 | 347 | TEveTrackList* tlist = tl[ti]; |
a8600b56 | 348 | ++tc[ti]; |
349 | ++count; | |
350 | ||
84aff7a4 | 351 | TEveTrack* track = esd_make_track(tlist->GetPropagator(), n, at, tp); |
51346b82 | 352 | track->SetAttLineAttMarker(tlist); |
d31ac39d | 353 | |
7be1e8cd | 354 | //PH The line below is replaced waiting for a fix in Root |
355 | //PH which permits to use variable siza arguments in CINT | |
356 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
357 | //PH track->SetName(Form("track %d, sigma=%5.3f", at->GetLabel(), s)); | |
358 | char form[1000]; | |
84aff7a4 | 359 | sprintf(form,"TEveTrack idx=%d, sigma=%5.3f", at->GetID(), s); |
7be1e8cd | 360 | track->SetName(form); |
84aff7a4 | 361 | gEve->AddElement(track, tlist); |
a8600b56 | 362 | } |
363 | ||
f206464b | 364 | for (Int_t ti=0; ti<5; ++ti) { |
84aff7a4 | 365 | TEveTrackList* tlist = tl[ti]; |
7be1e8cd | 366 | //PH The line below is replaced waiting for a fix in Root |
367 | //PH which permits to use variable siza arguments in CINT | |
368 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
369 | //PH const Text_t* tooltip = Form("N tracks=%d", tc[ti]); | |
846b5c55 | 370 | //MT Modified somewhat. |
371 | char buff[1000]; | |
fbc350a3 | 372 | sprintf(buff, "%s [%d]", tlist->GetName(), tlist->NumChildren()); |
846b5c55 | 373 | tlist->SetName(buff); |
374 | sprintf(buff, "N tracks=%d", tc[ti]); | |
375 | tlist->SetTitle(buff); // Not broadcasted automatically ... | |
a8600b56 | 376 | |
377 | tlist->MakeTracks(); | |
a8600b56 | 378 | } |
7be1e8cd | 379 | //PH The line below is replaced waiting for a fix in Root |
380 | //PH which permits to use variable siza arguments in CINT | |
381 | //PH on some platforms (alphalinuxgcc, solariscc5, etc.) | |
382 | //PH cont->SetTitle(Form("N all tracks = %d", count)); | |
383 | char form[1000]; | |
384 | sprintf(form,"N all tracks = %d", count); | |
385 | cont->SetTitle(form); | |
84aff7a4 | 386 | gEve->Redraw3D(); |
a8600b56 | 387 | |
388 | return cont; | |
389 | } |