]>
Commit | Line | Data |
---|---|---|
809a4336 | 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 | **************************************************************************/ | |
50685501 | 15 | // |
16 | // Class for TOF PID | |
17 | // Implements the abstract base class AliHFEpidBase | |
18 | // IsInitialized() does the PID decision | |
19 | // | |
20 | // Authors: | |
21 | // Markus Fasel <M.Fasel@gsi.de> | |
22 | // Matus Kalisky <matus.kalisky@cern.ch> (contact) | |
23 | // | |
809a4336 | 24 | |
809a4336 | 25 | #include <TMath.h> |
26 | ||
722347d8 | 27 | #include "AliAODTrack.h" |
809a4336 | 28 | #include "AliESDtrack.h" |
809a4336 | 29 | #include "AliPID.h" |
8c1c76e9 | 30 | #include "AliPIDResponse.h" |
ff8249bd | 31 | #include "AliTOFPIDResponse.h" |
809a4336 | 32 | |
3a72645a | 33 | #include "AliHFEdetPIDqa.h" |
809a4336 | 34 | #include "AliHFEpidTOF.h" |
3a72645a | 35 | #include "AliHFEpidQAmanager.h" |
809a4336 | 36 | |
37 | ||
38 | ClassImp(AliHFEpidTOF) | |
3a72645a | 39 | |
40 | //___________________________________________________________________ | |
41 | AliHFEpidTOF::AliHFEpidTOF(): | |
42 | AliHFEpidBase() | |
3a72645a | 43 | , fNsigmaTOF(3) |
4437a0d2 | 44 | , fUseOnlyIfAvailable(kFALSE) |
45 | , fRejectMismatch(kFALSE) | |
ff8249bd | 46 | , fGenerateTOFmismatch(kFALSE) |
47 | , fNmismatchTracks(0) | |
3a72645a | 48 | { |
49 | // | |
50 | // Constructor | |
51 | // | |
11ff28c5 | 52 | |
5cd679b7 | 53 | memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12); |
54 | memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12); | |
3a72645a | 55 | } |
56 | ||
809a4336 | 57 | //___________________________________________________________________ |
58 | AliHFEpidTOF::AliHFEpidTOF(const Char_t *name): | |
59 | AliHFEpidBase(name) | |
9bcfd1ab | 60 | , fNsigmaTOF(3) |
4437a0d2 | 61 | , fUseOnlyIfAvailable(kFALSE) |
62 | , fRejectMismatch(kFALSE) | |
ff8249bd | 63 | , fGenerateTOFmismatch(kFALSE) |
64 | , fNmismatchTracks(0) | |
809a4336 | 65 | { |
66 | // | |
67 | // Constructor | |
68 | // | |
5cd679b7 | 69 | memset(fSigmaBordersTOFLower, 0, sizeof(Float_t) * 12); |
70 | memset(fSigmaBordersTOFUpper, 0, sizeof(Float_t) * 12); | |
3024f297 | 71 | |
809a4336 | 72 | } |
3a72645a | 73 | |
809a4336 | 74 | //___________________________________________________________________ |
75 | AliHFEpidTOF::AliHFEpidTOF(const AliHFEpidTOF &c): | |
76 | AliHFEpidBase("") | |
9bcfd1ab | 77 | , fNsigmaTOF(3) |
4437a0d2 | 78 | , fUseOnlyIfAvailable(kFALSE) |
79 | , fRejectMismatch(kFALSE) | |
ff8249bd | 80 | , fGenerateTOFmismatch(c.fGenerateTOFmismatch) |
81 | , fNmismatchTracks(c.fNmismatchTracks) | |
809a4336 | 82 | { |
83 | // | |
84 | // Copy operator | |
85 | // | |
86 | ||
87 | c.Copy(*this); | |
88 | } | |
89 | //___________________________________________________________________ | |
90 | AliHFEpidTOF &AliHFEpidTOF::operator=(const AliHFEpidTOF &ref){ | |
91 | // | |
92 | // Assignment operator | |
93 | // | |
94 | ||
95 | if(this != &ref){ | |
96 | ref.Copy(*this); | |
97 | } | |
98 | ||
99 | return *this; | |
100 | } | |
101 | //___________________________________________________________________ | |
102 | AliHFEpidTOF::~AliHFEpidTOF(){ | |
103 | // | |
104 | // Destructor | |
105 | // | |
809a4336 | 106 | } |
107 | //___________________________________________________________________ | |
108 | void AliHFEpidTOF::Copy(TObject &ref) const { | |
109 | // | |
110 | // Performs the copying of the object | |
111 | // | |
112 | AliHFEpidTOF &target = dynamic_cast<AliHFEpidTOF &>(ref); | |
113 | ||
e3fc062d | 114 | target.fNsigmaTOF = fNsigmaTOF; |
4437a0d2 | 115 | target.fUseOnlyIfAvailable = fUseOnlyIfAvailable; |
116 | target.fRejectMismatch = fRejectMismatch; | |
ff8249bd | 117 | target.fGenerateTOFmismatch = fGenerateTOFmismatch; |
118 | target.fNmismatchTracks = fNmismatchTracks; | |
5cd679b7 | 119 | memcpy(target.fSigmaBordersTOFLower, fSigmaBordersTOFLower, sizeof(Float_t) * 12); |
120 | memcpy(target.fSigmaBordersTOFUpper, fSigmaBordersTOFUpper, sizeof(Float_t) * 12); | |
809a4336 | 121 | |
122 | AliHFEpidBase::Copy(ref); | |
123 | } | |
124 | //___________________________________________________________________ | |
8c1c76e9 | 125 | Bool_t AliHFEpidTOF::InitializePID(Int_t /*run*/){ |
809a4336 | 126 | // |
127 | // InitializePID: TOF experts have to implement code here | |
128 | // | |
129 | return kTRUE; | |
130 | } | |
131 | ||
132 | //___________________________________________________________________ | |
6555e2ad | 133 | Int_t AliHFEpidTOF::IsSelected(const AliHFEpidObject *track, AliHFEpidQAmanager *pidqa) const |
809a4336 | 134 | { |
faee3b18 | 135 | // |
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 | |
139 | // | |
8c1c76e9 | 140 | if(!fkPIDResponse) return 0; |
3a72645a | 141 | AliDebug(2, "PID object available"); |
e3fc062d | 142 | |
bf892a6a | 143 | const AliVTrack *vtrack = dynamic_cast<const AliVTrack *>(track->GetRecTrack()); |
4437a0d2 | 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"); | |
148 | return 11; | |
149 | } else if(!hasTOFpid){ | |
150 | AliDebug(2, "No TOF PID, and TOF PID is required always"); | |
151 | return 0; | |
152 | } | |
3a72645a | 153 | AliDebug(2, "Track Has TOF PID"); |
154 | ||
4437a0d2 | 155 | if(fRejectMismatch){ |
156 | if(IsMismatch(vtrack)) return 0; | |
157 | } | |
158 | ||
3a72645a | 159 | if(pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kBeforePID); |
faee3b18 | 160 | |
161 | // Fill before selection | |
8c1c76e9 | 162 | Double_t sigEle = fkPIDResponse->NumberOfSigmasTOF(track->GetRecTrack(), AliPID::kElectron); |
3a72645a | 163 | AliDebug(2, Form("Number of sigmas in TOF: %f", sigEle)); |
faee3b18 | 164 | Int_t pdg = 0; |
11ff28c5 | 165 | if(TestBit(kSigmaBand)){ |
5cd679b7 | 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; | |
11ff28c5 | 170 | } else { |
171 | // Fixed nsigma cut | |
172 | if(TMath::Abs(sigEle) < fNsigmaTOF) pdg = 11; | |
faee3b18 | 173 | } |
11ff28c5 | 174 | |
175 | if(pdg == 11 && pidqa) pidqa->ProcessTrack(track, AliHFEpid::kTOFpid, AliHFEdetPIDqa::kAfterPID); | |
faee3b18 | 176 | |
177 | return pdg; | |
178 | } | |
5cd679b7 | 179 | //___________________________________________________________________ |
959ea9d8 | 180 | void AliHFEpidTOF::SetTOFnSigmaBand(Float_t lower, Float_t upper) |
181 | { | |
182 | // | |
183 | // Lower and higher cut independant of the centrality | |
184 | // | |
185 | ||
186 | for(Int_t k=0; k < 12; k++) { | |
187 | fSigmaBordersTOFLower[k] = lower; | |
188 | fSigmaBordersTOFUpper[k] = upper; | |
189 | } | |
190 | ||
191 | SetBit(kSigmaBand, kTRUE); | |
192 | ||
193 | } | |
194 | //___________________________________________________________________ | |
5cd679b7 | 195 | void AliHFEpidTOF::SetTOFnSigmaBandCentrality(Float_t lower, Float_t upper, Int_t centralityBin) |
196 | { | |
197 | // | |
198 | // Lower and higher cut as function of centrality | |
199 | // | |
200 | ||
201 | if(centralityBin < 11) { | |
202 | fSigmaBordersTOFLower[centralityBin+1] = lower; | |
203 | fSigmaBordersTOFUpper[centralityBin+1] = upper; | |
204 | } | |
205 | ||
206 | SetBit(kSigmaBand, kTRUE); | |
207 | ||
208 | } | |
722347d8 | 209 | |
4437a0d2 | 210 | //___________________________________________________________________ |
211 | Bool_t AliHFEpidTOF::IsMismatch(const AliVTrack * const track) const { | |
212 | // | |
213 | // Check for mismatch | |
214 | // | |
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; | |
219 | } | |
ff8249bd | 220 | |
221 | //___________________________________________________________________ | |
222 | void AliHFEpidTOF::GenerateTOFmismatch(const AliVTrack * const trk, int ntrk, TArrayD &sigmaEl){ | |
223 | // | |
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 | |
228 | // | |
229 | if(sigmaEl.GetSize() < ntrk) sigmaEl.Set(ntrk); | |
230 | sigmaEl.Reset(); | |
231 | ||
232 | // work on copy | |
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))); | |
237 | } else { | |
238 | copytrk = new AliAODTrack(*(static_cast<const AliAODTrack *>(trk))); | |
239 | isAOD = kTRUE; | |
240 | } | |
241 | ||
242 | // Generate mismatch values for number of sigmas to the electron hypothesis and store then in the | |
243 | // output array | |
244 | for(int itrk = 0; itrk < ntrk; itrk++){ | |
245 | Double_t tofsignal = AliTOFPIDResponse::GetMismatchRandomValue(copytrk->Eta()); | |
246 | if(isAOD){ | |
247 | AliAODTrack *aodtrk = static_cast<AliAODTrack *>(copytrk); | |
248 | AliAODPid *aodpid = aodtrk->GetDetPid(); | |
249 | if(aodpid) aodpid->SetTOFsignal(tofsignal); | |
250 | } else { | |
251 | AliESDtrack *esdtrk = static_cast<AliESDtrack *>(copytrk); | |
252 | esdtrk->SetTOFsignal(tofsignal); | |
253 | } | |
254 | sigmaEl[itrk] = fkPIDResponse->NumberOfSigmasTOF(copytrk, AliPID::kElectron); | |
255 | } | |
256 | delete copytrk; | |
257 | } |