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