LCOV - code coverage report
Current view: top level - ANALYSIS/ANALYSISalice - AliAODv0KineCuts.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 1 492 0.2 %
Date: 2016-06-14 17:26:59 Functions: 1 32 3.1 %

          Line data    Source code
       1             : /**************************************************************************
       2             :  * Copyright(c) 1998-1999, 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             :  * 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             :  **************************************************************************/
      15             : 
      16             : /*
      17             :  * author: M.Kalisky@gsi.de
      18             :  * 08/Dec/2010
      19             :  *
      20             :  * Description: This class allows with purely kinematical cuts
      21             :  * to select clean samples of electrons, pions and protons from the
      22             :  * V0 online finder AOD V0 candidates for PID and dectector resonse
      23             :  * studies.
      24             :  */
      25             : 
      26             : #include <TVector3.h>
      27             : #include <TDatabasePDG.h>
      28             : #include <TPDGCode.h>
      29             : #include <TParticlePDG.h>
      30             : 
      31             : #include "AliAODv0.h"
      32             : #include "AliAODTrack.h"
      33             : #include "AliAODVertex.h"
      34             : #include "AliAODEvent.h"
      35             : #include "AliESDtrack.h"
      36             : #include "AliVEvent.h"
      37             : #include "AliLog.h"
      38             : #include "AliKFParticle.h"
      39             : #include "AliVTrack.h"
      40             : #include "AliKFVertex.h"
      41             : 
      42             : #include "AliAODv0KineCuts.h"
      43             : 
      44         170 : ClassImp(AliAODv0KineCuts)
      45             : 
      46             : //____________________________________________________________________
      47           0 : AliAODv0KineCuts::AliAODv0KineCuts() :
      48           0 :   fEvent(0x0)
      49           0 :   , fPrimaryVertex(0x0)
      50           0 :   , fType(0)
      51           0 :   , fMode(0)
      52           0 :   , fTPCNcls(30)
      53           0 :   , fTPCrefit(kTRUE)
      54           0 :   , fTPCclsRatio(0.6)
      55           0 :   , fNoKinks(kTRUE)
      56           0 :   , fKinkMotherList(1000)
      57           0 :   , fNumberKinkMothers(0)
      58           0 :   , fGcutChi2NDF(10)
      59           0 :   , fGcutInvMass(0.05)
      60           0 :   , fK0cutChi2NDF(10)
      61           0 :   , fLcutChi2NDF(10)
      62           0 :   , fUseExternalVertex(kFALSE)
      63           0 :   , fDeleteVertex(kFALSE)
      64           0 : {
      65             :   //
      66             :   // Default constructor
      67             :   //
      68             : 
      69             :   // default single track cuts
      70           0 :   fTPCNcls = 30;                // minimal number of the TPC clusters
      71           0 :   fTPCrefit = kTRUE;           // TPC refit
      72           0 :   fTPCclsRatio = 0.6;          // minimal foun/findable TPC cluster ratio
      73           0 :   fNoKinks = kTRUE;            // kinks - no [kTRUE] or do not care [kFalse]
      74             : 
      75             : 
      76             :   // default gamma cuts values
      77           0 :   fGcutChi2NDF = 10;           // Chi2NF cut value for the AliKFparticle gamma
      78           0 :   fGcutCosPoint[0] = 0;        // cos of the pointing angle [min, max]
      79           0 :   fGcutCosPoint[1] = 0.02;     // cos of the pointing angle [min, max]
      80           0 :   fGcutDCA[0] = 0.;            // DCA between the daughter tracks [min, max]
      81           0 :   fGcutDCA[1] = 0.25;          // DCA between the daughter tracks [min, max]
      82           0 :   fGcutVertexR[0] = 3.;        // radius of the conversion point [min, max]
      83           0 :   fGcutVertexR[1] = 90.;       // radius of the conversion point [min, max]
      84           0 :   fGcutPsiPair[0] = 0.;        // value of the psi pair cut [min, max]
      85           0 :   fGcutPsiPair[1] = 0.05;      // value of the psi pair cut [min, max]
      86           0 :   fGcutInvMass = 0.05;         // upper value on the gamma invariant mass
      87             :   // default K0 cuts
      88           0 :   fK0cutChi2NDF = 10;          // Chi2NF cut value for the AliKFparticle K0
      89           0 :   fK0cutCosPoint[0] = 0.;      // cos of the pointing angle [min, max]
      90           0 :   fK0cutCosPoint[1] = 0.02;    // cos of the pointing angle [min, max]
      91           0 :   fK0cutDCA[0] = 0.;           // DCA between the daughter tracks [min, max]
      92           0 :   fK0cutDCA[1] = 0.2;          // DCA between the daughter tracks [min, max]
      93           0 :   fK0cutVertexR[0] = 2.0;      // radius of the decay point [min, max]
      94           0 :   fK0cutVertexR[1] = 30.0;     // radius of the decay point [min, max]
      95           0 :   fK0cutInvMass[0] = 0.486;    // invariant mass window
      96           0 :   fK0cutInvMass[1] = 0.508;    // invariant mass window
      97             :   // Lambda & anti-Lambda cut values
      98           0 :   fLcutChi2NDF = 10;           // Chi2NF cut value for the AliKFparticle K0
      99           0 :   fLcutCosPoint[0] = 0.;       // cos of the pointing angle [min, max]
     100           0 :   fLcutCosPoint[1] = 0.02;     // cos of the pointing angle [min, max]
     101           0 :   fLcutDCA[0] = 0.;            // DCA between the daughter tracks [min, max]
     102           0 :   fLcutDCA[1] = 0.2;           // DCA between the daughter tracks [min, max]
     103           0 :   fLcutVertexR[0] = 2.0;       // radius of the decay point [min, max]
     104           0 :   fLcutVertexR[1] = 40.0;      // radius of the decay point [min, max]
     105           0 :   fLcutInvMass[0] = 1.11;      // invariant mass window
     106           0 :   fLcutInvMass[1] = 1.12;      // invariant mass window
     107             :     
     108           0 : }
     109             : //____________________________________________________________________
     110           0 : AliAODv0KineCuts::~AliAODv0KineCuts(){
     111             :   //
     112             :   // Destructor
     113             :   //
     114             : 
     115             : 
     116           0 : }
     117             : //____________________________________________________________________
     118             : AliAODv0KineCuts::AliAODv0KineCuts(const AliAODv0KineCuts &ref):
     119           0 :   TObject(ref)
     120           0 :   , fEvent(0x0)
     121           0 :   , fPrimaryVertex(0x0)
     122           0 :   , fType(0)
     123           0 :   , fMode(0)
     124           0 :   , fTPCNcls(30)
     125           0 :   , fTPCrefit(kTRUE)
     126           0 :   , fTPCclsRatio(0.6)
     127           0 :   , fNoKinks(kTRUE)
     128           0 :   , fKinkMotherList(ref.fKinkMotherList)
     129           0 :   , fNumberKinkMothers(ref.fNumberKinkMothers)
     130           0 :   , fGcutChi2NDF(10)
     131           0 :   , fGcutInvMass(0.05)
     132           0 :   , fK0cutChi2NDF(10)
     133           0 :   , fLcutChi2NDF(10)
     134           0 :   , fUseExternalVertex(kFALSE)
     135           0 :   , fDeleteVertex(kFALSE)
     136           0 : {
     137             :   //
     138             :   // Copy operator
     139             :   //
     140             : 
     141           0 :   ref.Copy(*this);
     142           0 : }
     143             : //____________________________________________________________________
     144             : AliAODv0KineCuts &AliAODv0KineCuts::operator=(const AliAODv0KineCuts &ref){
     145             :   //
     146             :   // assignment operator
     147             :   //
     148           0 :   if(this != &ref)
     149           0 :     ref.Copy(*this);
     150           0 :   return *this; 
     151             : }
     152             : //____________________________________________________________________
     153             : void AliAODv0KineCuts::Copy(TObject &ref) const {
     154             :   //
     155             :   // Performs the copying of the object
     156             :   //
     157             : 
     158           0 :   TObject::Copy(ref);
     159             : 
     160           0 :   AliAODv0KineCuts &target = dynamic_cast<AliAODv0KineCuts &>(ref);
     161             : 
     162             :   // default single track cuts
     163           0 :   target.fTPCNcls = fTPCNcls;
     164           0 :   target.fTPCrefit = fTPCrefit;
     165           0 :   target.fTPCclsRatio = fTPCclsRatio;
     166           0 :   target.fNoKinks = fNoKinks;
     167           0 :   target.fKinkMotherList = fKinkMotherList;
     168           0 :   target.fNumberKinkMothers = fNumberKinkMothers;
     169           0 :   target.fUseExternalVertex = fUseExternalVertex;  //added december 2nd 2011
     170           0 :   target.fDeleteVertex = fDeleteVertex;  //added december 2nd 2011
     171             : 
     172             :   // default gamma cuts values
     173           0 :   target.fGcutChi2NDF = fGcutChi2NDF;
     174           0 :   memcpy(target.fGcutCosPoint, fGcutCosPoint, sizeof(Float_t) * 2);
     175           0 :   memcpy(target.fGcutDCA, fGcutDCA, sizeof(Float_t) * 2); 
     176           0 :   memcpy(target.fGcutVertexR, fGcutVertexR, sizeof(Float_t) * 2);
     177           0 :   memcpy(target.fGcutPsiPair, fGcutPsiPair, sizeof(Float_t) * 2);
     178           0 :   target.fGcutInvMass = fGcutInvMass;
     179             :   // default K0 cuts
     180           0 :   target.fK0cutChi2NDF = fK0cutChi2NDF;
     181           0 :   memcpy(target.fK0cutCosPoint, fK0cutCosPoint, sizeof(Float_t) * 2);
     182           0 :   memcpy(target.fK0cutDCA, fK0cutDCA, sizeof(Float_t) * 2);
     183           0 :   memcpy(target.fK0cutVertexR, fK0cutVertexR, sizeof(Float_t) * 2);
     184           0 :   memcpy(target.fK0cutInvMass, fK0cutInvMass, sizeof(Float_t) * 2);
     185             :   // Lambda & anti-Lambda cut values
     186           0 :   target.fLcutChi2NDF = fLcutChi2NDF;
     187           0 :   memcpy(target.fLcutCosPoint, fLcutCosPoint, sizeof(Float_t) * 2);
     188           0 :   memcpy(target.fLcutDCA, fLcutDCA, sizeof(Float_t) * 2);
     189           0 :   memcpy(target.fLcutVertexR, fLcutVertexR, sizeof(Float_t) * 2);
     190           0 :   memcpy(target.fLcutInvMass, fLcutInvMass, sizeof(Float_t) * 2);
     191             :   
     192           0 : }
     193             : //____________________________________________________________________
     194             : Bool_t  AliAODv0KineCuts::ProcessV0(AliAODv0* const v0, Int_t &pdgV0, Int_t &pdgP, Int_t &pdgN) const 
     195             : {
     196             :   //
     197             :   // main user function
     198             :   //
     199             : 
     200           0 :   if(!v0) return kFALSE;
     201           0 :   if(!fEvent){
     202           0 :     AliErrorClass("No valid Event pointer available, provide it first");
     203           0 :     return kFALSE;
     204             :   }
     205             : 
     206           0 :   if(!V0CutsCommon(v0)) return kFALSE;
     207             : 
     208           0 :   const Int_t id = PreselectV0(v0);
     209             : 
     210           0 :   if(!SingleTrackCuts(v0)) return kFALSE;
     211             : 
     212           0 :   switch(id){
     213             :   case kUndef:
     214           0 :     return kFALSE;
     215             :   case kGamma:
     216           0 :     return CaseGamma(v0, pdgV0, pdgP, pdgN);
     217             :   case kK0:
     218           0 :     return CaseK0(v0, pdgV0, pdgP, pdgN);
     219             :   case kLambda:
     220           0 :     return CaseLambda(v0, pdgV0, pdgP, pdgN, 0);
     221             :   case kALambda:
     222           0 :     return CaseLambda(v0, pdgV0, pdgP, pdgN, 1);
     223             :   default:
     224           0 :     return kFALSE; 
     225             :   }
     226             : 
     227             :   return kFALSE;
     228           0 : }
     229             : //____________________________________________________________________
     230             : Bool_t  AliAODv0KineCuts::ProcessV0(AliAODv0* const v0, Int_t &pdgP, Int_t &pdgN) const 
     231             : {
     232             :   //
     233             :   // main user function, simplified if the V0 identity is not necessary
     234             :   //
     235             : 
     236           0 :   if(!v0) return kFALSE;
     237           0 :   if(!fEvent){
     238           0 :     AliErrorClass("No valid Event pointer available, provide it first");
     239           0 :     return kFALSE;
     240             :   }
     241             : 
     242           0 :   Int_t idV0 = -1;
     243           0 :   return ProcessV0(v0, idV0, pdgP, pdgN);
     244             : 
     245           0 : }
     246             : //____________________________________________________________________
     247             : Int_t AliAODv0KineCuts::PreselectV0(AliAODv0* const v0) const 
     248             : {
     249             :   //
     250             :   // Make a preselection (exclusive) of the V0 cadidates based on
     251             :   // Armenteros plot
     252             :   // the armenteros cut values are currently fixed and user is not able to set them via
     253             :   // set funcions. The reason is that these cuts are optimized and furneter changes should 
     254             :   // not be necessary. To prove otherwise please study in detail before changing the values
     255             :   //
     256             :  
     257             :   // for clarity
     258           0 :   const Float_t alpha =v0->AlphaV0(); //ap[0];
     259           0 :   const Float_t qt = v0->PtArmV0();//ap[1];
     260             : 
     261             :   // selection cuts 
     262             :   // - the reagions for different candidates must not overlap 
     263             : 
     264             :   // Gamma cuts
     265             :   const Double_t cutAlphaG = 0.35; 
     266             :   const Double_t cutQTG = 0.05;
     267             :   const Double_t cutAlphaG2[2] = {0.6, 0.8};
     268             :   const Double_t cutQTG2 = 0.04;
     269             : 
     270             :   // K0 cuts
     271             :   const Float_t cutQTK0[2] = {0.1075, 0.215};
     272             :   const Float_t cutAPK0[2] = {0.199, 0.8};   // parameters for curved QT cut
     273             :   
     274             :   // Lambda & A-Lambda cuts
     275             :   const Float_t cutQTL = 0.03;
     276             :   const Float_t cutAlphaL[2] = {0.35, 0.7};
     277             :   const Float_t cutAlphaAL[2] = {-0.7,  -0.35};
     278             :   const Float_t cutAPL[3] = {0.107, -0.69, 0.5};  // parameters fir curved QT cut
     279             : 
     280             : 
     281           0 :   if(kPurity == fMode){
     282             :   // Check for Gamma candidates
     283           0 :     if(qt < cutQTG){
     284           0 :       if( (TMath::Abs(alpha) < cutAlphaG) ) return kGamma;
     285             :     }
     286             :     // additional region - should help high pT gammas
     287           0 :     if(qt < cutQTG2){
     288           0 :       if( (TMath::Abs(alpha) > cutAlphaG2[0]) &&  (TMath::Abs(alpha) < cutAlphaG2[1]) ) return kGamma;
     289             :     }
     290             :   }
     291           0 :   if(kEffGamma == fMode){
     292           0 :     if(qt < cutQTG) return kGamma;
     293             :   }
     294             : 
     295             :   
     296             :   // Check for K0 candidates
     297           0 :   Float_t q = cutAPK0[0] * TMath::Sqrt(TMath::Abs(1 - alpha*alpha/(cutAPK0[1]*cutAPK0[1])));
     298           0 :   if( (qt > cutQTK0[0]) && (qt < cutQTK0[1]) && (qt > q) ){
     299           0 :     return kK0;
     300             :   }
     301             : 
     302             :   // Check for Lambda candidates
     303           0 :   q = cutAPL[0] * TMath::Sqrt(TMath::Abs(1 - ( (alpha + cutAPL[1]) * (alpha + cutAPL[1]) ) / (cutAPL[2]*cutAPL[2]) ));
     304           0 :   if( (alpha > cutAlphaL[0]) && (alpha < cutAlphaL[1]) && (qt > cutQTL) && (qt < q)  ){
     305           0 :     return kLambda;
     306             :   }
     307             : 
     308             :   // Check for A-Lambda candidates
     309           0 :   q = cutAPL[0] * TMath::Sqrt(TMath::Abs(1 - ( (alpha - cutAPL[1]) * (alpha - cutAPL[1]) ) / (cutAPL[2]*cutAPL[2]) ));
     310           0 :   if( (alpha > cutAlphaAL[0]) && (alpha < cutAlphaAL[1]) && (qt > cutQTL) && (qt < q)  ){
     311           0 :     return kALambda;
     312             :   }
     313             :   
     314           0 :   return kUndef;
     315           0 : }
     316             : //____________________________________________________________________
     317             : Bool_t  AliAODv0KineCuts::SingleTrackCuts(AliAODv0 * const v0) const 
     318             : {
     319             :   //
     320             :   // apply single track cuts
     321             :   // correct sign not relevat here
     322             :   //
     323             : 
     324           0 :   if(!v0) return kFALSE;
     325             :   
     326           0 :   AliAODTrack* d[2] = {
     327           0 :     dynamic_cast<AliAODTrack*>(v0->GetSecondaryVtx()->GetDaughter(0)),
     328           0 :     dynamic_cast<AliAODTrack*>(v0->GetSecondaryVtx()->GetDaughter(1))
     329             :   };
     330             :   
     331           0 :   for(Int_t i=0; i<2; ++i){
     332           0 :     if(!d[i]) return kFALSE;
     333             :     
     334             :     // status word
     335           0 :     ULong_t status = d[i]->GetStatus();
     336             : 
     337             :     // No. of TPC clusters leave to the users
     338           0 :     if(d[i]->GetTPCNcls() < 1) return kFALSE;
     339             : 
     340             :     // TPC refit
     341           0 :     if(!(status & AliAODTrack::kTPCrefit)) return kFALSE;
     342             :   
     343             :     // TPC cluster ratio
     344           0 :     Float_t cRatioTPC = d[i]->GetTPCNclsF() > 0. ? static_cast<Float_t>(d[i]->GetTPCNcls())/static_cast<Float_t> (d[i]->GetTPCNclsF()) : 1.;
     345           0 :     if(cRatioTPC < 0.6) return kFALSE;
     346             :     
     347             :     // kinks
     348           0 :     if(fNoKinks && (IsKinkDaughter(d[i]) || IsKinkMother(d[i]))) return kFALSE;
     349             :     
     350           0 :   }
     351             : 
     352           0 :   return kTRUE;
     353           0 : }
     354             : //____________________________________________________________________
     355             : Bool_t AliAODv0KineCuts::CaseGamma(AliAODv0* const v0, Int_t &pdgV0, Int_t &pdgP, Int_t &pdgN) const 
     356             : {
     357             :   //
     358             :   // process the gamma conversion candidate
     359             :   //
     360             : 
     361           0 :   if(!v0) return kFALSE;
     362             : 
     363             :   AliVTrack* daughter[2];
     364             :   Int_t pIndex = 0, nIndex = 0;
     365             : 
     366           0 :   Bool_t sign = CheckSigns(v0);
     367           0 :   if(sign){
     368             :     pIndex = 0;
     369             :     nIndex = 1;
     370           0 :   }
     371             :   else{
     372             :     pIndex = 1;
     373             :     nIndex = 0;    
     374             :   }
     375           0 :   daughter[0] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(pIndex));
     376           0 :   daughter[1] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(nIndex));
     377           0 :   if(!daughter[0] || !daughter[1]) return kFALSE;
     378             : 
     379           0 :   AliKFParticle *kfMother = CreateMotherParticle(daughter[0], daughter[1], TMath::Abs(kElectron), TMath::Abs(kElectron));
     380           0 :   if(!kfMother) return kFALSE;
     381             : 
     382             : //  AliAODTrack* d[2];
     383             : //  d[0] = dynamic_cast<AliAODTrack*>(fEvent->GetTrack(pIndex));
     384             : //  d[1] = dynamic_cast<AliAODTrack*>(fEvent->GetTrack(nIndex));
     385             : 
     386           0 :   Float_t iMass = v0->InvMass2Prongs(0,1,11,11);
     387             : 
     388             :   // cos pointing angle
     389           0 :   Double_t cosPoint = v0->CosPointingAngle(dynamic_cast<AliAODVertex *>(fEvent->GetPrimaryVertex()));
     390           0 :   cosPoint = TMath::ACos(cosPoint);
     391             : 
     392             :   // DCA between daughters
     393           0 :   Double_t dca = v0->DcaV0Daughters();
     394             : 
     395             :   // Production vertex
     396           0 :   Double_t xyz[3]; 
     397           0 :   v0->GetXYZ(xyz);
     398           0 :   Double_t r = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
     399             : 
     400           0 :   Double_t xy[2];
     401             :   Double_t r2 = -1.;
     402           0 :   if ( GetConvPosXY(static_cast<AliAODTrack *>(daughter[0]), static_cast<AliAODTrack*>(daughter[1]), xy) ){
     403           0 :     r2 = TMath::Sqrt(xy[0]*xy[0] + xy[1]*xy[1]);
     404           0 :   }
     405             : 
     406             :   // psi pair 
     407           0 :   Double_t psiPair = PsiPair(v0);
     408             :   
     409             :   // V0 chi2/ndf
     410           0 :   Double_t chi2ndf = kfMother->GetChi2()/kfMother->GetNDF();
     411             : 
     412           0 :   if(kfMother) delete kfMother; 
     413             :   
     414             :   // apply the cuts
     415             : 
     416           0 :   if(iMass > fGcutInvMass) return kFALSE;
     417             : 
     418           0 :   if(chi2ndf > fGcutChi2NDF) return kFALSE;
     419             : 
     420           0 :   if(cosPoint < fGcutCosPoint[0] || cosPoint > fGcutCosPoint[1]) return kFALSE;
     421             : 
     422           0 :   if(dca < fGcutDCA[0] || dca > fGcutDCA[1]) return kFALSE;
     423             : 
     424           0 :   if(r < fGcutVertexR[0] || r > fGcutVertexR[1]) return kFALSE;
     425             : 
     426           0 :   if(psiPair < fGcutPsiPair[0] || psiPair > fGcutPsiPair[1]) return kFALSE;
     427             :   
     428             :   // all cuts passed
     429             : 
     430           0 :   pdgV0 = 22;
     431           0 :   if(sign){
     432           0 :     pdgP = -11;
     433           0 :     pdgN = 11;
     434           0 :   }
     435             :   else{
     436           0 :     pdgP = 11;
     437           0 :     pdgN = -11;
     438             :   }
     439             : 
     440           0 :   return kTRUE;
     441           0 : }
     442             : //____________________________________________________________________
     443             : Bool_t  AliAODv0KineCuts::CaseK0(AliAODv0* const v0, Int_t &pdgV0, Int_t &pdgP, Int_t &pdgN) const {
     444             :   //
     445             :   // process the K0 candidate
     446             :   //
     447             : 
     448           0 :   if(!v0) return kFALSE;
     449             :   
     450             :   AliVTrack* daughter[2];
     451             :   Int_t pIndex = 0, nIndex = 0;
     452           0 :   Bool_t sign = CheckSigns(v0);
     453           0 :   if(sign){
     454             :     pIndex = 0;
     455             :     nIndex = 1;
     456           0 :   }
     457             :   else{
     458             :     pIndex = 1;
     459             :     nIndex = 0;    
     460             :   }
     461           0 :   daughter[0] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(pIndex));
     462           0 :   daughter[1] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(nIndex));
     463             : 
     464           0 :   if(!daughter[0] || !daughter[1]) return kFALSE;
     465             : 
     466           0 :   AliKFParticle *kfMother = CreateMotherParticle(daughter[0], daughter[1], TMath::Abs(kPiPlus), TMath::Abs(kPiPlus));
     467           0 :   if(!kfMother) return kFALSE;
     468             : 
     469             : //  AliAODTrack* d[2];
     470             : //  d[0] = dynamic_cast<AliAODTrack*>(fEvent->GetTrack(pIndex));
     471             : //  d[1] = dynamic_cast<AliAODTrack*>(fEvent->GetTrack(nIndex));
     472             : 
     473           0 :   Float_t iMass = v0->MassK0Short();
     474             : 
     475             :   // cos pointing angle
     476           0 :   Double_t cosPoint = v0->CosPointingAngle(dynamic_cast<AliAODVertex *>(fEvent->GetPrimaryVertex()));
     477           0 :   cosPoint = TMath::ACos(cosPoint);
     478             : 
     479             :   // DCA between daughters
     480           0 :   Double_t dca = v0->DcaV0Daughters();
     481             : 
     482             :   // Production vertex
     483           0 :   Double_t xyz[3]; 
     484           0 :   v0->GetXYZ(xyz);
     485             : 
     486           0 :   Double_t r = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);  
     487             : 
     488             :   // V0 chi2/ndf
     489           0 :   Double_t chi2ndf = kfMother->GetChi2()/kfMother->GetNDF();
     490             :   
     491           0 :   if(kfMother) delete kfMother; 
     492             : 
     493             :   //
     494             :   // apply the cuts
     495             :   //
     496           0 :   if(iMass < fK0cutInvMass[0] || iMass > fK0cutInvMass[1]) return kFALSE;
     497             : 
     498           0 :   if(chi2ndf > fK0cutChi2NDF) return kFALSE;
     499             : 
     500           0 :   if(cosPoint < fK0cutCosPoint[0] || cosPoint > fK0cutCosPoint[1]) return kFALSE;
     501             : 
     502           0 :   if(dca < fK0cutDCA[0] || dca > fK0cutDCA[1]) return kFALSE;
     503             : 
     504           0 :   if(r < fK0cutVertexR[0] || r > fK0cutVertexR[1]) return kFALSE;
     505             : 
     506             :   // all cuts passed
     507           0 :   pdgV0 = 310;
     508           0 :   if(sign){
     509           0 :     pdgP = 211;
     510           0 :     pdgN = -211;
     511           0 :   }
     512             :   else{
     513           0 :     pdgP = -211;
     514           0 :     pdgN = 211;
     515             :   }
     516             : 
     517           0 :   return kTRUE;
     518           0 : }
     519             : //____________________________________________________________________
     520             : Bool_t  AliAODv0KineCuts::CaseLambda(AliAODv0* const v0, Int_t &pdgV0, Int_t &pdgP, Int_t &pdgN, Int_t id) const {
     521             :   //
     522             :   // process teh Lambda and Anti-Lambda candidate
     523             :   //
     524             :   
     525           0 :   if(!v0) return kFALSE;
     526             : 
     527           0 :     const Double_t cL0mass=TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass();  // PDG lambda mass
     528             : 
     529             :   AliVTrack* daughter[2];
     530             :   Int_t pIndex = 0, nIndex = 0;
     531             :   Float_t mMass[2] = {-1., -1.};
     532           0 :   Bool_t sign = CheckSigns(v0);
     533           0 :   if(sign){
     534             :     pIndex = 0;
     535             :     nIndex = 1;
     536           0 :     mMass[0] = v0->MassLambda();
     537           0 :     mMass[1] = v0->MassAntiLambda();
     538           0 :   }
     539             :   else{
     540             :     pIndex = 1;
     541             :     nIndex = 0;    
     542           0 :     mMass[0] = v0->MassAntiLambda();
     543           0 :     mMass[1] = v0->MassLambda();
     544             :   }
     545           0 :   daughter[0] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(pIndex));
     546           0 :   daughter[1] = dynamic_cast<AliVTrack *>(v0->GetSecondaryVtx()->GetDaughter(nIndex));
     547             : 
     548           0 :   if(!daughter[0] || !daughter[1]) return kFALSE;
     549             : 
     550           0 :   AliKFParticle *kfMother[2] = {0x0, 0x0};
     551             :   // Lambda
     552           0 :   kfMother[0] = CreateMotherParticle(daughter[0], daughter[1], TMath::Abs(kProton), TMath::Abs(kPiPlus));
     553           0 :   if(!kfMother[0]) return kFALSE;
     554             :   
     555             :   // Anti-Lambda
     556           0 :   kfMother[1] = CreateMotherParticle(daughter[0], daughter[1], TMath::Abs(kPiPlus), TMath::Abs(kProton));
     557           0 :   if(!kfMother[1]) return kFALSE;
     558             : 
     559           0 :   Float_t dMass[2] = {static_cast<Float_t>(TMath::Abs(mMass[0] - cL0mass)), static_cast<Float_t>(TMath::Abs(mMass[1] - cL0mass))};
     560             :   
     561           0 :   Float_t p[2] = {static_cast<Float_t>(daughter[0]->P()), static_cast<Float_t>(daughter[1]->P())}; 
     562             : 
     563             :   // check the 3 lambda - antilambda variables
     564             :   Int_t check[2] = {-1, -1};   // 0 : lambda, 1 : antilambda
     565             :   // 1) momentum of the daughter particles - proton is expected to have higher momentum than pion
     566           0 :   check[0] = (p[0] > p[1]) ? 0 : 1;
     567             :   // 2) mass of the mother particle
     568           0 :   check[1] = (dMass[0] < dMass[1]) ? 0 : 1;
     569             :  
     570             :   // require positive correlation of (1) and (2)
     571           0 :   if(check[0] != check[1]){
     572           0 :     if(kfMother[0]) delete kfMother[0]; 
     573           0 :     if(kfMother[1]) delete kfMother[1]; 
     574           0 :     return kFALSE;
     575             :   }
     576             : 
     577             :   // now that the check[0] == check[1]
     578             :   const Int_t type = check[0];
     579             : 
     580             :   // require that the input armenteros preselection agree:
     581           0 :   if(type != id) return kFALSE;
     582             : 
     583             :   Float_t iMass =0.;
     584           0 :   if(sign){
     585           0 :     iMass = (type == 0) ? v0->MassLambda() : v0->MassAntiLambda();
     586           0 :   } else{
     587           0 :     iMass = (type == 0) ? v0->MassAntiLambda() : v0->MassLambda();
     588             :   }
     589             : 
     590             :   // cos pointing angle
     591           0 :   Double_t cosPoint = v0->CosPointingAngle(dynamic_cast<AliAODVertex *>(fEvent->GetPrimaryVertex()));
     592           0 :   cosPoint = TMath::ACos(cosPoint);
     593             : 
     594             :   // DCA between daughters
     595           0 :   Double_t dca = v0->DcaV0Daughters();
     596             :   
     597             :   // Production vertex
     598           0 :   Double_t xyz[3]; 
     599           0 :   v0->GetXYZ(xyz);
     600           0 :   Double_t r = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]);
     601             : 
     602             :   // proton - pion indices
     603             :   Int_t ix[2] = {0, 1};
     604           0 :   if(1 == type){
     605             :     ix[0] = 1;
     606             :     ix[1] = 0;
     607           0 :   }
     608             : 
     609             :   // V0 chi2/ndf
     610           0 :   Double_t chi2ndf = kfMother[type]->GetChi2()/kfMother[type]->GetNDF();
     611             : 
     612           0 :   if(kfMother[0]) delete kfMother[0]; 
     613           0 :   if(kfMother[1]) delete kfMother[1]; 
     614             : 
     615             :   //
     616             :   // apply the cuts
     617             :   //
     618             : 
     619           0 :   if(iMass < fLcutInvMass[0] || iMass > fLcutInvMass[1]) return kFALSE;
     620             : 
     621           0 :   if(chi2ndf > fLcutChi2NDF) return kFALSE;
     622             : 
     623           0 :   if(cosPoint < fLcutCosPoint[0] || cosPoint > fLcutCosPoint[1]) return kFALSE;
     624             : 
     625           0 :   if(dca < fLcutDCA[0] || dca > fLcutDCA[1]) return kFALSE;
     626             : 
     627           0 :   if(r < fLcutVertexR[0] || r > fLcutVertexR[1]) return kFALSE;
     628             : 
     629             :   // all cuts passed
     630             : 
     631           0 :   if(0 == type){
     632           0 :     pdgV0 = 3122;
     633           0 :     if(sign){
     634           0 :       pdgP = 2212;
     635           0 :       pdgN = -211;
     636           0 :     }
     637             :     else{
     638           0 :       pdgP = -211;
     639           0 :       pdgN = 2212;
     640             :     }
     641             :   }
     642             :   else{
     643           0 :     pdgV0 = -3122;
     644           0 :     if(sign){
     645           0 :       pdgP = 211;
     646           0 :       pdgN = -2212;
     647           0 :     }
     648             :     else{
     649           0 :       pdgP = -2212;
     650           0 :       pdgN = 211;
     651             :     }
     652             :   }
     653             : 
     654           0 :   return kTRUE;
     655           0 : }
     656             : //____________________________________________________________________
     657             : Bool_t  AliAODv0KineCuts::V0CutsCommon(const AliAODv0 * const v0) const 
     658             : {
     659             :   //
     660             :   // V0 cuts common to all V0s
     661             :   //
     662             : 
     663             :   AliAODTrack* dN, *dP; 
     664             : 
     665           0 :   dP = dynamic_cast<AliAODTrack *>(v0->GetSecondaryVtx()->GetDaughter(0));
     666           0 :   dN = dynamic_cast<AliAODTrack *>(v0->GetSecondaryVtx()->GetDaughter(1));
     667             :   
     668           0 :   if(!dN || !dP) return kFALSE;
     669             : 
     670           0 :   Int_t qP = dP->Charge();
     671           0 :   Int_t qN = dN->Charge();
     672             : 
     673           0 :   if((qP*qN) != -1) return kFALSE;
     674             : 
     675           0 :   return kTRUE;
     676           0 : }
     677             : //____________________________________________________________________
     678             : Bool_t AliAODv0KineCuts::CheckSigns(AliAODv0* const v0) const 
     679             : {
     680             :   //
     681             :   // check wheter the sign was correctly applied to 
     682             :   // V0 daughter tracks
     683             :   //
     684             :   
     685             :   Bool_t correct = kFALSE;
     686             : 
     687             :   AliAODTrack* d[2] = {
     688           0 :     dynamic_cast<AliAODTrack*>(v0->GetSecondaryVtx()->GetDaughter(0)),
     689           0 :     dynamic_cast<AliAODTrack*>(v0->GetSecondaryVtx()->GetDaughter(1))
     690             :   ,};
     691             : 
     692             :   Int_t sign[2];
     693           0 :   sign[0] = d[0]->Charge() > 0. ? 1 : -1;
     694           0 :   sign[1] = d[1]->Charge() > 0. ? 1 : -1;
     695             :   
     696           0 :   if(-1 == sign[0] && 1 == sign[1]){
     697             :     correct = kFALSE;
     698           0 :   }
     699             :   else{
     700             :     correct = kTRUE;
     701             :   }
     702             :   
     703           0 :   return correct;
     704             : }
     705             : //________________________________________________________________
     706             : Double_t AliAODv0KineCuts::PsiPair(AliAODv0* const v0) const 
     707             : {
     708             :   //
     709             :   // Angle between daughter momentum plane and plane 
     710             :   // 
     711             : 
     712           0 :   if(!fEvent) return -1.;
     713             : 
     714           0 :   Float_t magField = fEvent->GetMagneticField();
     715             : 
     716             :   Int_t pIndex = -1;
     717             :   Int_t nIndex = -1;
     718           0 :   if(CheckSigns(v0)){
     719             :     pIndex = 0;
     720             :     nIndex = 1;
     721           0 :   }
     722             :   else{
     723             :     pIndex = 1;
     724             :     nIndex = 0;    
     725             :   }
     726             :  
     727             : 
     728             :   AliESDtrack* daughter[2];
     729             : 
     730           0 :   daughter[0] = new AliESDtrack(dynamic_cast<AliAODTrack *>(v0->GetSecondaryVtx()->GetDaughter(pIndex)));
     731           0 :   daughter[1] = new AliESDtrack(dynamic_cast<AliAODTrack *>(v0->GetSecondaryVtx()->GetDaughter(nIndex)));
     732             : 
     733           0 :   Double_t xyz[3];
     734           0 :   v0->GetXYZ(xyz);//Reconstructed coordinates of V0; to be replaced by Markus Rammler's method in case of conversions!
     735             :   
     736             :   Double_t mn[3] = {0,0,0};
     737             :   Double_t mp[3] = {0,0,0};
     738             : 
     739             :   //reconstructed cartesian momentum components of negative daughter;
     740           0 :   mn[0] = v0->MomNegX();
     741           0 :   mn[1] = v0->MomNegY();
     742           0 :   mn[2] = v0->MomNegZ();
     743             :   //reconstructed cartesian momentum components of positive daughter;
     744           0 :   mp[0] = v0->MomPosX();
     745           0 :   mp[1] = v0->MomPosY();
     746           0 :   mp[2] = v0->MomPosZ();
     747             : 
     748             :   Double_t deltat = 1.;
     749           0 :   deltat = TMath::ATan(mp[2]/(TMath::Sqrt(mp[0]*mp[0] + mp[1]*mp[1])+1.e-13)) -  TMath::ATan(mn[2]/(TMath::Sqrt(mn[0]*mn[0] + mn[1]*mn[1])+1.e-13));//difference of angles of the two daughter tracks with z-axis
     750             : 
     751           0 :   Double_t radiussum = TMath::Sqrt(xyz[0]*xyz[0] + xyz[1]*xyz[1]) + 50;//radius to which tracks shall be propagated
     752             : 
     753           0 :   Double_t momPosProp[3];
     754           0 :   Double_t momNegProp[3];
     755             :     
     756           0 :   AliExternalTrackParam pt(*daughter[0]), nt(*daughter[1]);
     757             :     
     758             :   Double_t psiPair = 4.;
     759             : 
     760           0 :   if(nt.PropagateTo(radiussum,magField) == 0)//propagate tracks to the outside
     761           0 :     psiPair =  -5.;
     762           0 :   if(pt.PropagateTo(radiussum,magField) == 0)
     763           0 :     psiPair = -5.;
     764           0 :   pt.GetPxPyPz(momPosProp);//Get momentum vectors of tracks after propagation
     765           0 :   nt.GetPxPyPz(momNegProp);
     766             :   
     767             :   Double_t pEle =
     768           0 :     TMath::Sqrt(momNegProp[0]*momNegProp[0]+momNegProp[1]*momNegProp[1]+momNegProp[2]*momNegProp[2]);//absolute momentum value of negative daughter
     769             :   Double_t pPos =
     770           0 :     TMath::Sqrt(momPosProp[0]*momPosProp[0]+momPosProp[1]*momPosProp[1]+momPosProp[2]*momPosProp[2]);//absolute momentum value of positive daughter
     771             :     
     772             :   Double_t scalarproduct =
     773           0 :     momPosProp[0]*momNegProp[0]+momPosProp[1]*momNegProp[1]+momPosProp[2]*momNegProp[2];//scalar product of propagated positive and negative daughters' momenta
     774             :     
     775           0 :   Double_t chipair = TMath::ACos(scalarproduct/(pEle*pPos));//Angle between propagated daughter tracks
     776             : 
     777           0 :   psiPair =  TMath::Abs(TMath::ASin(deltat/chipair));  
     778             : 
     779           0 :   delete daughter[0]; delete daughter[1];
     780             :   return psiPair; 
     781           0 : }
     782             : //___________________________________________________________________
     783             : Bool_t  AliAODv0KineCuts::GetConvPosXY(AliAODTrack * const ptrack, AliAODTrack * const ntrack, Double_t convpos[2]) const
     784             : {
     785             :   //
     786             :   // recalculate the gamma conversion XY postition
     787             :   //
     788             : 
     789           0 :   const Double_t b = fEvent->GetMagneticField();
     790             : 
     791           0 :   AliESDtrack posESD(ptrack), negESD(ntrack);
     792             : 
     793           0 :   Double_t helixcenterpos[2];
     794           0 :   GetHelixCenter(ptrack,b,ptrack->Charge(),helixcenterpos);
     795             : 
     796           0 :   Double_t helixcenterneg[2];
     797           0 :   GetHelixCenter(ntrack,b,ntrack->Charge(),helixcenterneg);
     798             : 
     799           0 :   Double_t  poshelix[6];
     800           0 :   posESD.GetHelixParameters(poshelix,b);
     801           0 :   Double_t posradius = TMath::Abs(1./poshelix[4]);
     802             : 
     803           0 :   Double_t  neghelix[6];
     804           0 :   negESD.GetHelixParameters(neghelix,b);
     805           0 :   Double_t negradius = TMath::Abs(1./neghelix[4]);
     806             : 
     807           0 :   Double_t xpos = helixcenterpos[0];
     808           0 :   Double_t ypos = helixcenterpos[1];
     809           0 :   Double_t xneg = helixcenterneg[0];
     810           0 :   Double_t yneg = helixcenterneg[1];
     811             : 
     812           0 :   convpos[0] = (xpos*negradius + xneg*posradius)/(negradius+posradius);
     813           0 :   convpos[1] = (ypos*negradius+  yneg*posradius)/(negradius+posradius);
     814             : 
     815             :   return 1;
     816           0 : }
     817             : //___________________________________________________________________
     818             : Bool_t  AliAODv0KineCuts::GetHelixCenter(AliAODTrack * const track, Double_t b,Int_t charge, Double_t center[2]) const
     819             : {
     820             :   //
     821             :   // computes the center of the track helix
     822             :   //
     823             :   
     824           0 :   Double_t pi = TMath::Pi();
     825             :   
     826           0 :   Double_t  helix[6];
     827           0 :   AliESDtrack esddaughter(track);
     828           0 :   esddaughter.GetHelixParameters(helix,b);
     829             :   
     830           0 :   Double_t xpos =  helix[5];
     831           0 :   Double_t ypos =  helix[0];
     832           0 :   Double_t radius = TMath::Abs(1./helix[4]);
     833           0 :   Double_t phi = helix[2];
     834             : 
     835           0 :   if(phi < 0){
     836           0 :     phi = phi + 2*pi;
     837           0 :   }
     838             : 
     839           0 :   phi -= pi/2.;
     840           0 :   Double_t xpoint =  radius * TMath::Cos(phi);
     841           0 :   Double_t ypoint =  radius * TMath::Sin(phi);
     842             : 
     843           0 :   if(b<0){
     844           0 :     if(charge > 0){
     845           0 :       xpoint = - xpoint;
     846           0 :       ypoint = - ypoint;
     847           0 :     }
     848             :     /* avoid self assignment
     849             :     if(charge < 0){
     850             :       xpoint =  xpoint;
     851             :       ypoint =  ypoint;
     852             :     }
     853             :     */
     854             :   }
     855           0 :   if(b>0){
     856             :     /* avoid self assignment
     857             :     if(charge > 0){
     858             :       xpoint =  xpoint;
     859             :       ypoint =  ypoint;
     860             :     }
     861             :     */
     862           0 :     if(charge < 0){
     863           0 :       xpoint = - xpoint;
     864           0 :       ypoint = - ypoint;
     865           0 :     }
     866             :   }
     867           0 :   center[0] =  xpos + xpoint;
     868           0 :   center[1] =  ypos + ypoint;
     869             : 
     870             :   return 1;
     871           0 : }
     872             : //___________________________________________________________________
     873             : AliKFParticle *AliAODv0KineCuts::CreateMotherParticle(const AliVTrack* const pdaughter, const AliVTrack* const ndaughter, Int_t pspec, Int_t nspec) const
     874             : {
     875             :   //
     876             :   // Creates a mother particle
     877             :   //
     878           0 :   AliKFParticle pkfdaughter(*pdaughter, pspec);
     879           0 :   AliKFParticle nkfdaughter(*ndaughter, nspec);
     880             :   
     881             :   
     882             :   // Create the mother particle 
     883           0 :   AliKFParticle *m = new AliKFParticle(pkfdaughter, nkfdaughter);
     884           0 :   m->SetField(fEvent->GetMagneticField());
     885           0 :   if(TMath::Abs(kElectron) == pspec && TMath::Abs(kElectron) == nspec) m->SetMassConstraint(0, 0.001);
     886           0 :   else if(TMath::Abs(kPiPlus) == pspec && TMath::Abs(kPiPlus) == nspec) m->SetMassConstraint(TDatabasePDG::Instance()->GetParticle(kK0Short)->Mass(), 0.);
     887           0 :   else if(TMath::Abs(kProton) == pspec && TMath::Abs(kPiPlus) == nspec) m->SetMassConstraint(TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass(), 0.);
     888           0 :   else if(TMath::Abs(kPiPlus) == pspec && TMath::Abs(kProton) == nspec) m->SetMassConstraint(TDatabasePDG::Instance()->GetParticle(kLambda0)->Mass(), 0.);
     889             :   else{
     890           0 :     AliErrorClass("Wrong daughter ID - mass constraint can not be set");
     891             :   }
     892             : 
     893           0 :   AliKFVertex improvedVertex = *fPrimaryVertex;
     894           0 :   improvedVertex += *m;
     895           0 :   m->SetProductionVertex(improvedVertex);
     896             :   
     897             :   // update 15/06/2010
     898             :   // mother particle will not be added to primary vertex but only to its copy 
     899             :   // as this confilcts with calling
     900             :   // m->SetPrimaryVertex() function and
     901             :   // subsequently removing the mother particle afterwards
     902             :   // Source: Sergey Gorbunov
     903             : 
     904             :   return m;
     905           0 : }
     906             : //____________________________________________________________________
     907             : void  AliAODv0KineCuts::SetEvent(AliAODEvent* const event){
     908             :   //
     909             :   // direct setter of AOD event
     910             :   //
     911           0 :   fEvent = event;
     912           0 :   if(!fEvent){
     913           0 :     AliErrorClass("Invalid input event pointer");
     914           0 :     return;
     915             :   }
     916             : 
     917             :   // Set Mother vertex List
     918           0 :   fNumberKinkMothers = 0;
     919           0 :   if(fEvent->GetNumberOfVertices() > fKinkMotherList.GetSize()) fKinkMotherList.Set(fEvent->GetNumberOfVertices());
     920           0 :   for(Int_t ivertex=0; ivertex < fEvent->GetNumberOfVertices(); ivertex++) {
     921           0 :     AliAODVertex *aodvertex = fEvent->GetVertex(ivertex);
     922           0 :     if(!aodvertex) continue;
     923           0 :     if(aodvertex->GetType()==AliAODVertex::kKink) {
     924           0 :       AliAODTrack *mother = (AliAODTrack *) aodvertex->GetParent();
     925           0 :       if(!mother) continue;
     926           0 :       Int_t idmother = mother->GetID();
     927           0 :       fKinkMotherList[fNumberKinkMothers++] = idmother;
     928           0 :     }
     929           0 :   }
     930             : 
     931           0 :   if (fUseExternalVertex) return;
     932             :   else{
     933           0 :         if(fPrimaryVertex && fDeleteVertex){
     934           0 :                 delete  fPrimaryVertex;
     935           0 :                 fPrimaryVertex=0x0;
     936           0 :         }
     937           0 :         fPrimaryVertex = new AliKFVertex(*(fEvent->GetPrimaryVertex()));
     938           0 :         fDeleteVertex=kTRUE;
     939             :         }
     940             : 
     941             : 
     942             : 
     943           0 : }
     944             : //____________________________________________________________________
     945             : void  AliAODv0KineCuts::SetEvent(AliVEvent* const event){
     946             :   //
     947             :   // direct setter of AOD event
     948             :   //
     949             : 
     950           0 :   fEvent = dynamic_cast<AliAODEvent*>(event);
     951           0 :   if(!fEvent){
     952           0 :     AliErrorClass("Invalid input event pointer");
     953           0 :     return;
     954             :   }
     955             :   
     956             :   // Set Mother vertex List
     957           0 :   fNumberKinkMothers = 0;
     958           0 :   if(fEvent->GetNumberOfVertices() > fKinkMotherList.GetSize()) fKinkMotherList.Set(fEvent->GetNumberOfVertices());
     959           0 :   for(Int_t ivertex=0; ivertex < fEvent->GetNumberOfVertices(); ivertex++) {
     960           0 :     AliAODVertex *aodvertex = fEvent->GetVertex(ivertex);
     961           0 :     if(!aodvertex) continue;
     962           0 :     if(aodvertex->GetType()==AliAODVertex::kKink) {
     963           0 :       AliAODTrack *mother = (AliAODTrack *) aodvertex->GetParent();
     964           0 :       if(!mother) continue;
     965           0 :       Int_t idmother = mother->GetID();
     966           0 :       fKinkMotherList[fNumberKinkMothers++] = idmother;
     967           0 :     }
     968           0 :   }
     969             : 
     970           0 :   if (fUseExternalVertex) return;
     971             :   else{
     972           0 :     if(fPrimaryVertex && fDeleteVertex){
     973           0 :       delete    fPrimaryVertex;
     974           0 :       fPrimaryVertex=0x0;
     975           0 :       }
     976           0 :     fPrimaryVertex = new AliKFVertex(*(fEvent->GetPrimaryVertex()));
     977           0 :     fDeleteVertex=kTRUE;
     978             :   }
     979           0 : }
     980             : 
     981             : 
     982             : //________________________________________________________________
     983             : void     AliAODv0KineCuts::UseExternalVertex(Bool_t use_external){
     984             :         //
     985             :         // Reenable primary Vertex from AOD event
     986             :         //
     987           0 :         if (use_external) fUseExternalVertex =kTRUE;
     988           0 :         else fUseExternalVertex =kFALSE;
     989           0 : }
     990             : 
     991             : 
     992             : 
     993             : 
     994             : //________________________________________________________________
     995             : void AliAODv0KineCuts::SetPrimaryVertex(AliKFVertex* const v){
     996             :   //
     997             :   // set the primary vertex of the event
     998             :   //
     999           0 :         if(fPrimaryVertex && fDeleteVertex){   
    1000           0 :                 delete  fPrimaryVertex;
    1001           0 :                 fPrimaryVertex =0x0;
    1002           0 :                 fDeleteVertex = kFALSE;
    1003           0 :                 }  
    1004           0 :   fUseExternalVertex=kTRUE; 
    1005           0 :   fPrimaryVertex = v; // set primary Vertex
    1006           0 :   if(!fPrimaryVertex){
    1007           0 :     AliErrorClass("Failed to initialize the primary vertex");
    1008           0 :     return;
    1009             :   }
    1010           0 : }
    1011             : //___________________________________________________________________
    1012             : void AliAODv0KineCuts::SetMode(Int_t mode, Int_t type){
    1013             :   //
    1014             :   // this function allows the user to select (prior running the 'ProcessV0' function)
    1015             :   // to select different approaches to V0 selection - the 'mode'
    1016             :   // - and -
    1017             :   // different systems (pp, PbPb) - 'type' 
    1018             :   //
    1019             :   // To see the cut values for different modes please refer to the
    1020             :   // function SetCuts()
    1021             :   //
    1022             :   // Important notice: based on the parameters particular sets of cuts will
    1023             :   // be activated for teh V0 selection. If some additional changes to single
    1024             :   // cuts are needed please us the SetXXXcut function (see the header file)
    1025             :   // 
    1026             : 
    1027           0 :   switch(mode){
    1028             :   case kPurity:
    1029           0 :     fMode = kPurity;  // used to obtain highest purity possible - the efficiency may be low
    1030           0 :     break;
    1031             :   case kEffGamma:
    1032           0 :     fMode = kEffGamma; // used to obtain highes efficiency possible - the purity may be worse
    1033           0 :     break;
    1034             :   default:
    1035           0 :     AliError("V0 selection mode not recognozed, setting 'kPurity'");
    1036           0 :     fMode = kPurity;
    1037           0 :   }
    1038             : 
    1039           0 :   switch(type){
    1040             :   case kPP:
    1041           0 :     fType = kPP;  // cuts optimized for low multiplicity 
    1042           0 :     break;
    1043             :   case kPbPb:
    1044           0 :     fType = kPbPb;  // cuts optimized for high multiplicity
    1045           0 :     break;
    1046             :   }
    1047             :   
    1048             :   // setup the cut values for selected mode & type
    1049           0 :   SetCuts();
    1050             : 
    1051           0 : }
    1052             : //___________________________________________________________________
    1053             : void AliAODv0KineCuts::SetMode(Int_t mode, const char* type){
    1054             :   //
    1055             :   // overloaded function - please see above
    1056             :   // 
    1057             :   
    1058             :   Int_t t = -1;
    1059             : 
    1060           0 :   if(!strcmp("pp", type)) t = kPP;
    1061           0 :   else if(!(strcmp("PbPb", type))) t = kPbPb;
    1062             :   else{
    1063           0 :     AliError("data type not recognized, setting 'pp'");
    1064             :     t = kPP;    
    1065             :   }
    1066             : 
    1067           0 :   SetMode(mode, t);
    1068             : 
    1069           0 : }
    1070             : //___________________________________________________________________
    1071             : void AliAODv0KineCuts::SetCuts(){
    1072             :   //
    1073             :   // this funciton sets the default cut values based on the selected
    1074             :   // fMode and fType.
    1075             :   // please note that only the cuts that have different values than the default
    1076             :   // cuts are updated here
    1077             :   //
    1078             :   
    1079             :   // last update: 14/02/2011
    1080             :   // as a very preliminary  - the only change to default cuts is to apply
    1081             :   // less restricting gamma conversion selection in PreselectV0() function
    1082             :   
    1083             : 
    1084             :   
    1085           0 : }
    1086             : 
    1087             : //___________________________________________________________________
    1088             : Bool_t AliAODv0KineCuts::IsKinkMother(const AliAODTrack * const track) const {
    1089             :   //
    1090             :   // Check if track is a kink mother
    1091             :   //
    1092           0 :   for(int ivtx = 0; ivtx < fNumberKinkMothers; ivtx++){
    1093           0 :     if(track->GetID() == fKinkMotherList[ivtx]) return kTRUE;
    1094             :   }
    1095           0 :   return kFALSE;
    1096           0 : }
    1097             : 
    1098             : //___________________________________________________________________
    1099             : Bool_t AliAODv0KineCuts::IsKinkDaughter(const AliAODTrack * const track) const {
    1100             :   //
    1101             :   // Check if track is a kink daughter
    1102             :   //
    1103           0 :   AliAODVertex *vtx = track->GetProdVertex();
    1104           0 :   if(!vtx) return kFALSE;
    1105           0 :   if(vtx->GetType()==AliAODVertex::kKink) return kTRUE;
    1106           0 :   return kFALSE;
    1107           0 : }
    1108             : 

Generated by: LCOV version 1.11