]>
Commit | Line | Data |
---|---|---|
2dab9030 | 1 | // |
2 | // Class AliRsnCutESD2010 | |
3 | // | |
4 | // General implementation of a single cut strategy, which can be: | |
5 | // - a value contained in a given interval [--> IsBetween() ] | |
6 | // - a value equal to a given reference [--> MatchesValue()] | |
7 | // | |
8 | // In all cases, the reference value(s) is (are) given as data members | |
9 | // and each kind of cut requires a given value type (Int, UInt, Double), | |
10 | // but the cut check procedure is then automatized and chosen thanks to | |
11 | // an enumeration of the implemented cut types. | |
12 | // At the end, the user (or any other point which uses this object) has | |
13 | // to use the method IsSelected() to check if this cut has been passed. | |
14 | // | |
15 | // authors: Martin Vala (martin.vala@cern.ch) | |
16 | // Alberto Pulvirenti (alberto.pulvirenti@ct.infn.it) | |
17 | // | |
18 | ||
19 | #include <Riostream.h> | |
20 | ||
21 | #include "AliESDpid.h" | |
22 | #include "AliTOFT0maker.h" | |
23 | #include "AliTOFcalib.h" | |
24 | #include "AliCDBManager.h" | |
25 | #include "AliITSPIDResponse.h" | |
26 | ||
27 | #include "AliRsnEvent.h" | |
28 | #include "AliRsnDaughter.h" | |
29 | #include "AliRsnCutESD2010.h" | |
30 | ||
31 | ClassImp(AliRsnCutESD2010) | |
32 | ||
5faf5a07 | 33 | //Bool_t AliRsnCutESD2010::fgTOFcalibrateESD = kTRUE; |
34 | Bool_t AliRsnCutESD2010::fgTOFcorrectTExp = kTRUE; | |
35 | Bool_t AliRsnCutESD2010::fgTOFuseT0 = kTRUE; | |
36 | Bool_t AliRsnCutESD2010::fgTOFtuneMC = kFALSE; | |
37 | Double_t AliRsnCutESD2010::fgTOFresolution = 100.0; | |
38 | AliTOFT0maker* AliRsnCutESD2010::fgTOFmaker = 0x0; | |
39 | AliTOFcalib* AliRsnCutESD2010::fgTOFcalib = 0x0; | |
40 | Int_t AliRsnCutESD2010::fgLastRun = -1; | |
41 | Int_t AliRsnCutESD2010::fgLastEventID = -1; | |
32992791 | 42 | |
2dab9030 | 43 | //_________________________________________________________________________________________________ |
44 | AliRsnCutESD2010::AliRsnCutESD2010 | |
7ca95a3a | 45 | (const char *name, Bool_t isMC) : |
2dab9030 | 46 | AliRsnCut(name, AliRsnCut::kDaughter, 0.0, 0.0), |
7ca95a3a | 47 | fIsMC(isMC), |
2dab9030 | 48 | fCheckITS(kTRUE), |
49 | fCheckTPC(kTRUE), | |
50 | fCheckTOF(kTRUE), | |
32992791 | 51 | fUseITSTPC(kTRUE), |
35765294 | 52 | fUseITSSA(kTRUE), |
a5ccc095 | 53 | fPID(AliPID::kKaon), |
32992791 | 54 | fMaxITSPIDmom(0.0), |
7ca95a3a | 55 | fMaxITSband(3.0), |
2dab9030 | 56 | fTPCpLimit(0.35), |
7ca95a3a | 57 | fMinTPCband(3.0), |
0359289f | 58 | fMaxTPCband(5.0), |
5faf5a07 | 59 | fESDpid(), |
2dab9030 | 60 | fESDtrackCutsTPC(), |
61 | fESDtrackCutsITS(), | |
5faf5a07 | 62 | fMinTOF(-3.0), |
63 | fMaxTOF( 3.0) | |
2dab9030 | 64 | { |
65 | // | |
66 | // Main constructor. | |
67 | // | |
96e9d35d | 68 | |
7ca95a3a | 69 | SetMC(isMC); |
2dab9030 | 70 | } |
71 | ||
72 | //_________________________________________________________________________________________________ | |
73 | AliRsnCutESD2010::AliRsnCutESD2010 | |
74 | (const AliRsnCutESD2010& copy) : | |
75 | AliRsnCut(copy), | |
8d3d5c36 | 76 | fIsMC(copy.fIsMC), |
2dab9030 | 77 | fCheckITS(copy.fCheckITS), |
78 | fCheckTPC(copy.fCheckTPC), | |
79 | fCheckTOF(copy.fCheckTOF), | |
32992791 | 80 | fUseITSTPC(copy.fUseITSTPC), |
35765294 | 81 | fUseITSSA(copy.fUseITSSA), |
a5ccc095 | 82 | fPID(copy.fPID), |
32992791 | 83 | fMaxITSPIDmom(copy.fMaxITSPIDmom), |
2dab9030 | 84 | fMaxITSband(copy.fMaxITSband), |
85 | fTPCpLimit(copy.fTPCpLimit), | |
86 | fMinTPCband(copy.fMinTPCband), | |
87 | fMaxTPCband(copy.fMaxTPCband), | |
5faf5a07 | 88 | fESDpid(copy.fESDpid), |
2dab9030 | 89 | fESDtrackCutsTPC(copy.fESDtrackCutsTPC), |
90 | fESDtrackCutsITS(copy.fESDtrackCutsITS), | |
0359289f | 91 | fMinTOF(copy.fMinTOF), |
32992791 | 92 | fMaxTOF(copy.fMaxTOF) |
2dab9030 | 93 | { |
94 | // | |
7ca95a3a | 95 | // Copy constructor. |
2dab9030 | 96 | // |
96e9d35d | 97 | |
5faf5a07 | 98 | SetMC(copy.fIsMC); |
99 | ||
96e9d35d | 100 | Int_t i = 0; |
101 | for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; | |
2dab9030 | 102 | } |
103 | ||
104 | //_________________________________________________________________________________________________ | |
7ca95a3a | 105 | AliRsnCutESD2010& AliRsnCutESD2010::operator=(const AliRsnCutESD2010& copy) |
2dab9030 | 106 | { |
107 | // | |
7ca95a3a | 108 | // Assignment operator |
2dab9030 | 109 | // |
c79c04e1 | 110 | |
7ca95a3a | 111 | AliRsnCut::operator=(copy); |
112 | ||
5faf5a07 | 113 | SetMC(copy.fIsMC); |
114 | ||
7ca95a3a | 115 | fCheckITS = copy.fCheckITS; |
116 | fCheckTPC = copy.fCheckTPC; | |
117 | fCheckTOF = copy.fCheckTOF; | |
32992791 | 118 | fUseITSTPC = copy.fUseITSTPC; |
7ca95a3a | 119 | fUseITSSA = copy.fUseITSSA; |
a5ccc095 | 120 | fPID = copy.fPID; |
32992791 | 121 | fMaxITSPIDmom = copy.fMaxITSPIDmom; |
7ca95a3a | 122 | fMaxITSband = copy.fMaxITSband; |
123 | fTPCpLimit = copy.fTPCpLimit; | |
124 | fMinTPCband = copy.fMinTPCband; | |
125 | fMaxTPCband = copy.fMaxTPCband; | |
7ca95a3a | 126 | fMinTOF = copy.fMinTOF; |
127 | fMaxTOF = copy.fMaxTOF; | |
5faf5a07 | 128 | fESDpid = copy.fESDpid; |
7ca95a3a | 129 | |
130 | Int_t i = 0; | |
131 | for (i = 0; i < 5; i++) fTPCpar[i] = copy.fTPCpar[i]; | |
132 | ||
32992791 | 133 | |
5faf5a07 | 134 | fESDtrackCutsTPC = copy.fESDtrackCutsTPC; |
135 | fESDtrackCutsITS = copy.fESDtrackCutsITS; | |
52944696 | 136 | |
7ca95a3a | 137 | return (*this); |
138 | } | |
0359289f | 139 | |
7ca95a3a | 140 | //_________________________________________________________________________________________________ |
141 | void AliRsnCutESD2010::SetMC(Bool_t isMC) | |
142 | { | |
143 | // | |
144 | // Sets some aspects of cuts depending on the fact that runs on MC or not | |
145 | // | |
0359289f | 146 | |
7ca95a3a | 147 | fIsMC = isMC; |
148 | ||
5faf5a07 | 149 | AliITSPIDResponse itsresponse(fIsMC); |
150 | fESDpid.GetITSResponse() = itsresponse; | |
151 | ||
7ca95a3a | 152 | if (isMC) |
c79c04e1 | 153 | { |
5faf5a07 | 154 | //fgTOFcalibrateESD = kFALSE; |
155 | fgTOFtuneMC = kTRUE; | |
c79c04e1 | 156 | } |
157 | else | |
158 | { | |
5faf5a07 | 159 | //fgTOFcalibrateESD = kTRUE; |
160 | fgTOFtuneMC = kFALSE; | |
c79c04e1 | 161 | } |
2dab9030 | 162 | } |
163 | ||
164 | //_________________________________________________________________________________________________ | |
5faf5a07 | 165 | void AliRsnCutESD2010::ProcessEvent(AliESDEvent *esd) |
2dab9030 | 166 | { |
5faf5a07 | 167 | // get current run |
2dab9030 | 168 | Int_t run = esd->GetRunNumber(); |
5faf5a07 | 169 | |
170 | // if the run number has changed, update it now and give a message | |
32992791 | 171 | if (run != fgLastRun) |
2dab9030 | 172 | { |
32992791 | 173 | AliInfo("============================================================================================"); |
174 | AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", fgLastRun, run)); | |
175 | AliInfo("============================================================================================"); | |
176 | fgLastRun = run; | |
32992791 | 177 | |
5faf5a07 | 178 | AliCDBManager::Instance()->SetDefaultStorage("raw://"); |
179 | AliCDBManager::Instance()->SetRun(fgLastRun); | |
180 | ||
181 | if (fgTOFmaker) delete fgTOFmaker; | |
182 | if (fgTOFcalib) delete fgTOFcalib; | |
183 | ||
184 | fgTOFcalib = new AliTOFcalib(); | |
185 | if (fIsMC) | |
186 | { | |
187 | fgTOFcalib->SetRemoveMeanT0(kFALSE); | |
188 | fgTOFcalib->SetCalibrateTOFsignal(kFALSE); | |
189 | } | |
190 | else | |
191 | { | |
192 | fgTOFcalib->SetRemoveMeanT0(kTRUE); | |
193 | fgTOFcalib->SetCalibrateTOFsignal(kTRUE); | |
194 | } | |
195 | if (fgTOFcorrectTExp) fgTOFcalib->SetCorrectTExp(kTRUE); | |
196 | fgTOFcalib->Init(); | |
32992791 | 197 | |
5faf5a07 | 198 | fgTOFmaker = new AliTOFT0maker(&fESDpid, fgTOFcalib); |
199 | fgTOFmaker->SetTimeResolution(fgTOFresolution); | |
32992791 | 200 | } |
5faf5a07 | 201 | |
202 | /*if (fgTOFcalibrateESD)*/ fgTOFcalib->CalibrateESD(esd); | |
203 | if (fgTOFtuneMC) fgTOFmaker->TuneForMC(esd); | |
204 | if (fgTOFuseT0) | |
2dab9030 | 205 | { |
5faf5a07 | 206 | fgTOFmaker->ComputeT0TOF(esd); |
207 | fgTOFmaker->ApplyT0TOF(esd); | |
208 | fESDpid.MakePID(esd, kFALSE, 0.); | |
2dab9030 | 209 | } |
210 | } | |
211 | ||
212 | //_________________________________________________________________________________________________ | |
32992791 | 213 | Bool_t AliRsnCutESD2010::IsSelected(TObject *object) |
2dab9030 | 214 | { |
215 | // | |
216 | // Cut checker. | |
217 | // | |
218 | ||
219 | // coherence check: require an ESD track | |
32992791 | 220 | AliRsnDaughter *daughter = dynamic_cast<AliRsnDaughter*>(object); |
2dab9030 | 221 | if (!daughter) return kFALSE; |
222 | AliESDtrack *track = daughter->GetRefESDtrack(); | |
223 | if (!track) return kFALSE; | |
0359289f | 224 | |
2dab9030 | 225 | // if no reference event, skip |
5faf5a07 | 226 | AliRsnEvent *rsn = AliRsnTarget::GetCurrentEvent(); |
227 | if (!rsn) return kFALSE; | |
228 | if (fgLastEventID != rsn->GetLocalID()) | |
229 | { | |
230 | ProcessEvent(rsn->GetRefESD()); | |
231 | fgLastEventID = rsn->GetLocalID(); | |
232 | } | |
0359289f | 233 | |
32992791 | 234 | // check quality and track type and reject tracks not passing this step |
235 | if (!OkQuality(track)) | |
7ca95a3a | 236 | { |
32992791 | 237 | AliDebug(AliLog::kDebug+2, "Failed quality cut"); |
7ca95a3a | 238 | return kFALSE; |
239 | } | |
0359289f | 240 | |
32992791 | 241 | // ITS PID can be checked always |
242 | // if PID is not required, the flag is sed as | |
243 | // if the cut was alsways passed | |
244 | Bool_t okITSpid = OkITSPID(track); | |
245 | if (!fCheckITS) okITSpid = kTRUE; | |
246 | ||
247 | // TPC PID can be checked only for TPC+ITS tracks | |
248 | // if PID is not required, the flag is sed as | |
249 | // if the cut was alsways passed | |
250 | Bool_t okTPCpid = kFALSE; | |
251 | if (IsITSTPC(track)) okTPCpid = OkTPCPID(track); | |
252 | if (!fCheckTPC) okTPCpid = kTRUE; | |
0359289f | 253 | |
32992791 | 254 | // TOF PID can be checked only if TOF is matched |
255 | // if PID is not required, the flag is sed as | |
256 | // if the cut was alsways passed | |
257 | Bool_t okTOFpid = kFALSE; | |
258 | if (IsITSTPC(track) && MatchTOF(track)) okTOFpid = OkTOFPID(track); | |
259 | if (!fCheckTOF) okTOFpid = kTRUE; | |
2dab9030 | 260 | |
32992791 | 261 | // now combine all outcomes according to the different possibilities: |
262 | // -- ITS standalone: | |
263 | // --> only ITS PID, always | |
264 | // -- ITS + TPC: | |
265 | // --> ITS PID, only for momenta lower than 'fMaxITSPIDmom' and when the ITSpid flag is active | |
266 | // --> TPC PID, always --> MASTER (first to be checked, if fails, track is rejected) | |
267 | // --> TOF PID, only if matched | |
268 | if (IsITSSA(track)) | |
2dab9030 | 269 | { |
32992791 | 270 | if (!okITSpid) |
2dab9030 | 271 | { |
32992791 | 272 | AliDebug(AliLog::kDebug+2, "ITS standalone track --> ITS PID failed"); |
273 | return kFALSE; | |
7ca95a3a | 274 | } |
32992791 | 275 | } |
276 | else // checking IsITSTPC() is redundant due to OkQuality() cut check | |
277 | { | |
278 | if (!okTPCpid) | |
7ca95a3a | 279 | { |
32992791 | 280 | AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TPC PID failed"); |
281 | return kFALSE; | |
2dab9030 | 282 | } |
32992791 | 283 | else if (MatchTOF(track) && !okTOFpid) |
2dab9030 | 284 | { |
32992791 | 285 | AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TOF matched but TOF PID failed"); |
286 | return kFALSE; | |
0d73200d | 287 | } |
32992791 | 288 | else if (track->IsOn(AliESDtrack::kITSpid) && track->P() <= fMaxITSPIDmom && !okITSpid) |
0d73200d | 289 | { |
32992791 | 290 | AliDebug(AliLog::kDebug+2, Form("ITS+TPC track --> Momentum lower than limit (%.2f) and ITS PID failed", fMaxITSPIDmom)); |
291 | return kFALSE; | |
2dab9030 | 292 | } |
293 | } | |
32992791 | 294 | |
295 | // arriving here, the track has survived all checks | |
296 | return kTRUE; | |
297 | } | |
298 | ||
299 | //______________________________________________________________________________ | |
300 | Bool_t AliRsnCutESD2010::OkQuality(AliESDtrack *track) | |
301 | { | |
302 | // | |
303 | // Check track quality parameters. | |
304 | // Rejects all tracks which are not either TPC+ITS nor ITS standalone. | |
305 | // If tracks of any type are not flagged to be used, they are rejected anyway. | |
306 | // | |
307 | ||
308 | if (IsITSTPC(track)) return (fUseITSTPC && fESDtrackCutsTPC.IsSelected(track)); | |
309 | if (IsITSSA (track)) return (fUseITSSA && fESDtrackCutsITS.IsSelected(track)); | |
310 | ||
311 | return kFALSE; | |
312 | } | |
0359289f | 313 | |
32992791 | 314 | //______________________________________________________________________________ |
315 | Bool_t AliRsnCutESD2010::OkITSPID (AliESDtrack *track) | |
316 | { | |
317 | // | |
318 | // Check ITS particle identification with 3sigma cut | |
319 | // | |
320 | ||
321 | // count PID layers and reject if they are too few | |
322 | Int_t k, nITSpidLayers = 0; | |
323 | UChar_t itsCluMap = track->GetITSClusterMap(); | |
324 | for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITSpidLayers; | |
325 | if (nITSpidLayers < 3) | |
326 | { | |
327 | AliDebug(AliLog::kDebug+2, "Rejecting track with too few ITS pid layers"); | |
328 | return kFALSE; | |
7ca95a3a | 329 | } |
32992791 | 330 | |
331 | // check the track type (ITS+TPC or ITS standalone) | |
332 | // and reject it if it is of none of the allowed types | |
333 | Bool_t isSA = kFALSE; | |
334 | if (IsITSTPC(track)) isSA = kFALSE; | |
335 | else if (IsITSSA(track)) isSA = kTRUE; | |
7ca95a3a | 336 | else |
337 | { | |
32992791 | 338 | AliWarning("Track is neither ITS+TPC nor ITS standalone"); |
7ca95a3a | 339 | return kFALSE; |
2dab9030 | 340 | } |
32992791 | 341 | |
342 | // create the PID response object and compute nsigma | |
5faf5a07 | 343 | AliITSPIDResponse &itsrsp = fESDpid.GetITSResponse(); |
32992791 | 344 | Double_t mom = track->P(); |
345 | Double_t nSigma = itsrsp.GetNumberOfSigmas(mom, track->GetITSsignal(), fPID, nITSpidLayers, isSA); | |
346 | ||
347 | // evaluate the cut | |
348 | Bool_t ok = (TMath::Abs(nSigma) <= fMaxITSband); | |
349 | ||
350 | // debug message | |
351 | AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", nSigma, fMaxITSband, (ok ? "passed" : "failed"))); | |
352 | ||
353 | // outcome | |
354 | return ok; | |
355 | } | |
356 | ||
357 | //______________________________________________________________________________ | |
358 | Bool_t AliRsnCutESD2010::OkTPCPID (AliESDtrack *track) | |
359 | { | |
360 | // | |
361 | // Check TPC particle identification with {3|5}sigmacut, | |
362 | // depending on the track total momentum. | |
363 | // | |
364 | ||
365 | // setup TPC PID response | |
5faf5a07 | 366 | AliTPCPIDResponse &tpcrsp = fESDpid.GetTPCResponse(); |
367 | //tpcrsp.SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]); | |
32992791 | 368 | |
369 | // get momentum and number of sigmas and choose the reference band | |
370 | Double_t mom = track->GetInnerParam()->P(); | |
371 | Double_t nSigma = tpcrsp.GetNumberOfSigmas(mom, track->GetTPCsignal(), track->GetTPCsignalN(), fPID); | |
372 | Double_t maxNSigma = fMaxTPCband; | |
373 | if (mom < fTPCpLimit) maxNSigma = fMinTPCband; | |
374 | ||
375 | // evaluate the cut | |
376 | Bool_t ok = (TMath::Abs(nSigma) <= maxNSigma); | |
377 | ||
378 | // debug message | |
379 | AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", nSigma, maxNSigma, (ok ? "passed" : "failed"))); | |
380 | ||
381 | // outcome | |
382 | return ok; | |
383 | } | |
384 | ||
385 | //______________________________________________________________________________ | |
386 | Bool_t AliRsnCutESD2010::OkTOFPID (AliESDtrack *track) | |
387 | { | |
388 | // | |
389 | // Check TOF particle identification if matched there. | |
390 | // | |
391 | ||
5faf5a07 | 392 | // reject not TOF-matched tracks |
393 | if (!MatchTOF(track)) return kFALSE; | |
32992791 | 394 | |
395 | // setup TOF PID response | |
5faf5a07 | 396 | AliTOFPIDResponse &tofrsp = fESDpid.GetTOFResponse(); |
32992791 | 397 | |
398 | // get info for computation | |
399 | Double_t momentum = track->P(); | |
400 | Double_t time = track->GetTOFsignal(); | |
401 | Double_t timeint[AliPID::kSPECIES]; | |
402 | tofrsp.GetStartTime(momentum); | |
403 | track->GetIntegratedTimes(timeint); | |
404 | ||
405 | // check the cut | |
406 | Double_t timeDiff = time - timeint[(Int_t)fPID]; | |
407 | Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)fPID], AliPID::ParticleMass(fPID)); | |
408 | Double_t nSigma = timeDiff / sigmaRef; | |
409 | ||
410 | // evaluate the cut | |
411 | Bool_t ok = (nSigma >= fMinTOF && nSigma <= fMaxTOF); | |
412 | ||
413 | // debug message | |
414 | AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed"))); | |
415 | ||
416 | // outcome | |
417 | return ok; | |
2dab9030 | 418 | } |
aa24e021 | 419 | |
420 | //_________________________________________________________________________________________________ | |
421 | void AliRsnCutESD2010::Print(const Option_t *) const | |
422 | { | |
423 | // | |
424 | // Print information on this cut | |
425 | // | |
426 | ||
427 | AliInfo(Form("Cut name : %s", GetName())); | |
428 | AliInfo(Form("Using MC settings : %s", (fIsMC ? "YES" : "NO"))); | |
429 | AliInfo(Form("Using TPC+ITS tracks : %s", (fUseITSTPC ? "YES" : "NO"))); | |
430 | AliInfo(Form("Using ITS SA tracks : %s", (fUseITSSA ? "YES" : "NO"))); | |
431 | AliInfo(Form("Check ITS PID : %s", (fCheckITS ? "YES" : "NO"))); | |
432 | AliInfo(Form("Check TPC PID : %s", (fCheckTPC ? "YES" : "NO"))); | |
433 | AliInfo(Form("Check TOF PID : %s", (fCheckTOF ? "YES" : "NO"))); | |
434 | AliInfo(Form("Reference particle : %s", AliPID::ParticleName(fPID))); | |
435 | AliInfo(Form("ITS PID range (sigmas): %f", fMaxITSband)); | |
436 | AliInfo(Form("ITS PID range (pt) : %f", fMaxITSPIDmom)); | |
437 | AliInfo(Form("TPC PID ranges (sigmas): %f %f", fMinTPCband, fMaxTPCband)); | |
438 | AliInfo(Form("TPC PID limit (p) : %f", fTPCpLimit)); | |
5faf5a07 | 439 | AliInfo(Form("TOF resolution : %f", fgTOFresolution)); |
aa24e021 | 440 | AliInfo(Form("TOF range (sigmas) : %f - %f", fMinTOF, fMaxTOF)); |
5faf5a07 | 441 | AliInfo(Form("TOF PID tuning from MC : %s", (fgTOFtuneMC ? "YES" : "NO"))); |
aa24e021 | 442 | } |