1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Time Projection Chamber //
20 // Comparison macro for ESD //
22 // marian.ivanov@cern.ch //
31 .L $ALICE_ROOT/STEER/AliGenInfo.C+
32 //be sure you created genTracks file before
33 .L $ALICE_ROOT/STEER/AliESDComparisonMI.C+
35 ESDCmpTr *t2 = new ESDCmpTr("genTracks.root","cmpESDTracks.root","galice.root",-1,0,0);
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");
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");
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.")
56 AliESDComparisonDraw comp;
58 TFile f("genHits.root");
59 TTree * treel = (TTree*)f.Get("HitLines");
60 if (treel) comp->fTree->AddFriend(treel,"L");
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");
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)
78 comp.DrawXY("fTPCinP0[3]","fTPCDelta[4]/fTPCinP1[3]","fReconstructed==1"+cprim,"1",4,0.2,1.5,-0.06,0.06)
82 comp.DrawXY("fITSinP0[3]","fITSDelta[4]/fITSinP1[3]","fReconstructed==1&&fITSOn"+cprim,"1",4,0.2,1.5,-0.06,0.06)
85 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn",20,0.2,1.5)
88 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDTrack.fITSFakeRatio<0.1",10,0.2,1.5)
90 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDTrack.fITSFakeRatio>0.1",10,0.2,1.5)
93 comp.fTree->Draw("fESDTrack.fITSsignal/fESDTrack.fTPCsignal","fITSOn&&fTPCOn&&fESDTrack.fITSFakeRatio==0")
95 TH1F his("his","his",100,0,20);
96 TH1F hpools("hpools","hpools",100,-7,7);
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);
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)
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")
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);
119 hdedx3->SetXTitle("P(GeV/c)");
120 hdedx3->SetYTitle("dEdx(unit)");
121 hdedx3->Draw(); hdedx1->Draw("same"); hdedx2->Draw("same"); hdedx0->Draw("same");
123 comp.DrawXY("fITSinP0[3]","fITSPools[4]","fReconstructed==1&&fPdg==-211&&fITSOn"+cprim,"1",4,0.2,1.0,-8,8)
125 TProfile prof("prof","prof",10,0.5,5);
133 #if !defined(__CINT__) || defined(__MAKECINT__)
143 #include "TBenchmark.h"
144 #include "TStopwatch.h"
145 #include "TParticle.h"
148 #include "TVector3.h"
160 #include "AliStack.h"
161 #include "AliESDtrack.h"
162 #include "AliSimDigits.h"
163 #include "AliTPCParam.h"
165 #include "AliTPCLoader.h"
166 #include "AliDetector.h"
167 #include "AliTrackReference.h"
169 #include "AliTPCParamSR.h"
170 #include "AliTracker.h"
171 #include "AliComplexCluster.h"
172 #include "AliESDEvent.h"
173 #include "AliESDtrack.h"
174 #include "AliITStrackMI.h"
175 #include "AliTRDtrack.h"
176 #include "AliHelix.h"
177 #include "AliESDVertex.h"
178 #include "AliExternalTrackParam.h"
179 #include "AliESDkink.h"
180 #include "AliESDv0.h"
183 #include "AliGenInfo.h"
184 #include "AliESDComparisonMI.h"
190 void MakeAliases(AliESDComparisonDraw&comp)
193 // aliases definition
195 comp.fTree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)");
196 comp.fTree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy");
197 comp.fTree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy");
198 comp.fTree->SetAlias("theta","MC.fTrackRef.Theta()");
199 comp.fTree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)");
200 comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
201 comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
203 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 comp.fTree->SetAlias("dtofmc2","fESDTrack.fTrackTime[2]-(10^12*MC.fTOFReferences[0].fTime)");
206 comp.fTree->SetAlias("dtofrc2","(fESDTrack.fTrackTime[2]-fESDTrack.fTOFsignal)");
208 comp.fTree->SetAlias("psum","fESDTrack.fTOFr[4]+fESDTrack.fTOFr[3]+fESDTrack.fTOFr[2]+fESDTrack.fTOFr[1]+fESDTrack.fTOFr[0]");
209 comp.fTree->SetAlias("P0","fESDTrack.fTOFr[0]/psum");
210 comp.fTree->SetAlias("P1","fESDTrack.fTOFr[1]/psum");
211 comp.fTree->SetAlias("P2","fESDTrack.fTOFr[2]/psum");
212 comp.fTree->SetAlias("P3","fESDTrack.fTOFr[3]/psum");
213 comp.fTree->SetAlias("P4","fESDTrack.fTOFr[4]/psum");
214 comp.fTree->SetAlias("MaxP","max(max(max(P0,P1),max(P2,P3)),P4)");
220 void AliESDRecInfo::UpdatePoints(AliESDtrack*track)
224 Int_t iclusters[200];
225 Float_t density[160];
226 for (Int_t i=0;i<160;i++) density[i]=-1.;
230 if (fTPCPoints[0]<fTPCPoints[1]) return;
231 // Int_t nclusters=track->GetTPCclusters(iclusters);
237 for (Int_t i=0;i<160;i++){
238 Int_t last = i-range;
239 if (nall<range) nall++;
241 if (iclusters[last]>0&& (iclusters[last]&0x8000)==0) ngood--;
242 if (iclusters[last]==-1) undeff--;
244 if (iclusters[i]>0&& (iclusters[i]&0x8000)==0) ngood++;
245 if (iclusters[i]==-1) undeff++;
246 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
250 for (Int_t i=0;i<160;i++){
251 if (density[i]<0) continue;
252 if (density[i]>maxdens){
259 fTPCPoints[3] = maxdens;
260 fTPCPoints[1] = indexmax;
263 for (Int_t i=indexmax;i<160;i++){
264 if (density[i]<0) continue;
265 if (density[i]<maxdens/2.) {
272 for (Int_t i=indexmax;i>0;i--){
273 if (density[i]<0) continue;
274 if (density[i]<maxdens/2.) {
280 // Density at the last 30 padrows
285 for (Int_t i=159;i>0;i--){
286 if (iclusters[i]==-1) continue; //dead zone
288 if (iclusters[i]>0) ngood++;
291 fTPCPoints[4] = Float_t(ngood)/Float_t(nall);
293 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) fTPCPoints[0]=-1;
298 nclusters=track->GetTRDclusters(iclusters);
299 for (Int_t i=nclusters;i>0;i--){
309 void AliESDRecInfo::Update(AliMCInfo* info,AliTPCParam * /*par*/, Bool_t reconstructed, AliESDEvent *event)
313 //calculates derived variables
316 UpdatePoints(&fESDTrack);
318 AliTrackReference * ref = &(info->fTrackRef);
319 fTPCinR0[0] = info->fTrackRef.X();
320 fTPCinR0[1] = info->fTrackRef.Y();
321 fTPCinR0[2] = info->fTrackRef.Z();
322 fTPCinR0[3] = TMath::Sqrt(fTPCinR0[0]*fTPCinR0[0]+fTPCinR0[1]*fTPCinR0[1]);
323 fTPCinR0[4] = TMath::ATan2(fTPCinR0[1],fTPCinR0[0]);
325 fTPCinP0[0] = ref->Px();
326 fTPCinP0[1] = ref->Py();
327 fTPCinP0[2] = ref->Pz();
328 fTPCinP0[3] = ref->Pt();
329 fTPCinP0[4] = ref->P();
330 fDeltaP = (ref->P()-info->fParticle.P())/info->fParticle.P();
333 if (fTPCinP0[3]>0.0000001){
335 fTPCAngle0[0] = TMath::ATan2(fTPCinP0[1],fTPCinP0[0]);
336 fTPCAngle0[1] = TMath::ATan(fTPCinP0[2]/fTPCinP0[3]);
340 fITSinP0[0]=info->fParticle.Px();
341 fITSinP0[1]=info->fParticle.Py();
342 fITSinP0[2]=info->fParticle.Pz();
343 fITSinP0[3]=info->fParticle.Pt();
345 fITSinR0[0]=info->fParticle.Vx();
346 fITSinR0[1]=info->fParticle.Vy();
347 fITSinR0[2]=info->fParticle.Vz();
348 fITSinR0[3] = TMath::Sqrt(fITSinR0[0]*fITSinR0[0]+fITSinR0[1]*fITSinR0[1]);
349 fITSinR0[4] = TMath::ATan2(fITSinR0[1],fITSinR0[0]);
352 if (fITSinP0[3]>0.0000001){
353 fITSAngle0[0] = TMath::ATan2(fITSinP0[1],fITSinP0[0]);
354 fITSAngle0[1] = TMath::ATan(fITSinP0[2]/fITSinP0[3]);
357 for (Int_t i=0;i<4;i++) fStatus[i] =0;
358 fReconstructed = kFALSE;
362 if (reconstructed==kFALSE) return;
364 fLabels[0] = info->fLabel;
365 fLabels[1] = info->fPrimPart;
366 fReconstructed = kTRUE;
367 fTPCOn = ((fESDTrack.GetStatus()&AliESDtrack::kTPCrefit)>0) ? kTRUE : kFALSE;
368 fITSOn = ((fESDTrack.GetStatus()&AliESDtrack::kITSrefit)>0) ? kTRUE : kFALSE;
369 fTRDOn = ((fESDTrack.GetStatus()&AliESDtrack::kTRDrefit)>0) ? kTRUE : kFALSE;
372 if ((fESDTrack.GetStatus()&AliESDtrack::kTPCrefit)>0){
376 if ((fESDTrack.GetStatus()&AliESDtrack::kTPCout)>0){
380 if ((fESDTrack.GetStatus()&AliESDtrack::kTPCin)>0)
385 if ((fESDTrack.GetStatus()&AliESDtrack::kITSout)>0){
389 if ((fESDTrack.GetStatus()&AliESDtrack::kITSrefit)>0){
399 if ((fESDTrack.GetStatus()&AliESDtrack::kTRDrefit)>0){
403 if ((fESDTrack.GetStatus()&AliESDtrack::kTRDout)>0){
407 if ((fESDTrack.GetStatus()&AliESDtrack::kTRDStop)>0){
414 if (((fESDTrack.GetStatus()&AliESDtrack::kTOFout)>0)){
418 fESDTrack.GetIntegratedTimes(times);
419 for (Int_t i=0;i<5;i++){
420 if ( TMath::Abs(fESDTrack.GetTOFsignal()-times[i]) <TMath::Abs(fBestTOFmatch) ){
421 fBestTOFmatch = fESDTrack.GetTOFsignal()-times[i];
425 fESDTrack.GetTOFLabel(toflabel);
426 Bool_t toffake=kTRUE;
427 Bool_t tofdaughter=kFALSE;
428 for (Int_t i=0;i<3;i++){
429 if (toflabel[i]<0) continue;
430 if (toflabel[i]== TMath::Abs(fESDTrack.GetLabel())) toffake=kFALSE;
431 if (toflabel[i]==info->fParticle.GetDaughter(0) || (toflabel[i]==info->fParticle.GetDaughter(1))) tofdaughter=kTRUE; // decay product of original particle
434 if (toffake) fStatus[3] =3; //total fake
435 if (tofdaughter) fStatus[3]=2; //fake because of decay
441 if (fStatus[1]>0 &&info->fNTPCRef>0&&TMath::Abs(fTPCinP0[3])>0.0001){
443 fESDTrack.GetInnerXYZ(fTPCinR1);
444 fTPCinR1[3] = TMath::Sqrt(fTPCinR1[0]*fTPCinR1[0]+fTPCinR1[1]*fTPCinR1[1]);
445 fTPCinR1[4] = TMath::ATan2(fTPCinR1[1],fTPCinR1[0]);
446 fESDTrack.GetInnerPxPyPz(fTPCinP1);
447 fTPCinP1[3] = TMath::Sqrt(fTPCinP1[0]*fTPCinP1[0]+fTPCinP1[1]*fTPCinP1[1]);
448 fTPCinP1[4] = TMath::Sqrt(fTPCinP1[3]*fTPCinP1[3]+fTPCinP1[2]*fTPCinP1[2]);
451 if (fTPCinP1[3]>0.000000000000001){
452 fTPCAngle1[0] = TMath::ATan2(fTPCinP1[1],fTPCinP1[0]);
453 fTPCAngle1[1] = TMath::ATan(fTPCinP1[2]/fTPCinP1[3]);
455 Double_t cov[15], param[5],x, alpha;
456 fESDTrack.GetInnerExternalCovariance(cov);
457 fESDTrack.GetInnerExternalParameters(alpha, x,param);
460 fTPCDelta[0] = (fTPCinR0[4]-fTPCinR1[4])*fTPCinR1[3]; //delta rfi
461 fTPCPools[0] = fTPCDelta[0]/TMath::Sqrt(cov[0]);
462 fTPCDelta[1] = (fTPCinR0[2]-fTPCinR1[2]); //delta z
463 fTPCPools[1] = fTPCDelta[1]/TMath::Sqrt(cov[2]);
464 fTPCDelta[2] = (fTPCAngle0[0]-fTPCAngle1[0]);
465 fTPCPools[2] = fTPCDelta[2]/TMath::Sqrt(cov[5]);
466 fTPCDelta[3] = (TMath::Tan(fTPCAngle0[1])-TMath::Tan(fTPCAngle1[1]));
467 fTPCPools[3] = fTPCDelta[3]/TMath::Sqrt(cov[9]);
468 fTPCDelta[4] = (fTPCinP0[3]-fTPCinP1[3]);
469 Double_t sign = (param[4]>0)? 1.:-1;
471 fTPCPools[4] = sign*(1./fTPCinP0[3]-1./fTPCinP1[3])/TMath::Sqrt(TMath::Abs(cov[14]));
476 fESDTrack.GetExternalParameters(x,param);
477 // fESDTrack.GetConstrainedExternalParameters(x,param);
479 fESDTrack.GetExternalCovariance(cov);
480 //fESDTrack.GetConstrainedExternalCovariance(cov);
481 if (TMath::Abs(param[4])<0.0000000001) return;
483 fESDTrack.GetXYZ(fITSinR1);
484 fESDTrack.GetPxPyPz(fITSinP1);
485 fITSinP1[3] = TMath::Sqrt(fITSinP1[0]*fITSinP1[0]+fITSinP1[1]*fITSinP1[1]);
487 fITSinR1[3] = TMath::Sqrt(fITSinR1[0]*fITSinR1[0]+fITSinR1[1]*fITSinR1[1]);
488 fITSinR1[4] = TMath::ATan2(fITSinR1[1],fITSinR1[0]);
491 if (fITSinP1[3]>0.0000001){
492 fITSAngle1[0] = TMath::ATan2(fITSinP1[1],fITSinP1[0]);
493 fITSAngle1[1] = TMath::ATan(fITSinP1[2]/fITSinP1[3]);
497 fITSDelta[0] = (fITSinR0[4]-fITSinR1[4])*fITSinR1[3]; //delta rfi
498 fITSPools[0] = fITSDelta[0]/TMath::Sqrt(cov[0]);
499 fITSDelta[1] = (fITSinR0[2]-fITSinR1[2]); //delta z
500 fITSPools[1] = fITSDelta[1]/TMath::Sqrt(cov[2]);
501 fITSDelta[2] = (fITSAngle0[0]-fITSAngle1[0]);
502 fITSPools[2] = fITSDelta[2]/TMath::Sqrt(cov[5]);
503 fITSDelta[3] = (TMath::Tan(fITSAngle0[1])-TMath::Tan(fITSAngle1[1]));
504 fITSPools[3] = fITSDelta[3]/TMath::Sqrt(cov[9]);
505 fITSDelta[4] = (fITSinP0[3]-fITSinP1[3]);
506 Double_t sign = (param[4]>0) ? 1:-1;
508 fITSPools[4] = sign*(1./fITSinP0[3]-1./fITSinP1[3])/TMath::Sqrt(cov[14]);
514 void AliESDRecV0Info::Update(Float_t vertex[3])
517 if ( (fT1.fStatus[1]>0)&& (fT2.fStatus[1]>0)){
518 Float_t distance1,distance2;
519 Double_t xx[3],pp[3];
521 Double_t xd[3],pd[3],signd;
522 Double_t xm[3],pm[3],signm;
525 if (fT1.fITSOn&&fT2.fITSOn){
526 for (Int_t i=0;i<3;i++){
527 xd[i] = fT2.fITSinR1[i];
528 pd[i] = fT2.fITSinP1[i];
529 xm[i] = fT1.fITSinR1[i];
530 pm[i] = fT1.fITSinP1[i];
535 for (Int_t i=0;i<3;i++){
536 xd[i] = fT2.fTPCinR1[i];
537 pd[i] = fT2.fTPCinP1[i];
538 xm[i] = fT1.fTPCinR1[i];
539 pm[i] = fT1.fTPCinP1[i];
544 signd = fT2.fSign<0 ? -1:1;
545 signm = fT1.fSign<0 ? -1:1;
547 AliHelix dhelix1(xd,pd,signd);
548 dhelix1.GetMomentum(0,pp,0);
549 dhelix1.Evaluate(0,xx);
551 // Double_t x2[3],p2[3];
553 AliHelix mhelix(xm,pm,signm);
555 //find intersection linear
557 Double_t phase[2][2],radius[2];
558 Int_t points = dhelix1.GetRPHIintersections(mhelix, phase, radius,200);
559 Double_t delta1=10000,delta2=10000;
562 fRs[0] = TMath::Sqrt(radius[0]);
563 fRs[1] = TMath::Sqrt(radius[0]);
566 fRs[0] =TMath::Min(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1]));
567 fRs[1] =TMath::Max(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1]));
571 dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1);
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);
576 dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2);
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);
581 fRs[0] = TMath::Sqrt(radius[0]);
582 fRs[1] = TMath::Sqrt(radius[0]);
586 if (radius[0]<radius[1]){
587 fRs[0] = TMath::Sqrt(radius[0]);
588 fRs[1] = TMath::Sqrt(radius[1]);
592 fRs[0] = TMath::Sqrt(radius[1]);
593 fRs[1] = TMath::Sqrt(radius[0]);
599 distance1 = TMath::Min(delta1,delta2);
601 //find intersection parabolic
603 points = dhelix1.GetRPHIintersections(mhelix, phase, radius);
604 delta1=10000,delta2=10000;
607 dhelix1.ParabolicDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1);
610 dhelix1.ParabolicDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2);
613 distance2 = TMath::Min(delta1,delta2);
614 if (distance2>100) fDist2 =100;
618 dhelix1.Evaluate(phase[0][0],fXr);
619 dhelix1.GetMomentum(phase[0][0],fPdr);
620 mhelix.GetMomentum(phase[0][1],fPm);
621 dhelix1.GetAngle(phase[0][0],mhelix,phase[0][1],fAngle);
622 fRr = TMath::Sqrt(radius[0]);
625 dhelix1.Evaluate(phase[1][0],fXr);
626 dhelix1.GetMomentum(phase[1][0], fPdr);
627 mhelix.GetMomentum(phase[1][1], fPm);
628 dhelix1.GetAngle(phase[1][0],mhelix,phase[1][1],fAngle);
629 fRr = TMath::Sqrt(radius[1]);
631 fDist1 = TMath::Sqrt(distance1);
632 fDist2 = TMath::Sqrt(distance2);
635 Double_t x,alpha,param[5],cov[15];
637 fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param);
638 fT1.fESDTrack.GetInnerExternalCovariance(cov);
639 AliExternalTrackParam paramm(x,alpha,param,cov);
641 fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param);
642 fT2.fESDTrack.GetInnerExternalCovariance(cov);
643 AliExternalTrackParam paramd(x,alpha,param,cov);
648 Float_t v[3] = {fXr[0]-vertex[0],fXr[1]-vertex[1],fXr[2]-vertex[2]};
649 Float_t p[3] = {fPdr[0]+fPm[0], fPdr[1]+fPm[1],fPdr[2]+fPm[2]};
651 Float_t vnorm2 = v[0]*v[0]+v[1]*v[1];
652 Float_t vnorm3 = TMath::Sqrt(v[2]*v[2]+vnorm2);
653 vnorm2 = TMath::Sqrt(vnorm2);
654 Float_t pnorm2 = p[0]*p[0]+p[1]*p[1];
655 Float_t pnorm3 = TMath::Sqrt(p[2]*p[2]+pnorm2);
656 pnorm2 = TMath::Sqrt(pnorm2);
658 fPointAngleFi = (v[0]*p[0]+v[1]*p[1])/(vnorm2*pnorm2);
659 fPointAngleTh = (v[2]*p[2]+vnorm2*pnorm2)/(vnorm3*pnorm3);
660 fPointAngle = (v[0]*p[0]+v[1]*p[1]+v[2]*p[2])/(vnorm3*pnorm3);
665 void AliESDRecKinkInfo::Update()
668 if ( (fT1.fTPCOn)&& (fT2.fTPCOn)){
670 // IF BOTH RECONSTRUCTED
671 Float_t distance1,distance2;
672 Double_t xx[3],pp[3];
674 Double_t xd[3],pd[3],signd;
675 Double_t xm[3],pm[3],signm;
676 for (Int_t i=0;i<3;i++){
677 xd[i] = fT2.fTPCinR1[i];
678 pd[i] = fT2.fTPCinP1[i];
679 xm[i] = fT1.fTPCinR1[i];
680 pm[i] = fT1.fTPCinP1[i];
682 signd = fT2.fSign<0 ? -1:1;
683 signm = fT1.fSign<0 ? -1:1;
685 AliHelix dhelix1(xd,pd,signd);
686 dhelix1.GetMomentum(0,pp,0);
687 dhelix1.Evaluate(0,xx);
689 // Double_t x2[3],p2[3];
691 AliHelix mhelix(xm,pm,signm);
693 //find intersection linear
695 Double_t phase[2][2],radius[2];
696 Int_t points = dhelix1.GetRPHIintersections(mhelix, phase, radius,200);
697 Double_t delta1=10000,delta2=10000;
700 fMinR = TMath::Sqrt(radius[0]);
703 fMinR =TMath::Min(TMath::Sqrt(radius[0]),TMath::Sqrt(radius[1]));
707 dhelix1.LinearDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1);
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);
712 dhelix1.LinearDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2);
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);
717 fMinR = TMath::Sqrt(radius[0]);
721 if (radius[0]<radius[1]){
722 fMinR = TMath::Sqrt(radius[0]);
726 fMinR = TMath::Sqrt(radius[1]);
732 distance1 = TMath::Min(delta1,delta2);
734 //find intersection parabolic
736 points = dhelix1.GetRPHIintersections(mhelix, phase, radius);
737 delta1=10000,delta2=10000;
740 dhelix1.ParabolicDCA(mhelix,phase[0][0],phase[0][1],radius[0],delta1);
743 dhelix1.ParabolicDCA(mhelix,phase[1][0],phase[1][1],radius[1],delta2);
746 distance2 = TMath::Min(delta1,delta2);
749 dhelix1.Evaluate(phase[0][0],fXr);
750 dhelix1.GetMomentum(phase[0][0],fPdr);
751 mhelix.GetMomentum(phase[0][1],fPm);
752 dhelix1.GetAngle(phase[0][0],mhelix,phase[0][1],fAngle);
753 fRr = TMath::Sqrt(radius[0]);
756 dhelix1.Evaluate(phase[1][0],fXr);
757 dhelix1.GetMomentum(phase[1][0], fPdr);
758 mhelix.GetMomentum(phase[1][1], fPm);
759 dhelix1.GetAngle(phase[1][0],mhelix,phase[1][1],fAngle);
760 fRr = TMath::Sqrt(radius[1]);
762 fDist1 = TMath::Sqrt(distance1);
763 fDist2 = TMath::Sqrt(distance2);
766 Double_t x,alpha,param[5],cov[15];
768 fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param);
769 fT1.fESDTrack.GetInnerExternalCovariance(cov);
770 AliExternalTrackParam paramm(x,alpha,param,cov);
772 fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param);
773 fT2.fESDTrack.GetInnerExternalCovariance(cov);
774 AliExternalTrackParam paramd(x,alpha,param,cov);
777 kink.Update(¶mm,¶md);
779 Double_t diff = kink.fRr-fRr;
780 Double_t diff2 = kink.fDist2-fDist2;
781 printf("Diff\t%f\t%f\n",diff,diff2);
792 ////////////////////////////////////////////////////////////////////////
798 ////////////////////////////////////////////////////////////////////////
799 ESDCmpTr::ESDCmpTr(const char* fnGenTracks,
801 const char* fnGalice, Int_t direction,
802 Int_t nEvents, Int_t firstEvent)
805 // fFnGenTracks = fnGenTracks;
807 sprintf(fFnGenTracks,"%s",fnGenTracks);
808 sprintf(fFnCmp,"%s",fnCmp);
810 fFirstEventNr = firstEvent;
811 fEventNr = firstEvent;
813 fDirection = direction;
815 fLoader = AliRunLoader::Open(fnGalice);
817 //delete AliRunLoader::Instance();
821 if (fLoader->LoadgAlice()){
822 cerr<<"Error occured while l"<<endl;
824 Int_t nall = fLoader->GetNumberOfEvents();
832 cerr<<"no events available"<<endl;
836 if (firstEvent+nEvents>nall) {
837 fEventNr = nall-firstEvent;
838 cerr<<"restricted number of events availaible"<<endl;
844 ////////////////////////////////////////////////////////////////////////
845 ESDCmpTr::~ESDCmpTr()
852 //////////////////////////////////////////////////////////////
853 Int_t ESDCmpTr::SetIO()
858 if (!fTreeCmp) return 1;
859 fParamTPC = GetTPCParam();
861 if (!ConnectGenTree()) {
862 cerr<<"Cannot connect tree with generated tracks"<<endl;
868 //////////////////////////////////////////////////////////////
870 Int_t ESDCmpTr::SetIO(Int_t eventNr)
876 TFile f("AliESDs.root");
879 TTree* tree = (TTree*) f.Get("esdTree");
880 if(fEvent)delete fEvent;
881 fEvent = new AliESDEvent();
882 fEvent->ReadFromTree(tree);
883 tree->GetEntry(eventNr);
889 sprintf(ename,"%d",eventNr);
890 fEvent = (AliESD*)f.Get(ename);
892 sprintf(ename,"ESD%d",eventNr);
893 fEvent = (AliESD*)f.Get(ename);
896 TTree* tree = (TTree*) f.Get("esdTree");
898 Error("CheckESD", "no ESD tree found");
901 tree->SetBranchAddress("ESD", &fEvent);
902 tree->GetEntry(eventNr);
905 if (!fEvent) return 1;
912 ////////////////////////////////////////////////////////////////////////
913 void ESDCmpTr::Reset()
920 // fFnCmp = "cmpTracks.root";
928 ////////////////////////////////////////////////////////////////////////
929 Int_t ESDCmpTr::Exec(Int_t nEvents, Int_t firstEventNr)
932 fFirstEventNr = firstEventNr;
936 ////////////////////////////////////////////////////////////////////////
937 Int_t ESDCmpTr::Exec()
945 fNextTreeGenEntryToRead = 0;
948 cerr<<"fFirstEventNr, fNEvents: "<<fFirstEventNr<<" "<<fNEvents<<endl;
949 for (Int_t eventNr = fFirstEventNr; eventNr < fFirstEventNr+fNEvents;
953 fNParticles = gAlice->GetEvent(fEventNr);
955 fIndexRecTracks = new Short_t[fNParticles*20]; //write at maximum 4 tracks corresponding to particle
956 fIndexRecKinks = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle
957 fIndexRecV0 = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle
959 fFakeRecTracks = new Short_t[fNParticles];
960 fMultiRecTracks = new Short_t[fNParticles];
961 fMultiRecKinks = new Short_t[fNParticles];
962 fMultiRecV0 = new Short_t[fNParticles];
964 for (Int_t i = 0; i<fNParticles; i++) {
965 for (Int_t j=0;j<20;j++){
966 fIndexRecTracks[20*i+j] = -1;
967 fIndexRecKinks[20*i+j] = -1;
968 fIndexRecV0[20*i+j] = -1;
970 fFakeRecTracks[i] = 0;
971 fMultiRecTracks[i] = 0;
972 fMultiRecKinks[i] = 0;
976 cout<<"Start to process event "<<fEventNr<<endl;
977 cout<<"\tfNParticles = "<<fNParticles<<endl;
978 if (fDebug>2) cout<<"\tStart loop over TreeT"<<endl;
979 if (TreeTLoop()>0) return 1;
981 if (fDebug>2) cout<<"\tStart loop over tree genTracks"<<endl;
982 if (TreeGenLoop(eventNr)>0) return 1;
983 BuildKinkInfo0(eventNr);
984 BuildV0Info(eventNr);
987 if (fDebug>2) cout<<"\tEnd loop over tree genTracks"<<endl;
989 delete [] fIndexRecTracks;
990 delete [] fIndexRecKinks;
991 delete [] fIndexRecV0;
992 delete [] fFakeRecTracks;
993 delete [] fMultiRecTracks;
994 delete [] fMultiRecKinks;
995 delete [] fMultiRecV0;
1000 cerr<<"Exec finished"<<endl;
1006 ////////////////////////////////////////////////////////////////////////
1007 Bool_t ESDCmpTr::ConnectGenTree()
1010 // connect all branches from the genTracksTree
1011 // use the same variables as for the new cmp tree, it may work
1013 fFileGenTracks = TFile::Open(fFnGenTracks,"READ");
1014 if (!fFileGenTracks) {
1015 cerr<<"Error in ConnectGenTree: cannot open file "<<fFnGenTracks<<endl;
1018 fTreeGenTracks = (TTree*)fFileGenTracks->Get("genTracksTree");
1019 if (!fTreeGenTracks) {
1020 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
1021 <<fFnGenTracks<<endl;
1025 fMCInfo = new AliMCInfo;
1026 fTreeGenTracks->SetBranchAddress("MC",&fMCInfo);
1029 fTreeGenKinks = (TTree*)fFileGenTracks->Get("genKinksTree");
1030 if (!fTreeGenKinks) {
1031 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
1032 <<fFnGenTracks<<endl;
1036 fGenKinkInfo = new AliGenKinkInfo;
1037 fTreeGenKinks->SetBranchAddress("MC",&fGenKinkInfo);
1040 fTreeGenV0 = (TTree*)fFileGenTracks->Get("genV0Tree");
1042 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
1043 <<fFnGenTracks<<endl;
1047 fGenV0Info = new AliGenV0Info;
1048 fTreeGenV0->SetBranchAddress("MC",&fGenV0Info);
1052 cout<<"Number of gen. tracks with TR: "<<fTreeGenTracks->GetEntries()<<endl;
1058 ////////////////////////////////////////////////////////////////////////
1059 void ESDCmpTr::CreateTreeCmp()
1061 fFileCmp = TFile::Open(fFnCmp,"RECREATE");
1063 cerr<<"Error in CreateTreeCmp: cannot open file "<<fFnCmp<<endl;
1068 fTreeCmp = new TTree("ESDcmpTracks","ESDcmpTracks");
1069 fMCInfo = new AliMCInfo;
1070 fRecInfo = new AliESDRecInfo;
1071 AliESDtrack * esdTrack = new AliESDtrack;
1072 // AliITStrackMI * itsTrack = new AliITStrackMI;
1073 fTreeCmp->Branch("MC","AliMCInfo",&fMCInfo,256000);
1074 fTreeCmp->Branch("RC","AliESDRecInfo",&fRecInfo,256000);
1075 // fTreeCmp->Branch("fESDTrack","AliESDtrack",&esdTrack);
1076 // fTreeCmp->Branch("ITS","AliITStrackMI",&itsTrack);
1080 fTreeCmpKinks = new TTree("ESDcmpKinks","ESDcmpKinks");
1081 fGenKinkInfo = new AliGenKinkInfo;
1082 fRecKinkInfo = new AliESDRecKinkInfo;
1083 fTreeCmpKinks->Branch("MC.","AliGenKinkInfo",&fGenKinkInfo,256000);
1084 fTreeCmpKinks->Branch("RC.","AliESDRecKinkInfo",&fRecKinkInfo,256000);
1087 fTreeCmpV0 = new TTree("ESDcmpV0","ESDcmpV0");
1088 fGenV0Info = new AliGenV0Info;
1089 fRecV0Info = new AliESDRecV0Info;
1090 fTreeCmpV0->Branch("MC.","AliGenV0Info", &fGenV0Info,256000);
1091 fTreeCmpV0->Branch("RC.","AliESDRecV0Info",&fRecV0Info,256000);
1093 fTreeCmp->AutoSave();
1094 fTreeCmpKinks->AutoSave();
1095 fTreeCmpV0->AutoSave();
1097 ////////////////////////////////////////////////////////////////////////
1098 void ESDCmpTr::CloseOutputFile()
1101 cerr<<"File "<<fFnCmp<<" not found as an open file."<<endl;
1112 ////////////////////////////////////////////////////////////////////////
1114 TVector3 ESDCmpTr::TR2Local(AliTrackReference *trackRef,
1115 AliTPCParam *paramTPC) {
1117 Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()};
1119 paramTPC->Transform0to1(x,index);
1120 paramTPC->Transform1to2Ideal(x,index);
1123 ////////////////////////////////////////////////////////////////////////
1125 Int_t ESDCmpTr::TreeTLoop()
1128 // loop over all ESD reconstructed tracks and store info in memory
1130 // + loop over all reconstructed kinks
1134 Int_t nEntries = (Int_t)fEvent->GetNumberOfTracks();
1135 Int_t nKinks = (Int_t) fEvent->GetNumberOfKinks();
1136 Int_t nV0MIs = (Int_t) fEvent->GetNumberOfV0s();
1137 fSignedKinks = new Short_t[nKinks];
1138 fSignedV0 = new Short_t[nV0MIs];
1140 // load kinks to the memory
1141 for (Int_t i=0; i<nKinks;i++){
1142 AliESDkink * kink =fEvent->GetKink(i);
1144 if (kink->fStatus<0) continue;
1147 for (Int_t i=0; i<nV0MIs;i++){
1148 AliESDv0 * v0MI =fEvent->GetV0(i);
1150 if (v0MI->fStatus<0) continue;
1155 AliESDtrack * track=0;
1156 for (Int_t iEntry=0; iEntry<nEntries;iEntry++){
1157 //track = (AliESDtrack*)fTracks->UncheckedAt(iEntry);
1158 track = (AliESDtrack*)fEvent->GetTrack(iEntry);
1160 Int_t label = track->GetLabel();
1161 Int_t absLabel = abs(label);
1162 if (absLabel < fNParticles) {
1163 // fIndexRecTracks[absLabel] = iEntry;
1164 if (label < 0) fFakeRecTracks[absLabel]++;
1165 if (fMultiRecTracks[absLabel]>0){
1166 if (fMultiRecTracks[absLabel]<20)
1167 fIndexRecTracks[absLabel*20+fMultiRecTracks[absLabel]] = iEntry;
1170 fIndexRecTracks[absLabel*20] = iEntry;
1171 fMultiRecTracks[absLabel]++;
1174 // sort reconstructed kinks
1176 AliESDkink * kink=0;
1177 for (Int_t iEntry=0; iEntry<nKinks;iEntry++){
1178 kink = (AliESDkink*)fEvent->GetKink(iEntry);
1179 if (!kink) continue;
1181 Int_t label0 = TMath::Abs(kink->fLab[0]);
1182 Int_t label1 = TMath::Abs(kink->fLab[1]);
1183 Int_t absLabel = TMath::Min(label0,label1);
1184 if (absLabel < fNParticles) {
1185 if (fMultiRecKinks[absLabel]>0){
1186 if (fMultiRecKinks[absLabel]<20)
1187 fIndexRecKinks[absLabel*20+fMultiRecKinks[absLabel]] = iEntry;
1190 fIndexRecKinks[absLabel*20] = iEntry;
1191 fMultiRecKinks[absLabel]++;
1194 // --sort reconstructed V0
1197 for (Int_t iEntry=0; iEntry<nV0MIs;iEntry++){
1198 v0MI = fEvent->GetV0(iEntry);
1199 if (!v0MI) continue;
1201 // Int_t label0 = TMath::Abs(v0MI->fLab[0]);
1202 //Int_t label1 = TMath::Abs(v0MI->fLab[1]);
1204 for (Int_t i=0;i<2;i++){
1205 // Int_t absLabel = TMath::Min(label0,label1);
1206 Int_t absLabel = TMath::Abs(v0MI->fLab[i]);
1207 if (absLabel < fNParticles) {
1208 if (fMultiRecV0[absLabel]>0){
1209 if (fMultiRecV0[absLabel]<20)
1210 fIndexRecV0[absLabel*20+fMultiRecV0[absLabel]] = iEntry;
1213 fIndexRecV0[absLabel*20] = iEntry;
1214 fMultiRecV0[absLabel]++;
1220 printf("Time spended in TreeTLoop\n");
1223 if (fDebug > 2) cerr<<"end of TreeTLoop"<<endl;
1227 ////////////////////////////////////////////////////////////////////////
1228 Int_t ESDCmpTr::TreeGenLoop(Int_t eventNr)
1231 // loop over all entries for a given event, find corresponding
1232 // rec. track and store in the fTreeCmp
1236 Int_t entry = fNextTreeGenEntryToRead;
1237 Double_t nParticlesTR = fTreeGenTracks->GetEntriesFast();
1238 cerr<<"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<fNParticles<<" "
1239 <<nParticlesTR<<" "<<fNextTreeGenEntryToRead<<endl;
1240 TBranch * branch = fTreeCmp->GetBranch("RC");
1241 branch->SetAddress(&fRecInfo); // set all pointers
1242 fRecArray = new TObjArray(fNParticles);
1243 AliESDtrack dummytrack; //
1245 while (entry < nParticlesTR) {
1246 fTreeGenTracks->GetEntry(entry);
1248 if (eventNr < fMCInfo->fEventNr) continue;
1249 if (eventNr > fMCInfo->fEventNr) continue;;
1251 fNextTreeGenEntryToRead = entry-1;
1252 if (fDebug > 2 && fMCInfo->fLabel < 10) {
1253 cerr<<"Fill track with a label "<<fMCInfo->fLabel<<endl;
1255 // if (fMCInfo->fNTPCRef<1) continue; // not TPCref
1258 AliESDtrack * track=0;
1259 fRecInfo->fReconstructed =0;
1260 TVector3 local = TR2Local(&(fMCInfo->fTrackRef),fParamTPC);
1261 local.GetXYZ(fRecInfo->fTRLocalCoord);
1263 if (fIndexRecTracks[fMCInfo->fLabel*20] >= 0) {
1264 //track= (AliESDtrack*)fTracks->UncheckedAt(fIndexRecTracks[fMCInfo->fLabel*4]);
1265 track= (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20]);
1268 // find nearest track if multifound
1269 //Int_t sign = Int_t(track->GetSign()*fMCInfo->fCharge);
1272 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) status++;
1273 if ((track->GetStatus()&AliESDtrack::kTPCrefit)>0) status++;
1274 if ((track->GetStatus()&AliESDtrack::kTRDrefit)>0) status++;
1277 if (fIndexRecTracks[fMCInfo->fLabel*20+1]>0){
1280 track->GetInnerPxPyPz(p);
1281 Float_t maxp = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
1283 for (Int_t i=1;i<20;i++){
1284 if (fIndexRecTracks[fMCInfo->fLabel*20+i]>=0){
1285 AliESDtrack * track2 = (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20+i]);
1286 if (!track2) continue;
1287 //Int_t sign2 = track->GetSign()*fMCInfo->fCharge; //
1288 //if (sign2<0) continue;
1289 track2->GetInnerPxPyPz(p);
1290 Float_t mom = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
1301 if ((track2->GetStatus()&AliESDtrack::kITSrefit)>0) status2++;
1302 if ((track2->GetStatus()&AliESDtrack::kTPCrefit)>0) status2++;
1303 if ((track2->GetStatus()&AliESDtrack::kTRDrefit)>0) status2++;
1304 if (status2<status) continue;
1306 if (mom<maxp) continue;
1315 new (&(fRecInfo->fESDTrack)) AliESDtrack(*track);
1317 fRecInfo->fESDTrack = dummytrack;
1320 if (track->GetITStrack())
1321 fRecInfo->fITStrack = *((AliITStrackMI*)track->GetITStrack());
1323 fRecInfo->fITStrack = *track;
1325 if (track->GetTRDtrack()){
1326 fRecInfo->fTRDtrack = *((AliTRDtrack*)track->GetTRDtrack());
1329 fRecInfo->fTRDtrack.SetdEdx(-1);
1331 fRecInfo->fReconstructed = 1;
1332 fRecInfo->fFake = fFakeRecTracks[fMCInfo->fLabel];
1333 fRecInfo->fMultiple = fMultiRecTracks[fMCInfo->fLabel];
1335 fRecInfo->Update(fMCInfo,fParamTPC,kTRUE, fEvent);
1338 fRecInfo->fESDTrack = dummytrack;
1339 fRecInfo->Update(fMCInfo,fParamTPC,kFALSE, fEvent);
1341 fRecArray->AddAt(new AliESDRecInfo(*fRecInfo),fMCInfo->fLabel);
1344 fTreeCmp->AutoSave();
1345 //fTracks->Delete();
1346 printf("Time spended in TreeGenLoop\n");
1348 if (fDebug > 2) cerr<<"end of TreeGenLoop"<<endl;
1355 ////////////////////////////////////////////////////////////////////////
1356 ////////////////////////////////////////////////////////////////////////
1357 ////////////////////////////////////////////////////////////////////////
1358 Int_t ESDCmpTr::BuildKinkInfo0(Int_t eventNr)
1361 // loop over all entries for a given event, find corresponding
1362 // rec. track and store in the fTreeCmp
1366 Int_t entry = fNextKinkToRead;
1367 Double_t nParticlesTR = fTreeGenKinks->GetEntriesFast();
1368 cerr<<"fNParticles, nParticlesTR, fNextKinkToRead: "<<fNParticles<<" "
1369 <<nParticlesTR<<" "<<fNextKinkToRead<<endl;
1371 TBranch * branch = fTreeCmpKinks->GetBranch("RC.");
1372 branch->SetAddress(&fRecKinkInfo); // set all pointers
1375 while (entry < nParticlesTR) {
1376 fTreeGenKinks->GetEntry(entry);
1378 if (eventNr < fGenKinkInfo->fMCm.fEventNr) continue;
1379 if (eventNr > fGenKinkInfo->fMCm.fEventNr) continue;;
1381 fNextKinkToRead = entry-1;
1384 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->fMCm.fLabel);
1385 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->fMCd.fLabel);
1386 fRecKinkInfo->fT1 = (*fRecInfo1);
1387 fRecKinkInfo->fT2 = (*fRecInfo2);
1388 fRecKinkInfo->fStatus =0;
1389 if (fRecInfo1 && fRecInfo1->fTPCOn) fRecKinkInfo->fStatus+=1;
1390 if (fRecInfo2 && fRecInfo2->fTPCOn) fRecKinkInfo->fStatus+=2;
1391 if (fRecKinkInfo->fStatus==3&&fRecInfo1->fSign!=fRecInfo2->fSign) fRecKinkInfo->fStatus*=-1;
1393 if (fRecKinkInfo->fStatus==3){
1394 fRecKinkInfo->Update();
1396 Int_t label = TMath::Min(fGenKinkInfo->fMCm.fLabel,fGenKinkInfo->fMCd.fLabel);
1397 Int_t label2 = TMath::Max(fGenKinkInfo->fMCm.fLabel,fGenKinkInfo->fMCd.fLabel);
1400 fRecKinkInfo->fRecStatus =0;
1401 fRecKinkInfo->fMultiple = fMultiRecKinks[label];
1402 fRecKinkInfo->fKinkMultiple=0;
1404 if (fMultiRecKinks[label]>0){
1406 // for (Int_t j=0;j<TMath::Min(fMultiRecKinks[label],100);j++){
1407 for (Int_t j=TMath::Min(fMultiRecKinks[label],Short_t(20))-1;j>=0;j--){
1408 Int_t index = fIndexRecKinks[label*20+j];
1409 //AliESDkink *kink2 = (AliESDkink*)fKinks->At(index);
1410 AliESDkink *kink2 = (AliESDkink*)fEvent->GetKink(index);
1411 if (TMath::Abs(kink2->fLab[0])==label &&TMath::Abs(kink2->fLab[1])==label2) {
1412 fRecKinkInfo->fKinkMultiple++;
1413 fSignedKinks[index]=1;
1416 // if (kink->fTRDOn) c0++;
1417 //if (kink->fITSOn) c0++;
1418 if (kink->GetStatus(2)>0) c0++;
1419 if (kink->GetStatus(0)>0) c0++;
1422 // if (kink2->fTRDOn) c2++;
1423 //if (kink2->fITSOn) c2++;
1424 if (kink2->GetStatus(2)>0) c2++;
1425 if (kink2->GetStatus(0)>0) c2++;
1427 if (c2<c0) continue;
1430 if (TMath::Abs(kink2->fLab[1])==label &&TMath::Abs(kink2->fLab[0])==label2) {
1431 fRecKinkInfo->fKinkMultiple++;
1432 fSignedKinks[index]=1;
1435 //if (kink->fTRDOn) c0++;
1436 //if (kink->fITSOn) c0++;
1437 if (kink->GetStatus(2)>0) c0++;
1438 if (kink->GetStatus(0)>0) c0++;
1442 // if (kink2->fTRDOn) c2++;
1443 //if (kink2->fITSOn) c2++;
1444 if (kink2->GetStatus(2)>0) c2++;
1445 if (kink2->GetStatus(0)>0) c2++;
1447 if (c2<c0) continue;
1453 fRecKinkInfo->fKink = *kink;
1454 fRecKinkInfo->fRecStatus=1;
1456 fTreeCmpKinks->Fill();
1458 // Int_t nkinks = fKinks->GetEntriesFast();
1459 Int_t nkinks = fEvent->GetNumberOfKinks();
1460 for (Int_t i=0;i<nkinks;i++){
1461 if (fSignedKinks[i]==0){
1462 // AliESDkink *kink = (AliESDkink*)fKinks->At(i);
1463 AliESDkink *kink = (AliESDkink*)fEvent->GetKink(i);
1464 if (!kink) continue;
1466 fRecKinkInfo->fKink = *kink;
1467 fRecKinkInfo->fRecStatus =-2;
1469 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->fLab[0]));
1470 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->fLab[1]));
1471 if (fRecInfo1 && fRecInfo2){
1472 fRecKinkInfo->fT1 = (*fRecInfo1);
1473 fRecKinkInfo->fT2 = (*fRecInfo2);
1474 fRecKinkInfo->fRecStatus =-1;
1476 fTreeCmpKinks->Fill();
1481 fTreeCmpKinks->AutoSave();
1482 printf("Time spended in BuilKinkInfo Loop\n");
1484 if (fDebug > 2) cerr<<"end of BuildKinkInfo Loop"<<endl;
1490 void ESDCmpTr::MakePoints(AliESDtrack * track, AliPointsMI &points)
1493 // make points in global coordinate frame
1498 Int_t nits = track->GetITSclusters(itscl);
1500 Int_t ntpc = track->GetTPcclusters(tpccl);
1502 Int_t ntrd = track->GetTRDclusters(trdcl);
1504 AliLoader *itsloader = fLoader->GetLoader("ITSLoader");
1505 AliLoader *tpcloader = fLoader->GetLoader("TPCLoader");
1506 AliLoader *trdloader = fLoader->GetLoader("TRDLoader");
1508 AliITStrackerMI itstracker();
1513 ////////////////////////////////////////////////////////////////////////
1514 ////////////////////////////////////////////////////////////////////////
1515 ////////////////////////////////////////////////////////////////////////
1519 Int_t ESDCmpTr::BuildV0Info(Int_t eventNr)
1522 // loop over all entries for a given event, find corresponding
1523 // rec. track and store in the fTreeCmp
1527 Int_t entry = fNextV0ToRead;
1528 Double_t nParticlesTR = fTreeGenV0->GetEntriesFast();
1529 cerr<<"fNParticles, nParticlesTR, fNextV0ToRead: "<<fNParticles<<" "
1530 <<nParticlesTR<<" "<<fNextV0ToRead<<endl;
1532 TBranch * branch = fTreeCmpV0->GetBranch("RC.");
1533 branch->SetAddress(&fRecV0Info); // set all pointers
1534 const AliESDVertex * esdvertex = fEvent->GetVertex();
1535 Float_t vertex[3]= {esdvertex->GetXv(), esdvertex->GetYv(),esdvertex->GetZv()};
1538 while (entry < nParticlesTR) {
1539 fTreeGenV0->GetEntry(entry);
1541 if (eventNr < fGenV0Info->fMCm.fEventNr) continue;
1542 if (eventNr > fGenV0Info->fMCm.fEventNr) continue;;
1544 fNextV0ToRead = entry-1;
1547 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->fMCm.fLabel);
1548 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->fMCd.fLabel);
1549 if (fGenV0Info->fMCm.fCharge*fGenV0Info->fMCd.fCharge>0) continue; // interactions
1550 if (!fRecInfo1 || !fRecInfo2) continue;
1551 fRecV0Info->fT1 = (*fRecInfo1);
1552 fRecV0Info->fT2 = (*fRecInfo2);
1553 fRecV0Info->fV0Status =0;
1554 if (fRecInfo1 && fRecInfo1->fStatus[1]>0) fRecV0Info->fV0Status+=1;
1555 if (fRecInfo2 && fRecInfo2->fStatus[1]>0) fRecV0Info->fV0Status+=2;
1557 if (fRecV0Info->fV0Status==3&&fRecInfo1->fSign==fRecInfo2->fSign) fRecV0Info->fV0Status*=-1;
1560 if (abs(fRecV0Info->fV0Status)==3){
1561 fRecV0Info->Update(vertex);
1565 Double_t x,alpha, param[5],cov[15];
1566 if ( fRecV0Info->fT1.fESDTrack.GetInnerParam() && fRecV0Info->fT2.fESDTrack.GetInnerParam()){
1567 fRecV0Info->fT1.fESDTrack.GetInnerExternalParameters(alpha,x,param);
1568 fRecV0Info->fT1.fESDTrack.GetInnerExternalCovariance(cov);
1569 AliExternalTrackParam paramP(x,alpha,param,cov);
1571 fRecV0Info->fT2.fESDTrack.GetInnerExternalParameters(alpha,x,param);
1572 fRecV0Info->fT2.fESDTrack.GetInnerExternalCovariance(cov);
1573 AliExternalTrackParam paramM(x,alpha,param,cov);
1575 fRecV0Info->fV0tpc.SetM(paramM);
1576 fRecV0Info->fV0tpc.SetP(paramP);
1577 Double_t pid1[5],pid2[5];
1578 fRecV0Info->fT1.fESDTrack.GetESDpid(pid1);
1579 fRecV0Info->fT1.fESDTrack.GetESDpid(pid2);
1581 fRecV0Info->fV0tpc.UpdatePID(pid1,pid2);
1582 fRecV0Info->fV0tpc.Update(vertex);
1586 fRecV0Info->fT1.fESDTrack.GetExternalParameters(x,param);
1587 fRecV0Info->fT1.fESDTrack.GetExternalCovariance(cov);
1588 alpha = fRecV0Info->fT1.fESDTrack.GetAlpha();
1589 new (¶mP) AliExternalTrackParam(x,alpha,param,cov);
1591 fRecV0Info->fT2.fESDTrack.GetExternalParameters(x,param);
1592 fRecV0Info->fT2.fESDTrack.GetExternalCovariance(cov);
1593 alpha = fRecV0Info->fT2.fESDTrack.GetAlpha();
1594 new (¶mM) AliExternalTrackParam(x,alpha,param,cov);
1596 fRecV0Info->fV0its.SetM(paramM);
1597 fRecV0Info->fV0its.SetP(paramP);
1598 fRecV0Info->fV0its.UpdatePID(pid1,pid2);
1599 fRecV0Info->fV0its.Update(vertex);
1602 if (TMath::Abs(fGenV0Info->fMCm.fPdg)==11 &&TMath::Abs(fGenV0Info->fMCd.fPdg)==11){
1603 if (fRecV0Info->fDist2>10){
1604 fRecV0Info->Update(vertex);
1606 if (fRecV0Info->fDist2>10){
1607 fRecV0Info->Update(vertex);
1612 // take the V0 from reconstruction
1614 Int_t label = TMath::Min(fGenV0Info->fMCm.fLabel,fGenV0Info->fMCd.fLabel);
1615 Int_t label2 = TMath::Max(fGenV0Info->fMCm.fLabel,fGenV0Info->fMCd.fLabel);
1617 fRecV0Info->fRecStatus =0;
1618 fRecV0Info->fMultiple = fMultiRecV0[label];
1619 fRecV0Info->fV0Multiple=0;
1621 if (fMultiRecV0[label]>0 || fMultiRecV0[label2]>0){
1623 // for (Int_t j=0;j<TMath::Min(fMultiRecV0s[label],100);j++){
1624 for (Int_t j=TMath::Min(fMultiRecV0[label],Short_t(20))-1;j>=0;j--){
1625 Int_t index = fIndexRecV0[label*20+j];
1626 if (index<0) continue;
1627 AliESDv0 *v0MI2 = fEvent->GetV0(index);
1628 if (TMath::Abs(v0MI2->fLab[0])==label &&TMath::Abs(v0MI2->fLab[1])==label2) {
1630 fRecV0Info->fV0Multiple++;
1633 if (TMath::Abs(v0MI2->fLab[1])==label &&TMath::Abs(v0MI2->fLab[0])==label2) {
1635 fRecV0Info->fV0Multiple++;
1641 fRecV0Info->fV0rec = *v0MI;
1642 fRecV0Info->fRecStatus=1;
1650 Int_t nV0MIs = fEvent->GetNumberOfV0s();
1651 for (Int_t i=0;i<nV0MIs;i++){
1652 if (fSignedV0[i]==0){
1653 AliESDv0 *v0MI = fEvent->GetV0(i);
1654 if (!v0MI) continue;
1656 fRecV0Info->fV0rec = *v0MI;
1657 fRecV0Info->fV0Status =-10;
1658 fRecV0Info->fRecStatus =-2;
1660 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->fLab[0]));
1661 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->fLab[1]));
1662 if (fRecInfo1 && fRecInfo2){
1663 fRecV0Info->fT1 = (*fRecInfo1);
1664 fRecV0Info->fT2 = (*fRecInfo2);
1665 fRecV0Info->fRecStatus =-1;
1667 fRecV0Info->Update(vertex);
1674 fTreeCmpV0->AutoSave();
1675 printf("Time spended in BuilV0Info Loop\n");
1677 if (fDebug > 2) cerr<<"end of BuildV0Info Loop"<<endl;
1680 ////////////////////////////////////////////////////////////////////////
1681 ////////////////////////////////////////////////////////////////////////
1683 void AliESDComparisonDraw::SetIO(const char *fname)
1686 TFile* file = TFile::Open(fname);
1688 fTree = (TTree*) file->Get("ESDcmpTracks");
1690 printf("no track comparison tree found\n");