3 Reve::Track* esd_make_track(Reve::TrackRnrStyle* rnrStyle,
6 AliExternalTrackParam* tp=0)
9 Double_t pbuf[3], vbuf[3];
14 rt.label = at->GetLabel();
16 rt.status = (Int_t) at->GetStatus();
17 rt.sign = tp->GetSign();
22 Double_t ep = at->GetP(), mc = at->GetMass();
23 rt.beta = ep/TMath::Sqrt(ep*ep + mc*mc);
25 Reve::Track* track = new Reve::Track(&rt, rnrStyle);
26 //PH The line below is replaced waiting for a fix in Root
27 //PH which permits to use variable siza arguments in CINT
28 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
29 //PH track->SetName(Form("ESDTrack %d", rt.label));
30 //PH track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)",
31 //PH rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z,
32 //PH rt.V.x, rt.V.y, rt.V.z));
34 sprintf(form,"Track %d", rt.index);
40 Bool_t gkFixFailedITSExtr = kFALSE;
42 Reve::TrackList* esd_tracks(Double_t min_pt=0.1, Double_t max_pt=100)
44 AliESDEvent* esd = Alieve::Event::AssertESD();
46 Double_t minptsq = min_pt*min_pt;
47 Double_t maxptsq = max_pt*max_pt;
50 Reve::TrackList* cont = new Reve::TrackList("ESD Tracks");
51 cont->SetMainColor(Color_t(6));
52 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
53 rnrStyle->SetMagField( esd->GetMagneticField() );
55 gReve->AddRenderElement(cont);
59 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
61 AliESDtrack* at = esd->GetTrack(n);
63 // Here would be sweet to have TObjectFormula.
65 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
66 if(ptsq < minptsq || ptsq > maxptsq)
71 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
72 // if ITS refit failed, take track parameters at inner TPC radius.
73 AliExternalTrackParam* tp = at;
74 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
75 tp = at->GetInnerParam();
78 Reve::Track* track = esd_make_track(rnrStyle, n, at, tp);
79 track->SetAttLineAttMarker(cont);
80 gReve->AddRenderElement(track, cont);
83 //PH The line below is replaced waiting for a fix in Root
84 //PH which permits to use variable siza arguments in CINT
85 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
86 //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
88 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
89 cont->SetTitle(tooltip); // Not broadcasted automatically ...
99 /**************************************************************************/
100 // esd_tracks_from_array()
101 /**************************************************************************/
103 Reve::TrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
105 // Retrieves AliESDTrack's from collection.
106 // See example usage with AliAnalysisTrackCuts in the next function.
108 if(esd == 0) esd = Alieve::Event::AssertESD();
110 Reve::TrackList* cont = new Reve::TrackList("ESD Tracks");
111 cont->SetMainColor(Color_t(6));
112 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
113 rnrStyle->SetMagField( esd->GetMagneticField() );
115 gReve->AddRenderElement(cont);
120 while((obj = next()) != 0)
122 if(obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
123 Warning("Object '%s', '%s' is not an AliESDtrack.",
124 obj->GetName(), obj->GetTitle());
129 AliESDtrack* at = (AliESDtrack*) obj;
131 Reve::Track* track = esd_make_track(rnrStyle, count, at);
132 track->SetAttLineAttMarker(cont);
133 gReve->AddRenderElement(track, cont);
136 //PH The line below is replaced waiting for a fix in Root
137 //PH which permits to use variable siza arguments in CINT
138 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
139 //PH const Text_t* tooltip = Form("N=%d", count);
141 sprintf(tooltip,"N=%d", count);
142 cont->SetTitle(tooltip); // Not broadcasted automatically ...
152 void esd_tracks_alianalcuts_demo()
154 AliESDEvent* esd = Alieve::Event::AssertESD();
155 gSystem->Load("libANALYSIS");
157 AliAnalysisTrackCuts atc;
158 atc.SetPtRange(0.1, 5);
159 atc.SetRapRange(-1, 1);
161 esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd);
164 /**************************************************************************/
165 // esd_tracks_vertex_cut
166 /**************************************************************************/
168 Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
170 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
171 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
176 esdTrack->GetImpactParameters(b,bCov);
177 if (bCov[0]<=0 || bCov[2]<=0) {
178 printf("Estimated b resolution lower or equal zero!\n");
179 bCov[0]=0; bCov[2]=0;
181 bRes[0] = TMath::Sqrt(bCov[0]);
182 bRes[1] = TMath::Sqrt(bCov[2]);
184 // -----------------------------------
185 // How to get to a n-sigma cut?
187 // The accumulated statistics from 0 to d is
189 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
190 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
192 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
193 // Can this be expressed in a different way?
195 if (bRes[0] == 0 || bRes[1] ==0)
198 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
200 // stupid rounding problem screws up everything:
201 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
202 if (TMath::Exp(-d * d / 2) < 1e-10)
205 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
209 Reve::RenderElementList* esd_tracks_vertex_cut()
211 // Import ESD tracks, separate them into five containers according to
212 // primary-vertex cut and ITS refit status.
214 AliESDEvent* esd = Alieve::Event::AssertESD();
216 Reve::RenderElementList* cont = new Reve::RenderElementList("ESD Tracks", 0, kTRUE);
217 gReve->AddRenderElement(cont);
218 Reve::TrackList *tl[5];
222 tl[0] = new Reve::TrackList("Sigma < 3");
224 tl[0]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
225 tl[0]->SetMainColor(Color_t(3));
226 gReve->AddRenderElement(tl[0], cont);
228 tl[1] = new Reve::TrackList("3 < Sigma < 5");
230 tl[1]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
231 tl[1]->SetMainColor(Color_t(7));
232 gReve->AddRenderElement(tl[1], cont);
234 tl[2] = new Reve::TrackList("5 < Sigma");
236 tl[2]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
237 tl[2]->SetMainColor(Color_t(46));
238 gReve->AddRenderElement(tl[2], cont);
240 tl[3] = new Reve::TrackList("no ITS refit; Sigma < 5");
242 tl[3]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
243 tl[3]->SetMainColor(Color_t(41));
244 gReve->AddRenderElement(tl[3], cont);
246 tl[4] = new Reve::TrackList("no ITS refit; Sigma > 5");
248 tl[4]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
249 tl[4]->SetMainColor(Color_t(48));
250 gReve->AddRenderElement(tl[4], cont);
252 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
254 AliESDtrack* at = esd->GetTrack(n);
256 Float_t s = get_sigma_to_vertex(at);
259 else if (s <= 5) ti = 1;
262 AliExternalTrackParam* tp = at;
263 // If ITS refit failed, optionally take track parameters at inner
264 // TPC radius and put track in a special container.
265 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
266 // Use BOTH functions to compare results.
267 if (!at->IsOn(AliESDtrack::kITSrefit)) {
268 // tp = at->GetInnerParam();
269 ti = (ti == 2) ? 4 : 3;
272 Reve::TrackList* tlist = tl[ti];
276 Reve::Track* track = esd_make_track(tlist->GetRnrStyle(), n, at, tp);
277 track->SetAttLineAttMarker(tlist);
279 //PH The line below is replaced waiting for a fix in Root
280 //PH which permits to use variable siza arguments in CINT
281 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
282 //PH track->SetName(Form("track %d, sigma=%5.3f", at->GetLabel(), s));
284 sprintf(form,"Track idx=%d, sigma=%5.3f", at->GetID(), s);
285 track->SetName(form);
286 gReve->AddRenderElement(track, tlist);
289 for (Int_t ti=0; ti<5; ++ti) {
290 Reve::TrackList* tlist = tl[ti];
291 //PH The line below is replaced waiting for a fix in Root
292 //PH which permits to use variable siza arguments in CINT
293 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
294 //PH const Text_t* tooltip = Form("N tracks=%d", tc[ti]);
295 //MT Modified somewhat.
297 sprintf(buff, "%s [%d]", tlist->GetName(), tlist->GetNChildren());
298 tlist->SetName(buff);
299 sprintf(buff, "N tracks=%d", tc[ti]);
300 tlist->SetTitle(buff); // Not broadcasted automatically ...
301 tlist->UpdateItems();
305 //PH The line below is replaced waiting for a fix in Root
306 //PH which permits to use variable siza arguments in CINT
307 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
308 //PH cont->SetTitle(Form("N all tracks = %d", count));
310 sprintf(form,"N all tracks = %d", count);
311 cont->SetTitle(form);