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 //
32 gSystem->Load("libPWG1.so");
34 AliRecInfoMaker *t2 = new AliRecInfoMaker("genTracks.root","cmpESDTracks.root","galice.root",0,0);
38 TFile f("cmpESDTracks.root");
39 TTree * tree = (TTree*)f.Get("ESDcmpTracks");
47 //some cuts definition
48 TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.01&&abs(MC.fVDist[2])<0.01")
49 //TCut cprim("cprim","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<0.5&&abs(MC.fVDist[2])<0.5")
50 //TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<3.9");
51 TCut citsin("citsin","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)<5");
52 TCut csec("csec","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)>0.5");
55 TCut crec("crec","fReconstructed==1");
56 TCut cteta1("cteta1","abs(MC.fParticle.Theta()/3.1415-0.5)<0.25");
57 TCut cteta05("cteta05","abs(MC.fParticle.Theta()/3.1415-0.5)<0.1");
59 TCut cpos1("cpos1","abs(MC.fParticle.fVz/sqrt(MC.fParticle.fVx*MC.fParticle.fVx+MC.fParticle.fVy*MC.fParticle.fVy))<1");
60 TCut csens("csens","abs(sqrt(fVDist[0]**2+fVDist[1]**2)-170)<50");
61 TCut cmuon("cmuon","abs(MC.fParticle.fPdgCode==-13)");
62 TCut cchi2("cchi2","fESDtrack.fITSchi2MIP[0]<7.&&fESDtrack.fITSchi2MIP[1]<5.&&fESDtrack.fITSchi2MIP[2]<7.&&fESDtrack.fITSchi2MIP[3]<7.5&&fESDtrack.fITSchi2MIP[4]<6.")
67 comp.fTree->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)");
68 comp.fTree->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy");
69 comp.fTree->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy");
70 comp.fTree->SetAlias("theta","MC.fTrackRef.Theta()");
71 comp.fTree->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)");
72 comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
73 comp.fTree->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
76 TH1F his("his","his",100,0,20);
77 TH1F hpools("hpools","hpools",100,-7,7);
78 TH1F hfake("hfake","hfake",1000,0,150);
79 TProfile profp0("profp0","profp0",20,-0.4,0.9)
81 comp.DrawXY("fTPCinP0[3]","fTPCDelta[4]/fTPCinP1[3]","fReconstructed==1"+cprim,"1",4,0.2,1.5,-0.06,0.06)
85 comp.DrawXY("fITSinP0[3]","fITSDelta[4]/fITSinP1[3]","fReconstructed==1&&fITSOn"+cprim,"1",4,0.2,1.5,-0.06,0.06)
88 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn",20,0.2,1.5)
91 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDtrack.fITSFakeRatio<0.1",10,0.2,1.5)
93 comp.Eff("fTPCinP0[3]","fRowsWithDigits>120"+cteta1+cpos1+cprim,"fTPCOn&&fITSOn&&fESDtrack.fITSFakeRatio>0.1",10,0.2,1.5)
96 comp.fTree->Draw("fESDtrack.fITSsignal/fESDtrack.fTPCsignal","fITSOn&&fTPCOn&&fESDtrack.fITSFakeRatio==0")
98 TH1F his("his","his",100,0,20);
99 TH1F hpools("hpools","hpools",100,-7,7);
101 TH2F * hdedx0 = new TH2F("dEdx0","dEdx0",100, 0,2,200,0,550); hdedx0->SetMarkerColor(1);
102 TH2F * hdedx1 = new TH2F("dEdx1","dEdx1",100, 0,2,200,0,550); hdedx1->SetMarkerColor(4);
103 TH2F * hdedx2 = new TH2F("dEdx2","dEdx2",100, 0,2,200,0,550); hdedx2->SetMarkerColor(3);
104 TH2F * hdedx3 = new TH2F("dEdx3","dEdx3",100, 0,2,200,0,550); hdedx3->SetMarkerColor(2);
106 comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx0","fITSOn&&abs(fPdg)==211&&fITStrack.fN==6"+cprim)
107 comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx1","fITSOn&&abs(fPdg)==2212&&fITStrack.fN==6"+cprim)
108 comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx2","fITSOn&&abs(fPdg)==321&&fITStrack.fN==6"+cprim)
109 comp.fTree->Draw("fESDtrack.fITSsignal:MC.fParticle.P()>>dEdx3","fITSOn&&abs(fPdg)==11&&fITStrack.fN==6"+cprim)
112 comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx0","fTRDOn&&abs(fPdg)==211&&fTRDtrack.fN>40&&fStatus[2]>1")
113 comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx1","fTRDOn&&abs(fPdg)==2212&&fTRDtrack.fN>40&&fStatus[2]>1")
114 comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx2","fTRDOn&&abs(fPdg)==321&&fTRDtrack.fN>40&&fStatus[2]>1")
115 comp.fTree->Draw("fESDtrack.fTRDsignal:MC.fParticle.P()>>dEdx3","fTRDOn&&abs(fPdg)==11&&fTRDtrack.fN>40&&fStatus[2]>1")
117 comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx0","fTPCOn&&abs(fPdg)==211&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1);
118 comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx1","fTPCOn&&abs(fPdg)==2212&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1);
119 comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx2","fTPCOn&&abs(fPdg)==321&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1);
120 comp.fTree->Draw("fESDtrack.fTPCsignal:fTPCinP0[4]>>dEdx3","fTPCOn&&abs(fPdg)==11&&fESDtrack.fTPCncls>180&&fESDtrack.fTPCsignal>10"+cteta1);
122 hdedx3->SetXTitle("P(GeV/c)");
123 hdedx3->SetYTitle("dEdx(unit)");
124 hdedx3->Draw(); hdedx1->Draw("same"); hdedx2->Draw("same"); hdedx0->Draw("same");
126 comp.DrawXY("fITSinP0[3]","fITSPools[4]","fReconstructed==1&&fPdg==-211&&fITSOn"+cprim,"1",4,0.2,1.0,-8,8)
128 TProfile prof("prof","prof",10,0.5,5);
142 #include "TStopwatch.h"
143 #include "TVector3.h"
149 #include "AliESDtrack.h"
150 #include "AliTPCParam.h"
152 #include "AliTrackReference.h"
153 #include "AliTPCParamSR.h"
154 #include "AliTracker.h"
155 #include "AliESDEvent.h"
157 #include "AliESDfriend.h"
158 #include "AliESDtrack.h"
159 #include "AliTPCseed.h"
160 #include "AliITStrackMI.h"
161 #include "AliESDVertex.h"
162 #include "AliExternalTrackParam.h"
163 #include "AliESDkink.h"
164 #include "AliESDv0.h"
167 #include "AliTreeDraw.h"
168 #include "AliGenInfo.h"
169 #include "AliRecInfo.h"
170 #include "AliRecInfoMaker.h"
174 ClassImp(AliRecInfoMaker)
179 AliTPCParam * AliRecInfoMaker::GetTPCParam(){
183 AliTPCParamSR * par = new AliTPCParamSR;
190 void MakeAliases(AliTreeDraw&comp)
193 // aliases definition
195 comp.T()->SetAlias("radius","TMath::Sqrt(MC.fVDist[0]**2+MC.fVDist[1]**2)");
196 comp.T()->SetAlias("direction","MC.fParticle.fVx*MC.fParticle.fPx+MC.fParticle.fVy*MC.fParticle.fPy");
197 comp.T()->SetAlias("decaydir","MC.fTRdecay.fX*MC.fTRdecay.fPx+MC.fTRdecay.fY*MC.fTRdecay.fPy");
198 comp.T()->SetAlias("theta","MC.fTrackRef.Theta()");
199 comp.T()->SetAlias("primdca","sqrt(RC.fITStrack.fD[0]**2+RC.fITStrack.fD[1]**2)");
200 comp.T()->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
201 comp.T()->SetAlias("trdchi2","fTRDtrack.fChi2/fTRDtrack.fN");
203 comp.T()->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.T()->SetAlias("dtofmc2","fESDtrack.fTrackTime[2]-(10^12*MC.fTOFReferences[0].fTime)");
206 comp.T()->SetAlias("dtofrc2","(fESDtrack.fTrackTime[2]-fESDtrack.fTOFsignal)");
208 comp.T()->SetAlias("psum","fESDtrack.fTOFr[4]+fESDtrack.fTOFr[3]+fESDtrack.fTOFr[2]+fESDtrack.fTOFr[1]+fESDtrack.fTOFr[0]");
209 comp.T()->SetAlias("P0","fESDtrack.fTOFr[0]/psum");
210 comp.T()->SetAlias("P1","fESDtrack.fTOFr[1]/psum");
211 comp.T()->SetAlias("P2","fESDtrack.fTOFr[2]/psum");
212 comp.T()->SetAlias("P3","fESDtrack.fTOFr[3]/psum");
213 comp.T()->SetAlias("P4","fESDtrack.fTOFr[4]/psum");
214 comp.T()->SetAlias("MaxP","max(max(max(P0,P1),max(P2,P3)),P4)");
218 // ////////////////////////////////////////////////////////////////////////
219 // AliRecInfoMaker::AliRecInfoMaker()
222 // // Default constructor - never used
227 ////////////////////////////////////////////////////////////////////////
228 AliRecInfoMaker::AliRecInfoMaker(const char* fnGenTracks,
230 const char* fnGalice,
231 Int_t nEvents, Int_t firstEvent)
233 // AliRecInfoMaker - connencts the MC information with reconstructed information
234 // fnGenTracks - file with MC to be created before using AliGenInfoMaker
235 // fnCmp - file name to be created
236 // fnGalice - file with Loaders - usualy galice.root
238 // nEvent - number of event s to be analyzed
239 // AliRecInfoMaker *t2 = new AliRecInfoMaker("genTracks.root","cmpESDTracks.root","galice.root",0,0);
244 // fFnGenTracks = fnGenTracks;
246 sprintf(fFnGenTracks,"%s",fnGenTracks);
247 sprintf(fFnCmp,"%s",fnCmp);
249 fFirstEventNr = firstEvent;
250 fEventNr = firstEvent;
253 fLoader = AliRunLoader::Open(fnGalice);
255 //delete gAlice->GetRunLoader();
259 if (fLoader->LoadgAlice()){
260 cerr<<"Error occured while l"<<endl;
262 Int_t nall = fLoader->GetNumberOfEvents();
270 cerr<<"no events available"<<endl;
274 if (firstEvent+nEvents>nall) {
275 fEventNr = nall-firstEvent;
276 cerr<<"restricted number of events availaible"<<endl;
278 AliMagF * magf = gAlice->Field();
279 AliTracker::SetFieldMap(magf,0);
284 ////////////////////////////////////////////////////////////////////////
285 AliRecInfoMaker::~AliRecInfoMaker()
292 //////////////////////////////////////////////////////////////
293 Int_t AliRecInfoMaker::SetIO()
298 if (!fTreeCmp) return 1;
299 fParamTPC = GetTPCParam();
301 if (!ConnectGenTree()) {
302 cerr<<"Cannot connect tree with generated tracks"<<endl;
308 //////////////////////////////////////////////////////////////
310 Int_t AliRecInfoMaker::SetIO(Int_t eventNr)
316 TFile f("AliESDs.root");
319 TTree* tree = (TTree*) f.Get("esdTree");
320 tree->SetBranchStatus("*",1);
321 fEvent = new AliESDEvent;
323 if (tree->GetBranch("ESD")){
324 // tree->SetBranchAddress("ESD", &fEvent);
325 // tree->SetBranchAddress("ESDfriend.",&fESDfriend);
326 // tree->GetEntry(eventNr);
327 // fEvent->SetESDfriend(fESDfriend);
329 fEvent->ReadFromTree(tree);
330 fESDfriend = (AliESDfriend*)fEvent->FindListObject("AliESDfriend");
331 tree->GetEntry(eventNr);
332 fEvent->SetESDfriend(fESDfriend);
337 if (!fEvent) return 1;
344 ////////////////////////////////////////////////////////////////////////
345 void AliRecInfoMaker::Reset()
355 // fFnCmp = "cmpTracks.root";
363 ////////////////////////////////////////////////////////////////////////
364 Int_t AliRecInfoMaker::Exec(Int_t nEvents, Int_t firstEventNr)
367 // Exec comparison for subrange of events
370 fFirstEventNr = firstEventNr;
374 ////////////////////////////////////////////////////////////////////////
375 Int_t AliRecInfoMaker::Exec()
386 fNextTreeGenEntryToRead = 0;
389 cerr<<"fFirstEventNr, fNEvents: "<<fFirstEventNr<<" "<<fNEvents<<endl;
390 for (Int_t eventNr = fFirstEventNr; eventNr < fFirstEventNr+fNEvents;
394 fNParticles = gAlice->GetEvent(fEventNr);
396 fIndexRecTracks = new Short_t[fNParticles*20]; //write at maximum 4 tracks corresponding to particle
397 fIndexRecKinks = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle
398 fIndexRecV0 = new Short_t[fNParticles*20]; //write at maximum 20 tracks corresponding to particle
400 fFakeRecTracks = new Short_t[fNParticles];
401 fMultiRecTracks = new Short_t[fNParticles];
402 fMultiRecKinks = new Short_t[fNParticles];
403 fMultiRecV0 = new Short_t[fNParticles];
405 for (Int_t i = 0; i<fNParticles; i++) {
406 for (Int_t j=0;j<20;j++){
407 fIndexRecTracks[20*i+j] = -1;
408 fIndexRecKinks[20*i+j] = -1;
409 fIndexRecV0[20*i+j] = -1;
411 fFakeRecTracks[i] = 0;
412 fMultiRecTracks[i] = 0;
413 fMultiRecKinks[i] = 0;
417 cout<<"Start to process event "<<fEventNr<<endl;
418 cout<<"\tfNParticles = "<<fNParticles<<endl;
419 if (fDebug>2) cout<<"\tStart loop over TreeT"<<endl;
420 if (TreeTLoop()>0) return 1;
422 if (fDebug>2) cout<<"\tStart loop over tree genTracks"<<endl;
423 if (TreeGenLoop(eventNr)>0) return 1;
424 BuildKinkInfo0(eventNr);
425 //BuildV0Info(eventNr); // no V0 info for a moment
428 if (fDebug>2) cout<<"\tEnd loop over tree genTracks"<<endl;
430 delete [] fIndexRecTracks;
431 delete [] fIndexRecKinks;
432 delete [] fIndexRecV0;
433 delete [] fFakeRecTracks;
434 delete [] fMultiRecTracks;
435 delete [] fMultiRecKinks;
436 delete [] fMultiRecV0;
441 cerr<<"Exec finished"<<endl;
447 ////////////////////////////////////////////////////////////////////////
448 Bool_t AliRecInfoMaker::ConnectGenTree()
451 // connect all branches from the genTracksTree
452 // use the same variables as for the new cmp tree, it may work
454 fFileGenTracks = TFile::Open(fFnGenTracks,"READ");
455 if (!fFileGenTracks) {
456 cerr<<"Error in ConnectGenTree: cannot open file "<<fFnGenTracks<<endl;
459 fTreeGenTracks = (TTree*)fFileGenTracks->Get("genTracksTree");
460 if (!fTreeGenTracks) {
461 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
462 <<fFnGenTracks<<endl;
466 fMCInfo = new AliMCInfo;
467 fTreeGenTracks->SetBranchAddress("MC",&fMCInfo);
470 fTreeGenKinks = (TTree*)fFileGenTracks->Get("genKinksTree");
471 if (!fTreeGenKinks) {
472 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
473 <<fFnGenTracks<<endl;
477 fGenKinkInfo = new AliGenKinkInfo;
478 fTreeGenKinks->SetBranchAddress("MC",&fGenKinkInfo);
481 fTreeGenV0 = (TTree*)fFileGenTracks->Get("genV0Tree");
483 cerr<<"Error in ConnectGenTree: cannot find genTracksTree in the file "
484 <<fFnGenTracks<<endl;
488 fGenV0Info = new AliGenV0Info;
489 fTreeGenV0->SetBranchAddress("MC",&fGenV0Info);
493 cout<<"Number of gen. tracks with TR: "<<fTreeGenTracks->GetEntries()<<endl;
499 ////////////////////////////////////////////////////////////////////////
500 void AliRecInfoMaker::CreateTreeCmp()
503 // Create file and tree with comparison information
505 fFileCmp = TFile::Open(fFnCmp,"RECREATE");
507 cerr<<"Error in CreateTreeCmp: cannot open file "<<fFnCmp<<endl;
512 fTreeCmp = new TTree("ESDcmpTracks","ESDcmpTracks");
513 fMCInfo = new AliMCInfo;
514 fRecInfo = new AliESDRecInfo;
515 AliESDtrack * esdTrack = new AliESDtrack;
516 // AliITStrackMI * itsTrack = new AliITStrackMI;
517 fTreeCmp->Branch("MC","AliMCInfo",&fMCInfo,256000);
518 fTreeCmp->Branch("RC","AliESDRecInfo",&fRecInfo,256000);
519 // fTreeCmp->Branch("ITS","AliITStrackMI",&itsTrack);
523 fTreeCmpKinks = new TTree("ESDcmpKinks","ESDcmpKinks");
524 fGenKinkInfo = new AliGenKinkInfo;
525 fRecKinkInfo = new AliESDRecKinkInfo;
526 fTreeCmpKinks->Branch("MC.","AliGenKinkInfo",&fGenKinkInfo,256000);
527 fTreeCmpKinks->Branch("RC.","AliESDRecKinkInfo",&fRecKinkInfo,256000);
530 fTreeCmpV0 = new TTree("ESDcmpV0","ESDcmpV0");
531 fGenV0Info = new AliGenV0Info;
532 fRecV0Info = new AliESDRecV0Info;
533 fTreeCmpV0->Branch("MC.","AliGenV0Info", &fGenV0Info,256000);
534 fTreeCmpV0->Branch("RC.","AliESDRecV0Info",&fRecV0Info,256000);
536 fTreeCmp->AutoSave();
537 fTreeCmpKinks->AutoSave();
538 fTreeCmpV0->AutoSave();
541 ////////////////////////////////////////////////////////////////////////
542 void AliRecInfoMaker::CloseOutputFile()
549 cerr<<"File "<<fFnCmp<<" not found as an open file."<<endl;
560 ////////////////////////////////////////////////////////////////////////
562 TVector3 AliRecInfoMaker::TR2Local(AliTrackReference *trackRef,
563 AliTPCParam *paramTPC) {
566 // Transform position to the local coord frame
569 Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()};
571 paramTPC->Transform0to1(x,index);
572 paramTPC->Transform1to2Ideal(x,index);
575 ////////////////////////////////////////////////////////////////////////
577 Int_t AliRecInfoMaker::TreeTLoop()
580 // loop over all ESD reconstructed tracks and store info in memory
582 // + loop over all reconstructed kinks
586 Int_t nEntries = (Int_t)fEvent->GetNumberOfTracks();
587 Int_t nKinks = (Int_t) fEvent->GetNumberOfKinks();
588 Int_t nV0MIs = (Int_t) fEvent->GetNumberOfV0s();
589 fSignedKinks = new Short_t[nKinks];
590 fSignedV0 = new Short_t[nV0MIs];
592 // load kinks to the memory
593 for (Int_t i=0; i<nKinks;i++){
594 AliESDkink * kink =fEvent->GetKink(i);
598 for (Int_t i=0; i<nV0MIs;i++){
599 AliV0 * v0MI = (AliV0*)fEvent->GetV0(i);
605 AliESDtrack * track=0;
606 for (Int_t iEntry=0; iEntry<nEntries;iEntry++){
607 track = (AliESDtrack*)fEvent->GetTrack(iEntry);
609 Int_t label = track->GetLabel();
610 Int_t absLabel = abs(label);
611 if (absLabel < fNParticles) {
612 // fIndexRecTracks[absLabel] = iEntry;
613 if (label < 0) fFakeRecTracks[absLabel]++;
614 if (fMultiRecTracks[absLabel]>0){
615 if (fMultiRecTracks[absLabel]<20)
616 fIndexRecTracks[absLabel*20+fMultiRecTracks[absLabel]] = iEntry;
619 fIndexRecTracks[absLabel*20] = iEntry;
620 fMultiRecTracks[absLabel]++;
623 // sort reconstructed kinks
626 for (Int_t iEntry=0; iEntry<nKinks;iEntry++){
627 kink = (AliESDkink*)fEvent->GetKink(iEntry);
630 Int_t label0 = TMath::Abs(kink->GetLabel(0));
631 Int_t label1 = TMath::Abs(kink->GetLabel(1));
632 Int_t absLabel = TMath::Min(label0,label1);
633 if (absLabel < fNParticles) {
634 if (fMultiRecKinks[absLabel]>0){
635 if (fMultiRecKinks[absLabel]<20)
636 fIndexRecKinks[absLabel*20+fMultiRecKinks[absLabel]] = iEntry;
639 fIndexRecKinks[absLabel*20] = iEntry;
640 fMultiRecKinks[absLabel]++;
643 // --sort reconstructed V0
646 // for (Int_t iEntry=0; iEntry<nV0MIs;iEntry++){
647 // v0MI = (AliV0*)fEvent->GetV0(iEntry);
648 // if (!v0MI) continue;
650 // Int_t label0 = TMath::Abs(v0MI->GetLabel(0));
651 // Int_t label1 = TMath::Abs(v0MI->GetLabel(1));
653 // for (Int_t i=0;i<2;i++){
654 // Int_t absLabel = TMath::Abs(v0MI->GetLabel(i));
655 // if (absLabel < fNParticles) {
656 // if (fMultiRecV0[absLabel]>0){
657 // if (fMultiRecV0[absLabel]<20)
658 // fIndexRecV0[absLabel*20+fMultiRecV0[absLabel]] = iEntry;
661 // fIndexRecV0[absLabel*20] = iEntry;
662 // fMultiRecV0[absLabel]++;
668 printf("Time spended in TreeTLoop\n");
671 if (fDebug > 2) cerr<<"end of TreeTLoop"<<endl;
675 ////////////////////////////////////////////////////////////////////////
676 Int_t AliRecInfoMaker::TreeGenLoop(Int_t eventNr)
679 // loop over all entries for a given event, find corresponding
680 // rec. track and store in the fTreeCmp
684 Int_t entry = fNextTreeGenEntryToRead;
685 Double_t nParticlesTR = fTreeGenTracks->GetEntriesFast();
686 cerr<<"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<fNParticles<<" "
687 <<nParticlesTR<<" "<<fNextTreeGenEntryToRead<<endl;
688 TBranch * branch = fTreeCmp->GetBranch("RC");
689 TBranch * branchF = fTreeCmp->GetBranch("F");
691 branch->SetAddress(&fRecInfo); // set all pointers
692 fRecArray = new TObjArray(fNParticles);
693 AliESDtrack dummytrack; //
694 AliESDfriendTrack dummytrackF; //
696 while (entry < nParticlesTR) {
697 fTreeGenTracks->GetEntry(entry);
699 if (eventNr < fMCInfo->fEventNr) continue;
700 if (eventNr > fMCInfo->fEventNr) continue;;
702 fNextTreeGenEntryToRead = entry-1;
703 if (fDebug > 2 && fMCInfo->fLabel < 10) {
704 cerr<<"Fill track with a label "<<fMCInfo->fLabel<<endl;
706 // if (fMCInfo->fNTPCRef<1) continue; // not TPCref
709 AliESDtrack * track=0;
710 fRecInfo->fReconstructed =0;
711 TVector3 local = TR2Local(&(fMCInfo->fTrackRef),fParamTPC);
712 local.GetXYZ(fRecInfo->fTRLocalCoord);
714 if (fIndexRecTracks[fMCInfo->fLabel*20] >= 0) {
715 track= (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20]);
718 // find nearest track if multifound
719 //Int_t sign = Int_t(track->GetSign()*fMCInfo->fCharge);
722 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) status++;
723 if ((track->GetStatus()&AliESDtrack::kTPCrefit)>0) status++;
724 if ((track->GetStatus()&AliESDtrack::kTRDrefit)>0) status++;
727 if (fIndexRecTracks[fMCInfo->fLabel*20+1]>0){
730 track->GetInnerPxPyPz(p);
731 Float_t maxp = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
733 for (Int_t i=1;i<20;i++){
734 if (fIndexRecTracks[fMCInfo->fLabel*20+i]>=0){
735 AliESDtrack * track2 = (AliESDtrack*)fEvent->GetTrack(fIndexRecTracks[fMCInfo->fLabel*20+i]);
736 if (!track2) continue;
737 //Int_t sign2 = track->GetSign()*fMCInfo->fCharge; //
738 //if (sign2<0) continue;
739 track2->GetInnerPxPyPz(p);
740 Float_t mom = p[0]*p[0]+p[1]*p[1]+p[2]*p[2];
751 if ((track2->GetStatus()&AliESDtrack::kITSrefit)>0) status2++;
752 if ((track2->GetStatus()&AliESDtrack::kTPCrefit)>0) status2++;
753 if ((track2->GetStatus()&AliESDtrack::kTRDrefit)>0) status2++;
754 if (status2<status) continue;
756 if (mom<maxp) continue;
765 fRecInfo->SetESDtrack(track);
767 fRecInfo->SetESDtrack(&dummytrack);
771 fRecInfo->fReconstructed = 1;
772 fRecInfo->fFake = fFakeRecTracks[fMCInfo->fLabel];
773 fRecInfo->fMultiple = fMultiRecTracks[fMCInfo->fLabel];
775 fRecInfo->Update(fMCInfo,fParamTPC,kTRUE);
778 fRecInfo->SetESDtrack(&dummytrack);
779 fRecInfo->Update(fMCInfo,fParamTPC,kFALSE);
781 fRecArray->AddAt(new AliESDRecInfo(*fRecInfo),fMCInfo->fLabel);
784 fTreeCmp->AutoSave();
785 printf("Time spended in TreeGenLoop\n");
787 if (fDebug > 2) cerr<<"end of TreeGenLoop"<<endl;
794 ////////////////////////////////////////////////////////////////////////
795 ////////////////////////////////////////////////////////////////////////
796 ////////////////////////////////////////////////////////////////////////
797 Int_t AliRecInfoMaker::BuildKinkInfo0(Int_t eventNr)
800 // loop over all entries for a given event, find corresponding
801 // rec. track and store in the fTreeCmp
805 Int_t entry = fNextKinkToRead;
806 Double_t nParticlesTR = fTreeGenKinks->GetEntriesFast();
807 cerr<<"fNParticles, nParticlesTR, fNextKinkToRead: "<<fNParticles<<" "
808 <<nParticlesTR<<" "<<fNextKinkToRead<<endl;
810 TBranch * branch = fTreeCmpKinks->GetBranch("RC.");
811 branch->SetAddress(&fRecKinkInfo); // set all pointers
814 while (entry < nParticlesTR) {
815 fTreeGenKinks->GetEntry(entry);
817 if (eventNr < fGenKinkInfo->GetMinus().fEventNr) continue;
818 if (eventNr > fGenKinkInfo->GetMinus().fEventNr) continue;;
820 fNextKinkToRead = entry-1;
823 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetMinus().fLabel);
824 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenKinkInfo->GetPlus().fLabel);
825 fRecKinkInfo->fT1 = (*fRecInfo1);
826 fRecKinkInfo->fT2 = (*fRecInfo2);
827 fRecKinkInfo->fStatus =0;
828 if (fRecInfo1 && fRecInfo1->fTPCOn) fRecKinkInfo->fStatus+=1;
829 if (fRecInfo2 && fRecInfo2->fTPCOn) fRecKinkInfo->fStatus+=2;
830 if (fRecKinkInfo->fStatus==3&&fRecInfo1->fSign!=fRecInfo2->fSign) fRecKinkInfo->fStatus*=-1;
832 if (fRecKinkInfo->fStatus==3){
833 fRecKinkInfo->Update();
835 Int_t label = TMath::Min(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel);
836 Int_t label2 = TMath::Max(fGenKinkInfo->GetMinus().fLabel,fGenKinkInfo->GetPlus().fLabel);
839 fRecKinkInfo->fRecStatus =0;
840 fRecKinkInfo->fMultiple = fMultiRecKinks[label];
841 fRecKinkInfo->fKinkMultiple=0;
843 if (fMultiRecKinks[label]>0){
845 // for (Int_t j=0;j<TMath::Min(fMultiRecKinks[label],100);j++){
846 for (Int_t j=TMath::Min(fMultiRecKinks[label],Short_t(20))-1;j>=0;j--){
847 Int_t index = fIndexRecKinks[label*20+j];
848 //AliESDkink *kink2 = (AliESDkink*)fKinks->At(index);
849 AliESDkink *kink2 = (AliESDkink*)fEvent->GetKink(index);
850 if (TMath::Abs(kink2->GetLabel(0))==label &&TMath::Abs(kink2->GetLabel(1))==label2) {
851 fRecKinkInfo->fKinkMultiple++;
852 fSignedKinks[index]=1;
855 // if (kink->fTRDOn) c0++;
856 //if (kink->fITSOn) c0++;
857 if (kink->GetStatus(2)>0) c0++;
858 if (kink->GetStatus(0)>0) c0++;
861 // if (kink2->fTRDOn) c2++;
862 //if (kink2->fITSOn) c2++;
863 if (kink2->GetStatus(2)>0) c2++;
864 if (kink2->GetStatus(0)>0) c2++;
869 if (TMath::Abs(kink2->GetLabel(1))==label &&TMath::Abs(kink2->GetLabel(0))==label2) {
870 fRecKinkInfo->fKinkMultiple++;
871 fSignedKinks[index]=1;
874 //if (kink->fTRDOn) c0++;
875 //if (kink->fITSOn) c0++;
876 if (kink->GetStatus(2)>0) c0++;
877 if (kink->GetStatus(0)>0) c0++;
881 // if (kink2->fTRDOn) c2++;
882 //if (kink2->fITSOn) c2++;
883 if (kink2->GetStatus(2)>0) c2++;
884 if (kink2->GetStatus(0)>0) c2++;
892 fRecKinkInfo->fKink = *kink;
893 fRecKinkInfo->fRecStatus=1;
895 fTreeCmpKinks->Fill();
897 // Int_t nkinks = fKinks->GetEntriesFast();
898 Int_t nkinks = fEvent->GetNumberOfKinks();
899 for (Int_t i=0;i<nkinks;i++){
900 if (fSignedKinks[i]==0){
901 // AliESDkink *kink = (AliESDkink*)fKinks->At(i);
902 AliESDkink *kink = (AliESDkink*)fEvent->GetKink(i);
905 fRecKinkInfo->fKink = *kink;
906 fRecKinkInfo->fRecStatus =-2;
908 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(0)));
909 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(kink->GetLabel(1)));
910 if (fRecInfo1 && fRecInfo2){
911 fRecKinkInfo->fT1 = (*fRecInfo1);
912 fRecKinkInfo->fT2 = (*fRecInfo2);
913 fRecKinkInfo->fRecStatus =-1;
915 fTreeCmpKinks->Fill();
920 fTreeCmpKinks->AutoSave();
921 printf("Time spended in BuilKinkInfo Loop\n");
923 if (fDebug > 2) cerr<<"end of BuildKinkInfo Loop"<<endl;
929 ////////////////////////////////////////////////////////////////////////
930 ////////////////////////////////////////////////////////////////////////
931 ////////////////////////////////////////////////////////////////////////
935 Int_t AliRecInfoMaker::BuildV0Info(Int_t eventNr)
938 // loop over all entries for a given event, find corresponding
939 // rec. track and store in the fTreeCmp
943 Int_t entry = fNextV0ToRead;
944 Double_t nParticlesTR = fTreeGenV0->GetEntriesFast();
945 cerr<<"fNParticles, nParticlesTR, fNextV0ToRead: "<<fNParticles<<" "
946 <<nParticlesTR<<" "<<fNextV0ToRead<<endl;
948 TBranch * branch = fTreeCmpV0->GetBranch("RC.");
949 branch->SetAddress(&fRecV0Info); // set all pointers
950 const AliESDVertex * esdvertex = fEvent->GetVertex();
951 Float_t vertex[3]= {esdvertex->GetXv(), esdvertex->GetYv(),esdvertex->GetZv()};
954 while (entry < nParticlesTR) {
955 fTreeGenV0->GetEntry(entry);
957 if (eventNr < fGenV0Info->GetMinus().fEventNr) continue;
958 if (eventNr > fGenV0Info->GetMinus().fEventNr) continue;;
960 fNextV0ToRead = entry-1;
963 AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetMinus().fLabel);
964 AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(fGenV0Info->GetPlus().fLabel);
965 if (fGenV0Info->GetMinus().fCharge*fGenV0Info->GetPlus().fCharge>0) continue; // interactions
966 if (!fRecInfo1 || !fRecInfo2) continue;
967 fRecV0Info->fT1 = (*fRecInfo1);
968 fRecV0Info->fT2 = (*fRecInfo2);
969 fRecV0Info->fV0Status =0;
970 if (fRecInfo1 && fRecInfo1->fStatus[1]>0) fRecV0Info->fV0Status+=1;
971 if (fRecInfo2 && fRecInfo2->fStatus[1]>0) fRecV0Info->fV0Status+=2;
973 if (fRecV0Info->fV0Status==3&&fRecInfo1->fSign==fRecInfo2->fSign) fRecV0Info->fV0Status*=-1;
976 if (abs(fRecV0Info->fV0Status)==3){
977 fRecV0Info->Update(vertex);
981 Double_t x,alpha, param[5],cov[15];
982 if ( fRecV0Info->fT1.GetESDtrack()->GetInnerParam() && fRecV0Info->fT2.GetESDtrack()->GetInnerParam()){
983 fRecV0Info->fT1.GetESDtrack()->GetInnerExternalParameters(alpha,x,param);
984 fRecV0Info->fT1.GetESDtrack()->GetInnerExternalCovariance(cov);
985 AliExternalTrackParam paramP(x,alpha,param,cov);
987 fRecV0Info->fT2.GetESDtrack()->GetInnerExternalParameters(alpha,x,param);
988 fRecV0Info->fT2.GetESDtrack()->GetInnerExternalCovariance(cov);
989 AliExternalTrackParam paramM(x,alpha,param,cov);
991 fRecV0Info->fV0tpc->SetParamN(paramM);
992 fRecV0Info->fV0tpc->SetParamP(paramP);
993 Double_t pid1[5],pid2[5];
994 fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid1);
995 fRecV0Info->fT1.GetESDtrack()->GetESDpid(pid2);
997 //fRecV0Info->fV0tpc.UpdatePID(pid1,pid2);
998 fRecV0Info->fV0tpc->Update(vertex);
1002 fRecV0Info->fT1.GetESDtrack()->GetExternalParameters(x,param);
1003 fRecV0Info->fT1.GetESDtrack()->GetExternalCovariance(cov);
1004 alpha = fRecV0Info->fT1.GetESDtrack()->GetAlpha();
1005 new (¶mP) AliExternalTrackParam(x,alpha,param,cov);
1007 fRecV0Info->fT2.GetESDtrack()->GetExternalParameters(x,param);
1008 fRecV0Info->fT2.GetESDtrack()->GetExternalCovariance(cov);
1009 alpha = fRecV0Info->fT2.GetESDtrack()->GetAlpha();
1010 new (¶mM) AliExternalTrackParam(x,alpha,param,cov);
1012 fRecV0Info->fV0its->SetParamN(paramM);
1013 fRecV0Info->fV0its->SetParamP(paramP);
1014 // fRecV0Info->fV0its.UpdatePID(pid1,pid2);
1015 fRecV0Info->fV0its->Update(vertex);
1018 if (TMath::Abs(fGenV0Info->GetMinus().fPdg)==11 &&TMath::Abs(fGenV0Info->GetPlus().fPdg)==11){
1019 if (fRecV0Info->fDist2>10){
1020 fRecV0Info->Update(vertex);
1022 if (fRecV0Info->fDist2>10){
1023 fRecV0Info->Update(vertex);
1028 // take the V0 from reconstruction
1030 Int_t label = TMath::Min(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel);
1031 Int_t label2 = TMath::Max(fGenV0Info->GetMinus().fLabel,fGenV0Info->GetPlus().fLabel);
1033 fRecV0Info->fRecStatus =0;
1034 fRecV0Info->fMultiple = fMultiRecV0[label];
1035 fRecV0Info->fV0Multiple=0;
1037 if (fMultiRecV0[label]>0 || fMultiRecV0[label2]>0){
1039 // for (Int_t j=0;j<TMath::Min(fMultiRecV0s[label],100);j++){
1040 // for (Int_t j=TMath::Min(fMultiRecV0[label],Short_t(20))-1;j>=0;j--){
1041 // Int_t index = fIndexRecV0[label*20+j];
1042 // if (index<0) continue;
1043 // AliV0 *v0MI2 = (AliV0*)fEvent->GetV0(index);
1044 // if (TMath::Abs(v0MI2->GetLabel(0))==label &&TMath::Abs(v0MI2->GetLabel(1))==label2) {
1046 // fRecV0Info->fV0Multiple++;
1047 // fSignedV0[index]=1;
1049 // if (TMath::Abs(v0MI2->GetLabel(1))==label &&TMath::Abs(v0MI2->GetLabel(0))==label2) {
1051 // fRecV0Info->fV0Multiple++;
1052 // fSignedV0[index]=1;
1057 fRecV0Info->fV0rec = v0MI;
1058 fRecV0Info->fRecStatus=1;
1066 Int_t nV0MIs = fEvent->GetNumberOfV0s();
1067 for (Int_t i=0;i<nV0MIs;i++){
1068 if (fSignedV0[i]==0){
1069 AliV0 *v0MI = (AliV0*)fEvent->GetV0(i);
1070 if (!v0MI) continue;
1072 fRecV0Info->fV0rec = v0MI;
1073 fRecV0Info->fV0Status =-10;
1074 fRecV0Info->fRecStatus =-2;
1076 // AliESDRecInfo* fRecInfo1 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(0)));
1077 // AliESDRecInfo* fRecInfo2 = (AliESDRecInfo*)fRecArray->At(TMath::Abs(v0MI->GetLabel(1)));
1078 // if (fRecInfo1 && fRecInfo2){
1079 // fRecV0Info->fT1 = (*fRecInfo1);
1080 // fRecV0Info->fT2 = (*fRecInfo2);
1081 // fRecV0Info->fRecStatus =-1;
1083 fRecV0Info->Update(vertex);
1090 fTreeCmpV0->AutoSave();
1091 printf("Time spended in BuilV0Info Loop\n");
1093 if (fDebug > 2) cerr<<"end of BuildV0Info Loop"<<endl;
1096 ////////////////////////////////////////////////////////////////////////
1097 ////////////////////////////////////////////////////////////////////////