- // open file with tracks
- TFile *trkFile = TFile::Open(trkName.Data());
-
- // loop on events in file
- for(ev=evFirst; ev<=evLast; ev++) {
- printf(" --- Looking for D0->Kpi in event %d ---\n",ev);
-
- // retrieve primary vertex from file
- sprintf(vtxName,"VertexTracks_%d",ev);
- AliESDVertex *vertex1stored = (AliESDVertex*)trkFile->Get(vtxName);
- vertex1stored->GetXYZ(fV1);
- delete vertex1stored;
-
- // retrieve tracks from file
- sprintf(trkTreeName,"TreeT_ITS_%d",ev);
- TTree *trkTree=(TTree*)trkFile->Get(trkTreeName);
- if(!trkTree) {
- printf("AliD0toKpiAnalysis::FindCandidates():\n tracks tree not found for evet %d\n",ev);
- continue;
- }
- trkEntries = (Int_t)trkTree->GetEntries();
- printf(" Number of tracks: %d\n",trkEntries);
-
- // count the total number of events
- nTotEv++;
-
- // call function which applies sigle-track selection and
- // separetes positives and negatives
- TObjArray trksP(trkEntries/2);
- Int_t *trkEntryP = new Int_t[trkEntries];
- TObjArray trksN(trkEntries/2);
- Int_t *trkEntryN = new Int_t[trkEntries];
- SelectTracks(*trkTree,trksP,trkEntryP,nTrksP,trksN,trkEntryN,nTrksN);
-
- nD0rec1ev = 0;
-
- // loop on positive tracks
- for(iTrkP=0; iTrkP<nTrksP; iTrkP++) {
- if(iTrkP%10==0) printf(" Processing positive track number %d of %d\n",iTrkP,nTrksP);
-
- // get track from track array
- postrack = (AliITStrackV2*)trksP.At(iTrkP);
- trkNum[0] = trkEntryP[iTrkP];
-
- // loop on negative tracks
- for(iTrkN=0; iTrkN<nTrksN; iTrkN++) {
- // get track from tracks array
- negtrack = (AliITStrackV2*)trksN.At(iTrkN);
- trkNum[1] = trkEntryN[iTrkN];
-
- AliITStrackV2 nt(*negtrack), pt(*postrack), *pnt=&nt, *ppt=&pt;
-
- //
- // ----------- DCA MINIMIZATION ------------------
- //
- // find the DCA and propagate the tracks to the DCA
- dca = vertexer2->PropagateToDCA(pnt,ppt);
-
- // define the AliV0vertex object
- AliV0vertex *vertex2 = new AliV0vertex(*pnt,*ppt);
-
- // get position of the secondary vertex
- vertex2->GetXYZ(v2[0],v2[1],v2[2]);
-
- delete vertex2;
-
- // momenta of the tracks at the vertex
- ptP = 1./TMath::Abs(ppt->Get1Pt());
- alphaP = ppt->GetAlpha();
- phiP = alphaP+TMath::ASin(ppt->GetSnp());
- mom[0] = ptP*TMath::Cos(phiP);
- mom[1] = ptP*TMath::Sin(phiP);
- mom[2] = ptP*ppt->GetTgl();
-
- ptN = 1./TMath::Abs(pnt->Get1Pt());
- alphaN = pnt->GetAlpha();
- phiN = alphaN+TMath::ASin(pnt->GetSnp());
- mom[3] = ptN*TMath::Cos(phiN);
- mom[4] = ptN*TMath::Sin(phiN);
- mom[5] = ptN*pnt->GetTgl();
-
- goodVtx1 = kTRUE;
- // no vertexing if DeltaMass > fMassCut
- if(fVertexOnTheFly) {
- goodVtx1 = kFALSE;
- if(SelectInvMass(mom)) {
- // primary vertex from *other* tracks in event
- vertexer1->SetVtxStart(fV1[0],fV1[1]);
- skipped[0] = trkEntryP[iTrkP];
- skipped[1] = trkEntryN[iTrkN];
- vertexer1->SetSkipTracks(2,skipped);
- AliESDVertex *vertex1onfly =
- (AliESDVertex*)vertexer1->VertexOnTheFly(*trkTree);
- if(vertex1onfly->GetNContributors()>0) goodVtx1 = kTRUE;
- vertex1onfly->GetXYZ(fV1);
- //vertex1onfly->PrintStatus();
- delete vertex1onfly;
- }
- }
-
- // impact parameters of the tracks w.r.t. the primary vertex
- d0[0] = 10000.*ppt->GetD(fV1[0],fV1[1]);
- d0[1] = -10000.*pnt->GetD(fV1[0],fV1[1]);
-
- // create the object AliD0toKpi
- AliD0toKpi theD0(ev,trkNum,fV1,v2,dca,mom,d0);
-
- // select D0s
- if(goodVtx1 && theD0.Select(fD0Cuts,okD0,okD0bar)) {
-
- // fill the tree
- ioD0toKpi=&theD0;
- treeD0->Fill();
-
- nD0rec++; nD0rec1ev++;
- ioD0toKpi=0;
- }
-
- negtrack = 0;
- } // loop on negative tracks
- postrack = 0;
- } // loop on positive tracks
-
- trksP.Delete();
- trksN.Delete();
- delete [] trkEntryP;
- delete [] trkEntryN;
- delete trkTree;
-
- printf(" Number of D0 candidates: %d\n",nD0rec1ev);
- } // loop on events in file
-
-
- printf("\n+++\n+++ Total number of events: %d\n+++\n",nTotEv);
- printf("\n+++\n+++ Total number of D0 candidates: %d\n+++\n",nD0rec);
-
- delete vertexer1;
- delete vertexer2;
-
- trkFile->Close();
-
- // create a copy of this class to be written to output file
- AliD0toKpiAnalysis *copy = (AliD0toKpiAnalysis*)this->Clone("D0toKpiAnalysis");
- copy->PrintStatus();
-
- // add PDG codes to decay tracks in found candidates (in simulation mode)
- // and store tree in the output file
- if(!fSim) {
- TFile *outroot = new TFile(outName1.Data(),"recreate");
- treeD0->Write();
- copy->Write();
- outroot->Close();
- delete outroot;
- } else {
- printf(" Now adding information from simulation (PDG codes) ...\n");
- TTree *treeD0sim = new TTree("TreeD0","Tree with D0 candidates");
- MakeTracksRefFile(evFirst,evLast);
- SimulationInfo(treeD0,treeD0sim);
- delete treeD0;
- TFile *outroot = new TFile(outName1.Data(),"recreate");
- treeD0sim->Write();
- copy->Write();
- outroot->Close();
- delete outroot;
- }
-
- // write to a file the total number of events
- FILE *outdat = fopen(outName2.Data(),"w");
- fprintf(outdat,"%d\n",nTotEv);
- fclose(outdat);
-
- return;
-}
-*/
-//----------------------------------------------------------------------------
-void AliD0toKpiAnalysis::FindCandidatesESD(Int_t evFirst,Int_t evLast,
- const Char_t *outName) {
- // Find D0 candidates and calculate parameters
-
- if(fBz<-9000.) {
- printf("AliD0toKpiAnalysis::FindCandidatesESD(): Set B!\n");
- return;
- }
-
- TString esdName("AliESDs.root");