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