1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // Implements the abstract base class AliHFEpidBase
18 // IsInitialized() does the PID decision
21 // Markus Fasel <M.Fasel@gsi.de>
22 // Matus Kalisky <matus.kalisky@cern.ch> (contact)
27 #include "AliAODTrack.h"
28 #include "AliESDtrack.h"
30 #include "AliPIDResponse.h"
31 #include "AliTOFPIDResponse.h"
33 #include "AliHFEdetPIDqa.h"
34 #include "AliHFEpidTOF.h"
35 #include "AliHFEpidQAmanager.h"
38 ClassImp(AliHFEpidTOF)
40 //___________________________________________________________________
41 AliHFEpidTOF::AliHFEpidTOF():
44 , fUseOnlyIfAvailable(kFALSE)
45 , fRejectMismatch(kFALSE)
46 , fGenerateTOFmismatch(kFALSE)
53 memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12);
54 memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12);
57 //___________________________________________________________________
58 AliHFEpidTOF::AliHFEpidTOF(const Char_t *name):
61 , fUseOnlyIfAvailable(kFALSE)
62 , fRejectMismatch(kFALSE)
63 , fGenerateTOFmismatch(kFALSE)
69 memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12);
70 memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12);
74 //___________________________________________________________________
75 AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c):
78 , fUseOnlyIfAvailable(kFALSE)
79 , fRejectMismatch(kFALSE)
80 , fGenerateTOFmismatch(c.fGenerateTOFmismatch)
81 , fNmismatchTracks(c.fNmismatchTracks)
89 //___________________________________________________________________
90 AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){
92 // Assignment operator
101 //___________________________________________________________________
102 AliHFEpidTOF::~AliHFEpidTOF(){
107 //___________________________________________________________________
108 void AliHFEpidTOF::Copy(TObject &ref) const {
110 // Performs the copying of the object
112 AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref);
114 target.fNsigmaTOF = fNsigmaTOF;
115 target.fUseOnlyIfAvailable = fUseOnlyIfAvailable;
116 target.fRejectMismatch = fRejectMismatch;
117 target.fGenerateTOFmismatch = fGenerateTOFmismatch;
118 target.fNmismatchTracks = fNmismatchTracks;
119 memcpy(target.fSigmaBordersTOFLower, fSigmaBordersTOFLower, sizeof(Float_t) * 12);
120 memcpy(target.fSigmaBordersTOFUpper, fSigmaBordersTOFUpper, sizeof(Float_t) * 12);
122 AliHFEpidBase::Copy(ref);
124 //___________________________________________________________________
125 Bool_t AliHFEpidTOF::InitializePID(Int_t /*run*/){
127 // InitializePID: TOF experts have to implement code here
132 //___________________________________________________________________
133 Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const
136 // TOF PID based on n-Sigma cut
137 // Selects Protons and Kaons via n-sigma cut up to 3 GeV/c
138 // In addition histos for n-sigma before (all species) and after (only closest species) are filled
140 if(!fkPIDResponse) return 0;
141 AliDebug(2, "PID object available");
143 const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack());
144 if(!vtrack) return 0;
145 Bool_t hasTOFpid = vtrack->GetStatus() & AliESDtrack::kTOFpid;
146 if(fUseOnlyIfAvailable && !hasTOFpid){
147 AliDebug(2, "No TOF PID, but PID required only if available");
149 } else if(!hasTOFpid){
150 AliDebug(2, "No TOF PID, and TOF PID is required always");
153 AliDebug(2, "Track Has TOF PID");
156 if(IsMismatch(vtrack)) return 0;
159 if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID);
161 // Fill before selection
162 Double_t sigEle = fkPIDResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron);
163 AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle));
165 if(TestBit(kSigmaBand)){
166 Int_t centrality = track->IsPbPb() ? track->GetCentrality() + 1 : 0;
167 AliDebug(2, Form("Centrality: %d\n", centrality));
168 if(centrality > 11) return kFALSE;
169 if(sigEle > fSigmaBordersTOFLower[centrality] && sigEle < fSigmaBordersTOFUpper[centrality]) pdg = 11;
172 if(TMath::Abs(sigEle) < fNsigmaTOF) pdg = 11;
175 if(pdg == 11 && pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID);
179 //___________________________________________________________________
180 void AliHFEpidTOF::SetTOFnSigmaBand(Float_t lower, Float_t upper)
183 // Lower and higher cut independant of the centrality
186 for(Int_t k=0; k < 12; k++) {
187 fSigmaBordersTOFLower[k] = lower;
188 fSigmaBordersTOFUpper[k] = upper;
191 SetBit(kSigmaBand, kTRUE);
194 //___________________________________________________________________
195 void AliHFEpidTOF::SetTOFnSigmaBandCentrality(Float_t lower, Float_t upper, Int_t centralityBin)
198 // Lower and higher cut as function of centrality
201 if(centralityBin < 11) {
202 fSigmaBordersTOFLower[centralityBin+1] = lower;
203 fSigmaBordersTOFUpper[centralityBin+1] = upper;
206 SetBit(kSigmaBand, kTRUE);
210 //___________________________________________________________________
211 Bool_t AliHFEpidTOF::IsMismatch(const AliVTrack * const track) const {
213 // Check for mismatch
215 if(!fkPIDResponse) return kFALSE;
216 Double_t probs[AliPID::kSPECIESC];
217 AliPIDResponse::EDetPidStatus status = fkPIDResponse->ComputeTOFProbability(track, AliPID::kSPECIESC, probs);
218 return status == AliPIDResponse::kDetMismatch;
221 //___________________________________________________________________
222 void AliHFEpidTOF::GenerateTOFmismatch(const AliVTrack * const trk, int ntrk, TArrayD &sigmaEl){
224 // Function generate randomised TOF mismatch hits for a given input track. The number of generated
225 // mismatch tracks is steered by the parameter ntrk. For all mismatch tracks the number of sigmas
226 // to the electron time-of-flight hypothesis is calculated, and the resulting numbers of sigmas
227 // are stored in the array sigmaEl for further processing
229 if(sigmaEl.GetSize() < ntrk) sigmaEl.Set(ntrk);
233 AliVTrack *copytrk(NULL);
234 Bool_t isAOD = kFALSE;
235 if(dynamic_cast<const AliESDtrack *>(trk)){
236 copytrk = new AliESDtrack(*(static_cast<const AliESDtrack *>(trk)));
238 copytrk = new AliAODTrack(*(static_cast<const AliAODTrack *>(trk)));
242 // Generate mismatch values for number of sigmas to the electron hypothesis and store then in the
244 for(int itrk = 0; itrk < ntrk; itrk++){
245 Double_t tofsignal = AliTOFPIDResponse::GetMismatchRandomValue(copytrk->Eta());
247 AliAODTrack *aodtrk = static_cast<AliAODTrack *>(copytrk);
248 AliAODPid *aodpid = aodtrk->GetDetPid();
249 if(aodpid) aodpid->SetTOFsignal(tofsignal);
251 AliESDtrack *esdtrk = static_cast<AliESDtrack *>(copytrk);
252 esdtrk->SetTOFsignal(tofsignal);
254 sigmaEl[itrk] = fkPIDResponse->NumberOfSigmasTOF(copytrk, AliPID::kElectron);