ROOT logo
#ifndef ALIRSNCUTDAUGHTERD0_H
#define ALIRSNCUTDAUGHTERD0_H

//
// Cuts for selecting good pion candidates for D0 analysis
// with the data samples from pp/PbPb/pPb runs in 2010/2011/2012/2013.
// Applies track quality selection plus PID selection,
// with different tolerance ranges depending on the momentum.
//

#include "AliVTrack.h"
#include "AliPID.h"
#include "AliPIDResponse.h"
#include "AliRsnCut.h"
#include "AliRsnCutTrackQuality.h"

class AliRsnCutDaughterD0 : public AliRsnCut {

 public:

  AliRsnCutDaughterD0(const char *name = "", AliPID::EParticleType pid = AliPID::kPion);
  AliRsnCutDaughterD0(const AliRsnCutDaughterD0 &copy);
  AliRsnCutDaughterD0 &operator=(const AliRsnCutDaughterD0 &copy);
  virtual ~AliRsnCutDaughterD0() { }

  void           SetNoPID(Bool_t yn = kTRUE)                  {fNoPID = yn;}
  //void           SetIsCheckOnMother(Bool_t yn = kTRUE)        {fIsCheckOnMother = yn;}
  void           SetPtDependentPIDCut(Bool_t yn = kTRUE)      {fPtDepPIDCut = yn;}
  void           SetPID(AliPID::EParticleType type)           {fPID = type;}
   
  void           SetTPCPionPIDCut(Double_t value)             {fPionTPCPIDCut = value;}
  void           SetTPCKaonPIDCut(Double_t value)             {fKaonTPCPIDCut = value;}
   
  void           SetTOFPionPIDCut(Double_t value)             {fPionTOFPIDCut = value;}
  void           SetTOFKaonPIDCut(Double_t value)             {fKaonTOFPIDCut = value;}
   
  AliRsnCutTrackQuality *CutQuality()                       {return &fCutQuality;}
  Bool_t                 MatchTOF(const AliVTrack *vtrack);
  Bool_t                 MatchTPC(const AliVTrack *vtrack);
  virtual Bool_t         IsSelected(TObject *obj);
   
 private:
  Bool_t                fNoPID;            // flag to switch off PID check
  //Bool_t                fIsCheckOnMother;  // flag to switch off tracks check
  AliPID::EParticleType fPID;              // PID for track
  AliRsnCutTrackQuality fCutQuality;       // track quality cut 

 protected:
  Double_t         fPionTPCPIDCut;                // TPC nsigmas for pions
  Double_t         fKaonTPCPIDCut;                // TPC nsigmas for kaons
  Double_t         fPionTOFPIDCut;                // TOF nsigmas for pions
  Double_t         fKaonTOFPIDCut;                // TOF nsigmas for kaons
  Bool_t           fPtDepPIDCut;                  // flag for setting a pt dependent or independent PID cut

  ClassDef(AliRsnCutDaughterD0, 3)          // cut definitions for D0
    };

//__________________________________________________________________________________________________
inline Bool_t AliRsnCutDaughterD0::MatchTOF(const AliVTrack *vtrack)
{
  //
  // Checks if the track has matched the TOF detector
  //

  if (!vtrack) {
    AliWarning("NULL argument: impossible to check status");
    return kFALSE;
  }
  AliPIDResponse *fPidResponse = fEvent->GetPIDResponse();
  if (!fPidResponse) {
    AliFatal("NULL PID response");
    return kFALSE;
  }
  
  AliPIDResponse::EDetPidStatus status = fPidResponse->CheckPIDStatus(AliPIDResponse::kTOF,vtrack);
  if (status != AliPIDResponse::kDetPidOk) return kFALSE; 
  Float_t probMis = fPidResponse->GetTOFMismatchProbability(vtrack);
  if (probMis > 0.01) return kFALSE;
  if ((vtrack->GetStatus()&AliESDtrack::kTOFpid )==0 && vtrack->GetStatus()&AliESDtrack::kITSrefit )   return kFALSE;
  return kTRUE;
  

  //if (!(vtrack->GetStatus() & AliESDtrack::kTOFout)) return kFALSE;
  //if (!(vtrack->GetStatus() & AliESDtrack::kTIME  )) return kFALSE;

  return kTRUE;
}

//___________________________________________________________________________________________________
inline Bool_t AliRsnCutDaughterD0::MatchTPC(const AliVTrack *vtrack) 
{
  // Check if the track is good for TPC PID
  
  
  if (!vtrack) {
    AliWarning("NULL argument: impossible to check status");
    return kFALSE;
  }
  AliPIDResponse *fPidResponse = fEvent->GetPIDResponse();
  if (!fPidResponse) {
    AliFatal("NULL PID response");
    return kFALSE;
  }
  
  AliPIDResponse::EDetPidStatus status = fPidResponse->CheckPIDStatus(AliPIDResponse::kTPC,vtrack);
  if (status != AliPIDResponse::kDetPidOk) return kFALSE;
  /* UInt_t nclsTPCPID = vtrack->GetTPCsignalN(); */
  /* if(nclsTPCPID<0) return kFALSE; */
  return kTRUE;
}

#endif
 AliRsnCutDaughterD0.h:1
 AliRsnCutDaughterD0.h:2
 AliRsnCutDaughterD0.h:3
 AliRsnCutDaughterD0.h:4
 AliRsnCutDaughterD0.h:5
 AliRsnCutDaughterD0.h:6
 AliRsnCutDaughterD0.h:7
 AliRsnCutDaughterD0.h:8
 AliRsnCutDaughterD0.h:9
 AliRsnCutDaughterD0.h:10
 AliRsnCutDaughterD0.h:11
 AliRsnCutDaughterD0.h:12
 AliRsnCutDaughterD0.h:13
 AliRsnCutDaughterD0.h:14
 AliRsnCutDaughterD0.h:15
 AliRsnCutDaughterD0.h:16
 AliRsnCutDaughterD0.h:17
 AliRsnCutDaughterD0.h:18
 AliRsnCutDaughterD0.h:19
 AliRsnCutDaughterD0.h:20
 AliRsnCutDaughterD0.h:21
 AliRsnCutDaughterD0.h:22
 AliRsnCutDaughterD0.h:23
 AliRsnCutDaughterD0.h:24
 AliRsnCutDaughterD0.h:25
 AliRsnCutDaughterD0.h:26
 AliRsnCutDaughterD0.h:27
 AliRsnCutDaughterD0.h:28
 AliRsnCutDaughterD0.h:29
 AliRsnCutDaughterD0.h:30
 AliRsnCutDaughterD0.h:31
 AliRsnCutDaughterD0.h:32
 AliRsnCutDaughterD0.h:33
 AliRsnCutDaughterD0.h:34
 AliRsnCutDaughterD0.h:35
 AliRsnCutDaughterD0.h:36
 AliRsnCutDaughterD0.h:37
 AliRsnCutDaughterD0.h:38
 AliRsnCutDaughterD0.h:39
 AliRsnCutDaughterD0.h:40
 AliRsnCutDaughterD0.h:41
 AliRsnCutDaughterD0.h:42
 AliRsnCutDaughterD0.h:43
 AliRsnCutDaughterD0.h:44
 AliRsnCutDaughterD0.h:45
 AliRsnCutDaughterD0.h:46
 AliRsnCutDaughterD0.h:47
 AliRsnCutDaughterD0.h:48
 AliRsnCutDaughterD0.h:49
 AliRsnCutDaughterD0.h:50
 AliRsnCutDaughterD0.h:51
 AliRsnCutDaughterD0.h:52
 AliRsnCutDaughterD0.h:53
 AliRsnCutDaughterD0.h:54
 AliRsnCutDaughterD0.h:55
 AliRsnCutDaughterD0.h:56
 AliRsnCutDaughterD0.h:57
 AliRsnCutDaughterD0.h:58
 AliRsnCutDaughterD0.h:59
 AliRsnCutDaughterD0.h:60
 AliRsnCutDaughterD0.h:61
 AliRsnCutDaughterD0.h:62
 AliRsnCutDaughterD0.h:63
 AliRsnCutDaughterD0.h:64
 AliRsnCutDaughterD0.h:65
 AliRsnCutDaughterD0.h:66
 AliRsnCutDaughterD0.h:67
 AliRsnCutDaughterD0.h:68
 AliRsnCutDaughterD0.h:69
 AliRsnCutDaughterD0.h:70
 AliRsnCutDaughterD0.h:71
 AliRsnCutDaughterD0.h:72
 AliRsnCutDaughterD0.h:73
 AliRsnCutDaughterD0.h:74
 AliRsnCutDaughterD0.h:75
 AliRsnCutDaughterD0.h:76
 AliRsnCutDaughterD0.h:77
 AliRsnCutDaughterD0.h:78
 AliRsnCutDaughterD0.h:79
 AliRsnCutDaughterD0.h:80
 AliRsnCutDaughterD0.h:81
 AliRsnCutDaughterD0.h:82
 AliRsnCutDaughterD0.h:83
 AliRsnCutDaughterD0.h:84
 AliRsnCutDaughterD0.h:85
 AliRsnCutDaughterD0.h:86
 AliRsnCutDaughterD0.h:87
 AliRsnCutDaughterD0.h:88
 AliRsnCutDaughterD0.h:89
 AliRsnCutDaughterD0.h:90
 AliRsnCutDaughterD0.h:91
 AliRsnCutDaughterD0.h:92
 AliRsnCutDaughterD0.h:93
 AliRsnCutDaughterD0.h:94
 AliRsnCutDaughterD0.h:95
 AliRsnCutDaughterD0.h:96
 AliRsnCutDaughterD0.h:97
 AliRsnCutDaughterD0.h:98
 AliRsnCutDaughterD0.h:99
 AliRsnCutDaughterD0.h:100
 AliRsnCutDaughterD0.h:101
 AliRsnCutDaughterD0.h:102
 AliRsnCutDaughterD0.h:103
 AliRsnCutDaughterD0.h:104
 AliRsnCutDaughterD0.h:105
 AliRsnCutDaughterD0.h:106
 AliRsnCutDaughterD0.h:107
 AliRsnCutDaughterD0.h:108
 AliRsnCutDaughterD0.h:109
 AliRsnCutDaughterD0.h:110
 AliRsnCutDaughterD0.h:111
 AliRsnCutDaughterD0.h:112