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 TString esd_track_flags(AliESDtrack* t)
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));
29 TEveTrack* esd_make_track(TEveTrackPropagator* trkProp,
32 AliExternalTrackParam* tp=0)
35 Double_t pbuf[3], vbuf[3];
40 rt.fLabel = at->GetLabel();
42 rt.fStatus = (Int_t) at->GetStatus();
43 rt.fSign = tp->GetSign();
48 Double_t ep = at->GetP(), mc = at->GetMass();
49 rt.fBeta = ep/TMath::Sqrt(ep*ep + mc*mc);
51 TEveTrack* track = new TEveTrack(&rt, trkProp);
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.)
55 //PH track->SetName(Form("ESDTrack %d", rt.fLabel));
56 //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)",
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));
60 sprintf(form,"TEveTrack %d", rt.fIndex);
63 track->SetElementTitle(Form("%s\n%s", track->GetElementTitle(), esd_track_flags(at).Data()));
67 void esd_track_add_param(TEveTrack* track, AliExternalTrackParam* tp)
72 Double_t pbuf[3], vbuf[3];
76 TEvePathMark pm(TEvePathMark::kReference);
79 track->AddPathMark(pm);
82 // Use inner-tpc track params when its refit failed.
83 Bool_t gkFixFailedITSExtr = kFALSE;
85 // Also show lines as generated by AliESDtrack.
86 Bool_t gkMakeTrackParamLines = kFALSE;
88 TEveTrackList* esd_tracks(Double_t min_pt=0, Double_t max_pt=10000)
90 AliESDEvent* esd = AliEveEventManager::AssertESD();
92 Double_t minptsq = min_pt*min_pt;
93 Double_t maxptsq = max_pt*max_pt;
96 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
97 cont->SetMainColor(6);
98 TEveTrackPropagator* trkProp = cont->GetPropagator();
99 trkProp->SetMagField( 0.1*esd->GetMagneticField() );
100 trkProp->SetMaxR ( 520 );
102 gEve->AddElement(cont);
104 TEveElementList* contLines = 0;
105 if (gkMakeTrackParamLines)
107 contLines = new TEveElementList("MyTracks");
108 gEve->AddElement(contLines);
113 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
115 AliESDtrack* at = esd->GetTrack(n);
117 // Here would be sweet to have TObjectFormula.
119 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
120 if(ptsq < minptsq || ptsq > maxptsq)
125 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
126 // if ITS refit failed, take track parameters at inner TPC radius.
127 Bool_t innerTaken = kFALSE;
128 AliExternalTrackParam* tp = at;
129 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
130 tp = at->GetInnerParam();
134 TEveTrack* track = esd_make_track(trkProp, n, at, tp);
135 track->SetAttLineAttMarker(cont);
138 esd_track_add_param(track, at->GetInnerParam());
140 // esd_track_add_param(track, at->GetOuterParam());
142 gEve->AddElement(track, cont);
144 if (gkMakeTrackParamLines) {
145 TEveLine* l = new TEveLine;
146 l->SetName(Form("Track%d", count));
148 at->FillPolymarker(l, esd->GetMagneticField(), 0, 250, 5);
149 contLines->AddElement(l);
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);
158 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
159 cont->SetTitle(tooltip); // Not broadcasted automatically ...
168 /******************************************************************************/
169 // esd_tracks_from_array()
170 /******************************************************************************/
172 TEveTrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
174 // Retrieves AliESDTrack's from collection.
175 // See example usage with AliAnalysisTrackCuts in the next function.
177 if (esd == 0) esd = AliEveEventManager::AssertESD();
179 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
180 cont->SetMainColor(6);
181 TEveTrackPropagator* trkProp = cont->GetPropagator();
182 trkProp->SetMagField( 0.1*esd->GetMagneticField() );
183 trkProp->SetMaxR ( 520 );
185 gEve->AddElement(cont);
190 while ((obj = next()) != 0)
192 if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
193 Warning("Object '%s', '%s' is not an AliESDtrack.",
194 obj->GetName(), obj->GetTitle());
199 AliESDtrack* at = (AliESDtrack*) obj;
201 TEveTrack* track = esd_make_track(trkProp, count, at);
202 track->SetAttLineAttMarker(cont);
203 gEve->AddElement(track, cont);
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);
211 sprintf(tooltip,"N=%d", count);
212 cont->SetTitle(tooltip); // Not broadcasted automatically ...
221 void esd_tracks_alianalcuts_demo()
223 AliESDEvent* esd = AliEveEventManager::AssertESD();
224 gSystem->Load("libANALYSIS");
226 AliAnalysisTrackCuts atc;
227 atc.SetPtRange(0.1, 5);
228 atc.SetRapRange(-1, 1);
230 esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd);
233 /******************************************************************************/
234 // esd_tracks_vertex_cut
235 /******************************************************************************/
237 Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
239 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
240 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
245 esdTrack->GetImpactParameters(b,bCov);
246 if (bCov[0]<=0 || bCov[2]<=0) {
247 printf("Estimated b resolution lower or equal zero!\n");
248 bCov[0]=0; bCov[2]=0;
250 bRes[0] = TMath::Sqrt(bCov[0]);
251 bRes[1] = TMath::Sqrt(bCov[2]);
253 // -----------------------------------
254 // How to get to a n-sigma cut?
256 // The accumulated statistics from 0 to d is
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)
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?
264 if (bRes[0] == 0 || bRes[1] ==0)
267 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
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)
274 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
278 TEveElementList* esd_tracks_vertex_cut()
280 // Import ESD tracks, separate them into five containers according to
281 // primary-vertex cut and ITS refit status.
283 AliESDEvent* esd = AliEveEventManager::AssertESD();
285 TEveElementList* cont = new TEveElementList("ESD Tracks");
287 gEve->AddElement(cont);
288 TEveTrackList *tl[5];
292 tl[0] = new TEveTrackList("Sigma < 3");
294 tl[0]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
295 tl[0]->GetPropagator()->SetMaxR ( 520 );
296 tl[0]->SetMainColor(3);
297 gEve->AddElement(tl[0], cont);
299 tl[1] = new TEveTrackList("3 < Sigma < 5");
301 tl[1]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
302 tl[1]->GetPropagator()->SetMaxR ( 520 );
303 tl[1]->SetMainColor(7);
304 gEve->AddElement(tl[1], cont);
306 tl[2] = new TEveTrackList("5 < Sigma");
308 tl[2]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
309 tl[2]->GetPropagator()->SetMaxR ( 520 );
310 tl[2]->SetMainColor(46);
311 gEve->AddElement(tl[2], cont);
313 tl[3] = new TEveTrackList("no ITS refit; Sigma < 5");
315 tl[3]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
316 tl[3]->GetPropagator()->SetMaxR ( 520 );
317 tl[3]->SetMainColor(41);
318 gEve->AddElement(tl[3], cont);
320 tl[4] = new TEveTrackList("no ITS refit; Sigma > 5");
322 tl[4]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
323 tl[4]->GetPropagator()->SetMaxR ( 520 );
324 tl[4]->SetMainColor(48);
325 gEve->AddElement(tl[4], cont);
327 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
329 AliESDtrack* at = esd->GetTrack(n);
331 Float_t s = get_sigma_to_vertex(at);
334 else if (s <= 5) ti = 1;
337 AliExternalTrackParam* tp = at;
338 // If ITS refit failed, optionally take track parameters at inner
339 // TPC radius and put track in a special container.
340 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
341 // Use BOTH functions to compare results.
342 if (!at->IsOn(AliESDtrack::kITSrefit)) {
343 // tp = at->GetInnerParam();
344 ti = (ti == 2) ? 4 : 3;
347 TEveTrackList* tlist = tl[ti];
351 TEveTrack* track = esd_make_track(tlist->GetPropagator(), n, at, tp);
352 track->SetAttLineAttMarker(tlist);
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));
359 sprintf(form,"TEveTrack idx=%d, sigma=%5.3f", at->GetID(), s);
360 track->SetName(form);
361 gEve->AddElement(track, tlist);
364 for (Int_t ti=0; ti<5; ++ti) {
365 TEveTrackList* tlist = tl[ti];
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]);
370 //MT Modified somewhat.
372 sprintf(buff, "%s [%d]", tlist->GetName(), tlist->NumChildren());
373 tlist->SetName(buff);
374 sprintf(buff, "N tracks=%d", tc[ti]);
375 tlist->SetTitle(buff); // Not broadcasted automatically ...
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));
384 sprintf(form,"N all tracks = %d", count);
385 cont->SetTitle(form);