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 Bool_t gkFixFailedITSExtr = kFALSE;
49 TEveTrackList* esd_tracks(Double_t min_pt=0.1, Double_t max_pt=100)
51 AliESDEvent* esd = AliEveEventManager::AssertESD();
53 Double_t minptsq = min_pt*min_pt;
54 Double_t maxptsq = max_pt*max_pt;
57 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
58 cont->SetMainColor(Color_t(6));
59 TEveTrackPropagator* rnrStyle = cont->GetPropagator();
60 rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
62 gEve->AddElement(cont);
66 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
68 AliESDtrack* at = esd->GetTrack(n);
70 // Here would be sweet to have TObjectFormula.
72 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
73 if(ptsq < minptsq || ptsq > maxptsq)
78 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
79 // if ITS refit failed, take track parameters at inner TPC radius.
80 AliExternalTrackParam* tp = at;
81 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
82 tp = at->GetInnerParam();
85 TEveTrack* track = esd_make_track(rnrStyle, n, at, tp);
86 track->SetAttLineAttMarker(cont);
87 gEve->AddElement(track, cont);
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);
95 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
96 cont->SetTitle(tooltip); // Not broadcasted automatically ...
106 /******************************************************************************/
107 // esd_tracks_from_array()
108 /******************************************************************************/
110 TEveTrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
112 // Retrieves AliESDTrack's from collection.
113 // See example usage with AliAnalysisTrackCuts in the next function.
115 if (esd == 0) esd = AliEveEventManager::AssertESD();
117 TEveTrackList* cont = new TEveTrackList("ESD Tracks");
118 cont->SetMainColor(Color_t(6));
119 TEveTrackPropagator* rnrStyle = cont->GetPropagator();
120 rnrStyle->SetMagField( 0.1*esd->GetMagneticField() );
122 gEve->AddElement(cont);
127 while ((obj = next()) != 0)
129 if (obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
130 Warning("Object '%s', '%s' is not an AliESDtrack.",
131 obj->GetName(), obj->GetTitle());
136 AliESDtrack* at = (AliESDtrack*) obj;
138 TEveTrack* track = esd_make_track(rnrStyle, count, at);
139 track->SetAttLineAttMarker(cont);
140 gEve->AddElement(track, cont);
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);
148 sprintf(tooltip,"N=%d", count);
149 cont->SetTitle(tooltip); // Not broadcasted automatically ...
159 void esd_tracks_alianalcuts_demo()
161 AliESDEvent* esd = AliEveEventManager::AssertESD();
162 gSystem->Load("libANALYSIS");
164 AliAnalysisTrackCuts atc;
165 atc.SetPtRange(0.1, 5);
166 atc.SetRapRange(-1, 1);
168 esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd);
171 /******************************************************************************/
172 // esd_tracks_vertex_cut
173 /******************************************************************************/
175 Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
177 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
178 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
183 esdTrack->GetImpactParameters(b,bCov);
184 if (bCov[0]<=0 || bCov[2]<=0) {
185 printf("Estimated b resolution lower or equal zero!\n");
186 bCov[0]=0; bCov[2]=0;
188 bRes[0] = TMath::Sqrt(bCov[0]);
189 bRes[1] = TMath::Sqrt(bCov[2]);
191 // -----------------------------------
192 // How to get to a n-sigma cut?
194 // The accumulated statistics from 0 to d is
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)
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?
202 if (bRes[0] == 0 || bRes[1] ==0)
205 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
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)
212 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
216 TEveElementList* esd_tracks_vertex_cut()
218 // Import ESD tracks, separate them into five containers according to
219 // primary-vertex cut and ITS refit status.
221 AliESDEvent* esd = AliEveEventManager::AssertESD();
223 TEveElementList* cont = new TEveElementList("ESD Tracks", 0, kTRUE);
224 gEve->AddElement(cont);
225 TEveTrackList *tl[5];
229 tl[0] = new TEveTrackList("Sigma < 3");
231 tl[0]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
232 tl[0]->SetMainColor(Color_t(3));
233 gEve->AddElement(tl[0], cont);
235 tl[1] = new TEveTrackList("3 < Sigma < 5");
237 tl[1]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
238 tl[1]->SetMainColor(Color_t(7));
239 gEve->AddElement(tl[1], cont);
241 tl[2] = new TEveTrackList("5 < Sigma");
243 tl[2]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
244 tl[2]->SetMainColor(Color_t(46));
245 gEve->AddElement(tl[2], cont);
247 tl[3] = new TEveTrackList("no ITS refit; Sigma < 5");
249 tl[3]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
250 tl[3]->SetMainColor(Color_t(41));
251 gEve->AddElement(tl[3], cont);
253 tl[4] = new TEveTrackList("no ITS refit; Sigma > 5");
255 tl[4]->GetPropagator()->SetMagField( 0.1*esd->GetMagneticField() );
256 tl[4]->SetMainColor(Color_t(48));
257 gEve->AddElement(tl[4], cont);
259 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
261 AliESDtrack* at = esd->GetTrack(n);
263 Float_t s = get_sigma_to_vertex(at);
266 else if (s <= 5) ti = 1;
269 AliExternalTrackParam* tp = at;
270 // If ITS refit failed, optionally take track parameters at inner
271 // TPC radius and put track in a special container.
272 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
273 // Use BOTH functions to compare results.
274 if (!at->IsOn(AliESDtrack::kITSrefit)) {
275 // tp = at->GetInnerParam();
276 ti = (ti == 2) ? 4 : 3;
279 TEveTrackList* tlist = tl[ti];
283 TEveTrack* track = esd_make_track(tlist->GetPropagator(), n, at, tp);
284 track->SetAttLineAttMarker(tlist);
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));
291 sprintf(form,"TEveTrack idx=%d, sigma=%5.3f", at->GetID(), s);
292 track->SetName(form);
293 gEve->AddElement(track, tlist);
296 for (Int_t ti=0; ti<5; ++ti) {
297 TEveTrackList* tlist = tl[ti];
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]);
302 //MT Modified somewhat.
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 ...
308 tlist->UpdateItems();
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));
317 sprintf(form,"N all tracks = %d", count);
318 cont->SetTitle(form);