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