AliPhysics  9b6b435 (9b6b435)
AliAnalysisTaskSEXicZero2XiPifromAODtracks.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appeuear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
18 //
19 //
20 // XicZero2XiPi analysis code
21 //
22 // Input: AOD
23 // Output: TTree or THnSparse (mass vs pT vs Centrality)
24 //
25 // Cuts:
26 // TTree: very loose cut
27 // THnSparse: One THnSparse is created per cut. One cut is specified by
28 // an array of bits, each bit corresponds to a cut in "Cut" function.
29 //
30 //-------------------------------------------------------------------------
31 //
32 // Authors: Y.S Watanabe(a)
33 // (a) CNS, the University of Tokyo
34 // Contatcs: wyosuke@cns.s.u-tokyo.ac.jp
35 //-------------------------------------------------------------------------
36 
37 #include <TSystem.h>
38 #include <TParticle.h>
39 #include <TParticlePDG.h>
40 #include <THnSparse.h>
41 #include <TH1F.h>
42 #include <TH2F.h>
43 #include <TLorentzVector.h>
44 #include <TTree.h>
45 #include "TROOT.h"
46 #include <TDatabasePDG.h>
47 #include <AliAnalysisDataSlot.h>
48 #include <AliAnalysisDataContainer.h>
49 #include "AliMCEvent.h"
50 #include "AliAnalysisManager.h"
51 #include "AliAODMCHeader.h"
52 #include "AliAODHandler.h"
53 #include "AliLog.h"
54 #include "AliExternalTrackParam.h"
55 #include "AliAODVertex.h"
56 #include "AliESDVertex.h"
57 #include "AliAODRecoDecay.h"
58 #include "AliAODRecoDecayHF.h"
59 #include "AliAODRecoCascadeHF.h"
60 #include "AliESDtrack.h"
61 #include "AliAODTrack.h"
62 #include "AliAODv0.h"
63 #include "AliAODcascade.h"
64 #include "AliAODMCParticle.h"
65 #include "AliAnalysisTaskSE.h"
67 #include "AliPIDResponse.h"
68 #include "AliPIDCombined.h"
69 #include "AliAODPidHF.h"
70 #include "AliInputEventHandler.h"
71 #include "AliESDtrackCuts.h"
72 #include "AliNeutralTrackParam.h"
73 #include "AliKFParticle.h"
74 #include "AliKFVertex.h"
75 #include "AliExternalTrackParam.h"
76 #include "AliCentrality.h"
77 #include "AliVertexerTracks.h"
78 
79 using std::cout;
80 using std::endl;
81 
85 
86 //__________________________________________________________________________
89  fUseMCInfo(kFALSE),
90  fFillSignalOnly(kFALSE),
91  fFillBkgOnly(kFALSE),
92  fOutput(0),
93  fOutputAll(0),
94  fListCuts(0),
95  fCEvents(0),
96  fHTrigger(0),
97  fHCentrality(0),
98  fHSelectedCascadePerEv(0),
99  fHSelectedTracksPerEv(0),
100  fAnalCuts(0),
101  fIsEventSelected(kFALSE),
102  fWriteVariableTree(kFALSE),
103  fVariablesTree(0),
104  fReconstructPrimVert(kFALSE),
105  fIsMB(kFALSE),
106  fIsSemi(kFALSE),
107  fIsCent(kFALSE),
108  fIsINT7(kFALSE),
109  fIsEMC7(kFALSE),
110  fCandidateVariables(),
111  fVtx1(0),
112  fV1(0),
113  fBzkG(0),
114  fCentrality(0),
115  fTriggerCheck(0),
116  fHistoXicMass(0),
117  fHistoDcaPiCasc(0),
118  fHistoCascDcaXiDaughters(0),
119  fHistoCascDcaV0Daughters(0),
120  fHistoCascDcaV0ToPrimVertex(0),
121  fHistoCascDcaPosToPrimVertex(0),
122  fHistoCascDcaNegToPrimVertex(0),
123  fHistoCascDcaBachToPrimVertex(0),
124  fHistoCascCosPAXiPrim(0),
125  fHistoXiPt(0),
126  fHistoPiPt(0),
127  fHistoPid0(0),
128  fHistonSigmaTPCpi(0),
129  fHistonSigmaTOFpi(0),
130  fHistoProbPion(0),
131  fHistoXiMassvsPtRef(0),
132  fHistoXiMassvsPtRef2(0),
133  fHistoXiMassvsPtRef3(0),
134  fHistoXiMassvsPtRef4(0),
135  fHistoXiMassvsPtRef5(0),
136  fHistoXiMassvsPtRef6(0),
137  fHistoPiPtRef(0)
138 {
139  //
140  // Default Constructor.
141  //
142 }
143 
144 //___________________________________________________________________________
147  Bool_t writeVariableTree) :
148  AliAnalysisTaskSE(name),
149  fUseMCInfo(kFALSE),
150  fFillSignalOnly(kFALSE),
151  fFillBkgOnly(kFALSE),
152  fOutput(0),
153  fOutputAll(0),
154  fListCuts(0),
155  fCEvents(0),
156  fHTrigger(0),
157  fHCentrality(0),
160  fAnalCuts(analCuts),
161  fIsEventSelected(kFALSE),
162  fWriteVariableTree(writeVariableTree),
163  fVariablesTree(0),
164  fReconstructPrimVert(kFALSE),
165  fIsMB(kFALSE),
166  fIsSemi(kFALSE),
167  fIsCent(kFALSE),
168  fIsINT7(kFALSE),
169  fIsEMC7(kFALSE),
171  fVtx1(0),
172  fV1(0),
173  fBzkG(0),
174  fCentrality(0),
175  fTriggerCheck(0),
176  fHistoXicMass(0),
177  //fHistoDcaPi1Pi2(0),
178  fHistoDcaPiCasc(0),
179  //fHistoLikeDecayLength(0),
180  //fHistoLikeDecayLengthXY(0),
181  //fHistoXicCosPAXY(0),
182  fHistoXiMass(0),
190  fHistoXiPt(0),
191  fHistoPiPt(0),
192  fHistoPid0(0),
195  fHistoProbPion(0),
202  fHistoPiPtRef(0)
203 {
204  //
205  // Constructor. Initialization of Inputs and Outputs
206  //
207  Info("AliAnalysisTaskSEXicZero2XiPifromAODtracks","Calling Constructor");
208 
209  DefineOutput(1,TList::Class());
210  DefineOutput(2,TList::Class());
211  if(writeVariableTree){
212  DefineOutput(3,TTree::Class());
213  }else{
214  DefineOutput(3,TList::Class());
215  }
216 }
217 
218 //___________________________________________________________________________
220  //
221  // destructor
222  //
223  Info("~AliAnalysisTaskSEXicZero2XiPifromAODtracks","Calling Destructor");
224 
225 
226  if (fOutput) {
227  delete fOutput;
228  fOutput = 0;
229  }
230 
231  if (fOutputAll) {
232  delete fOutputAll;
233  fOutputAll = 0;
234  }
235 
236  if (fListCuts) {
237  delete fListCuts;
238  fListCuts = 0;
239  }
240 
241 
242  if (fAnalCuts) {
243  delete fAnalCuts;
244  fAnalCuts = 0;
245  }
246 
247  if (fVariablesTree) {
248  delete fVariablesTree;
249  fVariablesTree = 0;
250  }
251 
253  delete fCandidateVariables;
255  }
256 
257 }
258 
259 //_________________________________________________
261  //
262  // Initialization
263  //
264  //
265 
266  //Copied from $ALICE_ROOT/PWGHF/vertexingHF/ConfigVertexingHF.C
267 
268  fIsEventSelected=kFALSE;
269 
270  if (fDebug > 1) AliInfo("Init");
271 
272  fListCuts = new TList();
273  fListCuts->SetOwner();
274  fListCuts->SetName("ListCuts");
276  PostData(2,fListCuts);
277 
278  return;
279 }
280 
281 //_________________________________________________
283 {
284  //
285  // UserExec code
286  //
287  if (!fInputEvent) {
288  AliError("NO EVENT FOUND!");
289  return;
290  }
291  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(fInputEvent);
292 
293 
294  fCEvents->Fill(1);
295  //------------------------------------------------
296  // First check if the event has proper vertex and B
297  //------------------------------------------------
298  fVtx1 = (AliAODVertex*)aodEvent->GetPrimaryVertex();
299  if (!fVtx1) return;
300 
301  Double_t pos[3],cov[6];
302  fVtx1->GetXYZ(pos);
303  fVtx1->GetCovarianceMatrix(cov);
304  fV1 = new AliESDVertex(pos,cov,100.,100,fVtx1->GetName());
305 
306  fBzkG = (Double_t)aodEvent->GetMagneticField();
307  AliKFParticle::SetField(fBzkG);
308  if (TMath::Abs(fBzkG)<0.001) {
309  delete fV1;
310  return;
311  }
312  fCEvents->Fill(2);
313 
314  //------------------------------------------------
315  // Event selection
316  //------------------------------------------------
317  Bool_t fIsTriggerNotOK = fAnalCuts->IsEventRejectedDueToTrigger();
318  if(!fIsTriggerNotOK) fCEvents->Fill(3);
319 
321  if(!fIsEventSelected) {
322  //cout<<"Why: "<<fAnalCuts->GetWhyRejection()<<endl;
323  delete fV1;
324  return;
325  }
326 
327  //cout<<fabs(aodEvent->GetPrimaryVertex()->GetZ()-aodEvent->GetPrimaryVertexSPD()->GetZ())<<endl;
328 
329  fCEvents->Fill(4);
330 
331  fIsMB=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kMB)==(AliVEvent::kMB);
332  fIsSemi=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kSemiCentral)==(AliVEvent::kSemiCentral);
333  fIsCent=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kCentral)==(AliVEvent::kCentral);
334  fIsINT7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kINT7)==(AliVEvent::kINT7);
335  fIsEMC7=(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()&AliVEvent::kEMC7)==(AliVEvent::kEMC7);
337  if(fIsMB) fHTrigger->Fill(1);
338  if(fIsSemi) fHTrigger->Fill(2);
339  if(fIsCent) fHTrigger->Fill(3);
340  if(fIsINT7) fHTrigger->Fill(4);
341  if(fIsEMC7) fHTrigger->Fill(5);
342  if(fIsMB|fIsSemi|fIsCent) fHTrigger->Fill(7);
343  if(fIsINT7|fIsEMC7) fHTrigger->Fill(8);
344  if(fIsMB&fIsSemi) fHTrigger->Fill(10);
345  if(fIsMB&fIsCent) fHTrigger->Fill(11);
346  if(fIsINT7&fIsEMC7) fHTrigger->Fill(12);
347 
348  AliCentrality *cent = aodEvent->GetCentrality();
349  fCentrality = cent->GetCentralityPercentile("V0M");
350  fHCentrality->Fill(fCentrality);
351 
352  //------------------------------------------------
353  // Check if the event has cascade candidate
354  //------------------------------------------------
355  Int_t ncasc = aodEvent->GetNumberOfCascades();
356  Int_t nselecasc = 0.;
357  for(Int_t ic=0;ic<ncasc;ic++){
358  AliAODcascade *casc = aodEvent->GetCascade(ic);
359  if(!fAnalCuts) continue;
360  if(fAnalCuts->SingleCascadeCuts(casc,pos)) nselecasc++;
361  }
362 
363  if(nselecasc==0){
364  delete fV1;
365  return;
366  }
367 
368  fCEvents->Fill(5);
369 
370  //------------------------------------------------
371  // MC analysis setting
372  //------------------------------------------------
373 
374  TClonesArray *mcArray = 0;
375  AliAODMCHeader *mcHeader=0;
376  if (fUseMCInfo) {
377  // MC array need for maching
378  mcArray = dynamic_cast<TClonesArray*>(aodEvent->FindListObject(AliAODMCParticle::StdBranchName()));
379  if (!mcArray) {
380  AliError("Could not find Monte-Carlo in AOD");
381  delete fV1;
382  return;
383  }
384  fCEvents->Fill(6); // in case of MC events
385 
386  // load MC header
387  mcHeader = (AliAODMCHeader*)aodEvent->GetList()->FindObject(AliAODMCHeader::StdBranchName());
388  if (!mcHeader) {
389  AliError("AliAnalysisTaskSEXicZero2XiPifromAODtracks::UserExec: MC header branch not found!\n");
390  delete fV1;
391  return;
392  }
393  fCEvents->Fill(7); // in case of MC events
394 
395  Double_t zMCVertex = mcHeader->GetVtxZ();
396  if (TMath::Abs(zMCVertex) > fAnalCuts->GetMaxVtxZ()) {
397  AliDebug(2,Form("Event rejected: abs(zVtxMC)=%f > fAnalCuts->GetMaxVtxZ()=%f",zMCVertex,fAnalCuts->GetMaxVtxZ()));
398  delete fV1;
399  return;
400  } else {
401  fCEvents->Fill(17); // in case of MC events
402  }
403  }
404 
405  //------------------------------------------------
406  // Main analysis done in this function
407  //------------------------------------------------
408  MakeAnalysis(aodEvent, mcArray);
409 
410  PostData(1,fOutput);
411  if(fWriteVariableTree){
412  PostData(3,fVariablesTree);
413  }else{
414  PostData(3,fOutputAll);
415  }
416 
417  fIsEventSelected=kFALSE;
418 
419  delete fV1;
420  return;
421 }
422 
423 //________________________________________ terminate ___________________________
425 {
426  // The Terminate() function is the last function to be called during
427  // a query. It always runs on the client, it can be used to present
428  // the results graphically or save the results to file.
429 
430  //AliInfo("Terminate","");
431  AliAnalysisTaskSE::Terminate();
432 
433  fOutput = dynamic_cast<TList*> (GetOutputData(1));
434  if (!fOutput) {
435  AliError("fOutput not available");
436  return;
437  }
438 
439  if(!fWriteVariableTree){
440  fOutputAll = dynamic_cast<TList*> (GetOutputData(3));
441  if (!fOutputAll) {
442  AliError("fOutputAll not available");
443  return;
444  }
445  }
446 
447  return;
448 }
449 
450 //___________________________________________________________________________
452 {
453  //
454  // UserCreateOutputObjects
455  //
456 
457  AliInfo(Form("CreateOutputObjects of task %s\n", GetName()));
458 
459  //------------------------------------------------
460  // output object setting
461  //------------------------------------------------
462  fOutput = new TList();
463  fOutput->SetOwner();
464  fOutput->SetName("chist0");
465  DefineGeneralHistograms(); // define general histograms
466  PostData(1,fOutput);
467 
469  if (fWriteVariableTree) {
470  PostData(3,fVariablesTree);
471  }else{
472  fOutputAll = new TList();
473  fOutputAll->SetOwner();
474  fOutputAll->SetName("anahisto");
475  //DefineAnalysisHistograms(); // define general histograms
476  PostData(3,fOutputAll);
477  }
478 
479 
480  return;
481 }
482 
483 //________________________________________________________________________
485 {
486  //
487  // Main analysis part called from UserExec
488  //
489 
490  Int_t nCascades= aodEvent->GetNumberOfCascades();
491  if (nCascades==0) {
492  return;
493  }
494  Int_t nTracks= aodEvent->GetNumberOfTracks();
495  if (nTracks==0) {
496  return;
497  }
498 
499  //------------------------------------------------
500  // Select good track before hand to save time
501  //------------------------------------------------
502  Bool_t seleTrkFlags[nTracks];
503  Int_t nSeleTrks=0;
504  SelectTrack(aodEvent,nTracks,nSeleTrks,seleTrkFlags);
505  Bool_t seleCascFlags[nCascades];
506  Int_t nSeleCasc=0;
507  SelectCascade(aodEvent,nCascades,nSeleCasc,seleCascFlags);
508 
509  Int_t usedmclab[20];//Used Xic Label: Assuming there are less than 20 Xic/evt
510  Int_t nusedmclab[20];//Number of times the Xic label is used: Assuming there are less than 20 Xic/evt
511  for(Int_t i=0;i<20;i++) {
512  usedmclab[i]=-9999;
513  nusedmclab[i]=0;
514  }
515 
516  //------------------------------------------------
517  // Cascade loop
518  //------------------------------------------------
519  Int_t counterSelectedCascades = 0;
520  for (Int_t icasc = 0; icasc<nCascades; icasc++) {
521  if(!seleCascFlags[icasc]) continue;
522  AliAODcascade *casc = aodEvent->GetCascade(icasc);
523  if(!casc) continue;
524 
525  AliAODTrack *cptrack = (AliAODTrack*)(casc->GetDaughter(0));
526  AliAODTrack *cntrack = (AliAODTrack*)(casc->GetDaughter(1));
527  AliAODTrack *cbtrack = (AliAODTrack*)(casc->GetDecayVertexXi()->GetDaughter(0));
528  if(!cptrack || !cntrack || !cbtrack) continue;
529 
530  Int_t cpid = cptrack->GetID();
531  Int_t cnid = cntrack->GetID();
532  Int_t cbid = cbtrack->GetID();
533 
534  if(cptrack->Charge()==0) continue;
535  if(cntrack->Charge()==0) continue;
536  if(cbtrack->Charge()==0) continue;
537 
538  Short_t charge_casc = cptrack->Charge() + cntrack->Charge() + cbtrack->Charge();
539  counterSelectedCascades+=1;
540  Int_t counterSelectedTracks = 0;
541  //------------------------------------------------
542  // Track1 loop
543  //------------------------------------------------
544  for (Int_t itrk1 = 0; itrk1<nTracks; itrk1++) {
545  if(!seleTrkFlags[itrk1]) continue;
546  AliAODTrack *trk1 = (AliAODTrack*)aodEvent->GetTrack(itrk1);
547  if(!trk1||trk1->GetID()<0) continue;
548  Int_t lpid1 = trk1->GetID();
549  if((cpid==lpid1)||(cnid==lpid1)||(cbid==lpid1)) continue;
550  Short_t charge_like1 = trk1->Charge();
551  Bool_t ok_charge = kFALSE;
552  if((charge_casc==-1)&&(charge_like1==1)) ok_charge = kTRUE;
553  if((charge_casc==1)&&(charge_like1==-1)) ok_charge = kTRUE;
554  if(!ok_charge) continue;
555 
556  counterSelectedTracks+=1;
557 
558  AliAODVertex *secVert = ReconstructSecondaryVertex(casc,trk1,aodEvent);//Fake, prim vertex is just used as secondary vertex. place holder for future
559  if(!secVert) continue;
560 
561  AliAODRecoCascadeHF *exobj = MakeCascadeHF(casc,trk1,aodEvent,secVert);
562  if(!exobj) {
563  delete secVert;
564  continue;
565  }
566  AliAODMCParticle *mcxic = 0;
567  AliAODMCParticle *mcdaughter1 = 0;
568  AliAODMCParticle *mcdaughterxi = 0;
569  Int_t mclabxic = 0;
570  Int_t nmclabxic = 0;
571  Bool_t isXic = kFALSE;
572  if(fUseMCInfo)
573  {
574  Int_t pdgDg[2]={211,3312};
575  Int_t pdgDgcasc[2]={211,3122};
576  Int_t pdgDgv0[2]={2212,211};
577  mclabxic = MatchtoMC(exobj,4132,3312,pdgDg,pdgDgcasc,pdgDgv0,mcArray);
578  if(mclabxic>-1){
579  mcxic = (AliAODMCParticle*) mcArray->At(mclabxic);
580  for(Int_t ia=0;ia<20;ia++){
581  if(usedmclab[ia]==mclabxic){
582  nusedmclab[ia]++;
583  nmclabxic = nusedmclab[ia];
584  break;
585  }
586  if(usedmclab[ia]==-9999){
587  usedmclab[ia]=mclabxic;
588  nusedmclab[ia]++;
589  nmclabxic = nusedmclab[ia];
590  break;
591  }
592  }
593  isXic=kTRUE;
594  for(Int_t idau=mcxic->GetFirstDaughter();idau<mcxic->GetLastDaughter()+1;idau++)
595  {
596  //cout<<idau<<endl;
597  if(idau<0) break;
598  AliAODMCParticle *mcpart = (AliAODMCParticle*) mcArray->At(idau);
599  Int_t pdgcode = TMath::Abs(mcpart->GetPdgCode());
600  if(pdgcode==211){
601  mcdaughter1 = mcpart;
602  } else if(pdgcode==3312){
603  mcdaughterxi = mcpart;
604  }
605  }
606  }
607  }
608  FillROOTObjects(exobj,casc,trk1,mcxic,mcdaughter1,mcdaughterxi, nmclabxic,isXic);
609 
610  exobj->GetSecondaryVtx()->RemoveDaughters();
611  exobj->UnsetOwnPrimaryVtx();
612  delete exobj;exobj=NULL;
613  delete secVert;
614 
615 
616  }//trk1
617  fHSelectedTracksPerEv->Fill(counterSelectedTracks);
618  }//casc
619  fHSelectedCascadePerEv->Fill(counterSelectedCascades);
620  return;
621 }
622 
623 //________________________________________________________________________
624 void AliAnalysisTaskSEXicZero2XiPifromAODtracks::FillROOTObjects(AliAODRecoCascadeHF *xicobj, AliAODcascade *casc, AliAODTrack *part1, AliAODMCParticle *mcpart, AliAODMCParticle *mcdaughter1, AliAODMCParticle *mcdaughterxi, Int_t mcnused, Bool_t isXic)
625 {
626  //
627  // Fill histogram or Tree depending on fWriteVariableTree flag
628  //
629 
630  Double_t mxiPDG = TDatabasePDG::Instance()->GetParticle(3312)->Mass();
631  Double_t mPiPDG = TDatabasePDG::Instance()->GetParticle(211)->Mass();
632 
633  UInt_t pdgdg[2]={211,3312};
634 
635  Double_t posVtx[3] = {0.,0.,0.};
636  fVtx1->GetXYZ(posVtx);
637 
638  Double_t nSigmaTPCpi1=-9999.;
639  Double_t nSigmaTOFpi1=-9999.;
640  Double_t probPion1=-9999.;
641 
642  nSigmaTPCpi1 = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(part1,AliPID::kPion);
643  nSigmaTOFpi1 = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(part1,AliPID::kPion);
644 
645  if(casc->MassXi()< 1.315 || casc->MassXi()> 1.33 ||(casc->MassLambda()>1.2 && casc->MassAntiLambda()>1.2) ) return;
646  Double_t massXic= xicobj->InvMass(2,pdgdg);
647  if (massXic> 3. || massXic<2.) return;
648  if(nSigmaTPCpi1<-4 || nSigmaTPCpi1>4 || nSigmaTOFpi1<-4 || nSigmaTOFpi1>4) return;
649 
650  if ((fUseMCInfo && fFillSignalOnly && !fFillBkgOnly && !isXic) || (fUseMCInfo && !fFillSignalOnly && fFillBkgOnly && isXic)) return;
651  else {
652 
653  fCandidateVariables[ 0] = xicobj->InvMass(2,pdgdg);
654  fCandidateVariables[ 1] = xicobj->Px();
655  fCandidateVariables[ 2] = xicobj->Py();
656  fCandidateVariables[ 3] = xicobj->Pz();
657  fCandidateVariables[ 4] = part1->Px();
658  fCandidateVariables[ 5] = part1->Py();
659  fCandidateVariables[ 6] = part1->Pz();
660  fCandidateVariables[ 7] = 0;
661  fCandidateVariables[ 8] = 0;
662  fCandidateVariables[ 9] = 0;
663  fCandidateVariables[10] = casc->MassXi();
664  fCandidateVariables[11] = casc->MomXiX();
665  fCandidateVariables[12] = casc->MomXiY();
666  fCandidateVariables[13] = casc->MomXiZ();
667  fCandidateVariables[14] = casc->MassLambda();
668  fCandidateVariables[15] = casc->MassAntiLambda();
669 
671  fCandidateVariables[17] = fVtx1->GetX();
672  fCandidateVariables[18] = fVtx1->GetY();
673  fCandidateVariables[19] = fVtx1->GetZ();
674  fCandidateVariables[20] = xicobj->GetOwnPrimaryVtx()->GetX();
675  fCandidateVariables[21] = xicobj->GetOwnPrimaryVtx()->GetY();
676  fCandidateVariables[22] = xicobj->GetOwnPrimaryVtx()->GetZ();
677 
678  fCandidateVariables[23] = casc->DcaXiDaughters();
679  fCandidateVariables[24] = casc->DcaV0Daughters();
680  fCandidateVariables[25] = casc->DecayLengthXi(posVtx[0],posVtx[1],posVtx[2]);
681  fCandidateVariables[26] = casc->CosPointingAngleXi(posVtx[0],posVtx[1],posVtx[2]);
682  fCandidateVariables[27] = casc->DcaV0ToPrimVertex();
683  fCandidateVariables[28] = casc->DcaPosToPrimVertex();
684  fCandidateVariables[29] = casc->DcaNegToPrimVertex();
685  fCandidateVariables[30] = casc->DcaBachToPrimVertex();
686  fCandidateVariables[31] = casc->DecayLengthV0();
687  fCandidateVariables[32] = casc->CosPointingAngle(casc->GetDecayVertexXi());
688 
689  Double_t dca[3];
690  // xicobj->GetDCAs(dca);
691  fCandidateVariables[33] = 0;//dca[0];
692  fCandidateVariables[34] = 0;//dca[1];
693  fCandidateVariables[35] = 0;//dca[2];
694  fCandidateVariables[36] = xicobj->Getd0Prong(0);
695  fCandidateVariables[37] = 0; //xicobj->Getd0Prong(2);
696  fCandidateVariables[38] = xicobj->Getd0Prong(1);
697 
698  fCandidateVariables[39] = xicobj->DecayLength();
699  fCandidateVariables[40] = xicobj->DecayLengthXY();
700  fCandidateVariables[41] = 0; //xicobj->XicCosPointingAngle();
701 
702  if(fAnalCuts->GetIsUsePID())
703  {
704  fCandidateVariables[42] = nSigmaTPCpi1;
705  fCandidateVariables[43] = 0;
706  fCandidateVariables[44] = nSigmaTOFpi1;
707  fCandidateVariables[45] = 0;
708 
710  probPion1 = fAnalCuts->GetPionProbabilityTPCTOF(part1);
711  }
712  fCandidateVariables[46] = probPion1;
713  fCandidateVariables[47] = 0;
714  }
715  fCandidateVariables[48] = -9999;
716  fCandidateVariables[49] = -9999;
717  fCandidateVariables[50] = -9999;
718  fCandidateVariables[51] = -9999;
719  fCandidateVariables[52] = -9999;
720  fCandidateVariables[53] = -9999;
721  fCandidateVariables[54] = -9999;
722  fCandidateVariables[55] = -9999;
723  fCandidateVariables[56] = -9999;
724  fCandidateVariables[57] = -9999;
725  fCandidateVariables[65] = -9999;
726  fCandidateVariables[66] = -9999;
727  fCandidateVariables[67] = -9999;
728  fCandidateVariables[68] = -9999;
729  fCandidateVariables[69] = -9999;
730  fCandidateVariables[70] = -9999;
731  fCandidateVariables[71] = -9999;
732  fCandidateVariables[72] = -9999;
733  fCandidateVariables[73] = -9999;
734  fCandidateVariables[74] = -9999;
735  fCandidateVariables[75] = -9999;
736  fCandidateVariables[76] = -9999;
737 
738  if(fUseMCInfo){
739  if(mcpart){
740  fCandidateVariables[48] = mcpart->Label();
741  fCandidateVariables[49] = mcnused;
742  fCandidateVariables[50] = mcpart->GetPdgCode();
743  fCandidateVariables[54] = mcpart->Pt();
744  if(mcdaughter1&&mcdaughterxi){
745  Double_t mcprimvertx = mcpart->Xv();
746  Double_t mcprimverty = mcpart->Yv();
747  Double_t mcsecvertx = mcdaughter1->Xv();
748  Double_t mcsecverty = mcdaughter1->Yv();
749  Double_t recosecvertx = xicobj->GetSecondaryVtx()->GetX();
750  Double_t recosecverty = xicobj->GetSecondaryVtx()->GetY();
751  fCandidateVariables[51] = TMath::Sqrt((mcsecvertx-mcprimvertx)*(mcsecvertx-mcprimvertx)+(mcsecverty-mcprimverty)*(mcsecverty-mcprimverty));
752  fCandidateVariables[52] = TMath::Sqrt((recosecvertx-mcprimvertx)*(recosecvertx-mcprimvertx)+(recosecverty-mcprimverty)*(recosecverty-mcprimverty));
753  Double_t vecx_vert = recosecvertx-mcprimvertx;
754  Double_t vecy_vert = recosecverty-mcprimverty;
755  Double_t vecl_vert = TMath::Sqrt(vecx_vert*vecx_vert+vecy_vert*vecy_vert);
756  Double_t vecx_mom = xicobj->Px();
757  Double_t vecy_mom = xicobj->Py();
758  Double_t vecl_mom = xicobj->Pt();
759  if(vecl_vert>0.&&vecl_mom>0.)
760  fCandidateVariables[53] = (vecx_vert*vecx_mom+vecy_vert*vecy_mom)/vecl_vert/vecl_mom;
761  fCandidateVariables[55] = mcdaughter1->Pt();
762  fCandidateVariables[56] = 0; //mcdaughter2->Pt();
763  fCandidateVariables[57] = mcdaughterxi->Pt();
764  fCandidateVariables[65] = mcpart->Px();
765  fCandidateVariables[66] = mcpart->Py();
766  fCandidateVariables[67] = mcpart->Pz();
767  fCandidateVariables[68] = mcdaughter1->Px();
768  fCandidateVariables[69] = mcdaughter1->Py();
769  fCandidateVariables[70] = mcdaughter1->Pz();
770  fCandidateVariables[71] = 0; //mcdaughter2->Px();
771  fCandidateVariables[72] = 0; //mcdaughter2->Py();
772  fCandidateVariables[73] = 0; //mcdaughter2->Pz();
773  fCandidateVariables[74] = mcdaughterxi->Px();
774  fCandidateVariables[75] = mcdaughterxi->Py();
775  fCandidateVariables[76] = mcdaughterxi->Pz();
776  }
777  }
778  }
779  fCandidateVariables[58] = casc->Px();
780  fCandidateVariables[59] = casc->Py();
781  fCandidateVariables[60] = casc->Pz();
782  fCandidateVariables[61] = -9999.;
783  fCandidateVariables[62] = -9999.;
784  fCandidateVariables[63] = -9999.;
785  if(TMath::Abs(casc->MassLambda()-1.115683)<0.02){
786  fCandidateVariables[61] = casc->MomPosX();
787  fCandidateVariables[62] = casc->MomPosY();
788  fCandidateVariables[63] = casc->MomPosZ();
789  }else{
790  fCandidateVariables[61] = casc->MomNegX();
791  fCandidateVariables[62] = casc->MomNegY();
792  fCandidateVariables[63] = casc->MomNegZ();
793  }
794  fCandidateVariables[64] = 0; //xicobj->BachelorsCosPointingAngle();
795 
796  fCandidateVariables[77] = casc->DecayVertexV0X();
797  fCandidateVariables[78] = casc->DecayVertexV0Y();
798  fCandidateVariables[79] = casc->DecayVertexV0Z();
799  fCandidateVariables[80] = casc->DecayVertexXiX();
800  fCandidateVariables[81] = casc->DecayVertexXiY();
801  fCandidateVariables[82] = casc->DecayVertexXiZ();
802  fCandidateVariables[83] = xicobj->GetSecondaryVtx()->GetX();
803  fCandidateVariables[84] = xicobj->GetSecondaryVtx()->GetY();
804  fCandidateVariables[85] = xicobj->GetSecondaryVtx()->GetZ();
805  fCandidateVariables[86] = xicobj->InvMass(2,pdgdg)-casc->MassXi();
806 
807  fCandidateVariables[87] = part1->GetTPCClusterInfo(2,1);
808  AliAODTrack *ptrack = (AliAODTrack*) (casc->GetDaughter(0));
809  AliAODTrack *ntrack = (AliAODTrack*) (casc->GetDaughter(1));
810  AliAODTrack *btrack = (AliAODTrack*) (casc->GetDecayVertexXi()->GetDaughter(0));
811 
812  fCandidateVariables[88] = btrack->GetTPCClusterInfo(2,1);
813  fCandidateVariables[89] = ptrack->GetTPCClusterInfo(2,1);
814  fCandidateVariables[90] = ntrack->GetTPCClusterInfo(2,1);
815  }//close if to check the mc fill only signal
817  //this is commented at the moment because modifications to the AliAODRecoCascadeHF are needed.
818  //However, this part is not used for a first look with trees and it is useful only when first set of cuts is defined
819  /*
820  else {
821  if(fAnalCuts->IsSelected(xicobj,AliRDHFCuts::kCandidate))
822  {
823  Double_t cont[3];
824  cont[0] = xicobj->InvMass(2,pdgdg);
825  cont[1] = xicobj->Pt();
826  cont[2] = fCentrality;
827  fHistoXicMass->Fill(cont);
828 
829  //This is commented because the dca is not calculated at the moment.
830  fHistoDcaPiCasc->Fill(dca[0]);
831  fHistoDcaPiCasc->Fill(dca[1]);
832 
833  fHistoXiMass->Fill(casc->MassXi());
834  fHistoCascDcaXiDaughters->Fill(xicobj->CascDcaXiDaughters());
835  fHistoCascDcaV0Daughters->Fill(xicobj->CascDcaV0Daughters());
836  fHistoCascDcaV0ToPrimVertex->Fill(xicobj->CascDcaV0ToPrimVertex());
837  fHistoCascDcaPosToPrimVertex->Fill(xicobj->CascDcaPosToPrimVertex());
838  fHistoCascDcaNegToPrimVertex->Fill(xicobj->CascDcaNegToPrimVertex());
839  fHistoCascDcaBachToPrimVertex->Fill(xicobj->CascDcaBachToPrimVertex());
840  fHistoCascCosPAXiPrim->Fill(xicobj->CascCosPointingAngle());
841  fHistoXiPt->Fill(xicobj->PtProng(1));
842  fHistoPiPt->Fill(xicobj->PtProng(0));
843  fHistoPid0->Fill(xicobj->Getd0Prong(0));
844 
845  Double_t nSigmaTPCpi1=-9999.;
846  Double_t nSigmaTPCpi2=-9999.;
847  Double_t nSigmaTOFpi1=-9999.;
848  Double_t nSigmaTOFpi2=-9999.;
849  Double_t probPion1=-9999.;
850  Double_t probPion2=-9999.;
851 
852  if(fAnalCuts->GetIsUsePID())
853  {
854  nSigmaTPCpi1 = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTPC(part1,AliPID::kPion);
855  nSigmaTOFpi1 = fAnalCuts->GetPidHF()->GetPidResponse()->NumberOfSigmasTOF(part1,AliPID::kPion);
856 
857  if(fAnalCuts->GetPidHF()->GetUseCombined()){
858  probPion1 = fAnalCuts->GetPionProbabilityTPCTOF(part1);
859  }
860  }
861 
862  fHistonSigmaTPCpi->Fill(nSigmaTPCpi1);
863  fHistonSigmaTOFpi->Fill(nSigmaTOFpi1);
864  fHistoProbPion->Fill(probPion1);
865  }
866  }*/
867 
868 }
869 
870 //________________________________________________________________________
871 
873 {
874  //
875  // This is to define tree variables
876  //
877  const char* nameoutput = GetOutputSlot(3)->GetContainer()->GetName();
878  fVariablesTree = new TTree(nameoutput,"Candidates variables tree");
879  Int_t nVar = 91;
880  fCandidateVariables = new Float_t [nVar];
881  TString * fCandidateVariableNames = new TString[nVar];
882 
883  fCandidateVariableNames[ 0]="InvMassXic";
884  fCandidateVariableNames[ 1]="XicPx";
885  fCandidateVariableNames[ 2]="XicPy";
886  fCandidateVariableNames[ 3]="XicPz";
887  fCandidateVariableNames[ 4]="Pi1Px";
888  fCandidateVariableNames[ 5]="Pi1Py";
889  fCandidateVariableNames[ 6]="Pi1Pz";
890  fCandidateVariableNames[ 7]="Pi2Px";
891  fCandidateVariableNames[ 8]="Pi2Py";
892  fCandidateVariableNames[ 9]="Pi2Pz";
893  fCandidateVariableNames[10]="MassXi";
894  fCandidateVariableNames[11]="XiPx";
895  fCandidateVariableNames[12]="XiPy";
896  fCandidateVariableNames[13]="XiPz";
897  fCandidateVariableNames[14]="MassLambda";
898  fCandidateVariableNames[15]="MassAntiLambda";
899 
900  fCandidateVariableNames[16]="Centrality";
901  fCandidateVariableNames[17]="PrimVtxX";
902  fCandidateVariableNames[18]="PrimVtxY";
903  fCandidateVariableNames[19]="PrimVtxZ";
904  fCandidateVariableNames[20]="NewPrimVtxX";
905  fCandidateVariableNames[21]="NewPrimVtxY";
906  fCandidateVariableNames[22]="NewPrimVtxZ";
907 
908  fCandidateVariableNames[23]="CascDcaXiDaughters";
909  fCandidateVariableNames[24]="CascDcaV0Daughters";
910  fCandidateVariableNames[25]="CascDecayLengthXi";
911  fCandidateVariableNames[26]="CascCosPointingAngleXi";
912  fCandidateVariableNames[27]="CascDcaV0ToPrimVertex";
913  fCandidateVariableNames[28]="CascDcaPosToPrimVertex";
914  fCandidateVariableNames[29]="CascDcaNegToPrimVertex";
915  fCandidateVariableNames[30]="CascDcaBachToPrimVertex";
916  fCandidateVariableNames[31]="CascDecayLengthV0";
917  fCandidateVariableNames[32]="CascCosPointingAngleV0";
918 
919  fCandidateVariableNames[33]="DcaPi1Casc";
920  fCandidateVariableNames[34]="DcaPi2Casc";
921  fCandidateVariableNames[35]="DcaPi1Pi2";
922 
923  fCandidateVariableNames[36]="Pi1d0";
924  fCandidateVariableNames[37]="Pi2d0";
925  fCandidateVariableNames[38]="Cascd0";
926 
927  fCandidateVariableNames[39]="DecayLength";
928  fCandidateVariableNames[40]="DecayLengthXY";
929  fCandidateVariableNames[41]="XicCosPAXY";
930 
931  fCandidateVariableNames[42]="nSigmaTPCpi1";
932  fCandidateVariableNames[43]="nSigmaTPCpi2";
933  fCandidateVariableNames[44]="nSigmaTOFpi1";
934  fCandidateVariableNames[45]="nSigmaTOFpi2";
935  fCandidateVariableNames[46]="probPion1";
936  fCandidateVariableNames[47]="probPion2";
937 
938  fCandidateVariableNames[48]="mcxicID";
939  fCandidateVariableNames[49]="mcnused";
940  fCandidateVariableNames[50]="mcpdgcode";
941  fCandidateVariableNames[51]="mcdecaylength";
942  fCandidateVariableNames[52]="mcdecaylength_secsmear";
943  fCandidateVariableNames[53]="mcxiccospaxy";
944  fCandidateVariableNames[54]="mcxicpt";
945  fCandidateVariableNames[55]="mcpi1pt";
946  fCandidateVariableNames[56]="mcpi2pt";
947  fCandidateVariableNames[57]="mcxipt";
948 
949  fCandidateVariableNames[58]="LambdaPx";
950  fCandidateVariableNames[59]="LambdaPy";
951  fCandidateVariableNames[60]="LambdaPz";
952  fCandidateVariableNames[61]="ProtonPx";
953  fCandidateVariableNames[62]="ProtonPy";
954  fCandidateVariableNames[63]="ProtonPz";
955  fCandidateVariableNames[64]="BachelorsCosPAXY";
956 
957  fCandidateVariableNames[65]="mcxicpx";
958  fCandidateVariableNames[66]="mcxicpy";
959  fCandidateVariableNames[67]="mcxicpz";
960  fCandidateVariableNames[68]="mcpi1px";
961  fCandidateVariableNames[69]="mcpi1py";
962  fCandidateVariableNames[70]="mcpi1pz";
963  fCandidateVariableNames[71]="mcpi2px";
964  fCandidateVariableNames[72]="mcpi2py";
965  fCandidateVariableNames[73]="mcpi2pz";
966  fCandidateVariableNames[74]="mcxipx";
967  fCandidateVariableNames[75]="mcxipy";
968  fCandidateVariableNames[76]="mcxipz";
969 
970  fCandidateVariableNames[77]="LambdaVertX";
971  fCandidateVariableNames[78]="LambdaVertY";
972  fCandidateVariableNames[79]="LambdaVertZ";
973  fCandidateVariableNames[80]="XiVertX";
974  fCandidateVariableNames[81]="XiVertY";
975  fCandidateVariableNames[82]="XiVertZ";
976  fCandidateVariableNames[83]="XicVertX";
977  fCandidateVariableNames[84]="XicVertY";
978  fCandidateVariableNames[85]="XicVertZ";
979  fCandidateVariableNames[86]="DeltaMass";
980 
981  fCandidateVariableNames[87]="TPCClsP1";
982  fCandidateVariableNames[88]="TPCClsCascBach";
983  fCandidateVariableNames[89]="TPCClsV0trkPos";
984  fCandidateVariableNames[90]="TPCClsV0trkNeg";
985 
986  for (Int_t ivar=0; ivar<nVar; ivar++) {
987  fVariablesTree->Branch(fCandidateVariableNames[ivar].Data(),&fCandidateVariables[ivar],Form("%s/f",fCandidateVariableNames[ivar].Data()));
988  }
989 
990  return;
991 }
992 //__________________________________________________________________________
994  //
995  // This is to define general histograms
996  //
997 
998  fCEvents = new TH1F("fCEvents","counter",18,-0.5,17.5);
999  fCEvents->SetStats(kTRUE);
1000  fCEvents->GetXaxis()->SetBinLabel(1,"X1");
1001  fCEvents->GetXaxis()->SetBinLabel(2,"Analyzed events");
1002  fCEvents->GetXaxis()->SetBinLabel(3,"AliAODVertex exists");
1003  fCEvents->GetXaxis()->SetBinLabel(4,"TriggerOK");
1004  fCEvents->GetXaxis()->SetBinLabel(5,"IsEventSelected");
1005  fCEvents->GetXaxis()->SetBinLabel(6,"CascadesHF exists");
1006  fCEvents->GetXaxis()->SetBinLabel(7,"MCarray exists");
1007  fCEvents->GetXaxis()->SetBinLabel(8,"MCheader exists");
1008  fCEvents->GetXaxis()->SetBinLabel(9,"triggerClass!=CINT1");
1009  fCEvents->GetXaxis()->SetBinLabel(10,"triggerMask!=kAnyINT");
1010  fCEvents->GetXaxis()->SetBinLabel(11,"triggerMask!=kAny");
1011  fCEvents->GetXaxis()->SetBinLabel(12,"vtxTitle.Contains(Z)");
1012  fCEvents->GetXaxis()->SetBinLabel(13,"vtxTitle.Contains(3D)");
1013  fCEvents->GetXaxis()->SetBinLabel(14,"vtxTitle.Doesn'tContain(Z-3D)");
1014  fCEvents->GetXaxis()->SetBinLabel(15,Form("zVtx<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
1015  fCEvents->GetXaxis()->SetBinLabel(16,"!IsEventSelected");
1016  fCEvents->GetXaxis()->SetBinLabel(17,"triggerMask!=kAnyINT || triggerClass!=CINT1");
1017  fCEvents->GetXaxis()->SetBinLabel(18,Form("zVtxMC<=%2.0fcm",fAnalCuts->GetMaxVtxZ()));
1018  //fCEvents->GetXaxis()->SetTitle("");
1019  fCEvents->GetYaxis()->SetTitle("counts");
1020 
1021  fHTrigger = new TH1F("fHTrigger","counter",18,-0.5,17.5);
1022  fHTrigger->SetStats(kTRUE);
1023  fHTrigger->GetXaxis()->SetBinLabel(1,"X1");
1024  fHTrigger->GetXaxis()->SetBinLabel(2,"kMB");
1025  fHTrigger->GetXaxis()->SetBinLabel(3,"kSemiCentral");
1026  fHTrigger->GetXaxis()->SetBinLabel(4,"kCentral");
1027  fHTrigger->GetXaxis()->SetBinLabel(5,"kINT7");
1028  fHTrigger->GetXaxis()->SetBinLabel(6,"kEMC7");
1029  //fHTrigger->GetXaxis()->SetBinLabel(7,"Space");
1030  fHTrigger->GetXaxis()->SetBinLabel(8,"kMB|kSemiCentral|kCentral");
1031  fHTrigger->GetXaxis()->SetBinLabel(9,"kINT7|kEMC7");
1032  fHTrigger->GetXaxis()->SetBinLabel(11,"kMB&kSemiCentral");
1033  fHTrigger->GetXaxis()->SetBinLabel(12,"kMB&kCentral");
1034  fHTrigger->GetXaxis()->SetBinLabel(13,"kINT7&kEMC7");
1035 
1036  fHCentrality = new TH1F("fHCentrality","counter",100,0.,100.);
1037 
1038  fHSelectedCascadePerEv = new TH1F("fHSelectedCascadePerEv", "fHSelectedCascadePerEv", 50, 0, 50.);
1039 
1040  fHSelectedTracksPerEv = new TH1F("fHSelectedTracksPerEv", "fHSelectedTracksPerEv", 100, 0, 100.);
1041 
1042 
1043  Double_t binx[101];
1044  for(Int_t ib=0;ib<101;ib++){
1045  binx[ib] = 1.322-0.05 + 0.1/100.*(Double_t)ib ;
1046  }
1047  Double_t biny[21]={0.0,0.60,0.80,0.90,1.00,1.1,1.2,1.3,1.4,1.5,1.7,1.9,2.2,2.6,3.1,3.9,4.9,6.0,7.2,8.5,10.};
1048  fHistoXiMassvsPtRef = new TH2F("fHistoXiMassvsPtRef","Reference #Xi spectrum",100,binx,20,biny);
1049  fHistoXiMassvsPtRef2 = new TH2F("fHistoXiMassvsPtRef2","Reference #Xi spectrum",100,binx,20,biny);
1050  fHistoXiMassvsPtRef3 = new TH2F("fHistoXiMassvsPtRef3","Reference #Xi spectrum",100,binx,20,biny);
1051  fHistoXiMassvsPtRef4 = new TH2F("fHistoXiMassvsPtRef4","Reference #Xi spectrum",100,binx,20,biny);
1052  fHistoXiMassvsPtRef5 = new TH2F("fHistoXiMassvsPtRef5","Reference #Xi spectrum",100,binx,20,biny);
1053  fHistoXiMassvsPtRef6 = new TH2F("fHistoXiMassvsPtRef6","Reference #Xi spectrum",100,binx,20,biny);
1054  fHistoPiPtRef = new TH1F("fHistoPiPtRef","Reference #pi spectrum",20,0.,10.);
1055 
1056  fOutput->Add(fCEvents);
1057  fOutput->Add(fHTrigger);
1058  fOutput->Add(fHCentrality);
1067  fOutput->Add(fHistoPiPtRef);
1068 
1069  return;
1070 }
1071 
1072 //__________________________________________________________________________
1073 /*
1074  void AliAnalysisTaskSEXicZero2XiPifromAODtracks::DefineAnalysisHistograms()
1075  {
1076  //
1077  // Define histograms
1078  //
1079 
1080  //------------------------------------------------
1081  // Basic histograms
1082  //------------------------------------------------
1083  Int_t bins_base[3]= {80 ,20 ,10};
1084  Double_t xmin_base[3]={2.468-0.2,0 ,0.00};
1085  Double_t xmax_base[3]={2.468+0.2,20. ,100};
1086  fHistoXicMass = new THnSparseF("fHistoXicMass","",3,bins_base,xmin_base,xmax_base);
1087  fOutputAll->Add(fHistoXicMass);
1088 
1089  //------------------------------------------------
1090  // Checking histograms
1091  //------------------------------------------------
1092  fHistoDcaPi1Pi2 = new TH1F("fHistoDcaPi1Pi2","DCA (#pi_{1}-#pi_{2})",100,0.0,1.0);
1093  fOutputAll->Add(fHistoDcaPi1Pi2);
1094  fHistoDcaPiCasc = new TH1F("fHistoDcaPiCasc","DCA (#pi-#Xi)",100,0.0,1.0);
1095  fOutputAll->Add(fHistoDcaPiCasc);
1096  fHistoLikeDecayLength = new TH1F("fHistoLikeDecayLength","Decay Length (#pi-#pi)",100,0.,0.2);
1097  fOutputAll->Add(fHistoLikeDecayLength);
1098  fHistoLikeDecayLengthXY = new TH1F("fHistoLikeDecayLengthXY","Decay Length (#pi-#pi)",100,0.,0.2);
1099  fOutputAll->Add(fHistoLikeDecayLengthXY);
1100  fHistoXicCosPAXY = new TH1F("fHistoXicCosPAXY","#Xi_{c} cos(pa) ",100,-1.0,1.0);
1101  fOutputAll->Add(fHistoXicCosPAXY);
1102  fHistoXiMass=new TH1F("fHistoXiMass","#Xi^{-} Mass",100,1.322-0.05,1.322+0.05);
1103  fOutputAll->Add(fHistoXiMass);
1104  fHistoCascDcaXiDaughters=new TH1F("fHistoCascDcaXiDaughters","DCA #Xi daughters ",100,0.0,1.0);
1105  fOutputAll->Add(fHistoCascDcaXiDaughters);
1106  fHistoCascDcaV0Daughters=new TH1F("fHistoCascDcaV0Daughters","DCA #Xi daughters ",100,0.0,1.0);
1107  fOutputAll->Add(fHistoCascDcaV0Daughters);
1108  fHistoCascDcaV0ToPrimVertex=new TH1F("fHistoCascDcaV0ToPrimVertex","DCA V0 daughters ",100,0.0,1.0);
1109  fOutputAll->Add(fHistoCascDcaV0ToPrimVertex);
1110  fHistoCascDcaPosToPrimVertex=new TH1F("fHistoCascDcaPosToPrimVertex","DCA Pos-Prim ",100,0.0,1.0);
1111  fOutputAll->Add(fHistoCascDcaPosToPrimVertex);
1112  fHistoCascDcaNegToPrimVertex=new TH1F("fHistoCascDcaNegToPrimVertex","DCA Neg-Prim ",100,0.0,1.0);
1113  fOutputAll->Add(fHistoCascDcaNegToPrimVertex);
1114  fHistoCascDcaBachToPrimVertex=new TH1F("fHistoCascDcaBachToPrimVertex","DCA Bach-Prim ",100,0.0,1.0);
1115  fOutputAll->Add(fHistoCascDcaBachToPrimVertex);
1116  fHistoCascCosPAXiPrim=new TH1F("fHistoCascCosPAXiPrim","#Xi CosPA (prim)",100,0.8,1.0);
1117  fOutputAll->Add(fHistoCascCosPAXiPrim);
1118  fHistoXiPt=new TH1F("fHistoXiPt","#Xi^{-} p_{T}",100,0.,10.);
1119  fOutputAll->Add(fHistoXiPt);
1120  fHistoPiPt=new TH1F("fHistoPiPt","#pi p_{T}",100,0.,10);
1121  fOutputAll->Add(fHistoPiPt);
1122  fHistoPid0=new TH1F("fHistoPid0","#pi d_{0}",100,-0.1,0.1);
1123  fOutputAll->Add(fHistoPid0);
1124  fHistonSigmaTPCpi=new TH1F("fHistonSigmaTPCpi","n#sigma (TPC, pion)",100,-10.,10.);
1125  fOutputAll->Add(fHistonSigmaTPCpi);
1126  fHistonSigmaTOFpi=new TH1F("fHistonSigmaTOFpi","n#sigma (TOF, pion)",100,-10.,10.);
1127  fOutputAll->Add(fHistonSigmaTOFpi);
1128  fHistoProbPion=new TH1F("fHistoProbPion","Bayse Prob",100,0.0,1.);
1129  fOutputAll->Add(fHistoProbPion);
1130 
1131  return;
1132  }
1133 */
1134 //________________________________________________________________________
1135 void AliAnalysisTaskSEXicZero2XiPifromAODtracks::SelectTrack( const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks,Bool_t *seleFlags)
1136 {
1137  //
1138  // Select good tracks using fAnalCuts (AliRDHFCuts object) and return the array of their ids
1139  //
1140 
1141  //const Int_t entries = event->GetNumberOfTracks();
1142  if(trkEntries==0) return;
1143 
1144  nSeleTrks=0;
1145  for(Int_t i=0; i<trkEntries; i++) {
1146  seleFlags[i] = kFALSE;
1147 
1148  AliVTrack *track;
1149  track = (AliVTrack*)event->GetTrack(i);
1150 
1151  if(track->GetID()<0) continue;
1152  Double_t covtest[21];
1153  if(!track->GetCovarianceXYZPxPyPz(covtest)) continue;
1154 
1155  AliAODTrack *aodt = (AliAODTrack*)track;
1156 
1157  if(!fAnalCuts) continue;
1158  if(fAnalCuts->SingleTrkCuts(aodt)){
1159  seleFlags[i]=kTRUE;
1160  nSeleTrks++;
1161  fHistoPiPtRef->Fill(aodt->Pt());
1162  }
1163  } // end loop on tracks
1164 }
1165 
1166 //________________________________________________________________________
1167 void AliAnalysisTaskSEXicZero2XiPifromAODtracks::SelectCascade( const AliVEvent *event,Int_t nCascades,Int_t &nSeleCasc, Bool_t *seleCascFlags)
1168 {
1169  //
1170  // Select good cascade using fAnalCuts (AliRDHFCuts object) and return the array of their ids
1171  //
1172 
1173  Double_t primVtx[3];
1174  fVtx1->GetXYZ(primVtx);
1175 
1176  nSeleCasc = 0;
1177  for(Int_t icasc=0;icasc<nCascades;icasc++)
1178  {
1179  seleCascFlags[icasc] = kFALSE;
1180  AliAODcascade *casc = ((AliAODEvent*)event)->GetCascade(icasc);
1181 
1182  if(!fAnalCuts) continue;
1183  if(fAnalCuts->SingleCascadeCuts(casc,primVtx)){
1184  seleCascFlags[icasc] = kTRUE;
1185  nSeleCasc++;
1186  }
1187  if(fAnalCuts->SingleCascadeCutsRef(casc,primVtx))
1188  {
1189  Double_t rapxi = casc->RapXi();
1190  if(rapxi>-1.5&&rapxi<-1.0){
1191  fHistoXiMassvsPtRef2->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1192  }
1193  if(rapxi>-1.0&&rapxi<-0.5){
1194  fHistoXiMassvsPtRef3->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1195  }
1196  if(rapxi>-0.5&&rapxi<0.0){
1197  fHistoXiMassvsPtRef->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1198  }
1199  if(rapxi>0.0&&rapxi<0.5){
1200  fHistoXiMassvsPtRef4->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1201  }
1202  if(rapxi>0.5&&rapxi<1.0){
1203  fHistoXiMassvsPtRef5->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1204  }
1205  if(rapxi>1.0&&rapxi<1.5){
1206  fHistoXiMassvsPtRef6->Fill(casc->MassXi(),sqrt(pow(casc->MomXiX(),2)+pow(casc->MomXiY(),2)));
1207  }
1208  }
1209  }
1210 }
1211 
1212 //________________________________________________________________________
1213 //________________________________________________________________________
1214 AliAODRecoCascadeHF* AliAnalysisTaskSEXicZero2XiPifromAODtracks::MakeCascadeHF(AliAODcascade *casc, AliAODTrack *part, AliAODEvent * aod, AliAODVertex *secVert)
1215 {
1216  //
1217  // Create AliAODRecoCascadeHF object from the argument
1218  //
1219 
1220  if(!casc) return 0x0;
1221  if(!part) return 0x0;
1222  if(!aod) return 0x0;
1223 
1224  //------------------------------------------------
1225  // PrimaryVertex
1226  //------------------------------------------------
1227  AliAODVertex *primVertexAOD;
1228  Bool_t unsetvtx = kFALSE;
1230  primVertexAOD = CallPrimaryVertex(casc,part,aod);
1231  if(!primVertexAOD){
1232  primVertexAOD = fVtx1;
1233  }else{
1234  unsetvtx = kTRUE;
1235  }
1236  }else{
1237  primVertexAOD = fVtx1;
1238  }
1239  if(!primVertexAOD) return 0x0;
1240  Double_t posprim[3]; primVertexAOD->GetXYZ(posprim);
1241 
1242  //------------------------------------------------
1243  // DCA between tracks
1244  //------------------------------------------------
1245  AliESDtrack *esdtrack = new AliESDtrack((AliVTrack*)part);
1246 
1247  Double_t xyz[3], pxpypz[3], cv[21]; Short_t sign;
1248  xyz[0]=casc->DecayVertexXiX();
1249  xyz[1]=casc->DecayVertexXiY();
1250  xyz[2]=casc->DecayVertexXiZ();
1251  pxpypz[0]=casc->MomXiX();
1252  pxpypz[1]=casc->MomXiY();
1253  pxpypz[2]=casc->MomXiZ();
1254  casc->GetCovarianceXYZPxPyPz(cv);
1255  sign=casc->ChargeXi();
1256  AliExternalTrackParam *trackCasc = new AliExternalTrackParam(xyz,pxpypz,cv,sign);
1257 
1258  Double_t xdummy, ydummy;
1259  Double_t dca = esdtrack->GetDCA(trackCasc,fBzkG,xdummy,ydummy);
1260 
1261 
1262  //------------------------------------------------
1263  // Propagate all tracks to the secondary vertex and calculate momentum there
1264  //------------------------------------------------
1265 
1266  Double_t d0z0bach[2],covd0z0bach[3];
1267  if(sqrt(pow(secVert->GetX(),2)+pow(secVert->GetY(),2))<1.){
1268  part->PropagateToDCA(secVert,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
1269  trackCasc->PropagateToDCA(secVert,fBzkG,kVeryBig);
1270  }else{
1271  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
1272  trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig);
1273  }
1274  Double_t momcasc_new[3]={-9999,-9999,-9999.};
1275  trackCasc->GetPxPyPz(momcasc_new);
1276 
1277  Double_t px[2],py[2],pz[2];
1278  px[0] = part->Px(); py[0] = part->Py(); pz[0] = part->Pz();
1279  px[1] = momcasc_new[0]; py[1] = momcasc_new[1]; pz[1] = momcasc_new[2];
1280 
1281  //------------------------------------------------
1282  // d0
1283  //------------------------------------------------
1284  Double_t d0[2],d0err[2];
1285 
1286  part->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0bach,covd0z0bach);
1287  d0[0]= d0z0bach[0];
1288  d0err[0] = TMath::Sqrt(covd0z0bach[0]);
1289 
1290  Double_t d0z0casc[2],covd0z0casc[3];
1291  trackCasc->PropagateToDCA(primVertexAOD,fBzkG,kVeryBig,d0z0casc,covd0z0casc);
1292  d0[1]= d0z0casc[0];
1293  d0err[1] = TMath::Sqrt(covd0z0casc[0]);
1294 
1295  //------------------------------------------------
1296  // Create AliAODRecoCascadeHF
1297  //------------------------------------------------
1298  Short_t charge = part->Charge()+trackCasc->Charge(); //ho aggiunto al carica del cascade... e'corretto?
1299  AliAODRecoCascadeHF *theCascade = new AliAODRecoCascadeHF(secVert,charge,px,py,pz,d0,d0err,dca);
1300  if(!theCascade)
1301  {
1302  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
1303  if(esdtrack) delete esdtrack;
1304  if(trackCasc) delete trackCasc;
1305  return 0x0;
1306  }
1307  theCascade->SetOwnPrimaryVtx(primVertexAOD);
1308  UShort_t id[2]={(UShort_t)part->GetID(),(UShort_t)trackCasc->GetID()};
1309  theCascade->SetProngIDs(2,id);
1310 
1311  theCascade->GetSecondaryVtx()->AddDaughter(part);
1312  theCascade->GetSecondaryVtx()->AddDaughter(casc);
1313  if(unsetvtx) delete primVertexAOD; primVertexAOD=NULL;
1314  if(esdtrack) delete esdtrack;
1315  if(trackCasc) delete trackCasc;
1316 
1317  return theCascade;
1318 }
1319 
1320 //________________________________________________________________________
1321 AliAODVertex* AliAnalysisTaskSEXicZero2XiPifromAODtracks::CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent* aod)
1322 {
1323  //
1324  // Make an array of tracks which should not be used in primary vertex calculation and
1325  // Call PrimaryVertex function
1326  //
1327 
1328  TObjArray *TrackArray = new TObjArray(3);
1329 
1330  AliESDtrack *cptrk1 = new AliESDtrack((AliVTrack*)trk);
1331  TrackArray->AddAt(cptrk1,0);
1332 
1333  AliESDtrack *cascptrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(0));
1334  TrackArray->AddAt(cascptrack,1);
1335  AliESDtrack *cascntrack = new AliESDtrack((AliVTrack*)casc->GetDaughter(1));
1336  TrackArray->AddAt(cascntrack,2);
1337  AliESDtrack *cascbtrack = new AliESDtrack((AliVTrack*)casc->GetDecayVertexXi()->GetDaughter(0));
1338  TrackArray->AddAt(cascbtrack,3);
1339 
1340  AliAODVertex *newvert = PrimaryVertex(TrackArray,aod);
1341 
1342  for(Int_t i=0;i<4;i++)
1343  {
1344  AliESDtrack *tesd = (AliESDtrack*)TrackArray->UncheckedAt(i);
1345  delete tesd;
1346  }
1347  TrackArray->Clear();
1348  delete TrackArray;
1349 
1350  return newvert;
1351 }
1352 
1353 //________________________________________________________________________
1355  AliVEvent *event)
1356 {
1357  //
1358  //Used only for pp
1359  //copied from AliAnalysisVertexingHF (except for the following 3 lines)
1360  //
1361 
1362  Bool_t fRecoPrimVtxSkippingTrks = kTRUE;
1363  Bool_t fRmTrksFromPrimVtx = kFALSE;
1364 
1365  AliESDVertex *vertexESD = 0;
1366  AliAODVertex *vertexAOD = 0;
1367 
1368  //vertexESD = new AliESDVertex(*fV1);
1369 
1370 
1371  if(!fRecoPrimVtxSkippingTrks && !fRmTrksFromPrimVtx) {
1372  // primary vertex from the input event
1373 
1374  vertexESD = new AliESDVertex(*fV1);
1375 
1376  } else {
1377  // primary vertex specific to this candidate
1378 
1379  Int_t nTrks = trkArray->GetEntriesFast();
1380  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1381 
1382  if(fRecoPrimVtxSkippingTrks) {
1383  // recalculating the vertex
1384 
1385  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraint")) {
1386  Float_t diamondcovxy[3];
1387  event->GetDiamondCovXY(diamondcovxy);
1388  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1389  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
1390  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1391  vertexer->SetVtxStart(diamond);
1392  delete diamond; diamond=NULL;
1393  if(strstr(fV1->GetTitle(),"VertexerTracksWithConstraintOnlyFitter"))
1394  vertexer->SetOnlyFitter();
1395  }
1396  Int_t skipped[1000];
1397  Int_t nTrksToSkip=0,id;
1398  AliExternalTrackParam *t = 0;
1399  for(Int_t i=0; i<nTrks; i++) {
1400  t = (AliExternalTrackParam*)trkArray->UncheckedAt(i);
1401  id = (Int_t)t->GetID();
1402  if(id<0) continue;
1403  skipped[nTrksToSkip++] = id;
1404  }
1405  // TEMPORARY FIX
1406  // For AOD, skip also tracks without covariance matrix
1407  Double_t covtest[21];
1408  for(Int_t j=0; j<event->GetNumberOfTracks(); j++) {
1409  AliVTrack *vtrack = (AliVTrack*)event->GetTrack(j);
1410  if(!vtrack->GetCovarianceXYZPxPyPz(covtest)) {
1411  id = (Int_t)vtrack->GetID();
1412  if(id<0) continue;
1413  skipped[nTrksToSkip++] = id;
1414  }
1415  }
1416  for(Int_t ijk=nTrksToSkip; ijk<1000; ijk++) skipped[ijk]=-1;
1417  //
1418  vertexer->SetSkipTracks(nTrksToSkip,skipped);
1419  vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1420 
1421  } else if(fRmTrksFromPrimVtx && nTrks>0) {
1422  // removing the prongs tracks
1423 
1424  TObjArray rmArray(nTrks);
1425  UShort_t *rmId = new UShort_t[nTrks];
1426  AliESDtrack *esdTrack = 0;
1427  AliESDtrack *t = 0;
1428  for(Int_t i=0; i<nTrks; i++) {
1429  t = (AliESDtrack*)trkArray->UncheckedAt(i);
1430  esdTrack = new AliESDtrack(*t);
1431  rmArray.AddLast(esdTrack);
1432  if(esdTrack->GetID()>=0) {
1433  rmId[i]=(UShort_t)esdTrack->GetID();
1434  } else {
1435  rmId[i]=9999;
1436  }
1437  }
1438  Float_t diamondxy[2]={static_cast<Float_t>(event->GetDiamondX()),static_cast<Float_t>(event->GetDiamondY())};
1439  vertexESD = vertexer->RemoveTracksFromVertex(fV1,&rmArray,rmId,diamondxy);
1440  delete [] rmId; rmId=NULL;
1441  rmArray.Delete();
1442 
1443  }
1444 
1445  delete vertexer; vertexer=NULL;
1446  if(!vertexESD) return vertexAOD;
1447  if(vertexESD->GetNContributors()<=0) {
1448  //AliDebug(2,"vertexing failed");
1449  delete vertexESD; vertexESD=NULL;
1450  return vertexAOD;
1451  }
1452 
1453 
1454  }
1455 
1456  // convert to AliAODVertex
1457  Double_t pos[3],cov[6],chi2perNDF;
1458  vertexESD->GetXYZ(pos); // position
1459  vertexESD->GetCovMatrix(cov); //covariance matrix
1460  chi2perNDF = vertexESD->GetChi2toNDF();
1461  delete vertexESD; vertexESD=NULL;
1462 
1463  vertexAOD = new AliAODVertex(pos,cov,chi2perNDF);
1464 
1465  return vertexAOD;
1466 }
1467 
1468 //________________________________________________________________________
1469 AliAODVertex* AliAnalysisTaskSEXicZero2XiPifromAODtracks::ReconstructSecondaryVertex(AliAODcascade *casc, AliAODTrack *part, AliAODEvent * aod)
1470 {
1471  //
1472  // Reconstruct secondary vertex from trkArray (Copied from AliAnalysisVertexingHF)
1473  //
1474 
1475  AliAODVertex *primVertexAOD;
1476  Bool_t unsetvtx = kFALSE;
1478  primVertexAOD = CallPrimaryVertex(casc,part,aod);
1479  if(!primVertexAOD){
1480  primVertexAOD = fVtx1;
1481  }else{
1482  unsetvtx = kTRUE;
1483  }
1484  }else{
1485  primVertexAOD = fVtx1;
1486  }
1487  if(!primVertexAOD) return 0x0;
1488 
1489  AliESDVertex * vertexESD = new AliESDVertex(*fV1);
1490 
1491  Double_t pos[3],cov[6],chi2perNDF;
1492  vertexESD->GetXYZ(pos); // position
1493  vertexESD->GetCovMatrix(cov); //covariance matrix
1494  chi2perNDF = vertexESD->GetChi2toNDF();
1495  delete vertexESD; vertexESD=NULL;
1496 
1497  AliAODVertex *secVert = new AliAODVertex(pos,cov,chi2perNDF);
1498 
1499  return secVert;
1500 }
1501 //________________________________________________________________________
1502 Int_t AliAnalysisTaskSEXicZero2XiPifromAODtracks::MatchtoMC(AliAODRecoCascadeHF *exobj, Int_t pdgabs, Int_t pdgabscasc, Int_t *pdgDg,Int_t *pdgDgcasc,Int_t *pdgDgv0, TClonesArray *mcArray)
1503 {
1504  AliAODcascade *theCascade = dynamic_cast<AliAODcascade*>(exobj->GetCascade());
1505  if(!theCascade) return -1;
1506 
1507  AliAODTrack *trk = dynamic_cast<AliAODTrack*>(exobj->GetBachelor()); // the bachelor
1508  if (!trk) return -1;
1509 
1510  Int_t labcasc = MatchToMCCascade(theCascade,pdgabscasc,pdgDgcasc,pdgDgv0,mcArray);
1511 
1512  if(labcasc<0) return -1;
1513  Int_t labtrk = trk->GetLabel();
1514  if(labtrk<0) return -1;
1515 
1516  Int_t dgLabels[10]={0,0,0,0,0,0,0,0,0,0};
1517 
1518  dgLabels[0] = labtrk;
1519  dgLabels[1] = labcasc;
1520 
1521  Int_t finalLabel = MatchToMCXicZero(pdgabs,mcArray,dgLabels,2,2,pdgDg);
1522  return finalLabel;
1523 }
1524 //________________________________________________________________________
1525 Int_t AliAnalysisTaskSEXicZero2XiPifromAODtracks::MatchToMCCascade(AliAODcascade *theCascade, Int_t pdgabscasc, Int_t *pdgDgcasc, Int_t *pdgDgv0, TClonesArray *mcArray) // the cascade
1526 {
1527  AliAODTrack *cptrack = (AliAODTrack*) theCascade->GetDaughter(0);
1528  if(!cptrack) return -1;
1529  Int_t label_p = cptrack->GetLabel();
1530  if(label_p<0) return -1;
1531  AliAODTrack *cntrack = (AliAODTrack*) theCascade->GetDaughter(1);
1532  if(!cntrack) return -1;
1533  Int_t label_n = cntrack->GetLabel();
1534  if(label_n<0) return -1;
1535  Int_t labv0 = theCascade->MatchToMC(pdgDgcasc[1],mcArray,2,pdgDgv0);
1536  if(labv0<0) return -1;
1537  AliAODMCParticle *mcpartv0= (AliAODMCParticle*) mcArray->At(labv0);
1538 
1539  AliAODTrack *cbtrack = (AliAODTrack*) theCascade->GetDecayVertexXi()->GetDaughter(0);
1540  if(!cbtrack) return -1;
1541 
1542  Int_t label_b = cbtrack->GetLabel();
1543  if(label_b<0) return -1;
1544 
1545  AliAODMCParticle *mcpartb= (AliAODMCParticle*) mcArray->At(label_b);
1546  Int_t pdgb = TMath::Abs(mcpartb->GetPdgCode());
1547  if(pdgb!=pdgDgcasc[0]) return -1;
1548 
1549  AliAODMCParticle *mcmotherv0=mcpartv0;
1550  Bool_t isFromXiv0 = kFALSE;
1551  Int_t labxiv0 = mcmotherv0->GetMother();
1552  if(labxiv0<0) return -1;
1553  mcmotherv0 = (AliAODMCParticle*) mcArray->At(labxiv0);
1554  if(mcmotherv0){
1555  Int_t pdg = TMath::Abs(mcmotherv0 ->GetPdgCode());
1556  if(pdg==pdgabscasc){
1557  isFromXiv0 = kTRUE;
1558  }
1559  }
1560  if(!isFromXiv0) return -1;
1561 
1562  AliAODMCParticle *mcmotherb=mcpartb;
1563  Bool_t isFromXib = kFALSE;
1564  Int_t labxib = mcmotherb->GetMother();
1565  if(labxib<0) return -1;
1566  mcmotherb = (AliAODMCParticle*) mcArray->At(labxib);
1567  if(mcmotherb){
1568  Int_t pdg = TMath::Abs(mcmotherb ->GetPdgCode());
1569  if(pdg==pdgabscasc){
1570  isFromXib = kTRUE;
1571  }
1572  }
1573  if(!isFromXib) return -1;
1574 
1575  if(labxiv0!=labxib) return -1;//Bachelor and V0 should come from the same Xi
1576 
1577  return labxib;
1578 }
1579 //----------------------------------------------------------------------------
1581  Int_t dgLabels[10],Int_t ndg,
1582  Int_t ndgCk, const Int_t *pdgDg)
1583 {
1590 
1591  Int_t labMom[10]={0,0,0,0,0,0,0,0,0,0};
1592  Int_t i,j,lab,labMother,pdgMother,pdgPart;
1593  AliAODMCParticle *part=0;
1594  AliAODMCParticle *mother=0;
1595  Bool_t pdgUsed[10]={kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE,kFALSE};
1596 
1597  // loop on daughter labels
1598  for(i=0; i<ndg; i++) {
1599  labMom[i]=-1;
1600  lab = TMath::Abs(dgLabels[i]);
1601  if(lab<0) {
1602  printf("daughter with negative label %d\n",lab);
1603  return -1;
1604  }
1605  part = (AliAODMCParticle*)mcArray->At(lab);
1606  if(!part) {
1607  printf("no MC particle\n");
1608  return -1;
1609  }
1610 
1611  // check the PDG of the daughter, if requested
1612  if(ndgCk>0) {
1613  pdgPart=TMath::Abs(part->GetPdgCode());
1614  for(j=0; j<ndg; j++) {
1615  if(!pdgUsed[j] && pdgPart==pdgDg[j]) {
1616  pdgUsed[j]=kTRUE;
1617  break;
1618  }
1619  }
1620  }
1621 
1622  mother = part;
1623  while(mother->GetMother()>=0) {
1624  labMother=mother->GetMother();
1625  mother = (AliAODMCParticle*)mcArray->At(labMother);
1626  if(!mother) {
1627  printf("no MC mother particle\n");
1628  break;
1629  }
1630  pdgMother = TMath::Abs(mother->GetPdgCode());
1631  if(pdgMother==pdgabs) {
1632  labMom[i]=labMother;
1633  break;
1634  } else if(pdgMother>pdgabs || pdgMother<10) {
1635  break;
1636  }
1637  }
1638  if(labMom[i]==-1) return -1; // mother PDG not ok for this daughter
1639  } // end loop on daughters
1640 
1641  // check if the candidate is signal
1642  labMother=labMom[0];
1643  // all labels have to be the same and !=-1
1644  for(i=0; i<ndg; i++) {
1645  if(labMom[i]==-1) return -1;
1646  if(labMom[i]!=labMother) return -1;
1647  }
1648 
1649  // check that all daughter PDGs are matched
1650  if(ndgCk>0) {
1651  for(i=0; i<ndg; i++) {
1652  if(pdgUsed[i]==kFALSE) return -1;
1653  }
1654  }
1655 
1656  return labMother;
1657 }
Int_t charge
Int_t MatchToMCCascade(AliAODcascade *theCascade, Int_t pdgabscasc, Int_t *pdgDgcasc, Int_t *pdgDgv0, TClonesArray *mcArray)
Int_t pdg
double Double_t
Definition: External.C:58
Definition: External.C:236
AliRDHFCutsXicZerotoXiPifromAODtracks * fAnalCuts
histogram to check centrality
void FillROOTObjects(AliAODRecoCascadeHF *xicobj, AliAODcascade *casc, AliAODTrack *part1, AliAODMCParticle *mcpart, AliAODMCParticle *mcdaughter1, AliAODMCParticle *mcdaughterxi, Int_t mcnused, Bool_t isXiC)
Bool_t GetUseCombined()
Definition: AliAODPidHF.h:165
char Char_t
Definition: External.C:18
TH1F * fHistoCascDcaNegToPrimVertex
! DCA of negative track to primary vertex
TH1F * fHistoCascDcaPosToPrimVertex
! DCA of positive track to primary vertex
Double_t GetMaxVtxZ() const
Definition: AliRDHFCuts.h:258
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:248
int Int_t
Definition: External.C:63
Bool_t SingleCascadeCutsRef(AliAODcascade *casc, Double_t *vert)
unsigned int UInt_t
Definition: External.C:33
AliAODVertex * CallPrimaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *evt)
float Float_t
Definition: External.C:68
void SelectTrack(const AliVEvent *event, Int_t trkEntries, Int_t &nSeleTrks, Bool_t *seleFlags)
void SelectCascade(const AliVEvent *event, Int_t nCascades, Int_t &nSeleCasc, Bool_t *seleCascFlags)
AliAODVertex * ReconstructSecondaryVertex(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *aod)
AliAODTrack * GetBachelor() const
AliAODVertex * GetOwnPrimaryVtx() const
virtual void UserCreateOutputObjects()
Implementation of interface methods.
void SetProngIDs(Int_t nIDs, UShort_t *id)
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
short Short_t
Definition: External.C:23
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
AliAODcascade * GetCascade() const
Double_t DecayLengthXY() const
Bool_t IsEventSelected(AliVEvent *event)
AliAODRecoCascadeHF * MakeCascadeHF(AliAODcascade *casc, AliAODTrack *trk, AliAODEvent *aod, AliAODVertex *vert)
TTree * fVariablesTree
flag to decide whether to write the candidate variables on a tree variables
TH1F * fHistoCascDcaBachToPrimVertex
! DCA of bachelor track to primary vertex
unsigned short UShort_t
Definition: External.C:28
Bool_t GetIsUsePID() const
Definition: AliRDHFCuts.h:271
const char Option_t
Definition: External.C:48
Bool_t fIsMB
Reconstruct primary vertex excluding candidate tracks.
Bool_t SingleCascadeCuts(AliAODcascade *casc, Double_t *vert)
Bool_t IsEventRejectedDueToTrigger() const
Definition: AliRDHFCuts.h:319
bool Bool_t
Definition: External.C:53
AliAODVertex * PrimaryVertex(const TObjArray *trkArray, AliVEvent *event)
Double_t DecayLength() const
TH1F * fHistoCascCosPAXiPrim
! Cosine pointing angle of Xi to primary vertex
Int_t MatchToMCXicZero(Int_t pdgabs, TClonesArray *mcArray, Int_t dgLabels[10], Int_t ndg, Int_t ndgCk, const Int_t *pdgDg)
Int_t MatchtoMC(AliAODRecoCascadeHF *exobj, Int_t pdgabs, Int_t pdgabscasc, Int_t *pdgDg, Int_t *pdgDgcasc, Int_t *pdgDgv0, TClonesArray *mcArray)
TList * fOutputAll
! User output slot 3 // Analysis histos