]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | // $Id$ |
2 | ||
86f12f78 | 3 | Reve::Track* esd_make_track(Reve::TrackRnrStyle* rnrStyle, |
4 | AliESDtrack* at, | |
5 | AliExternalTrackParam* tp=0) | |
6 | { | |
a8600b56 | 7 | // Helper function |
86f12f78 | 8 | Double_t pbuf[3], vbuf[3]; |
9 | Reve::RecTrack rt; | |
10 | ||
11 | if(tp == 0) tp = at; | |
12 | ||
13 | rt.label = at->GetLabel(); | |
14 | rt.status = (Int_t) at->GetStatus(); | |
15 | rt.sign = tp->GetSign(); | |
16 | tp->GetXYZ(vbuf); | |
17 | rt.V.Set(vbuf); | |
18 | tp->GetPxPyPz(pbuf); | |
19 | rt.P.Set(pbuf); | |
20 | Double_t ep = at->GetP(), mc = at->GetMass(); | |
21 | rt.beta = ep/TMath::Sqrt(ep*ep + mc*mc); | |
22 | ||
23 | Reve::Track* track = new Reve::Track(&rt, rnrStyle); | |
24 | track->SetName(Form("ESDTrack %d", rt.label)); | |
25 | track->SetTitle(Form("pT=%.3f, pZ=%.3f; V=(%.3f, %.3f, %.3f)", | |
26 | rt.sign*TMath::Hypot(rt.P.x, rt.P.y), rt.P.z, | |
27 | rt.V.x, rt.V.y, rt.V.z)); | |
28 | return track; | |
29 | } | |
30 | ||
a8600b56 | 31 | Bool_t gkFixFailedITSExtr = kFALSE; |
86f12f78 | 32 | |
5a5a1232 | 33 | Reve::TrackList* esd_tracks(Double_t min_pt=0.1, Double_t max_pt=100) |
34 | { | |
35 | AliESD* esd = Alieve::Event::AssertESD(); | |
5a5a1232 | 36 | |
37 | Double_t minptsq = min_pt*min_pt; | |
38 | Double_t maxptsq = max_pt*max_pt; | |
39 | Double_t ptsq; | |
40 | ||
5a5a1232 | 41 | Reve::TrackList* cont = new Reve::TrackList("ESD Tracks"); |
42 | cont->SetMainColor(Color_t(6)); | |
86f12f78 | 43 | Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle(); |
44 | rnrStyle->SetMagField( esd->GetMagneticField() ); | |
5a5a1232 | 45 | |
5b96ea20 | 46 | gReve->AddRenderElement(cont); |
5a5a1232 | 47 | |
86f12f78 | 48 | Int_t count = 0; |
49 | Double_t pbuf[3]; | |
5a5a1232 | 50 | for (Int_t n=0; n<esd->GetNumberOfTracks(); n++) { |
86f12f78 | 51 | AliESDtrack* at = esd->GetTrack(n); |
5a5a1232 | 52 | |
53 | // Here would be sweet to have TObjectFormula. | |
54 | at->GetPxPyPz(pbuf); | |
55 | ptsq = pbuf[0]*pbuf[0] + pbuf[1]*pbuf[1]; | |
56 | if(ptsq < minptsq || ptsq > maxptsq) | |
57 | continue; | |
58 | ||
59 | ++count; | |
60 | ||
a8600b56 | 61 | // If gkFixFailedITSExtr is TRUE (FALSE by default) and |
62 | // if ITS refit failed, take track parameters at inner TPC radius. | |
86f12f78 | 63 | AliExternalTrackParam* tp = at; |
64 | if (gkFixFailedITSExtr && !at->IsOn(AliESDtrack::kITSrefit)) { | |
65 | tp = at->GetInnerParam(); | |
66 | } | |
5a5a1232 | 67 | |
86f12f78 | 68 | Reve::Track* track = esd_make_track(rnrStyle, at, tp); |
5b96ea20 | 69 | gReve->AddRenderElement(cont, track); |
5a5a1232 | 70 | } |
71 | ||
72 | const Text_t* tooltip = Form("pT ~ (%.2lf, %.2lf), N=%d", min_pt, max_pt, count); | |
73 | cont->SetTitle(tooltip); // Not broadcasted automatically ... | |
5b96ea20 | 74 | cont->UpdateItems(); |
5a5a1232 | 75 | |
76 | cont->MakeTracks(); | |
77 | cont->MakeMarkers(); | |
5b96ea20 | 78 | gReve->Redraw3D(); |
5a5a1232 | 79 | |
80 | return cont; | |
81 | } | |
82 | ||
a8600b56 | 83 | /**************************************************************************/ |
84 | // esd_tracks_from_array() | |
85 | /**************************************************************************/ | |
86 | ||
86f12f78 | 87 | Reve::TrackList* esd_tracks_from_array(TCollection* col, AliESD* esd=0) |
5a5a1232 | 88 | { |
89 | // Retrieves AliESDTrack's from collection. | |
90 | // See example usage with AliAnalysisTrackCuts in the next function. | |
91 | ||
86f12f78 | 92 | if(esd == 0) esd = Alieve::Event::AssertESD(); |
86f12f78 | 93 | |
5a5a1232 | 94 | Reve::TrackList* cont = new Reve::TrackList("ESD Tracks"); |
95 | cont->SetMainColor(Color_t(6)); | |
86f12f78 | 96 | Reve::TrackRnrStyle* rnrStyle = cont->GetRnrStyle(); |
97 | rnrStyle->SetMagField( esd->GetMagneticField() ); | |
5a5a1232 | 98 | |
5b96ea20 | 99 | gReve->AddRenderElement(cont); |
5a5a1232 | 100 | |
5a5a1232 | 101 | Int_t count = 0; |
102 | TIter next(col); | |
103 | TObject *obj; | |
5a5a1232 | 104 | while((obj = next()) != 0) { |
105 | if(obj->IsA()->InheritsFrom("AliESDtrack") == kFALSE) { | |
106 | Warning("Object '%s', '%s' is not an AliESDtrack.", | |
107 | obj->GetName(), obj->GetTitle()); | |
108 | continue; | |
109 | } | |
110 | ||
111 | ++count; | |
86f12f78 | 112 | AliESDtrack* at = (AliESDtrack*) obj; |
5a5a1232 | 113 | |
86f12f78 | 114 | Reve::Track* track = esd_make_track(rnrStyle, at); |
5b96ea20 | 115 | gReve->AddRenderElement(cont, track); |
5a5a1232 | 116 | } |
117 | ||
118 | const Text_t* tooltip = Form("N=%d", count); | |
119 | cont->SetTitle(tooltip); // Not broadcasted automatically ... | |
5b96ea20 | 120 | cont->UpdateItems(); |
5a5a1232 | 121 | |
122 | cont->MakeTracks(); | |
123 | cont->MakeMarkers(); | |
5b96ea20 | 124 | gReve->Redraw3D(); |
5a5a1232 | 125 | |
126 | return cont; | |
127 | } | |
128 | ||
129 | void esd_tracks_alianalcuts_demo() | |
130 | { | |
131 | AliESD* esd = Alieve::Event::AssertESD(); | |
86f12f78 | 132 | gSystem->Load("libANALYSIS"); |
5a5a1232 | 133 | |
134 | AliAnalysisTrackCuts atc; | |
135 | atc.SetPtRange(0.1, 5); | |
136 | atc.SetRapRange(-1, 1); | |
137 | ||
86f12f78 | 138 | esd_tracks_from_array(atc.GetAcceptedParticles(esd), esd); |
5a5a1232 | 139 | } |
a8600b56 | 140 | |
141 | /**************************************************************************/ | |
142 | // esd_tracks_vertex_cut | |
143 | /**************************************************************************/ | |
144 | ||
145 | Float_t get_sigma_to_vertex(AliESDtrack* esdTrack) | |
146 | { | |
147 | // Taken from: PWG0/esdTrackCuts/AliESDtrackCuts.cxx | |
148 | // Float_t AliESDtrackCuts::GetSigmaToVertex(AliESDtrack* esdTrack) | |
149 | ||
150 | Float_t b[2]; | |
151 | Float_t bRes[2]; | |
152 | Float_t bCov[3]; | |
153 | esdTrack->GetImpactParameters(b,bCov); | |
154 | if (bCov[0]<=0 || bCov[2]<=0) { | |
155 | AliDebug(1, "Estimated b resolution lower or equal zero!"); | |
156 | bCov[0]=0; bCov[2]=0; | |
157 | } | |
158 | bRes[0] = TMath::Sqrt(bCov[0]); | |
159 | bRes[1] = TMath::Sqrt(bCov[2]); | |
160 | ||
161 | // ----------------------------------- | |
162 | // How to get to a n-sigma cut? | |
163 | // | |
164 | // The accumulated statistics from 0 to d is | |
165 | // | |
166 | // -> Erf(d/Sqrt(2)) for a 1-dim gauss (d = n_sigma) | |
167 | // -> 1 - Exp(-d**2) for a 2-dim gauss (d*d = dx*dx + dy*dy != n_sigma) | |
168 | // | |
169 | // It means that for a 2-dim gauss: n_sigma(d) = Sqrt(2)*ErfInv(1 - Exp((-x**2)/2) | |
170 | // Can this be expressed in a different way? | |
171 | ||
172 | if (bRes[0] == 0 || bRes[1] ==0) | |
173 | return -1; | |
174 | ||
175 | Float_t d = TMath::Sqrt(TMath::Power(b[0]/bRes[0],2) + TMath::Power(b[1]/bRes[1],2)); | |
176 | ||
177 | // stupid rounding problem screws up everything: | |
178 | // if d is too big, TMath::Exp(...) gets 0, and TMath::ErfInverse(1) that should be infinite, gets 0 :( | |
179 | if (TMath::Exp(-d * d / 2) < 1e-10) | |
180 | return 1000; | |
181 | ||
182 | d = TMath::ErfInverse(1 - TMath::Exp(-d * d / 2)) * TMath::Sqrt(2); | |
183 | return d; | |
184 | } | |
185 | ||
186 | Reve::RenderElementList* esd_tracks_vertex_cut() | |
187 | { | |
188 | // Import ESD tracks, separate them into three containers according to | |
189 | // primary-vertex cut. | |
190 | ||
191 | AliESD* esd = Alieve::Event::AssertESD(); | |
192 | ||
193 | Reve::RenderElementList* cont = new Reve::RenderElementList("ESD Tracks", 0, kTRUE); | |
194 | gReve->AddRenderElement(cont); | |
195 | Reve::TrackList *tl[4]; | |
196 | Int_t tc[4]; | |
197 | Int_t count = 0; | |
198 | ||
199 | tl[0] = new Reve::TrackList("Sigma < 3"); | |
200 | printf("%p %s\n", tl[0], tl[0]->IsA()->GetName()); | |
201 | tc[0] = 0; | |
202 | tl[0]->GetRnrStyle()->SetMagField( esd->GetMagneticField() ); | |
203 | tl[0]->SetMainColor(Color_t(3)); | |
204 | gReve->AddRenderElement(cont, tl[0]); | |
205 | ||
206 | tl[1] = new Reve::TrackList("3 < Sigma < 5"); | |
207 | tc[1] = 0; | |
208 | tl[1]->GetRnrStyle()->SetMagField( esd->GetMagneticField() ); | |
209 | tl[1]->SetMainColor(Color_t(7)); | |
210 | gReve->AddRenderElement(cont, tl[1]); | |
211 | ||
212 | tl[2] = new Reve::TrackList("5 < Sigma"); | |
213 | tc[2] = 0; | |
214 | tl[2]->GetRnrStyle()->SetMagField( esd->GetMagneticField() ); | |
215 | tl[2]->SetMainColor(Color_t(46)); | |
216 | gReve->AddRenderElement(cont, tl[2]); | |
217 | ||
218 | tl[3] = new Reve::TrackList("ITS refit failed"); | |
219 | tc[3] = 0; | |
220 | tl[3]->GetRnrStyle()->SetMagField( esd->GetMagneticField() ); | |
221 | tl[3]->SetMainColor(Color_t(41)); | |
222 | gReve->AddRenderElement(cont, tl[3]); | |
223 | ||
224 | for (Int_t n=0; n<esd->GetNumberOfTracks(); n++) { | |
225 | AliESDtrack* at = esd->GetTrack(n); | |
226 | ||
227 | Float_t s = get_sigma_to_vertex(at); | |
228 | Int_t ti; | |
229 | if (s < 3) ti = 0; | |
230 | else if (s <= 5) ti = 1; | |
231 | else ti = 2; | |
232 | ||
233 | AliExternalTrackParam* tp = at; | |
234 | // If ITS refit failed, take track parameters at inner TPC radius and | |
235 | // put track in a special container. | |
236 | // This ignores state of gkFixFailedITSExtr (used in esd_tracks()). | |
237 | // Use BOTH functions to compare results. | |
238 | if (!at->IsOn(AliESDtrack::kITSrefit)) { | |
239 | tp = at->GetInnerParam(); | |
240 | ti = 3; | |
241 | } | |
242 | ||
243 | Reve::TrackList* tlist = tl[ti]; | |
244 | ++tc[ti]; | |
245 | ++count; | |
246 | ||
247 | Reve::Track* track = esd_make_track(tlist->GetRnrStyle(), at, tp); | |
248 | track->SetName(Form("track %d, sigma=%5.3f", at->GetLabel(), s)); | |
249 | gReve->AddRenderElement(tlist, track); | |
250 | } | |
251 | ||
252 | for (Int_t ti=0; ti<4; ++ti) { | |
253 | Reve::TrackList* tlist = tl[ti]; | |
254 | const Text_t* tooltip = Form("N tracks=%d", tc[ti]); | |
255 | tlist->SetTitle(tooltip); // Not broadcasted automatically ... | |
256 | tlist->UpdateItems(); | |
257 | ||
258 | tlist->MakeTracks(); | |
259 | tlist->MakeMarkers(); | |
260 | } | |
261 | cont->SetTitle(Form("N all tracks = %d", count)); | |
262 | cont->UpdateItems(); | |
263 | gReve->Redraw3D(); | |
264 | ||
265 | return cont; | |
266 | } |