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,"ESDTrack %d", rt.label);
36 sprintf(form,"Index=%d, Label=%d\npT=%.3f, pZ=%.3f\nV=(%.3f, %.3f, %.3f)",
38 rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z,
39 rt.V.x, rt.V.y, rt.V.z);
40 track->SetTitle(form);
44 Bool_t gkFixFailedITSExtr = kFALSE;
46 Reve::TrackList* esd_tracks(Double_t min_pt=0.1, Double_t max_pt=100)
48 AliESDEvent* esd = Alieve::Event::AssertESD();
50 Double_t minptsq = min_pt*min_pt;
51 Double_t maxptsq = max_pt*max_pt;
54 Reve::TrackList* cont = new Reve::TrackList("ESD Tracks");
55 cont->SetMainColor(Color_t(6));
56 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
57 rnrStyle->SetMagField( esd->GetMagneticField() );
59 gReve->AddRenderElement(cont);
63 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
65 AliESDtrack* at = esd->GetTrack(n);
67 // Here would be sweet to have TObjectFormula.
69 ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1];
70 if(ptsq < minptsq || ptsq > maxptsq)
75 // If gkFixFailedITSExtr is TRUE (FALSE by default) and
76 // if ITS refit failed, take track parameters at inner TPC radius.
77 AliExternalTrackParam* tp = at;
78 if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) {
79 tp = at->GetInnerParam();
82 Reve::Track* track = esd_make_track(rnrStyle, n, at, tp);
83 track->SetAttLineAttMarker(cont);
84 gReve->AddRenderElement(track, cont);
87 //PH The line below is replaced waiting for a fix in Root
88 //PH which permits to use variable siza arguments in CINT
89 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
90 //PH const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
92 sprintf(tooltip,"pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count);
93 cont->SetTitle(tooltip); // Not broadcasted automatically ...
103 /**************************************************************************/
104 // esd_tracks_from_array()
105 /**************************************************************************/
107 Reve::TrackList* esd_tracks_from_array(TCollection* col, AliESDEvent* esd=0)
109 // Retrieves AliESDTrack's from collection.
110 // See example usage with AliAnalysisTrackCuts in the next function.
112 if(esd == 0) esd = Alieve::Event::AssertESD();
114 Reve::TrackList* cont = new Reve::TrackList("ESD Tracks");
115 cont->SetMainColor(Color_t(6));
116 Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle();
117 rnrStyle->SetMagField( esd->GetMagneticField() );
119 gReve->AddRenderElement(cont);
124 while((obj = next()) != 0)
126 if(obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) {
127 Warning("Object '%s', '%s' is not an AliESDtrack.",
128 obj->GetName(), obj->GetTitle());
133 AliESDtrack* at = (AliESDtrack*) obj;
135 Reve::Track* track = esd_make_track(rnrStyle, count, at);
136 track->SetAttLineAttMarker(cont);
137 gReve->AddRenderElement(track, cont);
140 //PH The line below is replaced waiting for a fix in Root
141 //PH which permits to use variable siza arguments in CINT
142 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
143 //PH const Text_t* tooltip = Form("N=%d", count);
145 sprintf(tooltip,"N=%d", count);
146 cont->SetTitle(tooltip); // Not broadcasted automatically ...
156 void esd_tracks_alianalcuts_demo()
158 AliESDEvent* esd = Alieve::Event::AssertESD();
159 gSystem->Load("libANALYSIS");
161 AliAnalysisTrackCuts atc;
162 atc.SetPtRange(0.1, 5);
163 atc.SetRapRange(-1, 1);
165 esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd);
168 /**************************************************************************/
169 // esd_tracks_vertex_cut
170 /**************************************************************************/
172 Float_t get_sigma_to_vertex(AliESDtrack* esdTrack)
174 // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx
175 // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack)
180 esdTrack->GetImpactParameters(b,bCov);
181 if (bCov[0]<=0 || bCov[2]<=0) {
182 printf("Estimated b resolution lower or equal zero!\n");
183 bCov[0]=0; bCov[2]=0;
185 bRes[0] = TMath::Sqrt(bCov[0]);
186 bRes[1] = TMath::Sqrt(bCov[2]);
188 // -----------------------------------
189 // How to get to a n-sigma cut?
191 // The accumulated statistics from 0 to d is
193 // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma)
194 // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma)
196 // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2)
197 // Can this be expressed in a different way?
199 if (bRes[0] == 0 || bRes[1] ==0)
202 Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2));
204 // stupid rounding problem screws up everything:
205 // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :(
206 if (TMath::Exp(-d * d / 2) < 1e-10)
209 d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2);
213 Reve::RenderElementList* esd_tracks_vertex_cut()
215 // Import ESD tracks, separate them into five containers according to
216 // primary-vertex cut and ITS refit status.
218 AliESDEvent* esd = Alieve::Event::AssertESD();
220 Reve::RenderElementList* cont = new Reve::RenderElementList("ESD Tracks", 0, kTRUE);
221 gReve->AddRenderElement(cont);
222 Reve::TrackList *tl[5];
226 tl[0] = new Reve::TrackList("Sigma < 3");
228 tl[0]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
229 tl[0]->SetMainColor(Color_t(3));
230 gReve->AddRenderElement(tl[0], cont);
232 tl[1] = new Reve::TrackList("3 < Sigma < 5");
234 tl[1]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
235 tl[1]->SetMainColor(Color_t(7));
236 gReve->AddRenderElement(tl[1], cont);
238 tl[2] = new Reve::TrackList("5 < Sigma");
240 tl[2]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
241 tl[2]->SetMainColor(Color_t(46));
242 gReve->AddRenderElement(tl[2], cont);
244 tl[3] = new Reve::TrackList("no ITS refit; Sigma < 5");
246 tl[3]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
247 tl[3]->SetMainColor(Color_t(41));
248 gReve->AddRenderElement(tl[3], cont);
250 tl[4] = new Reve::TrackList("no ITS refit; Sigma > 5");
252 tl[4]->GetRnrStyle()->SetMagField( esd->GetMagneticField() );
253 tl[4]->SetMainColor(Color_t(48));
254 gReve->AddRenderElement(tl[4], cont);
256 for (Int_t n=0; n<esd->GetNumberOfTracks(); n++)
258 AliESDtrack* at = esd->GetTrack(n);
260 Float_t s = get_sigma_to_vertex(at);
263 else if (s <= 5) ti = 1;
266 AliExternalTrackParam* tp = at;
267 // If ITS refit failed, optionally take track parameters at inner
268 // TPC radius and put track in a special container.
269 // This ignores state of gkFixFailedITSExtr (used in esd_tracks()).
270 // Use BOTH functions to compare results.
271 if (!at->IsOn(AliESDtrack::kITSrefit)) {
272 // tp = at->GetInnerParam();
273 ti = (ti == 2) ? 4 : 3;
276 Reve::TrackList* tlist = tl[ti];
280 Reve::Track* track = esd_make_track(tlist->GetRnrStyle(), n, at, tp);
281 track->SetAttLineAttMarker(tlist);
283 //PH The line below is replaced waiting for a fix in Root
284 //PH which permits to use variable siza arguments in CINT
285 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
286 //PH track->SetName(Form("track %d, sigma=%5.3f", at->GetLabel(), s));
288 sprintf(form,"Track lbl=%d, sigma=%5.3f", at->GetLabel(), s);
289 track->SetName(form);
290 gReve->AddRenderElement(track, tlist);
293 for (Int_t ti=0; ti<5; ++ti) {
294 Reve::TrackList* tlist = tl[ti];
295 //PH The line below is replaced waiting for a fix in Root
296 //PH which permits to use variable siza arguments in CINT
297 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
298 //PH const Text_t* tooltip = Form("N tracks=%d", tc[ti]);
299 //MT Modified somewhat.
301 sprintf(buff, "%s [%d]", tlist->GetName(), tlist->GetNChildren());
302 tlist->SetName(buff);
303 sprintf(buff, "N tracks=%d", tc[ti]);
304 tlist->SetTitle(buff); // Not broadcasted automatically ...
305 tlist->UpdateItems();
309 //PH The line below is replaced waiting for a fix in Root
310 //PH which permits to use variable siza arguments in CINT
311 //PH on some platforms (alphalinuxgcc, solariscc5, etc.)
312 //PH cont->SetTitle(Form("N all tracks = %d", count));
314 sprintf(form,"N all tracks = %d", count);
315 cont->SetTitle(form);