]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PWGHF/hfe/AliHFEpidTOF.cxx
Update of the hfe package from gsi svn
[u/mrichter/AliRoot.git] / PWGHF / hfe / AliHFEpidTOF.cxx
index f22faa4690432127d776f9eb847afb6f90e00638..96ef3a964c23540b76268c4bb09df0315c62645b 100644 (file)
@@ -28,6 +28,7 @@
 #include "AliESDtrack.h"
 #include "AliPID.h"
 #include "AliPIDResponse.h"
+#include "AliTOFPIDResponse.h"
 
 #include "AliHFEdetPIDqa.h"
 #include "AliHFEpidTOF.h"
@@ -40,6 +41,10 @@ ClassImp(AliHFEpidTOF)
 AliHFEpidTOF::AliHFEpidTOF():
   AliHFEpidBase()
   , fNsigmaTOF(3)
+  , fUseOnlyIfAvailable(kFALSE)
+  , fRejectMismatch(kFALSE)
+  , fGenerateTOFmismatch(kFALSE)
+  , fNmismatchTracks(0)
 {
   //
   // Constructor
@@ -53,6 +58,10 @@ AliHFEpidTOF::AliHFEpidTOF():
 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
   AliHFEpidBase(name)
   , fNsigmaTOF(3)
+  , fUseOnlyIfAvailable(kFALSE)
+  , fRejectMismatch(kFALSE)
+  , fGenerateTOFmismatch(kFALSE)
+  , fNmismatchTracks(0)
 {
   //
   // Constructor
@@ -66,6 +75,10 @@ AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
   AliHFEpidBase("")
   , fNsigmaTOF(3)
+  , fUseOnlyIfAvailable(kFALSE)
+  , fRejectMismatch(kFALSE)
+  , fGenerateTOFmismatch(c.fGenerateTOFmismatch)
+  , fNmismatchTracks(c.fNmismatchTracks)
 {  
   // 
   // Copy operator
@@ -99,6 +112,10 @@ void AliHFEpidTOF::Copy(TObject &ref) const {
   AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
 
   target.fNsigmaTOF = fNsigmaTOF;
+  target.fUseOnlyIfAvailable = fUseOnlyIfAvailable;
+  target.fRejectMismatch = fRejectMismatch;
+  target.fGenerateTOFmismatch = fGenerateTOFmismatch;
+  target.fNmismatchTracks = fNmismatchTracks;
   memcpy(target.fSigmaBordersTOFLower, fSigmaBordersTOFLower, sizeof(Float_t) * 12);
   memcpy(target.fSigmaBordersTOFUpper, fSigmaBordersTOFUpper, sizeof(Float_t) * 12);
 
@@ -124,9 +141,21 @@ Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager
   AliDebug(2, "PID object available");
 
   const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
-  if(!(vtrack && (vtrack->GetStatus() & AliESDtrack::kTOFpid))) return 0;
+  if(!vtrack) return 0;
+  Bool_t hasTOFpid = vtrack->GetStatus() & AliESDtrack::kTOFpid;
+  if(fUseOnlyIfAvailable && !hasTOFpid){
+    AliDebug(2, "No TOF PID, but PID required only if available");
+    return 11;   
+  } else if(!hasTOFpid){
+    AliDebug(2, "No TOF PID, and TOF PID is required always");
+    return 0;
+  }
   AliDebug(2, "Track Has TOF PID");
 
+  if(fRejectMismatch){
+    if(IsMismatch(vtrack)) return 0;
+  }
+
   if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
 
   // Fill before selection
@@ -148,6 +177,21 @@ Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager
   return pdg;
 }
 //___________________________________________________________________
+void AliHFEpidTOF::SetTOFnSigmaBand(Float_t lower, Float_t upper)
+{
+  //
+  // Lower and higher cut independant of the centrality
+  //
+
+  for(Int_t k=0; k < 12; k++) {
+    fSigmaBordersTOFLower[k] = lower;
+    fSigmaBordersTOFUpper[k] = upper;
+  }
+
+  SetBit(kSigmaBand, kTRUE);
+
+}
+//___________________________________________________________________
 void AliHFEpidTOF::SetTOFnSigmaBandCentrality(Float_t lower, Float_t upper, Int_t centralityBin)
 {
   //
@@ -163,3 +207,51 @@ void AliHFEpidTOF::SetTOFnSigmaBandCentrality(Float_t lower, Float_t upper, Int_
 
 }
 
+//___________________________________________________________________
+Bool_t AliHFEpidTOF::IsMismatch(const AliVTrack * const track) const {
+  //
+  // Check for mismatch
+  //
+  if(!fkPIDResponse) return kFALSE;
+  Double_t probs[AliPID::kSPECIESC];
+  AliPIDResponse::EDetPidStatus status = fkPIDResponse->ComputeTOFProbability(track, AliPID::kSPECIESC, probs);
+  return status == AliPIDResponse::kDetMismatch;
+}
+
+//___________________________________________________________________
+void AliHFEpidTOF::GenerateTOFmismatch(const AliVTrack * const trk, int ntrk, TArrayD &sigmaEl){
+  //
+  // Function generate randomised TOF mismatch hits for a given input track. The number of generated
+  // mismatch tracks is steered by the parameter ntrk. For all mismatch tracks the number of sigmas
+  // to the electron time-of-flight hypothesis is calculated, and the resulting numbers of sigmas
+  // are stored in the array sigmaEl for further processing
+  //
+  if(sigmaEl.GetSize() < ntrk) sigmaEl.Set(ntrk);
+  sigmaEl.Reset();
+
+  // work on copy
+  AliVTrack *copytrk(NULL);
+  Bool_t isAOD = kFALSE;
+  if(dynamic_cast<const AliESDtrack *>(trk)){
+    copytrk = new AliESDtrack(*(static_cast<const AliESDtrack *>(trk)));
+  } else {
+    copytrk = new AliAODTrack(*(static_cast<const AliAODTrack *>(trk)));
+    isAOD = kTRUE;
+  }
+
+  // Generate mismatch values for number of sigmas to the electron hypothesis and store then in the 
+  // output array
+  for(int itrk = 0; itrk < ntrk; itrk++){
+    Double_t tofsignal = AliTOFPIDResponse::GetMismatchRandomValue(copytrk->Eta());
+    if(isAOD){
+      AliAODTrack *aodtrk = static_cast<AliAODTrack *>(copytrk);
+      AliAODPid *aodpid = aodtrk->GetDetPid();
+      if(aodpid) aodpid->SetTOFsignal(tofsignal);
+    } else {
+      AliESDtrack *esdtrk = static_cast<AliESDtrack *>(copytrk);
+      esdtrk->SetTOFsignal(tofsignal);
+    }
+    sigmaEl[itrk] = fkPIDResponse->NumberOfSigmasTOF(copytrk, AliPID::kElectron);
+  }
+  delete copytrk;
+}