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 // Implementation of a branch replicator
18 // to produce aods with only few branches.
20 // This replicator is in charge of replicating the nuclei primary vertices
21 // tracks identified as nuclei with Z>=2, secondary vertices in form of
22 // AliAODRecoDecayLF2Prong and their daughter tracks.
23 // These informations are stored into a reduced AODs (AliAOD.NuclEx.root)
25 // The vertices are filtered so that only the primary vertices make it
26 // to the output aods.
28 // The secondary vertices are recreated here, as a AliAODRecoDecayLF2Prong
29 // plus cuts that select secondary vericesoutside the primary vertex
31 // Authors: S. Bufalino (stefania.bufalino@cern.ch)
32 // R. Lea (ramona.lea@cern.ch)
33 // Based on AliAODMuonReplicator.cxx
39 class AliAODRecoDecay;
41 #include "AliAODDimuon.h"
42 #include "AliAODEvent.h"
43 #include "AliAODMCHeader.h"
44 #include "AliAODMCParticle.h"
45 #include "AliAODTZERO.h"
46 #include "AliAODTrack.h"
47 #include "AliAODVZERO.h"
48 //#include "AliAnalysisCuts.h"
50 #include "AliExternalTrackParam.h"
53 #include "AliPIDResponse.h"
56 #include "AliESDtrack.h"
57 #include "TObjArray.h"
58 #include "AliAnalysisFilter.h"
59 #include "AliAODRecoDecay.h"
60 #include "AliAODRecoDecayLF.h"
61 #include "AliAODRecoDecayLF2Prong.h"
64 #include <TDatabasePDG.h>
68 #include "AliVEvent.h"
69 #include "AliVVertex.h"
70 #include "AliVTrack.h"
71 #include "AliVertexerTracks.h"
72 #include "AliKFVertex.h"
73 #include "AliESDEvent.h"
74 #include "AliESDVertex.h"
75 #include "AliESDtrackCuts.h"
76 #include "AliAODEvent.h"
77 #include "AliAnalysisFilter.h"
78 //#include "AliAnalysisVertexingLF.h"
79 #include "AliAnalysisManager.h"
80 #include "AliAODNuclExReplicator.h"
83 #include "AliInputEventHandler.h"
88 ClassImp(AliAODNuclExReplicator)
90 //_____________________________________________________________________________
91 AliAODNuclExReplicator::AliAODNuclExReplicator(const char* name, const char* title,
92 // AliAnalysisCuts* trackCut,
93 // AliAnalysisCuts* vertexCut,
95 Int_t nsigmaTrk1, Int_t partType1,
96 Int_t nsigmaTrk2, Int_t partType2
98 :AliAODBranchReplicator(name,title),
107 //fVertexCut(vertexCut),
110 // fTrackCut(trackCut),
111 fSecondaryVerices(0x0),
112 fDaughterTracks(0x0),
119 fReplicateHeader(kTRUE), //replicateHeader //to be fixed
120 fnSigmaTrk1(nsigmaTrk1),
121 fnSigmaTrk2(nsigmaTrk2),
122 fpartType1(partType1),
123 fpartType2(partType2),
124 fSecVtxWithKF(kFALSE),
125 fVertexerTracks(0x0),
134 //_____________________________________________________________________________
135 AliAODNuclExReplicator::~AliAODNuclExReplicator()
139 // delete fVertexCut;
143 //_____________________________________________________________________________
144 void AliAODNuclExReplicator::SelectParticle(Int_t i)
146 // taking the absolute values here, need to take care
147 // of negative daughter and mother
150 if (!IsParticleSelected(TMath::Abs(i)))
152 fParticleSelected.Add(TMath::Abs(i),1);
156 //_____________________________________________________________________________
157 Bool_t AliAODNuclExReplicator::IsParticleSelected(Int_t i)
159 // taking the absolute values here, need to take
160 // care with negative daughter and mother
162 return (fParticleSelected.GetValue(TMath::Abs(i))==1);
166 //_____________________________________________________________________________
167 void AliAODNuclExReplicator::CreateLabelMap(const AliAODEvent& source)
170 // this should be called once all selections are done
175 TClonesArray* mcParticles = static_cast<TClonesArray*>(source.FindListObject(AliAODMCParticle::StdBranchName()));
180 TIter next(mcParticles);
184 if (IsParticleSelected(i))
186 fLabelMap.Add(i,j++);
192 //_____________________________________________________________________________
193 Int_t AliAODNuclExReplicator::GetNewLabel(Int_t i)
195 // Gets the label from the new created Map
196 // Call CreatLabelMap before
197 // otherwise only 0 returned
198 return fLabelMap.GetValue(TMath::Abs(i));
201 //_____________________________________________________________________________
202 // void AliAODNuclExReplicator::FilterMC(const AliAODEvent& source)
204 // // Filter MC information
206 // fMCHeader->Reset();
207 // fMCParticles->Clear("C");
209 // AliAODMCHeader* mcHeader(0x0);
210 // TClonesArray* mcParticles(0x0);
212 // fParticleSelected.Delete();
214 // if ( fMCMode>=2 && !fTracks->GetEntries() ) return;
215 // // for fMCMode==1 we only copy MC information for events where there's at least one muon track
217 // mcHeader = static_cast<AliAODMCHeader*>(source.FindListObject(AliAODMCHeader::StdBranchName()));
221 // *fMCHeader = *mcHeader;
224 // mcParticles = static_cast<TClonesArray*>(source.FindListObject(AliAODMCParticle::StdBranchName()));
226 // if ( mcParticles && fMCMode>=2 )
228 // // loop on (kept) muon tracks to find their ancestors
229 // TIter nextMT(fTracks);
232 // while ( ( mt = static_cast<AliAODTrack*>(nextMT()) ) )
234 // Int_t label = mt->GetLabel();
236 // while ( label >= 0 )
238 // SelectParticle(label);
239 // AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(mcParticles->UncheckedAt(label));
242 // AliError("Got a null mother ! Check that !");
247 // label = mother->GetMother();
252 // CreateLabelMap(source);
254 // // Actual filtering and label remapping (shamelessly taken for the implementation of AliAODHandler::StoreMCParticles)
255 // TIter nextMC(mcParticles);
256 // AliAODMCParticle* p;
260 // while ( ( p = static_cast<AliAODMCParticle*>(nextMC()) ) )
262 // AliAODMCParticle c(*p);
264 // if ( IsParticleSelected(nmc) )
267 // Int_t d0 = p->GetDaughter(0);
268 // Int_t d1 = p->GetDaughter(1);
269 // Int_t m = p->GetMother();
271 // // other than for the track labels, negative values mean
272 // // no daughter/mother so preserve it
276 // // no first daughter -> no second daughter
277 // // nothing to be done
278 // // second condition not needed just for sanity check at the end
279 // c.SetDaughter(0,d0);
280 // c.SetDaughter(1,d1);
281 // } else if(d1 < 0 && d0 >= 0)
283 // // Only one daughter
284 // // second condition not needed just for sanity check at the end
285 // if(IsParticleSelected(d0))
287 // c.SetDaughter(0,GetNewLabel(d0));
290 // c.SetDaughter(0,-1);
292 // c.SetDaughter(1,d1);
294 // else if (d0 > 0 && d1 > 0 )
296 // // we have two or more daughters loop on the stack to see if they are
300 // for (int id = d0; id<=d1;++id)
302 // if (IsParticleSelected(id))
307 // d0tmp = GetNewLabel(id);
308 // d1tmp = d0tmp; // this is to have the same schema as on the stack i.e. with one daugther d0 and d1 are the same
310 // else d1tmp = GetNewLabel(id);
313 // c.SetDaughter(0,d0tmp);
314 // c.SetDaughter(1,d1tmp);
317 // AliError(Form("Unxpected indices %d %d",d0,d1));
325 // if (IsParticleSelected(m))
327 // c.SetMother(GetNewLabel(m));
331 // AliError(Form("PROBLEM Mother not selected %d", m));
335 // new ((*fMCParticles)[nmcout++]) AliAODMCParticle(c);
341 // // now remap the tracks...
343 // TIter nextTrack(fTracks);
346 // while ( ( t = static_cast<AliAODTrack*>(nextTrack()) ) )
348 // t->SetLabel(GetNewLabel(t->GetLabel()));
352 // else if ( mcParticles )
354 // // simple copy of input MC particles to ouput MC particles
355 // TIter nextMC(mcParticles);
356 // AliAODMCParticle* p;
359 // while ( ( p = static_cast<AliAODMCParticle*>(nextMC()) ) )
361 // new ((*fMCParticles)[nmcout++]) AliAODMCParticle(*p);
365 // AliDebug(1,Form("input mc %d output mc %d",
366 // mcParticles ? mcParticles->GetEntries() : 0,
367 // fMCParticles ? fMCParticles->GetEntries() : 0));
372 //_____________________________________________________________________________
373 TList* AliAODNuclExReplicator::GetList() const
375 // return (and build if not already done) our internal list of managed objects
379 if ( fReplicateHeader )
381 fHeader = new AliAODHeader;
385 fSecondaryVerices = new TClonesArray("AliAODRecoDecayLF2Prong",30);
386 fSecondaryVerices->SetName("SecondaryVertices");
388 fVertices = new TClonesArray("AliAODVertex",2);
389 fVertices->SetName("vertices");
391 fNuclei = new TClonesArray("AliAODTrack",30);
392 fNuclei->SetName("Nuclei");
394 fDaughterTracks = new TClonesArray("AliAODTrack",30);
395 fDaughterTracks->SetName("DaughterTracks");
399 fList->SetOwner(kTRUE);
402 fList->Add(fVertices);
404 fList->Add(fSecondaryVerices);
405 fList->Add(fDaughterTracks);
410 fMCHeader = new AliAODMCHeader;
411 fMCParticles = new TClonesArray("AliAODMCParticle",1000);
412 fMCParticles->SetName(AliAODMCParticle::StdBranchName());
413 fList->Add(fMCHeader);
414 fList->Add(fMCParticles);
420 //_____________________________________________________________________________
421 void AliAODNuclExReplicator::ReplicateAndFilter(const AliAODEvent& source)
423 // Replicate (and filter if filters are there) the relevant parts we're interested in AODEvent
425 //-----------------------------------------------
428 AliPIDResponse *fPIDResponse;
429 AliAnalysisManager *man=AliAnalysisManager::GetAnalysisManager();
430 AliInputEventHandler* inputHandler = (AliInputEventHandler*) (man->GetInputEventHandler());
431 fPIDResponse = inputHandler->GetPIDResponse();
433 //--------------------------------------------------------
435 // printf("Execute NuclEx Replicator\n");
437 //---------------------------------
439 if (fReplicateHeader)
441 AliAODHeader * header = dynamic_cast<AliAODHeader*>(source.GetHeader());
442 if(!header) AliFatal("Not a standard AOD");
443 *fHeader = *(header);
446 fVertices->Clear("C");
450 fSecondaryVerices->Clear("C");
452 fDaughterTracks->Clear("C");
454 //----------------------------------
456 // cout<<"Centrality AOD source: "<<source.GetHeader()->GetCentrality()<<endl;
463 Double_t xdummy,ydummy;
465 AliAODRecoDecayLF2Prong *io2Prong = 0;
467 TObjArray *twoTrackArray = new TObjArray(2);
470 // cout<<"Qui"<<endl;
471 //cout<<source.GetMagneticField()<<endl;
473 AliAODVertex *vtx = source.GetPrimaryVertex();
475 // cout<<"Source "<<source<<endl;
476 //cout<<"vtx: "<<vtx<<endl;
478 // A Set of very loose cut for a weak strange decay
487 //----------------------------------------------------------
490 UShort_t *indices = 0;
491 const Int_t entries = source.GetNumberOfTracks();
493 Double_t pos[3],cov[6];
495 vtx->GetCovarianceMatrix(cov);
496 fV1 = new AliESDVertex(pos,cov,100.,100,vtx->GetName());
497 // cout<<"fV1 pricipal loop: "<<fV1<<endl;
499 if(entries<=0) return;
500 indices = new UShort_t[entries];
501 memset(indices,0,sizeof(UShort_t)*entries);
502 fAODMapSize = 100000;
503 fAODMap = new Int_t[fAODMapSize];
504 memset(fAODMap,0,sizeof(Int_t)*fAODMapSize);
505 // cent=((AliAODEvent&)source)->GetCentrality();
507 //-------------------------------------------------------------
509 //AliAODRecoDecayLF *rd = 0;
510 // AliAODRecoDecayLF2Prong*rd = 0;
513 if(vtx->GetNContributors()<1) {
516 vtx =source.GetPrimaryVertexSPD();
518 if(vtx->GetNContributors()<1) {
519 Info("AliAnalysisTaskHelium3Pi","No good vertex, skip event");
520 return; // NO GOOD VERTEX, SKIP EVENT
524 Double_t xPrimaryVertex=0.,yPrimaryVertex=0.;
525 xPrimaryVertex=vtx->GetX();
526 yPrimaryVertex=vtx->GetY();
528 fBzkG=source.GetMagneticField();
529 fVertexerTracks=new AliVertexerTracks(fBzkG);
531 // TF1 *foPion=new TF1("foPion", "[0]*([1]*TMath::Power(TMath::Sqrt(1 + (x/0.13957)*(x/0.13957))/(x/0.13957) , [3]) - 1 - TMath::Power(TMath::Sqrt(1 + (x/0.13957)*(x/0.13957))/(x/0.13957) , [3])*TMath::Log([2] + 1/TMath::Power((x/0.13957), [4])))",0.01,20);
532 // foPion->SetParameters(4.1,8.98482806165147636e+00,1.54000000000000005e-05,2.30445734159456084e+00,2.25624744086878559e+00);
534 Double_t TrackNumber = source.GetNumberOfTracks();
538 TArrayI Track0(TrackNumber); //Pions
541 TArrayI Track1(TrackNumber); //Helium3
544 for(Int_t j=0; j<TrackNumber; j++){
546 // cout<<"Inside loop tracks"<<endl;
548 AliVTrack *track = (AliVTrack*)source.GetTrack(j);
550 AliAODTrack *aodtrack =(AliAODTrack*)track;
552 //-----------------------------------------------------------
554 if(aodtrack->GetTPCNcls() < 70 )continue;
555 if(aodtrack->Chi2perNDF() > 4 )continue;
557 // cout<<"Filter Map: "<<aodtrack->GetFilterMap()<<endl;
558 // if (!aodtrack->TestFilterMask(BIT(4))) continue;
559 // if(aodtrack->TestFilterMask(BIT(4))!=0)
560 // cout<<"!!!!!!!!!!!!!!!!!!!!!!!!!!! Filter bit mask: !!!!!!!!!!!!!!!!!!!!!!!!!!!"<<endl;
562 if (!aodtrack->IsOn(AliAODTrack::kTPCrefit)) continue;
563 if (!aodtrack->IsOn(AliAODTrack::kTPCin)) continue;
564 if (aodtrack->IsOn(AliAODTrack::kITSpureSA)) continue;
566 //---------------------------------------------------------------
568 // Double_t mom = aodtrack->GetDetPid()->GetTPCmomentum();
569 Double_t mom = aodtrack->P();
571 if(mom<0.150)continue;
575 Double_t nSigmaNegPion = TMath::Abs(fPIDResponse->NumberOfSigmasTPC(aodtrack,(AliPID::EParticleType)fpartType1));
576 // cout<<"%%% nsigma Pi: "<<nSigmaNegPion<<endl;
577 // Double_t nSigmaNegPion = TMath::Abs((aodtrack->GetTPCsignal() - foPion->Eval(mom))/foPion->Eval(mom))/0.07;
579 if ( nSigmaNegPion <= fnSigmaTrk1 /*&& aodtrack->Charge()==-1*/){
583 Double_t nSigmaNuclei = fPIDResponse->NumberOfSigmasTPC(aodtrack,(AliPID::EParticleType)fpartType2); //To be changed
584 //cout<<"%%% nsigma Nuclei: "<<nSigmaNuclei<<endl;
586 if(nSigmaNuclei>-fnSigmaTrk2 && aodtrack->GetTPCsignal()<1000 && mom>0.2){
588 //Double_t triggerDeDx = 4*AliExternalTrackParam::BetheBlochAleph((mom*2)/(0.938*3),1.0288,31.9806,5.04114e-11,2.13096,2.38541);
589 //if(aodtrack->GetTPCsignal() > triggerDeDx && aodtrack->GetTPCsignal()<5000 && mom>0.2 /*&& aodtrack->Charge()==1*/){
592 new((*fNuclei)[nnuclei++]) AliAODTrack(*aodtrack);
593 //cout<<"@@@ n sigma NUCLEI"<<nSigmaNuclei<<endl;
598 // cout<<"Delete AodTrack..."<<endl;
600 // aodtrack->Delete();
602 //Set Track Daughters
606 // cout<<"Track loops..."<<endl;
608 AliAODTrack *postrackAOD = 0;
609 AliAODTrack *negtrackAOD = 0;
611 AliESDtrack *postrack = 0;
612 AliESDtrack *negtrack = 0;
614 // cout <<"nTrack1 "<< nTrack1<<endl;
615 // cout <<"nTrack0 "<< nTrack0<<endl;
617 for (Int_t i=0; i<nTrack1; i++){ //! He Tracks Loop
619 // cout<<"Inside track loop"<<endl;
621 Int_t Track1idx=Track1[i];
623 AliVTrack *trackpos = (AliVTrack*)source.GetTrack(Track1idx);
625 postrackAOD = (AliAODTrack*)trackpos;
626 postrack = new AliESDtrack(trackpos);
628 for (Int_t k=0; k <nTrack0 ; k++) { //! Pion Tracks Loop
630 Int_t Track0idx=Track0[k];
632 AliVTrack *trackneg = (AliVTrack*)source.GetTrack(Track0idx);
633 negtrackAOD =(AliAODTrack*)trackneg;
634 negtrack = new AliESDtrack(trackneg);
636 twoTrackArray->AddAt(negtrack,0);
637 twoTrackArray->AddAt(postrack,1);
639 Double_t dcap1n1 = postrack->GetDCA(negtrack,fBzkG,xdummy,ydummy);
641 Double_t dcap1toPV = TMath::Abs(postrack->GetD(xPrimaryVertex, yPrimaryVertex,fBzkG));
642 Double_t dcan1toPV = TMath::Abs(negtrack->GetD(xPrimaryVertex, yPrimaryVertex,fBzkG));
644 if(dcap1n1>fDCAtracksMin)continue;
645 if((xdummy+ydummy)>fRmax )continue;
646 if((xdummy+ydummy)< fRmin)continue;
648 if ( dcan1toPV < fDNmin)
649 if ( dcap1toPV < fDPmin) continue;
651 // cout<<"dcap1n1: "<<dcap1n1<<endl;
653 AliAODVertex *vertexp1n1 = ReconstructSecondaryVertex(twoTrackArray,dispersion,kTRUE);
657 twoTrackArray->Clear();
663 // cout<<"vertexp1n1: "<<vertexp1n1<<endl;
665 io2Prong = Make2Prong(twoTrackArray,source,vertexp1n1,dcap1n1);
667 //cout<<"Fuori dal loop e' quello che salvo \npr0: "<<io2Prong->GetProngID(0)<<" pr1: "<<io2Prong->GetProngID(1)<<" pr2"<<io2Prong->GetProngID(2)<<endl;
669 if(io2Prong->CosPointingAngle()<fCosMin)continue;
671 // cout<<"if CPA \npr0: "<<io2Prong->GetProngID(0)<<" pr1: "<<io2Prong->GetProngID(1)<<" pr2"<<io2Prong->GetProngID(2)<<endl;
672 // cout<<"pointing angle "<<io2Prong->CosPointingAngle()<<endl;
675 // AliAODTrack *trk0 = (AliAODTrack*)io2Prong->GetDaughter(0);
676 // AliAODTrack *trk1 = (AliAODTrack*)io2Prong->GetDaughter(1);
678 // cout<<"**********************************************"<<endl;
679 // cout<<trk0/*->GetID()*/<<" "<<negtrackAOD->GetID()<<endl;
680 // cout<<trk1/*->GetID()*/<<" "<<postrackAOD->GetID()<<endl;
681 // cout<<"d0 io2Prong: "<<io2Prong->GetProngID(1)<<endl;
682 // cout<<"d1 io2Prong: "<<io2Prong->GetProngID(0)<<endl;
683 // cout<<"**********************************************"<<endl;
685 // rd = new((*fSecondaryVerices)[nsv++]) AliAODRecoDecayLF2Prong(*io2Prong);
687 new((*fSecondaryVerices)[nsv++]) AliAODRecoDecayLF2Prong(*io2Prong);
689 // cout<<"QUELLO CHE SALVo \npr0: "<<rd->GetProngID(0)<<" pr1: "<<rd->GetProngID(1)<<" pr2"<<rd->GetProngID(2)<<endl;
691 // rd->SetSecondaryVtx(vertexp1n1);
692 // vertexp1n1->SetParent(rd);
693 // AddRefs(vertexp1n1,rd,source,twoTrackArray);
696 new((*fDaughterTracks)[ntracksD++]) AliAODTrack(*negtrackAOD);
697 new((*fDaughterTracks)[ntracksD++]) AliAODTrack(*postrackAOD);
712 //----------------------------------------------------------
714 assert(fVertices!=0x0);
715 fVertices->Clear("C");
716 TIter nextV(source.GetVertices());
720 while ( ( v = static_cast<AliAODVertex*>(nextV()) ) )
722 if ( v->GetType() == AliAODVertex::kPrimary ||
723 v->GetType() == AliAODVertex::kMainSPD ||
724 v->GetType() == AliAODVertex::kPileupSPD ||
725 v->GetType() == AliAODVertex::kPileupTracks||
726 v->GetType() == AliAODVertex::kMainTPC )
728 AliAODVertex* tmp = v->CloneWithoutRefs();
729 AliAODVertex* copiedVertex = new((*fVertices)[nvertices++]) AliAODVertex(*tmp);
731 // to insure the main vertex retains the ncontributors information
732 // (which is otherwise computed dynamically from
733 // references to tracks, which we do not keep in muon aods...)
736 copiedVertex->SetNContributors(v->GetNContributors());
738 // fVertices->Delete();
739 // delete copiedVertex;
744 // printf("....Done NuclEx Replicator...\n");
746 AliDebug(1,Form("input mu tracks=%d tracks=%d vertices=%d nnuclei=%d",
747 input,fSecondaryVerices->GetEntries(),fVertices->GetEntries(),fNuclei->GetEntries()));
749 // Finally, deal with MC information, if needed
751 // if ( fMCMode > 0 )
756 //cout<<"Delete..."<<endl;
759 //cout<<"Delete 1"<< endl;
761 if(io2Prong) {delete io2Prong; io2Prong=NULL;}
762 //cout<<"Delete 2"<< endl;
763 twoTrackArray->Delete(); delete twoTrackArray;
764 //cout<<"Delete 3"<< endl;
765 // vtx->Delete(); delete vtx;
766 //cout<<"Delete 4"<< endl;
767 if(fV1) { delete fV1; fV1=NULL; }
768 //cout<<"Delete 5"<< endl;
769 if(fAODMap) { delete [] fAODMap; fAODMap=NULL; }
771 //cout<<"Delete 6"<< endl;
772 delete fVertexerTracks;
777 //-----------------------------------------------------------------------------
779 AliAODVertex *AliAODNuclExReplicator::ReconstructSecondaryVertex(TObjArray *trkArray,
780 Double_t &dispersion,Bool_t useTRefArray) const
783 // Secondary vertex reconstruction with AliVertexerTracks or AliKFParticle
784 //AliCodeTimerAuto("",0);
786 AliESDVertex *vertexESD = 0;
787 AliAODVertex *vertexAOD = 0;
789 if(!fSecVtxWithKF) { // AliVertexerTracks
791 fVertexerTracks->SetVtxStart(fV1);
792 vertexESD = (AliESDVertex*)fVertexerTracks->VertexForSelectedESDTracks(trkArray);
794 if(!vertexESD) return vertexAOD;
797 Double_t vertRadius2=vertexESD->GetX()*vertexESD->GetX()+vertexESD->GetY()*vertexESD->GetY();
798 if(vertRadius2>200.){
799 // vertex outside beam pipe, reject candidate to avoid propagation through material
800 delete vertexESD; vertexESD=NULL;
804 } else { // Kalman Filter vertexer (AliKFParticle)
806 AliKFParticle::SetField(fBzkG);
808 AliKFVertex vertexKF;
810 Int_t nTrks = trkArray->GetEntriesFast();
811 for(Int_t i=0; i<nTrks; i++) {
812 AliESDtrack *esdTrack = (AliESDtrack*)trkArray->At(i);
813 AliKFParticle daughterKF(*esdTrack,211);
814 vertexKF.AddDaughter(daughterKF);
816 vertexESD = new AliESDVertex(vertexKF.Parameters(),
817 vertexKF.CovarianceMatrix(),
819 vertexKF.GetNContributors());
822 // convert to AliAODVertex
823 Double_t pos[3],cov[6],chi2perNDF;
824 vertexESD->GetXYZ(pos); // position
825 vertexESD->GetCovMatrix(cov); //covariance matrix
826 chi2perNDF = vertexESD->GetChi2toNDF();
827 dispersion = vertexESD->GetDispersion();
831 Int_t nprongs= (useTRefArray ? 0 : trkArray->GetEntriesFast());
832 vertexAOD = new AliAODVertex(pos,cov,chi2perNDF,0x0,-1,AliAODVertex::kUndef,nprongs);
834 //cout<<"------------------> Reconstruct vertexAOD: "<<vertexAOD<<endl;
841 //-----------------------------------------------------------------------------
843 AliAODRecoDecayLF2Prong* AliAODNuclExReplicator::Make2Prong(TObjArray *twoTrackArray,const AliAODEvent &evento,
844 AliAODVertex *secVert,Double_t dca)
849 //cout<<"Inside make 2 prong"<<endl;
852 charge[0]=1; //it was -1 //Ramona
855 // From AliAnalysisVertexingLF.cxx Method:Make2Prongs
857 fBzkG = evento.GetMagneticField();
859 Double_t px[2],py[2],pz[2],d0[2],d0err[2];
860 // Also this has been changed //Ramona
861 AliESDtrack *negtrack = (AliESDtrack*)twoTrackArray->UncheckedAt(0);
862 AliESDtrack *postrack = (AliESDtrack*)twoTrackArray->UncheckedAt(1);
864 //cout<<"negtrack: "<<negtrack<<" postrack: "<<postrack<<endl;
865 //cout<<"kVeryBig: "<<kVeryBig<<endl;
866 //cout<<"secVert: "<<secVert<<endl;
868 // // propagate tracks to secondary vertex, to compute inv. mass
870 postrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
871 negtrack->PropagateToDCA(secVert,fBzkG,kVeryBig);
873 Double_t momentum[3];
875 negtrack->GetPxPyPz(momentum);
876 px[0] = charge[0]*momentum[0];
877 py[0] = charge[0]*momentum[1];
878 pz[0] = charge[0]*momentum[2];
880 postrack->GetPxPyPz(momentum);
881 px[1] = charge[1]*momentum[0];
882 py[1] = charge[1]*momentum[1];
883 pz[1] = charge[1]*momentum[2];
885 //cout<< px[0] <<" "<< " "<< py[0] << " "<< pz[0]<<endl;
886 // px[0] = momentum[0]; py[0] = momentum[1]; pz[0] = momentum[2];
887 //cout<< px[1] <<" "<< " "<< py[1] << " "<< pz[1]<<endl;
888 //px[1] = momentum[0]; py[1] = momentum[1]; pz[1] = momentum[2];
891 // primary vertex to be used by this candidate
892 AliAODVertex *primVertexAOD = evento.GetPrimaryVertex();
893 //cout<<"primVertexAOD "<<primVertexAOD<<endl;
894 if(!primVertexAOD) return 0x0;
896 Double_t d0z0[2],covd0z0[3];
905 d0err[0] = TMath::Sqrt(TMath::Abs(covd0z0[0]));
908 d0err[1] = TMath::Sqrt(TMath::Abs(covd0z0[0]));
910 // create the object AliAODRecoDecayLF2Prong
911 // AliAODRecoDecayLF2Prong *the2Prong = new AliAODRecoDecayLF2Prong(secVert,px,py,pz,d0,d0err,dcap1n1);
912 AliAODRecoDecayLF2Prong *the2Prong = new AliAODRecoDecayLF2Prong(secVert,px,py,pz,d0,d0err,dca);
913 the2Prong->SetOwnPrimaryVtx(primVertexAOD);
915 // the2Prong->SetProngIDs(2,{-999,999});
916 // UShort_t id0[2]={99999,999999};
917 // the2Prong->SetProngIDs(2,id0);
919 UShort_t id[2]={(UShort_t)postrack->GetID(),(UShort_t)negtrack->GetID()};
920 the2Prong->SetProngIDs(2,id);
922 // cout<<"\n\n\nMake 2 Prong: id[0]"<<id[0]<<" id[1]: "<<id[1]<<endl;
923 // cout<<"Get: 1 "<<the2Prong->GetProngID(0)<<" 2 "<<the2Prong->GetProngID(1)<<endl;
924 // cout<<"Get: 3 "<<the2Prong->GetProngID(2)<<" 4 "<<the2Prong->GetProngID(3)<<endl<<endl<<endl;
925 //delete primVertexAOD; primVertexAOD=NULL;
927 if(postrack->Charge()!=0 && negtrack->Charge()!=0) {
929 AddDaughterRefs(secVert,(AliAODEvent&)evento,twoTrackArray);
930 // AddDaughterRefs(secVert,(AliAODEvent*)evento,twoTrackArray);
939 //----------------------------------------------------------------------------
940 void AliAODNuclExReplicator::AddDaughterRefs(AliAODVertex *v,
941 const AliAODEvent &event,
942 const TObjArray *trkArray) const
945 // Add the AOD tracks as daughters of the vertex (TRef)
946 // AliCodeTimerAuto("",0);
947 // cout<<"Inside AddDaughterRefs "<<endl;
949 Int_t nDg = v->GetNDaughters();
952 if(nDg) dg = v->GetDaughter(0);
953 if(dg) return; // daughters already added
955 Int_t nTrks = trkArray->GetEntriesFast();
957 AliExternalTrackParam *track = 0;
958 AliAODTrack *aodTrack = 0;
961 for(Int_t i=0; i<nTrks; i++) {
962 track = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
964 id = (Int_t)track->GetID();
965 // printf("---> %d\n",id);
966 if(id<0) continue; // this track is a AliAODRecoDecay
968 aodTrack = (AliAODTrack*)event.GetTrack(fAODMap[id]);
969 v->AddDaughter(aodTrack);
973 //----------------------------------------------------------------------------
975 void AliAODNuclExReplicator::AddRefs(AliAODVertex *v,AliAODRecoDecayLF *rd,
976 const AliAODEvent &event,
977 const TObjArray *trkArray) const
980 // Add the AOD tracks as daughters of the vertex (TRef)
981 // Also add the references to the primary vertex and to the cuts
982 //AliCodeTimerAuto("",0);
984 AddDaughterRefs(v,event,trkArray);
985 rd->SetPrimaryVtxRef((AliAODVertex*)event.GetPrimaryVertex());
989 //---------------------------------------------------------------------------
991 void AliAODNuclExReplicator::Terminate(){