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* rnrStyle,
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, rnrStyle);
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.1, Double_t max_pt=100)
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(Color_t(6));
78 TEveTrackPropagator* rnrStyle = cont->GetPropagator();
79 rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
81 gEve->AddElement(cont);
83 TEveElementList* contLines = 0;
84 if (gkMakeTrackParamLines)
86 contLines = new TEveElementList("MyTracks");
87 gEve->AddElement(contLines);
92 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
94 AliESDtrack* at = esd->GetTrack(n);
96 // Here would be sweet to have TObjectFormula.
98 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
99 if(ptsq < minptsq || ptsq > maxptsq)
104 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
105 // if ITS refit failed, take track parameters at inner TPC radius.
106 Bool_t innerTaken = kFALSE;
107 AliExternalTrackParam* tp = at;
108 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
109 tp = at->GetInnerParam();
113 TEveTrack* track = esd_make_track(rnrStyle, n, at, tp);
114 track->SetAttLineAttMarker(cont);
117 esd_track_add_param(track, at->GetInnerParam());
119 // esd_track_add_param(track, at->GetOuterParam());
121 gEve->AddElement(track, cont);
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);
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);
137 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
138 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(Color_t(6));
161 TEveTrackPropagator* rnrStyle = cont->GetPropagator();
162 rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
164 gEve->AddElement(cont);
169 while ((obj = next()) != 0)
171 if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
172 Warning("Object '%s', '%s' is not an AliESDtrack.",
173 obj->GetName(), obj->GetTitle());
178 AliESDtrack* at = (AliESDtrack*) obj;
180 TEveTrack* track = esd_make_track(rnrStyle, count, at);
181 track->SetAttLineAttMarker(cont);
182 gEve->AddElement(track, cont);
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);
190 sprintf(tooltip,"N=%d", count);
191 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", 0, kTRUE);
266 gEve->AddElement(cont);
267 TEveTrackList *tl[5];
271 tl[0] = new TEveTrackList("Sigma < 3");
273 tl[0]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
274 tl[0]->SetMainColor(Color_t(3));
275 gEve->AddElement(tl[0], cont);
277 tl[1] = new TEveTrackList("3 < Sigma < 5");
279 tl[1]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
280 tl[1]->SetMainColor(Color_t(7));
281 gEve->AddElement(tl[1], cont);
283 tl[2] = new TEveTrackList("5 < Sigma");
285 tl[2]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
286 tl[2]->SetMainColor(Color_t(46));
287 gEve->AddElement(tl[2], cont);
289 tl[3] = new TEveTrackList("no ITS refit; Sigma < 5");
291 tl[3]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
292 tl[3]->SetMainColor(Color_t(41));
293 gEve->AddElement(tl[3], cont);
295 tl[4] = new TEveTrackList("no ITS refit; Sigma > 5");
297 tl[4]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
298 tl[4]->SetMainColor(Color_t(48));
299 gEve->AddElement(tl[4], cont);
301 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
303 AliESDtrack* at = esd->GetTrack(n);
305 Float_t s = get_sigma_to_vertex(at);
308 else if (s <= 5) ti = 1;
311 AliExternalTrackParam* tp = at;
312 // If ITS refit failed, optionally take track parameters at inner
313 // TPC radius and put track in a special container.
314 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
315 // Use BOTH functions to compare results.
316 if (!at->IsOn(AliESDtrack::kITSrefit)) {
317 // tp = at->GetInnerParam();
318 ti = (ti == 2) ? 4 : 3;
321 TEveTrackList* tlist = tl[ti];
325 TEveTrack* track = esd_make_track(tlist->GetPropagator(), n, at, tp);
326 track->SetAttLineAttMarker(tlist);
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));
333 sprintf(form,"TEveTrack idx=%d, sigma=%5.3f", at->GetID(), s);
334 track->SetName(form);
335 gEve->AddElement(track, tlist);
338 for (Int_t ti=0; ti<5; ++ti) {
339 TEveTrackList* tlist = tl[ti];
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]);
344 //MT Modified somewhat.
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 ...
350 tlist->UpdateItems();
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));
359 sprintf(form,"N all tracks = %d", count);
360 cont->SetTitle(form);