2 // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007
4 /**************************************************************************
5 * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. *
6 * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for *
7 * full copyright notice. *
8 **************************************************************************/
10 TEveTrack* esd_make_track(TEveTrackPropagator* trkProp,
13 AliExternalTrackParam* tp=0)
16 Double_t pbuf[3], vbuf[3];
21 rt.fLabel = at->GetLabel();
23 rt.fStatus = (Int_t) at->GetStatus();
24 rt.fSign = tp->GetSign();
29 Double_t ep = at->GetP(), mc = at->GetMass();
30 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
32 TEveTrack* track = new TEveTrack(&rt, trkProp);
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.)
36 //PH track->SetName(Form("ESDTrack %d", rt.fLabel));
37 //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)",
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));
41 sprintf(form,"TEveTrack %d", rt.fIndex);
47 void esd_track_add_param(TEveTrack* track, AliExternalTrackParam* tp)
52 Double_t pbuf[3], vbuf[3];
56 TEvePathMark pm(TEvePathMark::kReference);
59 track->AddPathMark(pm);
62 // Use inner-tpc track params when its refit failed.
63 Bool_t gkFixFailedITSExtr = kFALSE;
65 // Also show lines as generated by AliESDtrack.
66 Bool_t gkMakeTrackParamLines = kFALSE;
68 TEveTrackList* esd_tracks(Double_t min_pt=0, Double_t max_pt=10000)
70 AliESDEvent* esd = AliEveEventManager::AssertESD();
72 Double_t minptsq = min_pt*min_pt;
73 Double_t maxptsq = max_pt*max_pt;
76 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
77 cont->SetMainColor(6);
78 TEveTrackPropagator* trkProp = cont->GetPropagator();
79 trkProp->SetMagField( 0.1*esd->GetMagneticField() );
80 trkProp->SetMaxR ( 520 );
82 gEve->AddElement(cont);
84 TEveElementList* contLines = 0;
85 if (gkMakeTrackParamLines)
87 contLines = new TEveElementList("MyTracks");
88 gEve->AddElement(contLines);
93 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
95 AliESDtrack* at = esd->GetTrack(n);
97 // Here would be sweet to have TObjectFormula.
99 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
100 if(ptsq < minptsq || ptsq > maxptsq)
105 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
106 // if ITS refit failed, take track parameters at inner TPC radius.
107 Bool_t innerTaken = kFALSE;
108 AliExternalTrackParam* tp = at;
109 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
110 tp = at->GetInnerParam();
114 TEveTrack* track = esd_make_track(trkProp, n, at, tp);
115 track->SetAttLineAttMarker(cont);
118 esd_track_add_param(track, at->GetInnerParam());
120 // esd_track_add_param(track, at->GetOuterParam());
122 gEve->AddElement(track, cont);
124 if (gkMakeTrackParamLines) {
125 TEveLine* l = new TEveLine;
126 l->SetName(Form("Track%d", count));
128 at->FillPolymarker(l, esd->GetMagneticField(), 0, 250, 5);
129 contLines->AddElement(l);
133 //PH The line below is replaced waiting for a fix in Root
134 //PH which permits to use variable siza arguments in CINT
135 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
136 //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
138 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
139 cont->SetTitle(tooltip); // Not broadcasted automatically ...
148 /******************************************************************************/
149 // esd_tracks_from_array()
150 /******************************************************************************/
152 TEveTrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
154 // Retrieves AliESDTrack's from collection.
155 // See example usage with AliAnalysisTrackCuts in the next function.
157 if (esd == 0) esd = AliEveEventManager::AssertESD();
159 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
160 cont->SetMainColor(6);
161 TEveTrackPropagator* trkProp = cont->GetPropagator();
162 trkProp->SetMagField( 0.1*esd->GetMagneticField() );
163 trkProp->SetMaxR ( 520 );
165 gEve->AddElement(cont);
170 while ((obj = next()) != 0)
172 if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
173 Warning("Object '%s', '%s' is not an AliESDtrack.",
174 obj->GetName(), obj->GetTitle());
179 AliESDtrack* at = (AliESDtrack*) obj;
181 TEveTrack* track = esd_make_track(trkProp, count, at);
182 track->SetAttLineAttMarker(cont);
183 gEve->AddElement(track, cont);
186 //PH The line below is replaced waiting for a fix in Root
187 //PH which permits to use variable siza arguments in CINT
188 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
189 //PH const Text_t* tooltip = Form("N=%d", count);
191 sprintf(tooltip,"N=%d", count);
192 cont->SetTitle(tooltip); // Not broadcasted automatically ...
201 void esd_tracks_alianalcuts_demo()
203 AliESDEvent* esd = AliEveEventManager::AssertESD();
204 gSystem->Load("libANALYSIS");
206 AliAnalysisTrackCuts atc;
207 atc.SetPtRange(0.1, 5);
208 atc.SetRapRange(-1, 1);
210 esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd);
213 /******************************************************************************/
214 // esd_tracks_vertex_cut
215 /******************************************************************************/
217 Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
219 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
220 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
225 esdTrack->GetImpactParameters(b,bCov);
226 if (bCov[0]<=0 || bCov[2]<=0) {
227 printf("Estimated b resolution lower or equal zero!\n");
228 bCov[0]=0; bCov[2]=0;
230 bRes[0] = TMath::Sqrt(bCov[0]);
231 bRes[1] = TMath::Sqrt(bCov[2]);
233 // -----------------------------------
234 // How to get to a n-sigma cut?
236 // The accumulated statistics from 0 to d is
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)
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?
244 if (bRes[0] == 0 || bRes[1] ==0)
247 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
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)
254 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
258 TEveElementList* esd_tracks_vertex_cut()
260 // Import ESD tracks, separate them into five containers according to
261 // primary-vertex cut and ITS refit status.
263 AliESDEvent* esd = AliEveEventManager::AssertESD();
265 TEveElementList* cont = new TEveElementList("ESD Tracks");
267 gEve->AddElement(cont);
268 TEveTrackList *tl[5];
272 tl[0] = new TEveTrackList("Sigma < 3");
274 tl[0]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
275 tl[0]->GetPropagator()->SetMaxR ( 520 );
276 tl[0]->SetMainColor(3);
277 gEve->AddElement(tl[0], cont);
279 tl[1] = new TEveTrackList("3 < Sigma < 5");
281 tl[1]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
282 tl[1]->GetPropagator()->SetMaxR ( 520 );
283 tl[1]->SetMainColor(7);
284 gEve->AddElement(tl[1], cont);
286 tl[2] = new TEveTrackList("5 < Sigma");
288 tl[2]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
289 tl[2]->GetPropagator()->SetMaxR ( 520 );
290 tl[2]->SetMainColor(46);
291 gEve->AddElement(tl[2], cont);
293 tl[3] = new TEveTrackList("no ITS refit; Sigma < 5");
295 tl[3]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
296 tl[3]->GetPropagator()->SetMaxR ( 520 );
297 tl[3]->SetMainColor(41);
298 gEve->AddElement(tl[3], cont);
300 tl[4] = new TEveTrackList("no ITS refit; Sigma > 5");
302 tl[4]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
303 tl[4]->GetPropagator()->SetMaxR ( 520 );
304 tl[4]->SetMainColor(48);
305 gEve->AddElement(tl[4], cont);
307 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
309 AliESDtrack* at = esd->GetTrack(n);
311 Float_t s = get_sigma_to_vertex(at);
314 else if (s <= 5) ti = 1;
317 AliExternalTrackParam* tp = at;
318 // If ITS refit failed, optionally take track parameters at inner
319 // TPC radius and put track in a special container.
320 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
321 // Use BOTH functions to compare results.
322 if (!at->IsOn(AliESDtrack::kITSrefit)) {
323 // tp = at->GetInnerParam();
324 ti = (ti == 2) ? 4 : 3;
327 TEveTrackList* tlist = tl[ti];
331 TEveTrack* track = esd_make_track(tlist->GetPropagator(), n, at, tp);
332 track->SetAttLineAttMarker(tlist);
334 //PH The line below is replaced waiting for a fix in Root
335 //PH which permits to use variable siza arguments in CINT
336 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
337 //PH track->SetName(Form("track %d, sigma=%5.3f", at->GetLabel(), s));
339 sprintf(form,"TEveTrack idx=%d, sigma=%5.3f", at->GetID(), s);
340 track->SetName(form);
341 gEve->AddElement(track, tlist);
344 for (Int_t ti=0; ti<5; ++ti) {
345 TEveTrackList* tlist = tl[ti];
346 //PH The line below is replaced waiting for a fix in Root
347 //PH which permits to use variable siza arguments in CINT
348 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
349 //PH const Text_t* tooltip = Form("N tracks=%d", tc[ti]);
350 //MT Modified somewhat.
352 sprintf(buff, "%s [%d]", tlist->GetName(), tlist->NumChildren());
353 tlist->SetName(buff);
354 sprintf(buff, "N tracks=%d", tc[ti]);
355 tlist->SetTitle(buff); // Not broadcasted automatically ...
359 //PH The line below is replaced waiting for a fix in Root
360 //PH which permits to use variable siza arguments in CINT
361 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
362 //PH cont->SetTitle(Form("N all tracks = %d", count));
364 sprintf(form,"N all tracks = %d", count);
365 cont->SetTitle(form);