]>
Commit | Line | Data |
---|---|---|
1 | /************************************************************************** | |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
16 | ||
17 | /////////////////////////////////////////////////////////////////////////////// | |
18 | // // | |
19 | // Time Projection Chamber // | |
20 | // Comparison macro for ESD // | |
21 | // responsible: | |
22 | // marian.ivanov@cern.ch // | |
23 | // | |
24 | // | |
25 | ||
26 | /* | |
27 | marian.ivanov@cern.ch | |
28 | Usage: | |
29 | ||
30 | ||
31 | .L $ALICE_ROOT/STEER/AliGenInfo.C+ | |
32 | //be sure you created genTracks file before | |
33 | .L $ALICE_ROOT/STEER/AliESDComparisonMI.C+ | |
34 | // | |
35 | ESDCmpTr *t2 = new ESDCmpTr("genTracks.root","cmpESDTracks.root","galice.root",-1,0,0); | |
36 | t2->Exec(); | |
37 | ||
38 | // | |
39 | //some cuts definition | |
40 | TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.01&&abs(MC.fVDist[2])<0.01") | |
41 | //TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.5&&abs(MC.fVDist[2])<0.5") | |
42 | //TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<3.9"); | |
43 | TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<5"); | |
44 | TCut csec("csec","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)>0.5"); | |
45 | ||
46 | ||
47 | TCut crec("crec","fReconstructed==1"); | |
48 | TCut cteta1("cteta1","abs(MC.fParticle.Theta()/3.1415-0.5)<0.25"); | |
49 | TCut cteta05("cteta05","abs(MC.fParticle.Theta()/3.1415-0.5)<0.1"); | |
50 | ||
51 | TCut cpos1("cpos1","abs(MC.fParticle.fVz/sqrt(MC.fParticle.fVx*MC.fParticle.fVx+MC.fParticle.fVy*MC.fParticle.fVy))<1"); | |
52 | TCut csens("csens","abs(sqrt(fVDist[0]**2+fVDist[1]**2)-170)<50"); | |
53 | TCut cmuon("cmuon","abs(MC.fParticle.fPdgCode==-13)"); | |
54 | TCut cchi2("cchi2","fESDTrack.fITSchi2MIP[0]<7.&&fESDTrack.fITSchi2MIP[1]<5.&&fESDTrack.fITSchi2MIP[2]<7.&&fESDTrack.fITSchi2MIP[3]<7.5&&fESDTrack.fITSchi2MIP[4]<6.") | |
55 | ||
56 | AliESDComparisonDraw comp; | |
57 | comp.SetIO(); | |
58 | TFile f("genHits.root"); | |
59 | TTree * treel = (TTree*)f.Get("HitLines"); | |
60 | if (treel) comp->fTree->AddFriend(treel,"L"); | |
61 | ||
62 | // | |
63 | //example | |
64 | comp.fTree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)"); | |
65 | comp.fTree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy"); | |
66 | comp.fTree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy"); | |
67 | comp.fTree->SetAlias("theta","MC.fTrackRef.Theta()"); | |
68 | comp.fTree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)"); | |
69 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
70 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
71 | ||
72 | ||
73 | TH1F his("his","his",100,0,20); | |
74 | TH1F hpools("hpools","hpools",100,-7,7); | |
75 | TH1F hfake("hfake","hfake",1000,0,150); | |
76 | TProfile profp0("profp0","profp0",20,-0.4,0.9) | |
77 | ||
78 | comp.DrawXY("fTPCinP0[3]","fTPCDelta[4]/fTPCinP1[3]","fReconstructed==1"+cprim,"1",4,0.2,1.5,-0.06,0.06) | |
79 | comp.fRes->Draw(); | |
80 | comp.fMean->Draw(); | |
81 | ||
82 | comp.DrawXY("fITSinP0[3]","fITSDelta[4]/fITSinP1[3]","fReconstructed==1&&fITSOn"+cprim,"1",4,0.2,1.5,-0.06,0.06) | |
83 | comp.fRes->Draw(); | |
84 | ||
85 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn",20,0.2,1.5) | |
86 | comp.fRes->Draw(); | |
87 | ||
88 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDTrack.fITSFakeRatio<0.1",10,0.2,1.5) | |
89 | comp.fRes->Draw(); | |
90 | comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDTrack.fITSFakeRatio>0.1",10,0.2,1.5) | |
91 | comp.fRes->Draw(); | |
92 | ||
93 | comp.fTree->Draw("fESDTrack.fITSsignal/fESDTrack.fTPCsignal","fITSOn&&fTPCOn&&fESDTrack.fITSFakeRatio==0") | |
94 | ||
95 | TH1F his("his","his",100,0,20); | |
96 | TH1F hpools("hpools","hpools",100,-7,7); | |
97 | ||
98 | TH2F * hdedx0 = new TH2F("dEdx0","dEdx0",100, 0,2,200,0,550); hdedx0->SetMarkerColor(1); | |
99 | TH2F * hdedx1 = new TH2F("dEdx1","dEdx1",100, 0,2,200,0,550); hdedx1->SetMarkerColor(4); | |
100 | TH2F * hdedx2 = new TH2F("dEdx2","dEdx2",100, 0,2,200,0,550); hdedx2->SetMarkerColor(3); | |
101 | TH2F * hdedx3 = new TH2F("dEdx3","dEdx3",100, 0,2,200,0,550); hdedx3->SetMarkerColor(2); | |
102 | ||
103 | comp.fTree->Draw("fESDTrack.fITSsignal:MC.fParticle.P()>>dEdx0","fITSOn&&abs(fPdg)==211&&fITStrack.fN==6"+cprim) | |
104 | comp.fTree->Draw("fESDTrack.fITSsignal:MC.fParticle.P()>>dEdx1","fITSOn&&abs(fPdg)==2212&&fITStrack.fN==6"+cprim) | |
105 | comp.fTree->Draw("fESDTrack.fITSsignal:MC.fParticle.P()>>dEdx2","fITSOn&&abs(fPdg)==321&&fITStrack.fN==6"+cprim) | |
106 | comp.fTree->Draw("fESDTrack.fITSsignal:MC.fParticle.P()>>dEdx3","fITSOn&&abs(fPdg)==11&&fITStrack.fN==6"+cprim) | |
107 | ||
108 | ||
109 | comp.fTree->Draw("fESDTrack.fTRDsignal:MC.fParticle.P()>>dEdx0","fTRDOn&&abs(fPdg)==211&&fTRDtrack.fN>40&&fStatus[2]>1") | |
110 | comp.fTree->Draw("fESDTrack.fTRDsignal:MC.fParticle.P()>>dEdx1","fTRDOn&&abs(fPdg)==2212&&fTRDtrack.fN>40&&fStatus[2]>1") | |
111 | comp.fTree->Draw("fESDTrack.fTRDsignal:MC.fParticle.P()>>dEdx2","fTRDOn&&abs(fPdg)==321&&fTRDtrack.fN>40&&fStatus[2]>1") | |
112 | comp.fTree->Draw("fESDTrack.fTRDsignal:MC.fParticle.P()>>dEdx3","fTRDOn&&abs(fPdg)==11&&fTRDtrack.fN>40&&fStatus[2]>1") | |
113 | ||
114 | comp.fTree->Draw("fESDTrack.fTPCsignal:fTPCinP0[4]>>dEdx0","fTPCOn&&abs(fPdg)==211&&fESDTrack.fTPCncls>180&&fESDTrack.fTPCsignal>10"+cteta1); | |
115 | comp.fTree->Draw("fESDTrack.fTPCsignal:fTPCinP0[4]>>dEdx1","fTPCOn&&abs(fPdg)==2212&&fESDTrack.fTPCncls>180&&fESDTrack.fTPCsignal>10"+cteta1); | |
116 | comp.fTree->Draw("fESDTrack.fTPCsignal:fTPCinP0[4]>>dEdx2","fTPCOn&&abs(fPdg)==321&&fESDTrack.fTPCncls>180&&fESDTrack.fTPCsignal>10"+cteta1); | |
117 | comp.fTree->Draw("fESDTrack.fTPCsignal:fTPCinP0[4]>>dEdx3","fTPCOn&&abs(fPdg)==11&&fESDTrack.fTPCncls>180&&fESDTrack.fTPCsignal>10"+cteta1); | |
118 | ||
119 | hdedx3->SetXTitle("P(GeV/c)"); | |
120 | hdedx3->SetYTitle("dEdx(unit)"); | |
121 | hdedx3->Draw(); hdedx1->Draw("same"); hdedx2->Draw("same"); hdedx0->Draw("same"); | |
122 | ||
123 | comp.DrawXY("fITSinP0[3]","fITSPools[4]","fReconstructed==1&&fPdg==-211&&fITSOn"+cprim,"1",4,0.2,1.0,-8,8) | |
124 | ||
125 | TProfile prof("prof","prof",10,0.5,5); | |
126 | ||
127 | ||
128 | ||
129 | ||
130 | */ | |
131 | ||
132 | ||
133 | #if !defined(__CINT__) || defined(__MAKECINT__) | |
134 | #include <stdio.h> | |
135 | #include <string.h> | |
136 | //ROOT includes | |
137 | #include "Rtypes.h" | |
138 | #include "TFile.h" | |
139 | #include "TTree.h" | |
140 | #include "TChain.h" | |
141 | #include "TCut.h" | |
142 | #include "TString.h" | |
143 | #include "TBenchmark.h" | |
144 | #include "TStopwatch.h" | |
145 | #include "TParticle.h" | |
146 | #include "TSystem.h" | |
147 | #include "TTimer.h" | |
148 | #include "TVector3.h" | |
149 | #include "TPad.h" | |
150 | #include "TCanvas.h" | |
151 | #include "TH1F.h" | |
152 | #include "TH2F.h" | |
153 | #include "TF1.h" | |
154 | #include "TText.h" | |
155 | #include "Getline.h" | |
156 | #include "TStyle.h" | |
157 | ||
158 | //ALIROOT includes | |
159 | #include "AliRun.h" | |
160 | #include "AliStack.h" | |
161 | #include "AliESDtrack.h" | |
162 | #include "AliSimDigits.h" | |
163 | #include "AliTPCParam.h" | |
164 | #include "AliTPC.h" | |
165 | #include "AliTPCLoader.h" | |
166 | #include "AliDetector.h" | |
167 | #include "AliTrackReference.h" | |
168 | #include "AliRun.h" | |
169 | #include "AliTPCParamSR.h" | |
170 | #include "AliTracker.h" | |
171 | #include "AliComplexCluster.h" | |
172 | #include "AliMagF.h" | |
173 | #include "AliESDEvent.h" | |
174 | #include "AliESDtrack.h" | |
175 | #include "AliITStrackMI.h" | |
176 | #include "AliTRDtrack.h" | |
177 | #include "AliHelix.h" | |
178 | #include "AliESDVertex.h" | |
179 | #include "AliExternalTrackParam.h" | |
180 | #include "AliESDkink.h" | |
181 | #include "AliESDv0.h" | |
182 | ||
183 | #endif | |
184 | #include "AliGenInfo.h" | |
185 | #include "AliESDComparisonMI.h" | |
186 | ||
187 | ||
188 | ||
189 | ||
190 | ||
191 | void MakeAliases(AliESDComparisonDraw&comp) | |
192 | { | |
193 | // | |
194 | // aliases definition | |
195 | // | |
196 | comp.fTree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)"); | |
197 | comp.fTree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy"); | |
198 | comp.fTree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy"); | |
199 | comp.fTree->SetAlias("theta","MC.fTrackRef.Theta()"); | |
200 | comp.fTree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)"); | |
201 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
202 | comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN"); | |
203 | ||
204 | comp.fTree->SetAlias("trddedx","(RC.fESDTrack.fTRDsignals[0]+RC.fESDTrack.fTRDsignals[1]+RC.fESDTrack.fTRDsignals[2]+RC.fESDTrack.fTRDsignals[3]+RC.fESDTrack.fTRDsignals[4]+RC.fESDTrack.fTRDsignals[5])/6."); | |
205 | ||
206 | comp.fTree->SetAlias("dtofmc2","fESDTrack.fTrackTime[2]-(10^12*MC.fTOFReferences[0].fTime)"); | |
207 | comp.fTree->SetAlias("dtofrc2","(fESDTrack.fTrackTime[2]-fESDTrack.fTOFsignal)"); | |
208 | ||
209 | comp.fTree->SetAlias("psum","fESDTrack.fTOFr[4]+fESDTrack.fTOFr[3]+fESDTrack.fTOFr[2]+fESDTrack.fTOFr[1]+fESDTrack.fTOFr[0]"); | |
210 | comp.fTree->SetAlias("P0","fESDTrack.fTOFr[0]/psum"); | |
211 | comp.fTree->SetAlias("P1","fESDTrack.fTOFr[1]/psum"); | |
212 | comp.fTree->SetAlias("P2","fESDTrack.fTOFr[2]/psum"); | |
213 | comp.fTree->SetAlias("P3","fESDTrack.fTOFr[3]/psum"); | |
214 | comp.fTree->SetAlias("P4","fESDTrack.fTOFr[4]/psum"); | |
215 | comp.fTree->SetAlias("MaxP","max(max(max(P0,P1),max(P2,P3)),P4)"); | |
216 | } | |
217 | ||
218 | ||
219 | ||
220 | ||
221 | void AliESDRecInfo::UpdatePoints(AliESDtrack*track) | |
222 | { | |
223 | // | |
224 | // | |
225 | Int_t iclusters[200]; | |
226 | Float_t density[160]; | |
227 | for (Int_t i=0;i<160;i++) density[i]=-1.; | |
228 | fTPCPoints[0]= 160; | |
229 | fTPCPoints[1] = -1; | |
230 | // | |
231 | if (fTPCPoints[0]<fTPCPoints[1]) return; | |
232 | // Int_t nclusters=track->GetTPCclusters(iclusters); | |
233 | ||
234 | Int_t ngood=0; | |
235 | Int_t undeff=0; | |
236 | Int_t nall =0; | |
237 | Int_t range=20; | |
238 | for (Int_t i=0;i<160;i++){ | |
239 | Int_t last = i-range; | |
240 | if (nall<range) nall++; | |
241 | if (last>=0){ | |
242 | if (iclusters[last]>0&& (iclusters[last]&0x8000)==0) ngood--; | |
243 | if (iclusters[last]==-1) undeff--; | |
244 | } | |
245 | if (iclusters[i]>0&& (iclusters[i]&0x8000)==0) ngood++; | |
246 | if (iclusters[i]==-1) undeff++; | |
247 | if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff); | |
248 | } | |
249 | Float_t maxdens=0; | |
250 | Int_t indexmax =0; | |
251 | for (Int_t i=0;i<160;i++){ | |
252 | if (density[i]<0) continue; | |
253 | if (density[i]>maxdens){ | |
254 | maxdens=density[i]; | |
255 | indexmax=i; | |
256 | } | |
257 | } | |
258 | // | |
259 | //max dens point | |
260 | fTPCPoints[3] = maxdens; | |
261 | fTPCPoints[1] = indexmax; | |
262 | // | |
263 | // last point | |
264 | for (Int_t i=indexmax;i<160;i++){ | |
265 | if (density[i]<0) continue; | |
266 | if (density[i]<maxdens/2.) { | |
267 | break; | |
268 | } | |
269 | fTPCPoints[2]=i; | |
270 | } | |
271 | // | |
272 | // first point | |
273 | for (Int_t i=indexmax;i>0;i--){ | |
274 | if (density[i]<0) continue; | |
275 | if (density[i]<maxdens/2.) { | |
276 | break; | |
277 | } | |
278 | fTPCPoints[0]=i; | |
279 | } | |
280 | // | |
281 | // Density at the last 30 padrows | |
282 | // | |
283 | // | |
284 | nall = 0; | |
285 | ngood = 0; | |
286 | for (Int_t i=159;i>0;i--){ | |
287 | if (iclusters[i]==-1) continue; //dead zone | |
288 | nall++; | |
289 | if (iclusters[i]>0) ngood++; | |
290 | if (nall>20) break; | |
291 | } | |
292 | fTPCPoints[4] = Float_t(ngood)/Float_t(nall); | |
293 | // | |
294 | if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) fTPCPoints[0]=-1; | |
295 | // | |
296 | // | |
297 | // check TRDPoints | |
298 | /* | |
299 | nclusters=track->GetTRDclusters(iclusters); | |
300 | for (Int_t i=nclusters;i>0;i--){ | |
301 | ||
302 | } | |
303 | */ | |
304 | ||
305 | ||
306 | } | |
307 | ||
308 | // | |
309 | // | |
310 | void AliESDRecInfo::Update(AliMCInfo* info,AliTPCParam * /*par*/, Bool_t reconstructed, AliESDEvent *event) | |
311 | { | |
312 | // | |
313 | // | |
314 | //calculates derived variables | |
315 | // | |
316 | // | |
317 | UpdatePoints(&fESDTrack); | |
318 | fBestTOFmatch=1000; | |
319 | AliTrackReference * ref = &(info->fTrackRef); | |
320 | fTPCinR0[0] = info->fTrackRef.X(); | |
321 | fTPCinR0[1] = info->fTrackRef.Y(); | |
322 | fTPCinR0[2] = info->fTrackRef.Z(); | |
323 | fTPCinR0[3] = TMath::Sqrt(fTPCinR0[0]*fTPCinR0[0]+fTPCinR0[1]*fTPCinR0[1]); | |
324 | fTPCinR0[4] = TMath::ATan2(fTPCinR0[1],fTPCinR0[0]); | |
325 | // | |
326 | fTPCinP0[0] = ref->Px(); | |
327 | fTPCinP0[1] = ref->Py(); | |
328 | fTPCinP0[2] = ref->Pz(); | |
329 | fTPCinP0[3] = ref->Pt(); | |
330 | fTPCinP0[4] = ref->P(); | |
331 | fDeltaP = (ref->P()-info->fParticle.P())/info->fParticle.P(); | |
332 | // | |
333 | // | |
334 | if (fTPCinP0[3]>0.0000001){ | |
335 | // | |
336 | fTPCAngle0[0] = TMath::ATan2(fTPCinP0[1],fTPCinP0[0]); | |
337 | fTPCAngle0[1] = TMath::ATan(fTPCinP0[2]/fTPCinP0[3]); | |
338 | } | |
339 | // | |
340 | // | |
341 | fITSinP0[0]=info->fParticle.Px(); | |
342 | fITSinP0[1]=info->fParticle.Py(); | |
343 | fITSinP0[2]=info->fParticle.Pz(); | |
344 | fITSinP0[3]=info->fParticle.Pt(); | |
345 | // | |
346 | fITSinR0[0]=info->fParticle.Vx(); | |
347 | fITSinR0[1]=info->fParticle.Vy(); | |
348 | fITSinR0[2]=info->fParticle.Vz(); | |
349 | fITSinR0[3] = TMath::Sqrt(fITSinR0[0]*fITSinR0[0]+fITSinR0[1]*fITSinR0[1]); | |
350 | fITSinR0[4] = TMath::ATan2(fITSinR0[1],fITSinR0[0]); | |
351 | // | |
352 | // | |
353 | if (fITSinP0[3]>0.0000001){ | |
354 | fITSAngle0[0] = TMath::ATan2(fITSinP0[1],fITSinP0[0]); | |
355 | fITSAngle0[1] = TMath::ATan(fITSinP0[2]/fITSinP0[3]); | |
356 | } | |
357 | // | |
358 | for (Int_t i=0;i<4;i++) fStatus[i] =0; | |
359 | fReconstructed = kFALSE; | |
360 | fTPCOn = kFALSE; | |
361 | fITSOn = kFALSE; | |
362 | fTRDOn = kFALSE; | |
363 | if (reconstructed==kFALSE) return; | |
364 | ||
365 | fLabels[0] = info->fLabel; | |
366 | fLabels[1] = info->fPrimPart; | |
367 | fReconstructed = kTRUE; | |
368 | fTPCOn = ((fESDTrack.GetStatus()&AliESDtrack::kTPCrefit)>0) ? kTRUE : kFALSE; | |
369 | fITSOn = ((fESDTrack.GetStatus()&AliESDtrack::kITSrefit)>0) ? kTRUE : kFALSE; | |
370 | fTRDOn = ((fESDTrack.GetStatus()&AliESDtrack::kTRDrefit)>0) ? kTRUE : kFALSE; | |
371 | // | |
372 | // | |
373 | if ((fESDTrack.GetStatus()&AliESDtrack::kTPCrefit)>0){ | |
374 | fStatus[1] =3; | |
375 | } | |
376 | else{ | |
377 | if ((fESDTrack.GetStatus()&AliESDtrack::kTPCout)>0){ | |
378 | fStatus[1] =2; | |
379 | } | |
380 | else{ | |
381 | if ((fESDTrack.GetStatus()&AliESDtrack::kTPCin)>0) | |
382 | fStatus[1]=1; | |
383 | } | |
384 | } | |
385 | // | |
386 | if ((fESDTrack.GetStatus()&AliESDtrack::kITSout)>0){ | |
387 | fStatus[0] =2; | |
388 | } | |
389 | else{ | |
390 | if ((fESDTrack.GetStatus()&AliESDtrack::kITSrefit)>0){ | |
391 | fStatus[0] =1; | |
392 | } | |
393 | else{ | |
394 | fStatus[0]=0; | |
395 | } | |
396 | } | |
397 | ||
398 | // | |
399 | // | |
400 | if ((fESDTrack.GetStatus()&AliESDtrack::kTRDrefit)>0){ | |
401 | fStatus[2] =2; | |
402 | } | |
403 | else{ | |
404 | if ((fESDTrack.GetStatus()&AliESDtrack::kTRDout)>0){ | |
405 | fStatus[2] =1; | |
406 | } | |
407 | } | |
408 | if ((fESDTrack.GetStatus()&AliESDtrack::kTRDStop)>0){ | |
409 | fStatus[2] =10; | |
410 | } | |
411 | ||
412 | // | |
413 | //TOF | |
414 | // | |
415 | if (((fESDTrack.GetStatus()&AliESDtrack::kTOFout)>0)){ | |
416 | // | |
417 | // best tof match | |
418 | Double_t times[5]; | |
419 | fESDTrack.GetIntegratedTimes(times); | |
420 | for (Int_t i=0;i<5;i++){ | |
421 | if ( TMath::Abs(fESDTrack.GetTOFsignal()-times[i]) <TMath::Abs(fBestTOFmatch) ){ | |
422 | fBestTOFmatch = fESDTrack.GetTOFsignal()-times[i]; | |
423 | } | |
424 | } | |
425 | Int_t toflabel[3]; | |
426 | fESDTrack.GetTOFLabel(toflabel); | |
427 | Bool_t toffake=kTRUE; | |
428 | Bool_t tofdaughter=kFALSE; | |
429 | for (Int_t i=0;i<3;i++){ | |
430 | if (toflabel[i]<0) continue; | |
431 | if (toflabel[i]== TMath::Abs(fESDTrack.GetLabel())) toffake=kFALSE; | |
432 | if (toflabel[i]==info->fParticle.GetDaughter(0) || (toflabel[i]==info->fParticle.GetDaughter(1))) tofdaughter=kTRUE; // decay product of original particle | |
433 | fStatus[3]=1; | |
434 | } | |
435 | if (toffake) fStatus[3] =3; //total fake | |
436 | if (tofdaughter) fStatus[3]=2; //fake because of decay | |
437 | }else{ | |
438 | fStatus[3]=0; | |
439 | } | |
440 | ||
441 | ||
442 | if (fStatus[1]>0 &&info->fNTPCRef>0&&TMath::Abs(fTPCinP0[3])>0.0001){ | |
443 | //TPC | |
444 | fESDTrack.GetInnerXYZ(fTPCinR1); | |
445 | fTPCinR1[3] = TMath::Sqrt(fTPCinR1[0]*fTPCinR1[0]+fTPCinR1[1]*fTPCinR1[1]); | |
446 | fTPCinR1[4] = TMath::ATan2(fTPCinR1[1],fTPCinR1[0]); | |
447 | fESDTrack.GetInnerPxPyPz(fTPCinP1); | |
448 | fTPCinP1[3] = TMath::Sqrt(fTPCinP1[0]*fTPCinP1[0]+fTPCinP1[1]*fTPCinP1[1]); | |
449 | fTPCinP1[4] = TMath::Sqrt(fTPCinP1[3]*fTPCinP1[3]+fTPCinP1[2]*fTPCinP1[2]); | |
450 | // | |
451 | // | |
452 | if (fTPCinP1[3]>0.000000000000001){ | |
453 | fTPCAngle1[0] = TMath::ATan2(fTPCinP1[1],fTPCinP1[0]); | |
454 | fTPCAngle1[1] = TMath::ATan(fTPCinP1[2]/fTPCinP1[3]); | |
455 | } | |
456 | Double_t cov[15], param[5],x, alpha; | |
457 | fESDTrack.GetInnerExternalCovariance(cov); | |
458 | fESDTrack.GetInnerExternalParameters(alpha, x,param); | |
459 | if (x<50) return ; | |
460 | // | |
461 | fTPCDelta[0] = (fTPCinR0[4]-fTPCinR1[4])*fTPCinR1[3]; //delta rfi | |
462 | fTPCPools[0] = fTPCDelta[0]/TMath::Sqrt(cov[0]); | |
463 | fTPCDelta[1] = (fTPCinR0[2]-fTPCinR1[2]); //delta z | |
464 | fTPCPools[1] = fTPCDelta[1]/TMath::Sqrt(cov[2]); | |
465 | fTPCDelta[2] = (fTPCAngle0[0]-fTPCAngle1[0]); | |
466 | fTPCPools[2] = fTPCDelta[2]/TMath::Sqrt(cov[5]); | |
467 | fTPCDelta[3] = (TMath::Tan(fTPCAngle0[1])-TMath::Tan(fTPCAngle1[1])); | |
468 | fTPCPools[3] = fTPCDelta[3]/TMath::Sqrt(cov[9]); | |
469 | fTPCDelta[4] = (fTPCinP0[3]-fTPCinP1[3]); | |
470 | Double_t sign = (param[4]>0)? 1.:-1; | |
471 | fSign =sign; | |
472 | fTPCPools[4] = sign*(1./fTPCinP0[3]-1./fTPCinP1[3])/TMath::Sqrt(TMath::Abs(cov[14])); | |
473 | } | |
474 | if (fITSOn){ | |
475 | // ITS | |
476 | Double_t param[5],x; | |
477 | fESDTrack.GetExternalParameters(x,param); | |
478 | // fESDTrack.GetConstrainedExternalParameters(x,param); | |
479 | Double_t cov[15]; | |
480 | fESDTrack.GetExternalCovariance(cov); | |
481 | //fESDTrack.GetConstrainedExternalCovariance(cov); | |
482 | if (TMath::Abs(param[4])<0.0000000001) return; | |
483 | ||
484 | fESDTrack.GetXYZ(fITSinR1); | |
485 | fESDTrack.GetPxPyPz(fITSinP1); | |
486 | fITSinP1[3] = TMath::Sqrt(fITSinP1[0]*fITSinP1[0]+fITSinP1[1]*fITSinP1[1]); | |
487 | // | |
488 | fITSinR1[3] = TMath::Sqrt(fITSinR1[0]*fITSinR1[0]+fITSinR1[1]*fITSinR1[1]); | |
489 | fITSinR1[4] = TMath::ATan2(fITSinR1[1],fITSinR1[0]); | |
490 | // | |
491 | // | |
492 | if (fITSinP1[3]>0.0000001){ | |
493 | fITSAngle1[0] = TMath::ATan2(fITSinP1[1],fITSinP1[0]); | |
494 | fITSAngle1[1] = TMath::ATan(fITSinP1[2]/fITSinP1[3]); | |
495 | } | |
496 | // | |
497 | // | |
498 | fITSDelta[0] = (fITSinR0[4]-fITSinR1[4])*fITSinR1[3]; //delta rfi | |
499 | fITSPools[0] = fITSDelta[0]/TMath::Sqrt(cov[0]); | |
500 | fITSDelta[1] = (fITSinR0[2]-fITSinR1[2]); //delta z | |
501 | fITSPools[1] = fITSDelta[1]/TMath::Sqrt(cov[2]); | |
502 | fITSDelta[2] = (fITSAngle0[0]-fITSAngle1[0]); | |
503 | fITSPools[2] = fITSDelta[2]/TMath::Sqrt(cov[5]); | |
504 | fITSDelta[3] = (TMath::Tan(fITSAngle0[1])-TMath::Tan(fITSAngle1[1])); | |
505 | fITSPools[3] = fITSDelta[3]/TMath::Sqrt(cov[9]); | |
506 | fITSDelta[4] = (fITSinP0[3]-fITSinP1[3]); | |
507 | Double_t sign = (param[4]>0) ? 1:-1; | |
508 | fSign = sign; | |
509 | fITSPools[4] = sign*(1./fITSinP0[3]-1./fITSinP1[3])/TMath::Sqrt(cov[14]); | |
510 | } | |
511 | ||
512 | } | |
513 | ||
514 | ||
515 | void AliESDRecV0Info::Update(Float_t vertex[3]) | |
516 | { | |
517 | ||
518 | if ( (fT1.fStatus[1]>0)&& (fT2.fStatus[1]>0)){ | |
519 | Float_t distance1,distance2; | |
520 | Double_t xx[3],pp[3]; | |
521 | // | |
522 | Double_t xd[3],pd[3],signd; | |
523 | Double_t xm[3],pm[3],signm; | |
524 | // | |
525 | // | |
526 | if (fT1.fITSOn&&fT2.fITSOn){ | |
527 | for (Int_t i=0;i<3;i++){ | |
528 | xd[i] = fT2.fITSinR1[i]; | |
529 | pd[i] = fT2.fITSinP1[i]; | |
530 | xm[i] = fT1.fITSinR1[i]; | |
531 | pm[i] = fT1.fITSinP1[i]; | |
532 | } | |
533 | } | |
534 | else{ | |
535 | ||
536 | for (Int_t i=0;i<3;i++){ | |
537 | xd[i] = fT2.fTPCinR1[i]; | |
538 | pd[i] = fT2.fTPCinP1[i]; | |
539 | xm[i] = fT1.fTPCinR1[i]; | |
540 | pm[i] = fT1.fTPCinP1[i]; | |
541 | } | |
542 | } | |
543 | // | |
544 | // | |
545 | signd = fT2.fSign<0 ? -1:1; | |
546 | signm = fT1.fSign<0 ? -1:1; | |
547 | ||
548 | AliHelix dhelix1(xd,pd,signd); | |
549 | dhelix1.GetMomentum(0,pp,0); | |
550 | dhelix1.Evaluate(0,xx); | |
551 | // | |
552 | // Double_t x2[3],p2[3]; | |
553 | // | |
554 | AliHelix mhelix(xm,pm,signm); | |
555 | // | |
556 | //find intersection linear | |
557 | // | |
558 | Double_t phase[2][2],radius[2]; | |
559 | Int_t points = dhelix1.GetRPHIintersections(mhelix, phase, radius,200); | |
560 | Double_t delta1=10000,delta2=10000; | |
561 | ||
562 | if (points==1){ | |
563 | fRs[0] = TMath::Sqrt(radius[0]); | |
564 | fRs[1] = TMath::Sqrt(radius[0]); | |
565 | } | |
566 | if (points==2){ | |
567 | fRs[0] =TMath::Min(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1])); | |
568 | fRs[1] =TMath::Max(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1])); | |
569 | } | |
570 | ||
571 | if (points>0){ | |
572 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
573 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
574 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
575 | } | |
576 | if (points==2){ | |
577 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
578 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
579 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
580 | } | |
581 | if (points==1){ | |
582 | fRs[0] = TMath::Sqrt(radius[0]); | |
583 | fRs[1] = TMath::Sqrt(radius[0]); | |
584 | fDistMinR = delta1; | |
585 | } | |
586 | if (points==2){ | |
587 | if (radius[0]<radius[1]){ | |
588 | fRs[0] = TMath::Sqrt(radius[0]); | |
589 | fRs[1] = TMath::Sqrt(radius[1]); | |
590 | fDistMinR = delta1; | |
591 | } | |
592 | else{ | |
593 | fRs[0] = TMath::Sqrt(radius[1]); | |
594 | fRs[1] = TMath::Sqrt(radius[0]); | |
595 | fDistMinR = delta2; | |
596 | } | |
597 | } | |
598 | // | |
599 | // | |
600 | distance1 = TMath::Min(delta1,delta2); | |
601 | // | |
602 | //find intersection parabolic | |
603 | // | |
604 | points = dhelix1.GetRPHIintersections(mhelix, phase, radius); | |
605 | delta1=10000,delta2=10000; | |
606 | ||
607 | if (points>0){ | |
608 | dhelix1.ParabolicDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
609 | } | |
610 | if (points==2){ | |
611 | dhelix1.ParabolicDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
612 | } | |
613 | ||
614 | distance2 = TMath::Min(delta1,delta2); | |
615 | if (distance2>100) fDist2 =100; | |
616 | return; | |
617 | if (delta1<delta2){ | |
618 | //get V0 info | |
619 | dhelix1.Evaluate(phase[0][0],fXr); | |
620 | dhelix1.GetMomentum(phase[0][0],fPdr); | |
621 | mhelix.GetMomentum(phase[0][1],fPm); | |
622 | dhelix1.GetAngle(phase[0][0],mhelix,phase[0][1],fAngle); | |
623 | fRr = TMath::Sqrt(radius[0]); | |
624 | } | |
625 | else{ | |
626 | dhelix1.Evaluate(phase[1][0],fXr); | |
627 | dhelix1.GetMomentum(phase[1][0], fPdr); | |
628 | mhelix.GetMomentum(phase[1][1], fPm); | |
629 | dhelix1.GetAngle(phase[1][0],mhelix,phase[1][1],fAngle); | |
630 | fRr = TMath::Sqrt(radius[1]); | |
631 | } | |
632 | fDist1 = TMath::Sqrt(distance1); | |
633 | fDist2 = TMath::Sqrt(distance2); | |
634 | ||
635 | if (fDist2<10.5){ | |
636 | Double_t x,alpha,param[5],cov[15]; | |
637 | // | |
638 | fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
639 | fT1.fESDTrack.GetInnerExternalCovariance(cov); | |
640 | AliExternalTrackParam paramm(x,alpha,param,cov); | |
641 | // | |
642 | fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
643 | fT2.fESDTrack.GetInnerExternalCovariance(cov); | |
644 | AliExternalTrackParam paramd(x,alpha,param,cov); | |
645 | } | |
646 | // | |
647 | // | |
648 | ||
649 | Float_t v[3] = {fXr[0]-vertex[0],fXr[1]-vertex[1],fXr[2]-vertex[2]}; | |
650 | Float_t p[3] = {fPdr[0]+fPm[0], fPdr[1]+fPm[1],fPdr[2]+fPm[2]}; | |
651 | ||
652 | Float_t vnorm2 = v[0]*v[0]+v[1]*v[1]; | |
653 | Float_t vnorm3 = TMath::Sqrt(v[2]*v[2]+vnorm2); | |
654 | vnorm2 = TMath::Sqrt(vnorm2); | |
655 | Float_t pnorm2 = p[0]*p[0]+p[1]*p[1]; | |
656 | Float_t pnorm3 = TMath::Sqrt(p[2]*p[2]+pnorm2); | |
657 | pnorm2 = TMath::Sqrt(pnorm2); | |
658 | ||
659 | fPointAngleFi = (v[0]*p[0]+v[1]*p[1])/(vnorm2*pnorm2); | |
660 | fPointAngleTh = (v[2]*p[2]+vnorm2*pnorm2)/(vnorm3*pnorm3); | |
661 | fPointAngle = (v[0]*p[0]+v[1]*p[1]+v[2]*p[2])/(vnorm3*pnorm3); | |
662 | } | |
663 | } | |
664 | ||
665 | //// | |
666 | void AliESDRecKinkInfo::Update() | |
667 | { | |
668 | ||
669 | if ( (fT1.fTPCOn)&& (fT2.fTPCOn)){ | |
670 | // | |
671 | // IF BOTH RECONSTRUCTED | |
672 | Float_t distance1,distance2; | |
673 | Double_t xx[3],pp[3]; | |
674 | // | |
675 | Double_t xd[3],pd[3],signd; | |
676 | Double_t xm[3],pm[3],signm; | |
677 | for (Int_t i=0;i<3;i++){ | |
678 | xd[i] = fT2.fTPCinR1[i]; | |
679 | pd[i] = fT2.fTPCinP1[i]; | |
680 | xm[i] = fT1.fTPCinR1[i]; | |
681 | pm[i] = fT1.fTPCinP1[i]; | |
682 | } | |
683 | signd = fT2.fSign<0 ? -1:1; | |
684 | signm = fT1.fSign<0 ? -1:1; | |
685 | ||
686 | AliHelix dhelix1(xd,pd,signd); | |
687 | dhelix1.GetMomentum(0,pp,0); | |
688 | dhelix1.Evaluate(0,xx); | |
689 | // | |
690 | // Double_t x2[3],p2[3]; | |
691 | // | |
692 | AliHelix mhelix(xm,pm,signm); | |
693 | // | |
694 | //find intersection linear | |
695 | // | |
696 | Double_t phase[2][2],radius[2]; | |
697 | Int_t points = dhelix1.GetRPHIintersections(mhelix, phase, radius,200); | |
698 | Double_t delta1=10000,delta2=10000; | |
699 | ||
700 | if (points==1){ | |
701 | fMinR = TMath::Sqrt(radius[0]); | |
702 | } | |
703 | if (points==2){ | |
704 | fMinR =TMath::Min(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1])); | |
705 | } | |
706 | ||
707 | if (points>0){ | |
708 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
709 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
710 | dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
711 | } | |
712 | if (points==2){ | |
713 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
714 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
715 | dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
716 | } | |
717 | if (points==1){ | |
718 | fMinR = TMath::Sqrt(radius[0]); | |
719 | fDistMinR = delta1; | |
720 | } | |
721 | if (points==2){ | |
722 | if (radius[0]<radius[1]){ | |
723 | fMinR = TMath::Sqrt(radius[0]); | |
724 | fDistMinR = delta1; | |
725 | } | |
726 | else{ | |
727 | fMinR = TMath::Sqrt(radius[1]); | |
728 | fDistMinR = delta2; | |
729 | } | |
730 | } | |
731 | // | |
732 | // | |
733 | distance1 = TMath::Min(delta1,delta2); | |
734 | // | |
735 | //find intersection parabolic | |
736 | // | |
737 | points = dhelix1.GetRPHIintersections(mhelix, phase, radius); | |
738 | delta1=10000,delta2=10000; | |
739 | ||
740 | if (points>0){ | |
741 | dhelix1.ParabolicDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1); | |
742 | } | |
743 | if (points==2){ | |
744 | dhelix1.ParabolicDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2); | |
745 | } | |
746 | ||
747 | distance2 = TMath::Min(delta1,delta2); | |
748 | if (delta1<delta2){ | |
749 | //get V0 info | |
750 | dhelix1.Evaluate(phase[0][0],fXr); | |
751 | dhelix1.GetMomentum(phase[0][0],fPdr); | |
752 | mhelix.GetMomentum(phase[0][1],fPm); | |
753 | dhelix1.GetAngle(phase[0][0],mhelix,phase[0][1],fAngle); | |
754 | fRr = TMath::Sqrt(radius[0]); | |
755 | } | |
756 | else{ | |
757 | dhelix1.Evaluate(phase[1][0],fXr); | |
758 | dhelix1.GetMomentum(phase[1][0], fPdr); | |
759 | mhelix.GetMomentum(phase[1][1], fPm); | |
760 | dhelix1.GetAngle(phase[1][0],mhelix,phase[1][1],fAngle); | |
761 | fRr = TMath::Sqrt(radius[1]); | |
762 | } | |
763 | fDist1 = TMath::Sqrt(distance1); | |
764 | fDist2 = TMath::Sqrt(distance2); | |
765 | ||
766 | if (fDist2<10.5){ | |
767 | Double_t x,alpha,param[5],cov[15]; | |
768 | // | |
769 | fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
770 | fT1.fESDTrack.GetInnerExternalCovariance(cov); | |
771 | AliExternalTrackParam paramm(x,alpha,param,cov); | |
772 | // | |
773 | fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
774 | fT2.fESDTrack.GetInnerExternalCovariance(cov); | |
775 | AliExternalTrackParam paramd(x,alpha,param,cov); | |
776 | /* | |
777 | AliESDkink kink; | |
778 | kink.Update(¶mm,¶md); | |
779 | // kink.Dump(); | |
780 | Double_t diff = kink.fRr-fRr; | |
781 | Double_t diff2 = kink.fDist2-fDist2; | |
782 | printf("Diff\t%f\t%f\n",diff,diff2); | |
783 | */ | |
784 | } | |
785 | ||
786 | // | |
787 | // | |
788 | } | |
789 | ||
790 | } | |
791 | ||
792 | ||
793 | //////////////////////////////////////////////////////////////////////// | |
794 | ESDCmpTr::ESDCmpTr() | |
795 | { | |
796 | Reset(); | |
797 | } | |
798 | ||
799 | //////////////////////////////////////////////////////////////////////// | |
800 | ESDCmpTr::ESDCmpTr(const char* fnGenTracks, | |
801 | const char* fnCmp, | |
802 | const char* fnGalice, Int_t direction, | |
803 | Int_t nEvents, Int_t firstEvent) | |
804 | { | |
805 | Reset(); | |
806 | // fFnGenTracks = fnGenTracks; | |
807 | // fFnCmp = fnCmp; | |
808 | sprintf(fFnGenTracks,"%s",fnGenTracks); | |
809 | sprintf(fFnCmp,"%s",fnCmp); | |
810 | ||
811 | fFirstEventNr = firstEvent; | |
812 | fEventNr = firstEvent; | |
813 | fNEvents = nEvents; | |
814 | fDirection = direction; | |
815 | // | |
816 | fLoader = AliRunLoader::Open(fnGalice); | |
817 | if (gAlice){ | |
818 | //delete gAlice->GetRunLoader(); | |
819 | delete gAlice; | |
820 | gAlice = 0x0; | |
821 | } | |
822 | if (fLoader->LoadgAlice()){ | |
823 | cerr<<"Error occured while l"<<endl; | |
824 | } | |
825 | Int_t nall = fLoader->GetNumberOfEvents(); | |
826 | if (nEvents==0) { | |
827 | nEvents =nall; | |
828 | fNEvents=nall; | |
829 | fFirstEventNr=0; | |
830 | } | |
831 | ||
832 | if (nall<=0){ | |
833 | cerr<<"no events available"<<endl; | |
834 | fEventNr = 0; | |
835 | return; | |
836 | } | |
837 | if (firstEvent+nEvents>nall) { | |
838 | fEventNr = nall-firstEvent; | |
839 | cerr<<"restricted number of events availaible"<<endl; | |
840 | } | |
841 | AliMagF * magf = gAlice->Field(); | |
842 | AliTracker::SetFieldMap(magf,0); | |
843 | ||
844 | } | |
845 | ||
846 | ||
847 | //////////////////////////////////////////////////////////////////////// | |
848 | ESDCmpTr::~ESDCmpTr() | |
849 | { | |
850 | if (fLoader) { | |
851 | delete fLoader; | |
852 | } | |
853 | } | |
854 | ||
855 | ////////////////////////////////////////////////////////////// | |
856 | Int_t ESDCmpTr::SetIO() | |
857 | { | |
858 | // | |
859 | // | |
860 | CreateTreeCmp(); | |
861 | if (!fTreeCmp) return 1; | |
862 | fParamTPC = GetTPCParam(); | |
863 | // | |
864 | if (!ConnectGenTree()) { | |
865 | cerr<<"Cannot connect tree with generated tracks"<<endl; | |
866 | return 1; | |
867 | } | |
868 | return 0; | |
869 | } | |
870 | ||
871 | ////////////////////////////////////////////////////////////// | |
872 | ||
873 | Int_t ESDCmpTr::SetIO(Int_t eventNr) | |
874 | { | |
875 | // | |
876 | // | |
877 | // SET INPUT | |
878 | // | |
879 | TFile f("AliESDs.root"); | |
880 | // | |
881 | ||
882 | TTree* tree = (TTree*) f.Get("esdTree"); | |
883 | if(fEvent)delete fEvent; | |
884 | fEvent = new AliESDEvent(); | |
885 | fEvent->ReadFromTree(tree); | |
886 | tree->GetEntry(eventNr); | |
887 | ||
888 | ||
889 | ||
890 | /* | |
891 | Char_t ename[100]; | |
892 | sprintf(ename,"%d",eventNr); | |
893 | fEvent = (AliESD*)f.Get(ename); | |
894 | if (!fEvent){ | |
895 | sprintf(ename,"ESD%d",eventNr); | |
896 | fEvent = (AliESD*)f.Get(ename); | |
897 | } | |
898 | ||
899 | TTree* tree = (TTree*) f.Get("esdTree"); | |
900 | if (!tree) { | |
901 | Error("CheckESD", "no ESD tree found"); | |
902 | return kFALSE; | |
903 | } | |
904 | tree->SetBranchAddress("ESD", &fEvent); | |
905 | tree->GetEntry(eventNr); | |
906 | */ | |
907 | ||
908 | if (!fEvent) return 1; | |
909 | ||
910 | return 0; | |
911 | } | |
912 | ||
913 | ||
914 | ||
915 | //////////////////////////////////////////////////////////////////////// | |
916 | void ESDCmpTr::Reset() | |
917 | { | |
918 | fEventNr = 0; | |
919 | fNEvents = 0; | |
920 | fTreeCmp = 0; | |
921 | fTreeCmpKinks =0; | |
922 | fTreeCmpV0 =0; | |
923 | // fFnCmp = "cmpTracks.root"; | |
924 | fFileGenTracks = 0; | |
925 | fDebug = 0; | |
926 | // | |
927 | fParamTPC = 0; | |
928 | fEvent =0; | |
929 | } | |
930 | ||
931 | //////////////////////////////////////////////////////////////////////// | |
932 | Int_t ESDCmpTr::Exec(Int_t nEvents, Int_t firstEventNr) | |
933 | { | |
934 | fNEvents = nEvents; | |
935 | fFirstEventNr = firstEventNr; | |
936 | return Exec(); | |
937 | } | |
938 | ||
939 | //////////////////////////////////////////////////////////////////////// | |
940 | Int_t ESDCmpTr::Exec() | |
941 | { | |
942 | TStopwatch timer; | |
943 | timer.Start(); | |
944 | ||
945 | if (SetIO()==1) | |
946 | return 1; | |
947 | ||
948 | fNextTreeGenEntryToRead = 0; | |
949 | fNextKinkToRead = 0; | |
950 | fNextV0ToRead =0; | |
951 | cerr<<"fFirstEventNr, fNEvents: "<<fFirstEventNr<<" "<<fNEvents<<endl; | |
952 | for (Int_t eventNr = fFirstEventNr; eventNr < fFirstEventNr+fNEvents; | |
953 | eventNr++) { | |
954 | fEventNr = eventNr; | |
955 | SetIO(fEventNr); | |
956 | fNParticles = gAlice->GetEvent(fEventNr); | |
957 | ||
958 | fIndexRecTracks = new Short_t[fNParticles*20]; //write at maximum 4 tracks corresponding to particle | |
959 | fIndexRecKinks = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
960 | fIndexRecV0 = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle | |
961 | ||
962 | fFakeRecTracks = new Short_t[fNParticles]; | |
963 | fMultiRecTracks = new Short_t[fNParticles]; | |
964 | fMultiRecKinks = new Short_t[fNParticles]; | |
965 | fMultiRecV0 = new Short_t[fNParticles]; | |
966 | ||
967 | for (Int_t i = 0; i<fNParticles; i++) { | |
968 | for (Int_t j=0;j<20;j++){ | |
969 | fIndexRecTracks[20*i+j] = -1; | |
970 | fIndexRecKinks[20*i+j] = -1; | |
971 | fIndexRecV0[20*i+j] = -1; | |
972 | } | |
973 | fFakeRecTracks[i] = 0; | |
974 | fMultiRecTracks[i] = 0; | |
975 | fMultiRecKinks[i] = 0; | |
976 | fMultiRecV0[i] = 0; | |
977 | } | |
978 | ||
979 | cout<<"Start to process event "<<fEventNr<<endl; | |
980 | cout<<"\tfNParticles = "<<fNParticles<<endl; | |
981 | if (fDebug>2) cout<<"\tStart loop over TreeT"<<endl; | |
982 | if (TreeTLoop()>0) return 1; | |
983 | ||
984 | if (fDebug>2) cout<<"\tStart loop over tree genTracks"<<endl; | |
985 | if (TreeGenLoop(eventNr)>0) return 1; | |
986 | BuildKinkInfo0(eventNr); | |
987 | BuildV0Info(eventNr); | |
988 | fRecArray->Delete(); | |
989 | ||
990 | if (fDebug>2) cout<<"\tEnd loop over tree genTracks"<<endl; | |
991 | ||
992 | delete [] fIndexRecTracks; | |
993 | delete [] fIndexRecKinks; | |
994 | delete [] fIndexRecV0; | |
995 | delete [] fFakeRecTracks; | |
996 | delete [] fMultiRecTracks; | |
997 | delete [] fMultiRecKinks; | |
998 | delete [] fMultiRecV0; | |
999 | } | |
1000 | ||
1001 | CloseOutputFile(); | |
1002 | ||
1003 | cerr<<"Exec finished"<<endl; | |
1004 | timer.Stop(); | |
1005 | timer.Print(); | |
1006 | return 0; | |
1007 | ||
1008 | } | |
1009 | //////////////////////////////////////////////////////////////////////// | |
1010 | Bool_t ESDCmpTr::ConnectGenTree() | |
1011 | { | |
1012 | // | |
1013 | // connect all branches from the genTracksTree | |
1014 | // use the same variables as for the new cmp tree, it may work | |
1015 | // | |
1016 | fFileGenTracks = TFile::Open(fFnGenTracks,"READ"); | |
1017 | if (!fFileGenTracks) { | |
1018 | cerr<<"Error in ConnectGenTree: cannot open file "<<fFnGenTracks<<endl; | |
1019 | return kFALSE; | |
1020 | } | |
1021 | fTreeGenTracks = (TTree*)fFileGenTracks->Get("genTracksTree"); | |
1022 | if (!fTreeGenTracks) { | |
1023 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
1024 | <<fFnGenTracks<<endl; | |
1025 | return kFALSE; | |
1026 | } | |
1027 | // | |
1028 | fMCInfo = new AliMCInfo; | |
1029 | fTreeGenTracks->SetBranchAddress("MC",&fMCInfo); | |
1030 | // | |
1031 | // | |
1032 | fTreeGenKinks = (TTree*)fFileGenTracks->Get("genKinksTree"); | |
1033 | if (!fTreeGenKinks) { | |
1034 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
1035 | <<fFnGenTracks<<endl; | |
1036 | //return kFALSE; | |
1037 | } | |
1038 | else{ | |
1039 | fGenKinkInfo = new AliGenKinkInfo; | |
1040 | fTreeGenKinks->SetBranchAddress("MC",&fGenKinkInfo); | |
1041 | } | |
1042 | ||
1043 | fTreeGenV0 = (TTree*)fFileGenTracks->Get("genV0Tree"); | |
1044 | if (!fTreeGenV0) { | |
1045 | cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file " | |
1046 | <<fFnGenTracks<<endl; | |
1047 | //return kFALSE; | |
1048 | } | |
1049 | else{ | |
1050 | fGenV0Info = new AliGenV0Info; | |
1051 | fTreeGenV0->SetBranchAddress("MC",&fGenV0Info); | |
1052 | } | |
1053 | // | |
1054 | if (fDebug > 1) { | |
1055 | cout<<"Number of gen. tracks with TR: "<<fTreeGenTracks->GetEntries()<<endl; | |
1056 | } | |
1057 | return kTRUE; | |
1058 | } | |
1059 | ||
1060 | ||
1061 | //////////////////////////////////////////////////////////////////////// | |
1062 | void ESDCmpTr::CreateTreeCmp() | |
1063 | { | |
1064 | fFileCmp = TFile::Open(fFnCmp,"RECREATE"); | |
1065 | if (!fFileCmp) { | |
1066 | cerr<<"Error in CreateTreeCmp: cannot open file "<<fFnCmp<<endl; | |
1067 | return; | |
1068 | } | |
1069 | // | |
1070 | // | |
1071 | fTreeCmp = new TTree("ESDcmpTracks","ESDcmpTracks"); | |
1072 | fMCInfo = new AliMCInfo; | |
1073 | fRecInfo = new AliESDRecInfo; | |
1074 | AliESDtrack * esdTrack = new AliESDtrack; | |
1075 | // AliITStrackMI * itsTrack = new AliITStrackMI; | |
1076 | fTreeCmp->Branch("MC","AliMCInfo",&fMCInfo,256000); | |
1077 | fTreeCmp->Branch("RC","AliESDRecInfo",&fRecInfo,256000); | |
1078 | // fTreeCmp->Branch("fESDTrack","AliESDtrack",&esdTrack); | |
1079 | // fTreeCmp->Branch("ITS","AliITStrackMI",&itsTrack); | |
1080 | delete esdTrack; | |
1081 | // | |
1082 | // | |
1083 | fTreeCmpKinks = new TTree("ESDcmpKinks","ESDcmpKinks"); | |
1084 | fGenKinkInfo = new AliGenKinkInfo; | |
1085 | fRecKinkInfo = new AliESDRecKinkInfo; | |
1086 | fTreeCmpKinks->Branch("MC.","AliGenKinkInfo",&fGenKinkInfo,256000); | |
1087 | fTreeCmpKinks->Branch("RC.","AliESDRecKinkInfo",&fRecKinkInfo,256000); | |
1088 | // | |
1089 | // | |
1090 | fTreeCmpV0 = new TTree("ESDcmpV0","ESDcmpV0"); | |
1091 | fGenV0Info = new AliGenV0Info; | |
1092 | fRecV0Info = new AliESDRecV0Info; | |
1093 | fTreeCmpV0->Branch("MC.","AliGenV0Info", &fGenV0Info,256000); | |
1094 | fTreeCmpV0->Branch("RC.","AliESDRecV0Info",&fRecV0Info,256000); | |
1095 | // | |
1096 | fTreeCmp->AutoSave(); | |
1097 | fTreeCmpKinks->AutoSave(); | |
1098 | fTreeCmpV0->AutoSave(); | |
1099 | } | |
1100 | //////////////////////////////////////////////////////////////////////// | |
1101 | void ESDCmpTr::CloseOutputFile() | |
1102 | { | |
1103 | if (!fFileCmp) { | |
1104 | cerr<<"File "<<fFnCmp<<" not found as an open file."<<endl; | |
1105 | return; | |
1106 | } | |
1107 | fFileCmp->cd(); | |
1108 | fTreeCmp->Write(); | |
1109 | delete fTreeCmp; | |
1110 | ||
1111 | fFileCmp->Close(); | |
1112 | delete fFileCmp; | |
1113 | return; | |
1114 | } | |
1115 | //////////////////////////////////////////////////////////////////////// | |
1116 | ||
1117 | TVector3 ESDCmpTr::TR2Local(AliTrackReference *trackRef, | |
1118 | AliTPCParam *paramTPC) { | |
1119 | ||
1120 | Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()}; | |
1121 | Int_t index[4]; | |
1122 | paramTPC->Transform0to1(x,index); | |
1123 | paramTPC->Transform1to2Ideal(x,index); | |
1124 | return TVector3(x); | |
1125 | } | |
1126 | //////////////////////////////////////////////////////////////////////// | |
1127 | ||
1128 | Int_t ESDCmpTr::TreeTLoop() | |
1129 | { | |
1130 | // | |
1131 | // loop over all ESD reconstructed tracks and store info in memory | |
1132 | // | |
1133 | // + loop over all reconstructed kinks | |
1134 | TStopwatch timer; | |
1135 | timer.Start(); | |
1136 | // | |
1137 | Int_t nEntries = (Int_t)fEvent->GetNumberOfTracks(); | |
1138 | Int_t nKinks = (Int_t) fEvent->GetNumberOfKinks(); | |
1139 | Int_t nV0MIs = (Int_t) fEvent->GetNumberOfV0s(); | |
1140 | fSignedKinks = new Short_t[nKinks]; | |
1141 | fSignedV0 = new Short_t[nV0MIs]; | |
1142 | // | |
1143 | // load kinks to the memory | |
1144 | for (Int_t i=0; i<nKinks;i++){ | |
1145 | AliESDkink * kink =fEvent->GetKink(i); | |
1146 | fSignedKinks[i]=0; | |
1147 | if (kink->fStatus<0) continue; | |
1148 | } | |
1149 | // | |
1150 | for (Int_t i=0; i<nV0MIs;i++){ | |
1151 | AliESDv0 * v0MI =fEvent->GetV0(i); | |
1152 | fSignedV0[i]=0; | |
1153 | if (v0MI->fStatus<0) continue; | |
1154 | } | |
1155 | ||
1156 | // | |
1157 | // | |
1158 | AliESDtrack * track=0; | |
1159 | for (Int_t iEntry=0; iEntry<nEntries;iEntry++){ | |
1160 | //track = (AliESDtrack*)fTracks->UncheckedAt(iEntry); | |
1161 | track = (AliESDtrack*)fEvent->GetTrack(iEntry); | |
1162 | // | |
1163 | Int_t label = track->GetLabel(); | |
1164 | Int_t absLabel = abs(label); | |
1165 | if (absLabel < fNParticles) { | |
1166 | // fIndexRecTracks[absLabel] = iEntry; | |
1167 | if (label < 0) fFakeRecTracks[absLabel]++; | |
1168 | if (fMultiRecTracks[absLabel]>0){ | |
1169 | if (fMultiRecTracks[absLabel]<20) | |
1170 | fIndexRecTracks[absLabel*20+fMultiRecTracks[absLabel]] = iEntry; | |
1171 | } | |
1172 | else | |
1173 | fIndexRecTracks[absLabel*20] = iEntry; | |
1174 | fMultiRecTracks[absLabel]++; | |
1175 | } | |
1176 | } | |
1177 | // sort reconstructed kinks | |
1178 | // | |
1179 | AliESDkink * kink=0; | |
1180 | for (Int_t iEntry=0; iEntry<nKinks;iEntry++){ | |
1181 | kink = (AliESDkink*)fEvent->GetKink(iEntry); | |
1182 | if (!kink) continue; | |
1183 | // | |
1184 | Int_t label0 = TMath::Abs(kink->fLab[0]); | |
1185 | Int_t label1 = TMath::Abs(kink->fLab[1]); | |
1186 | Int_t absLabel = TMath::Min(label0,label1); | |
1187 | if (absLabel < fNParticles) { | |
1188 | if (fMultiRecKinks[absLabel]>0){ | |
1189 | if (fMultiRecKinks[absLabel]<20) | |
1190 | fIndexRecKinks[absLabel*20+fMultiRecKinks[absLabel]] = iEntry; | |
1191 | } | |
1192 | else | |
1193 | fIndexRecKinks[absLabel*20] = iEntry; | |
1194 | fMultiRecKinks[absLabel]++; | |
1195 | } | |
1196 | } | |
1197 | // --sort reconstructed V0 | |
1198 | // | |
1199 | AliESDv0 * v0MI=0; | |
1200 | for (Int_t iEntry=0; iEntry<nV0MIs;iEntry++){ | |
1201 | v0MI = fEvent->GetV0(iEntry); | |
1202 | if (!v0MI) continue; | |
1203 | // | |
1204 | // Int_t label0 = TMath::Abs(v0MI->fLab[0]); | |
1205 | //Int_t label1 = TMath::Abs(v0MI->fLab[1]); | |
1206 | // | |
1207 | for (Int_t i=0;i<2;i++){ | |
1208 | // Int_t absLabel = TMath::Min(label0,label1); | |
1209 | Int_t absLabel = TMath::Abs(v0MI->fLab[i]); | |
1210 | if (absLabel < fNParticles) { | |
1211 | if (fMultiRecV0[absLabel]>0){ | |
1212 | if (fMultiRecV0[absLabel]<20) | |
1213 | fIndexRecV0[absLabel*20+fMultiRecV0[absLabel]] = iEntry; | |
1214 | } | |
1215 | else | |
1216 | fIndexRecV0[absLabel*20] = iEntry; | |
1217 | fMultiRecV0[absLabel]++; | |
1218 | } | |
1219 | } | |
1220 | } | |
1221 | ||
1222 | ||
1223 | printf("Time spended in TreeTLoop\n"); | |
1224 | timer.Print(); | |
1225 | ||
1226 | if (fDebug > 2) cerr<<"end of TreeTLoop"<<endl; | |
1227 | return 0; | |
1228 | } | |
1229 | ||
1230 | //////////////////////////////////////////////////////////////////////// | |
1231 | Int_t ESDCmpTr::TreeGenLoop(Int_t eventNr) | |
1232 | { | |
1233 | // | |
1234 | // loop over all entries for a given event, find corresponding | |
1235 | // rec. track and store in the fTreeCmp | |
1236 | // | |
1237 | TStopwatch timer; | |
1238 | timer.Start(); | |
1239 | Int_t entry = fNextTreeGenEntryToRead; | |
1240 | Double_t nParticlesTR = fTreeGenTracks->GetEntriesFast(); | |
1241 | cerr<<"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<fNParticles<<" " | |
1242 | <<nParticlesTR<<" "<<fNextTreeGenEntryToRead<<endl; | |
1243 | TBranch * branch = fTreeCmp->GetBranch("RC"); | |
1244 | branch->SetAddress(&fRecInfo); // set all pointers | |
1245 | fRecArray = new TObjArray(fNParticles); | |
1246 | AliESDtrack dummytrack; // | |
1247 | ||
1248 | while (entry < nParticlesTR) { | |
1249 | fTreeGenTracks->GetEntry(entry); | |
1250 | entry++; | |
1251 | if (eventNr < fMCInfo->fEventNr) continue; | |
1252 | if (eventNr > fMCInfo->fEventNr) continue;; | |
1253 | // | |
1254 | fNextTreeGenEntryToRead = entry-1; | |
1255 | if (fDebug > 2 && fMCInfo->fLabel < 10) { | |
1256 | cerr<<"Fill track with a label "<<fMCInfo->fLabel<<endl; | |
1257 | } | |
1258 | // if (fMCInfo->fNTPCRef<1) continue; // not TPCref | |
1259 | // | |
1260 | fRecInfo->Reset(); | |
1261 | AliESDtrack * track=0; | |
1262 | fRecInfo->fReconstructed =0; | |
1263 | TVector3 local = TR2Local(&(fMCInfo->fTrackRef),fParamTPC); | |
1264 | local.GetXYZ(fRecInfo->fTRLocalCoord); | |
1265 | // | |
1266 | if (fIndexRecTracks[fMCInfo->fLabel*20] >= 0) { | |
1267 | //track= (AliESDtrack*)fTracks->UncheckedAt(fIndexRecTracks[fMCInfo->fLabel*4]); | |
1268 | track= (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20]); | |
1269 | // | |
1270 | // | |
1271 | // find nearest track if multifound | |
1272 | //Int_t sign = Int_t(track->GetSign()*fMCInfo->fCharge); | |
1273 | // | |
1274 | Int_t status = 0; | |
1275 | if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) status++; | |
1276 | if ((track->GetStatus()&AliESDtrack::kTPCrefit)>0) status++; | |
1277 | if ((track->GetStatus()&AliESDtrack::kTRDrefit)>0) status++; | |
1278 | ||
1279 | // | |
1280 | if (fIndexRecTracks[fMCInfo->fLabel*20+1]>0){ | |
1281 | // | |
1282 | Double_t p[3]; | |
1283 | track->GetInnerPxPyPz(p); | |
1284 | Float_t maxp = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
1285 | // | |
1286 | for (Int_t i=1;i<20;i++){ | |
1287 | if (fIndexRecTracks[fMCInfo->fLabel*20+i]>=0){ | |
1288 | AliESDtrack * track2 = (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20+i]); | |
1289 | if (!track2) continue; | |
1290 | //Int_t sign2 = track->GetSign()*fMCInfo->fCharge; // | |
1291 | //if (sign2<0) continue; | |
1292 | track2->GetInnerPxPyPz(p); | |
1293 | Float_t mom = p[0]*p[0]+p[1]*p[1]+p[2]*p[2]; | |
1294 | /* | |
1295 | if (sign<0){ | |
1296 | sign = sign2; | |
1297 | track = track2; | |
1298 | maxp = mom; | |
1299 | continue; | |
1300 | } | |
1301 | */ | |
1302 | // | |
1303 | Int_t status2 = 0; | |
1304 | if ((track2->GetStatus()&AliESDtrack::kITSrefit)>0) status2++; | |
1305 | if ((track2->GetStatus()&AliESDtrack::kTPCrefit)>0) status2++; | |
1306 | if ((track2->GetStatus()&AliESDtrack::kTRDrefit)>0) status2++; | |
1307 | if (status2<status) continue; | |
1308 | // | |
1309 | if (mom<maxp) continue; | |
1310 | maxp = mom; | |
1311 | track = track2; | |
1312 | // | |
1313 | } | |
1314 | } | |
1315 | } | |
1316 | // | |
1317 | if (track) { | |
1318 | new (&(fRecInfo->fESDTrack)) AliESDtrack(*track); | |
1319 | }else{ | |
1320 | fRecInfo->fESDTrack = dummytrack; | |
1321 | } | |
1322 | ||
1323 | if (track->GetITStrack()) | |
1324 | fRecInfo->fITStrack = *((AliITStrackMI*)track->GetITStrack()); | |
1325 | else{ | |
1326 | fRecInfo->fITStrack = *track; | |
1327 | } | |
1328 | if (track->GetTRDtrack()){ | |
1329 | fRecInfo->fTRDtrack = *((AliTRDtrack*)track->GetTRDtrack()); | |
1330 | } | |
1331 | else{ | |
1332 | fRecInfo->fTRDtrack.SetdEdx(-1); | |
1333 | } | |
1334 | fRecInfo->fReconstructed = 1; | |
1335 | fRecInfo->fFake = fFakeRecTracks[fMCInfo->fLabel]; | |
1336 | fRecInfo->fMultiple = fMultiRecTracks[fMCInfo->fLabel]; | |
1337 | // | |
1338 | fRecInfo->Update(fMCInfo,fParamTPC,kTRUE, fEvent); | |
1339 | } | |
1340 | else{ | |
1341 | fRecInfo->fESDTrack = dummytrack; | |
1342 | fRecInfo->Update(fMCInfo,fParamTPC,kFALSE, fEvent); | |
1343 | } | |
1344 | fRecArray->AddAt(new AliESDRecInfo(*fRecInfo),fMCInfo->fLabel); | |
1345 | fTreeCmp->Fill(); | |
1346 | } | |
1347 | fTreeCmp->AutoSave(); | |
1348 | //fTracks->Delete(); | |
1349 | printf("Time spended in TreeGenLoop\n"); | |
1350 | timer.Print(); | |
1351 | if (fDebug > 2) cerr<<"end of TreeGenLoop"<<endl; | |
1352 | ||
1353 | return 0; | |
1354 | } | |
1355 | ||
1356 | ||
1357 | ||
1358 | //////////////////////////////////////////////////////////////////////// | |
1359 | //////////////////////////////////////////////////////////////////////// | |
1360 | //////////////////////////////////////////////////////////////////////// | |
1361 | Int_t ESDCmpTr::BuildKinkInfo0(Int_t eventNr) | |
1362 | { | |
1363 | // | |
1364 | // loop over all entries for a given event, find corresponding | |
1365 | // rec. track and store in the fTreeCmp | |
1366 | // | |
1367 | TStopwatch timer; | |
1368 | timer.Start(); | |
1369 | Int_t entry = fNextKinkToRead; | |
1370 | Double_t nParticlesTR = fTreeGenKinks->GetEntriesFast(); | |
1371 | cerr<<"fNParticles, nParticlesTR, fNextKinkToRead: "<<fNParticles<<" " | |
1372 | <<nParticlesTR<<" "<<fNextKinkToRead<<endl; | |
1373 | // | |
1374 | TBranch * branch = fTreeCmpKinks->GetBranch("RC."); | |
1375 | branch->SetAddress(&fRecKinkInfo); // set all pointers | |
1376 | ||
1377 | // | |
1378 | while (entry < nParticlesTR) { | |
1379 | fTreeGenKinks->GetEntry(entry); | |
1380 | entry++; | |
1381 | if (eventNr < fGenKinkInfo->fMCm.fEventNr) continue; | |
1382 | if (eventNr > fGenKinkInfo->fMCm.fEventNr) continue;; | |
1383 | // | |
1384 | fNextKinkToRead = entry-1; | |
1385 | // | |
1386 | // | |
1387 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->fMCm.fLabel); | |
1388 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->fMCd.fLabel); | |
1389 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
1390 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
1391 | fRecKinkInfo->fStatus =0; | |
1392 | if (fRecInfo1 && fRecInfo1->fTPCOn) fRecKinkInfo->fStatus+=1; | |
1393 | if (fRecInfo2 && fRecInfo2->fTPCOn) fRecKinkInfo->fStatus+=2; | |
1394 | if (fRecKinkInfo->fStatus==3&&fRecInfo1->fSign!=fRecInfo2->fSign) fRecKinkInfo->fStatus*=-1; | |
1395 | ||
1396 | if (fRecKinkInfo->fStatus==3){ | |
1397 | fRecKinkInfo->Update(); | |
1398 | } | |
1399 | Int_t label = TMath::Min(fGenKinkInfo->fMCm.fLabel,fGenKinkInfo->fMCd.fLabel); | |
1400 | Int_t label2 = TMath::Max(fGenKinkInfo->fMCm.fLabel,fGenKinkInfo->fMCd.fLabel); | |
1401 | ||
1402 | AliESDkink *kink=0; | |
1403 | fRecKinkInfo->fRecStatus =0; | |
1404 | fRecKinkInfo->fMultiple = fMultiRecKinks[label]; | |
1405 | fRecKinkInfo->fKinkMultiple=0; | |
1406 | // | |
1407 | if (fMultiRecKinks[label]>0){ | |
1408 | ||
1409 | // for (Int_t j=0;j<TMath::Min(fMultiRecKinks[label],100);j++){ | |
1410 | for (Int_t j=TMath::Min(fMultiRecKinks[label],Short_t(20))-1;j>=0;j--){ | |
1411 | Int_t index = fIndexRecKinks[label*20+j]; | |
1412 | //AliESDkink *kink2 = (AliESDkink*)fKinks->At(index); | |
1413 | AliESDkink *kink2 = (AliESDkink*)fEvent->GetKink(index); | |
1414 | if (TMath::Abs(kink2->fLab[0])==label &&TMath::Abs(kink2->fLab[1])==label2) { | |
1415 | fRecKinkInfo->fKinkMultiple++; | |
1416 | fSignedKinks[index]=1; | |
1417 | Int_t c0=0; | |
1418 | if (kink){ | |
1419 | // if (kink->fTRDOn) c0++; | |
1420 | //if (kink->fITSOn) c0++; | |
1421 | if (kink->GetStatus(2)>0) c0++; | |
1422 | if (kink->GetStatus(0)>0) c0++; | |
1423 | } | |
1424 | Int_t c2=0; | |
1425 | // if (kink2->fTRDOn) c2++; | |
1426 | //if (kink2->fITSOn) c2++; | |
1427 | if (kink2->GetStatus(2)>0) c2++; | |
1428 | if (kink2->GetStatus(0)>0) c2++; | |
1429 | ||
1430 | if (c2<c0) continue; | |
1431 | kink =kink2; | |
1432 | } | |
1433 | if (TMath::Abs(kink2->fLab[1])==label &&TMath::Abs(kink2->fLab[0])==label2) { | |
1434 | fRecKinkInfo->fKinkMultiple++; | |
1435 | fSignedKinks[index]=1; | |
1436 | Int_t c0=0; | |
1437 | if (kink){ | |
1438 | //if (kink->fTRDOn) c0++; | |
1439 | //if (kink->fITSOn) c0++; | |
1440 | if (kink->GetStatus(2)>0) c0++; | |
1441 | if (kink->GetStatus(0)>0) c0++; | |
1442 | ||
1443 | } | |
1444 | Int_t c2=0; | |
1445 | // if (kink2->fTRDOn) c2++; | |
1446 | //if (kink2->fITSOn) c2++; | |
1447 | if (kink2->GetStatus(2)>0) c2++; | |
1448 | if (kink2->GetStatus(0)>0) c2++; | |
1449 | ||
1450 | if (c2<c0) continue; | |
1451 | kink =kink2; | |
1452 | } | |
1453 | } | |
1454 | } | |
1455 | if (kink){ | |
1456 | fRecKinkInfo->fKink = *kink; | |
1457 | fRecKinkInfo->fRecStatus=1; | |
1458 | } | |
1459 | fTreeCmpKinks->Fill(); | |
1460 | } | |
1461 | // Int_t nkinks = fKinks->GetEntriesFast(); | |
1462 | Int_t nkinks = fEvent->GetNumberOfKinks(); | |
1463 | for (Int_t i=0;i<nkinks;i++){ | |
1464 | if (fSignedKinks[i]==0){ | |
1465 | // AliESDkink *kink = (AliESDkink*)fKinks->At(i); | |
1466 | AliESDkink *kink = (AliESDkink*)fEvent->GetKink(i); | |
1467 | if (!kink) continue; | |
1468 | // | |
1469 | fRecKinkInfo->fKink = *kink; | |
1470 | fRecKinkInfo->fRecStatus =-2; | |
1471 | // | |
1472 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->fLab[0])); | |
1473 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->fLab[1])); | |
1474 | if (fRecInfo1 && fRecInfo2){ | |
1475 | fRecKinkInfo->fT1 = (*fRecInfo1); | |
1476 | fRecKinkInfo->fT2 = (*fRecInfo2); | |
1477 | fRecKinkInfo->fRecStatus =-1; | |
1478 | } | |
1479 | fTreeCmpKinks->Fill(); | |
1480 | } | |
1481 | } | |
1482 | ||
1483 | ||
1484 | fTreeCmpKinks->AutoSave(); | |
1485 | printf("Time spended in BuilKinkInfo Loop\n"); | |
1486 | timer.Print(); | |
1487 | if (fDebug > 2) cerr<<"end of BuildKinkInfo Loop"<<endl; | |
1488 | return 0; | |
1489 | } | |
1490 | ||
1491 | ||
1492 | ||
1493 | void ESDCmpTr::MakePoints(AliESDtrack * track, AliPointsMI &points) | |
1494 | { | |
1495 | // | |
1496 | // make points in global coordinate frame | |
1497 | // | |
1498 | return; | |
1499 | /* | |
1500 | UInt_t itscl[10]; | |
1501 | Int_t nits = track->GetITSclusters(itscl); | |
1502 | Int_t tpccl[1000]; | |
1503 | Int_t ntpc = track->GetTPcclusters(tpccl); | |
1504 | UInt_t trdcl[1000]; | |
1505 | Int_t ntrd = track->GetTRDclusters(trdcl); | |
1506 | // | |
1507 | AliLoader *itsloader = fLoader->GetLoader("ITSLoader"); | |
1508 | AliLoader *tpcloader = fLoader->GetLoader("TPCLoader"); | |
1509 | AliLoader *trdloader = fLoader->GetLoader("TRDLoader"); | |
1510 | // | |
1511 | AliITStrackerMI itstracker(); | |
1512 | */ | |
1513 | } | |
1514 | ||
1515 | ||
1516 | //////////////////////////////////////////////////////////////////////// | |
1517 | //////////////////////////////////////////////////////////////////////// | |
1518 | //////////////////////////////////////////////////////////////////////// | |
1519 | ||
1520 | ||
1521 | ||
1522 | Int_t ESDCmpTr::BuildV0Info(Int_t eventNr) | |
1523 | { | |
1524 | // | |
1525 | // loop over all entries for a given event, find corresponding | |
1526 | // rec. track and store in the fTreeCmp | |
1527 | // | |
1528 | TStopwatch timer; | |
1529 | timer.Start(); | |
1530 | Int_t entry = fNextV0ToRead; | |
1531 | Double_t nParticlesTR = fTreeGenV0->GetEntriesFast(); | |
1532 | cerr<<"fNParticles, nParticlesTR, fNextV0ToRead: "<<fNParticles<<" " | |
1533 | <<nParticlesTR<<" "<<fNextV0ToRead<<endl; | |
1534 | // | |
1535 | TBranch * branch = fTreeCmpV0->GetBranch("RC."); | |
1536 | branch->SetAddress(&fRecV0Info); // set all pointers | |
1537 | const AliESDVertex * esdvertex = fEvent->GetVertex(); | |
1538 | Float_t vertex[3]= {esdvertex->GetXv(), esdvertex->GetYv(),esdvertex->GetZv()}; | |
1539 | ||
1540 | // | |
1541 | while (entry < nParticlesTR) { | |
1542 | fTreeGenV0->GetEntry(entry); | |
1543 | entry++; | |
1544 | if (eventNr < fGenV0Info->fMCm.fEventNr) continue; | |
1545 | if (eventNr > fGenV0Info->fMCm.fEventNr) continue;; | |
1546 | // | |
1547 | fNextV0ToRead = entry-1; | |
1548 | // | |
1549 | // | |
1550 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->fMCm.fLabel); | |
1551 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->fMCd.fLabel); | |
1552 | if (fGenV0Info->fMCm.fCharge*fGenV0Info->fMCd.fCharge>0) continue; // interactions | |
1553 | if (!fRecInfo1 || !fRecInfo2) continue; | |
1554 | fRecV0Info->fT1 = (*fRecInfo1); | |
1555 | fRecV0Info->fT2 = (*fRecInfo2); | |
1556 | fRecV0Info->fV0Status =0; | |
1557 | if (fRecInfo1 && fRecInfo1->fStatus[1]>0) fRecV0Info->fV0Status+=1; | |
1558 | if (fRecInfo2 && fRecInfo2->fStatus[1]>0) fRecV0Info->fV0Status+=2; | |
1559 | ||
1560 | if (fRecV0Info->fV0Status==3&&fRecInfo1->fSign==fRecInfo2->fSign) fRecV0Info->fV0Status*=-1; | |
1561 | ||
1562 | ||
1563 | if (abs(fRecV0Info->fV0Status)==3){ | |
1564 | fRecV0Info->Update(vertex); | |
1565 | { | |
1566 | // | |
1567 | // TPC V0 Info | |
1568 | Double_t x,alpha, param[5],cov[15]; | |
1569 | if ( fRecV0Info->fT1.fESDTrack.GetInnerParam() && fRecV0Info->fT2.fESDTrack.GetInnerParam()){ | |
1570 | fRecV0Info->fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
1571 | fRecV0Info->fT1.fESDTrack.GetInnerExternalCovariance(cov); | |
1572 | AliExternalTrackParam paramP(x,alpha,param,cov); | |
1573 | // | |
1574 | fRecV0Info->fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param); | |
1575 | fRecV0Info->fT2.fESDTrack.GetInnerExternalCovariance(cov); | |
1576 | AliExternalTrackParam paramM(x,alpha,param,cov); | |
1577 | // | |
1578 | fRecV0Info->fV0tpc.SetM(paramM); | |
1579 | fRecV0Info->fV0tpc.SetP(paramP); | |
1580 | Double_t pid1[5],pid2[5]; | |
1581 | fRecV0Info->fT1.fESDTrack.GetESDpid(pid1); | |
1582 | fRecV0Info->fT1.fESDTrack.GetESDpid(pid2); | |
1583 | // | |
1584 | fRecV0Info->fV0tpc.UpdatePID(pid1,pid2); | |
1585 | fRecV0Info->fV0tpc.Update(vertex); | |
1586 | ||
1587 | // | |
1588 | // | |
1589 | fRecV0Info->fT1.fESDTrack.GetExternalParameters(x,param); | |
1590 | fRecV0Info->fT1.fESDTrack.GetExternalCovariance(cov); | |
1591 | alpha = fRecV0Info->fT1.fESDTrack.GetAlpha(); | |
1592 | new (¶mP) AliExternalTrackParam(x,alpha,param,cov); | |
1593 | // | |
1594 | fRecV0Info->fT2.fESDTrack.GetExternalParameters(x,param); | |
1595 | fRecV0Info->fT2.fESDTrack.GetExternalCovariance(cov); | |
1596 | alpha = fRecV0Info->fT2.fESDTrack.GetAlpha(); | |
1597 | new (¶mM) AliExternalTrackParam(x,alpha,param,cov); | |
1598 | // | |
1599 | fRecV0Info->fV0its.SetM(paramM); | |
1600 | fRecV0Info->fV0its.SetP(paramP); | |
1601 | fRecV0Info->fV0its.UpdatePID(pid1,pid2); | |
1602 | fRecV0Info->fV0its.Update(vertex); | |
1603 | } | |
1604 | } | |
1605 | if (TMath::Abs(fGenV0Info->fMCm.fPdg)==11 &&TMath::Abs(fGenV0Info->fMCd.fPdg)==11){ | |
1606 | if (fRecV0Info->fDist2>10){ | |
1607 | fRecV0Info->Update(vertex); | |
1608 | } | |
1609 | if (fRecV0Info->fDist2>10){ | |
1610 | fRecV0Info->Update(vertex); | |
1611 | } | |
1612 | } | |
1613 | } | |
1614 | // | |
1615 | // take the V0 from reconstruction | |
1616 | ||
1617 | Int_t label = TMath::Min(fGenV0Info->fMCm.fLabel,fGenV0Info->fMCd.fLabel); | |
1618 | Int_t label2 = TMath::Max(fGenV0Info->fMCm.fLabel,fGenV0Info->fMCd.fLabel); | |
1619 | AliESDv0 *v0MI=0; | |
1620 | fRecV0Info->fRecStatus =0; | |
1621 | fRecV0Info->fMultiple = fMultiRecV0[label]; | |
1622 | fRecV0Info->fV0Multiple=0; | |
1623 | // | |
1624 | if (fMultiRecV0[label]>0 || fMultiRecV0[label2]>0){ | |
1625 | ||
1626 | // for (Int_t j=0;j<TMath::Min(fMultiRecV0s[label],100);j++){ | |
1627 | for (Int_t j=TMath::Min(fMultiRecV0[label],Short_t(20))-1;j>=0;j--){ | |
1628 | Int_t index = fIndexRecV0[label*20+j]; | |
1629 | if (index<0) continue; | |
1630 | AliESDv0 *v0MI2 = fEvent->GetV0(index); | |
1631 | if (TMath::Abs(v0MI2->fLab[0])==label &&TMath::Abs(v0MI2->fLab[1])==label2) { | |
1632 | v0MI =v0MI2; | |
1633 | fRecV0Info->fV0Multiple++; | |
1634 | fSignedV0[index]=1; | |
1635 | } | |
1636 | if (TMath::Abs(v0MI2->fLab[1])==label &&TMath::Abs(v0MI2->fLab[0])==label2) { | |
1637 | v0MI =v0MI2; | |
1638 | fRecV0Info->fV0Multiple++; | |
1639 | fSignedV0[index]=1; | |
1640 | } | |
1641 | } | |
1642 | } | |
1643 | if (v0MI){ | |
1644 | fRecV0Info->fV0rec = *v0MI; | |
1645 | fRecV0Info->fRecStatus=1; | |
1646 | } | |
1647 | ||
1648 | fTreeCmpV0->Fill(); | |
1649 | } | |
1650 | // | |
1651 | // write fake v0s | |
1652 | ||
1653 | Int_t nV0MIs = fEvent->GetNumberOfV0s(); | |
1654 | for (Int_t i=0;i<nV0MIs;i++){ | |
1655 | if (fSignedV0[i]==0){ | |
1656 | AliESDv0 *v0MI = fEvent->GetV0(i); | |
1657 | if (!v0MI) continue; | |
1658 | // | |
1659 | fRecV0Info->fV0rec = *v0MI; | |
1660 | fRecV0Info->fV0Status =-10; | |
1661 | fRecV0Info->fRecStatus =-2; | |
1662 | // | |
1663 | AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->fLab[0])); | |
1664 | AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->fLab[1])); | |
1665 | if (fRecInfo1 && fRecInfo2){ | |
1666 | fRecV0Info->fT1 = (*fRecInfo1); | |
1667 | fRecV0Info->fT2 = (*fRecInfo2); | |
1668 | fRecV0Info->fRecStatus =-1; | |
1669 | } | |
1670 | fRecV0Info->Update(vertex); | |
1671 | fTreeCmpV0->Fill(); | |
1672 | } | |
1673 | } | |
1674 | ||
1675 | ||
1676 | ||
1677 | fTreeCmpV0->AutoSave(); | |
1678 | printf("Time spended in BuilV0Info Loop\n"); | |
1679 | timer.Print(); | |
1680 | if (fDebug > 2) cerr<<"end of BuildV0Info Loop"<<endl; | |
1681 | return 0; | |
1682 | } | |
1683 | //////////////////////////////////////////////////////////////////////// | |
1684 | //////////////////////////////////////////////////////////////////////// | |
1685 | ||
1686 | void AliESDComparisonDraw::SetIO(const char *fname) | |
1687 | { | |
1688 | // | |
1689 | TFile* file = TFile::Open(fname); | |
1690 | // | |
1691 | fTree = (TTree*) file->Get("ESDcmpTracks"); | |
1692 | if (!fTree) { | |
1693 | printf("no track comparison tree found\n"); | |
1694 | file->Close(); | |
1695 | delete file; | |
1696 | } | |
1697 | } | |
1698 | ||
1699 |