]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/RESONANCES/AliRsnAnalysisPhi7TeV.cxx
Missing macro commented out
[u/mrichter/AliRoot.git] / PWG2 / RESONANCES / AliRsnAnalysisPhi7TeV.cxx
CommitLineData
6279d59e 1//
2// Implementation file for implementation of data analysis aft 900 GeV
3//
4// Author: A. Pulvirenti
5//
6
7#include "Riostream.h"
4c06ce33 8#include <iomanip>
6279d59e 9
10#include "TH1.h"
5faf5a07 11#include "TH3.h"
12#include "TFile.h"
6279d59e 13#include "TTree.h"
14#include "TParticle.h"
15#include "TRandom.h"
16#include "TLorentzVector.h"
17
18#include "AliLog.h"
19#include "AliESDpid.h"
20#include "AliESDEvent.h"
21#include "AliESDVertex.h"
22#include "AliESDtrack.h"
5faf5a07 23#include "AliESDtrackCuts.h"
6279d59e 24#include "AliStack.h"
25#include "AliMCEvent.h"
26#include "AliTOFT0maker.h"
27#include "AliTOFcalib.h"
28#include "AliCDBManager.h"
4c06ce33 29#include "AliITSPIDResponse.h"
6279d59e 30
5faf5a07 31#include "AliRsnEvent.h"
32#include "AliRsnTarget.h"
33#include "AliRsnDaughter.h"
34#include "AliRsnCutESD2010.h"
35
6279d59e 36#include "AliRsnAnalysisPhi7TeV.h"
37
38//__________________________________________________________________________________________________
5faf5a07 39AliRsnAnalysisPhi7TeV::AliRsnAnalysisPhi7TeV(const char *name, Bool_t isMC) :
6279d59e 40 AliAnalysisTaskSE(name),
41 fUseMC(kFALSE),
0d73200d 42 fCheckITS(kTRUE),
43 fCheckTPC(kTRUE),
44 fCheckTOF(kTRUE),
5faf5a07 45 fAddITSSA(kFALSE),
4c06ce33 46 fMaxVz(1E6),
47 fMaxITSband(1E6),
5faf5a07 48 fMaxITSmom(0.0),
4c06ce33 49 fTPCpLimit(0.35),
6279d59e 50 fMinTPCband(-1E6),
51 fMaxTPCband( 1E6),
5faf5a07 52 fMinTOF(-3.0),
53 fMaxTOF( 3.0),
6279d59e 54 fOutList(0x0),
5faf5a07 55 fUnlike(0x0),
56 fLikePP(0x0),
57 fLikeMM(0x0),
58 fTrues(0x0),
6279d59e 59 fHEvents(0x0),
4c06ce33 60 fESDtrackCutsTPC(),
61 fESDtrackCutsITS(),
6279d59e 62 fESDpid(0x0),
63 fTOFmaker(0x0),
64 fTOFcalib(0x0),
5faf5a07 65 fTOFcalibrateESD(!isMC),
66 fTOFcorrectTExp(kTRUE),
67 fTOFuseT0(kTRUE),
68 fTOFtuneMC(isMC),
69 fTOFresolution(100.0),
70 fDaughter(),
71 fRsnCuts()
6279d59e 72{
73//
74// Constructor
75//
76
5faf5a07 77 SetUseMC(isMC);
78 DefineOutput(1, TList::Class());
6279d59e 79}
80
81//__________________________________________________________________________________________________
82AliRsnAnalysisPhi7TeV::AliRsnAnalysisPhi7TeV(const AliRsnAnalysisPhi7TeV& copy) :
83 AliAnalysisTaskSE(copy),
84 fUseMC(copy.fUseMC),
0d73200d 85 fCheckITS(copy.fCheckITS),
86 fCheckTPC(copy.fCheckTPC),
87 fCheckTOF(copy.fCheckTOF),
5faf5a07 88 fAddITSSA(copy.fAddITSSA),
4c06ce33 89 fMaxVz(copy.fMaxVz),
90 fMaxITSband(copy.fMaxITSband),
5faf5a07 91 fMaxITSmom(copy.fMaxITSmom),
4c06ce33 92 fTPCpLimit(copy.fTPCpLimit),
6279d59e 93 fMinTPCband(copy.fMinTPCband),
94 fMaxTPCband(copy.fMaxTPCband),
5faf5a07 95 fMinTOF(copy.fMinTOF),
96 fMaxTOF(copy.fMaxTOF),
6279d59e 97 fOutList(0x0),
5faf5a07 98 fUnlike(0x0),
99 fLikePP(0x0),
100 fLikeMM(0x0),
101 fTrues(0x0),
6279d59e 102 fHEvents(0x0),
4c06ce33 103 fESDtrackCutsTPC(copy.fESDtrackCutsTPC),
104 fESDtrackCutsITS(copy.fESDtrackCutsITS),
6279d59e 105 fESDpid(0x0),
106 fTOFmaker(0x0),
107 fTOFcalib(0x0),
108 fTOFcalibrateESD(kFALSE),
109 fTOFcorrectTExp(kFALSE),
110 fTOFuseT0(kFALSE),
111 fTOFtuneMC(kFALSE),
5faf5a07 112 fTOFresolution(0.0),
113 fDaughter(),
114 fRsnCuts()
6279d59e 115{
116//
117// Copy constructor
118//
5faf5a07 119
120 SetUseMC(copy.fUseMC);
6279d59e 121}
122
123//__________________________________________________________________________________________________
124AliRsnAnalysisPhi7TeV& AliRsnAnalysisPhi7TeV::operator=(const AliRsnAnalysisPhi7TeV& copy)
125{
126//
127// Assignment operator
128//
129
130 fUseMC = copy.fUseMC;
0d73200d 131 fCheckITS = copy.fCheckITS;
132 fCheckTPC = copy.fCheckTPC;
133 fCheckTOF = copy.fCheckTOF;
5faf5a07 134 fAddITSSA = copy.fAddITSSA;
6279d59e 135
4c06ce33 136 fMaxVz = copy.fMaxVz;
137 fMaxITSband = copy.fMaxITSband;
5faf5a07 138 fMaxITSmom = copy.fMaxITSmom;
4c06ce33 139
140 fTPCpLimit = copy.fTPCpLimit;
6279d59e 141 fMinTPCband = copy.fMinTPCband;
142 fMaxTPCband = copy.fMaxTPCband;
143
4c06ce33 144 fESDtrackCutsTPC = copy.fESDtrackCutsTPC;
145 fESDtrackCutsITS = copy.fESDtrackCutsITS;
146
6279d59e 147 fTOFcalibrateESD = copy.fTOFcalibrateESD;
148 fTOFcorrectTExp = copy.fTOFcorrectTExp;
149 fTOFuseT0 = copy.fTOFuseT0;
150 fTOFtuneMC = copy.fTOFtuneMC;
151 fTOFresolution = copy.fTOFresolution;
5faf5a07 152
153 SetUseMC(copy.fUseMC);
6279d59e 154
155 return (*this);
156}
157
158//__________________________________________________________________________________________________
159AliRsnAnalysisPhi7TeV::~AliRsnAnalysisPhi7TeV()
160{
161//
162// Destructor
5faf5a07 163//
164}
165
166//_________________________________________________________________________________________________
167void AliRsnAnalysisPhi7TeV::SetUseMC(Bool_t isMC)
168{
169//
170// Sets some aspects of cuts depending on the fact that runs on MC or not
6279d59e 171//
172
5faf5a07 173 fUseMC = isMC;
174
175 if (isMC)
176 {
177 SetTPCpar(2.15898 / 50.0, 1.75295E1, 3.40030E-9, 1.96178, 3.91720);
178 SetTOFcalibrateESD(kFALSE);
179 SetTOFtuneMC(kTRUE);
180 }
181 else
182 {
183 SetTPCpar(1.41543 / 50.0, 2.63394E1, 5.0411E-11, 2.12543, 4.88663);
184 SetTOFcalibrateESD(kTRUE);
185 SetTOFtuneMC(kFALSE);
186 }
6279d59e 187}
188
189//__________________________________________________________________________________________________
190void AliRsnAnalysisPhi7TeV::UserCreateOutputObjects()
191{
192//
193// Create the output data container
194//
6279d59e 195
196 // initialize random
5faf5a07 197 //gRandom->SetSeed(0);
6279d59e 198
199 // create output trees
200 OpenFile(1);
4c06ce33 201 fOutList = new TList;
5faf5a07 202 fHEvents = new TH1I("hEvents", "Event details", 6, 0, 6);
37dcaaad 203 fVertexX[0] = new TH1F("hVertexTracksX", "X position of primary vertex (tracks)", 200, -2, 2);
204 fVertexY[0] = new TH1F("hVertexTracksY", "Y position of primary vertex (tracks)", 200, -2, 2);
4c06ce33 205 fVertexZ[0] = new TH1F("hVertexTracksZ", "Z position of primary vertex (tracks)", 400, -40, 40);
37dcaaad 206 fVertexX[1] = new TH1F("hVertexSPDX", "X position of primary vertex (SPD)", 200, -2, 2);
207 fVertexY[1] = new TH1F("hVertexSPDY", "Y position of primary vertex (SPD)", 200, -2, 2);
208 fVertexZ[1] = new TH1F("hVertexSPDZ", "Z position of primary vertex (SPD)", 400, -40, 40);
5faf5a07 209 //fUnlike = new TH3F("hPM", "+- pairs", 500, 0.9, 1.4, 100, 0.0, 10.0, 24, -1.2, 1.2);
210 //fLikePP = new TH3F("hPP", "++ pairs", 500, 0.9, 1.4, 100, 0.0, 10.0, 24, -1.2, 1.2);
211 //fLikeMM = new TH3F("hMM", "-- pairs", 500, 0.9, 1.4, 100, 0.0, 10.0, 24, -1.2, 1.2);
212 //fTrues = new TH3F("hTR", "True pairs", 500, 0.9, 1.4, 100, 0.0, 10.0, 24, -1.2, 1.2);
213 TFile *ffile = TFile::Open("template.root");
214 if (ffile)
215 {
216 TH3F *tmp = (TH3F*)ffile->Get("template");
217 fUnlike = (TH3F*)tmp->Clone("hPM");
218 fLikePP = (TH3F*)tmp->Clone("hPP");
219 fLikeMM = (TH3F*)tmp->Clone("hMM");
220 fTrues = (TH3F*)tmp->Clone("hTR");
221 }
4c06ce33 222
223 fHEvents->GetXaxis()->SetBinLabel(1, "Good vertex with tracks");
224 fHEvents->GetXaxis()->SetBinLabel(2, "Good vertex with SPD");
225 fHEvents->GetXaxis()->SetBinLabel(3, "Far vertex with tracks");
226 fHEvents->GetXaxis()->SetBinLabel(4, "Far vertex with SPD");
227 fHEvents->GetXaxis()->SetBinLabel(5, "No good vertex");
5faf5a07 228 fHEvents->GetXaxis()->SetBinLabel(6, "Empty event");
4c06ce33 229
6279d59e 230 fOutList->Add(fHEvents);
4c06ce33 231 fOutList->Add(fVertexX[0]);
232 fOutList->Add(fVertexY[0]);
233 fOutList->Add(fVertexZ[0]);
234 fOutList->Add(fVertexX[1]);
235 fOutList->Add(fVertexY[1]);
236 fOutList->Add(fVertexZ[1]);
5faf5a07 237 fOutList->Add(fUnlike);
238 fOutList->Add(fLikePP);
239 fOutList->Add(fLikeMM);
240 fOutList->Add(fTrues);
241
242 // setup RSN-related objects
243
244 fRsnCuts.SetMC (fUseMC);
245 fRsnCuts.SetCheckITS (fCheckITS);
246 fRsnCuts.SetCheckTPC (fCheckTPC);
247 fRsnCuts.SetCheckTOF (fCheckTOF);
248 fRsnCuts.SetUseITSTPC(kTRUE);
249 fRsnCuts.SetUseITSSA (fAddITSSA);
250 fRsnCuts.SetPID (AliPID::kKaon);
251 fRsnCuts.SetMaxITSPIDmom(fMaxITSmom);
252 fRsnCuts.SetITSband(fMaxITSband);
253 fRsnCuts.SetTPCpLimit(fTPCpLimit);
254 fRsnCuts.SetTPCrange(fMinTPCband, fMaxTPCband);
255 fRsnCuts.SetTPCpar(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]);
256 //fRsnCuts.SetTOFcalibrateESD(fTOFcalibrateESD);
257 fRsnCuts.SetTOFcorrectTExp (fTOFcorrectTExp);
258 fRsnCuts.SetTOFuseT0 (fTOFuseT0);
259 fRsnCuts.SetTOFtuneMC (fTOFtuneMC);
260 fRsnCuts.SetTOFresolution (fTOFresolution);
261 fRsnCuts.SetTOFrange (fMinTOF, fMaxTOF);
262 fRsnCuts.GetCutsTPC()->Copy(fESDtrackCutsTPC);
263 fRsnCuts.GetCutsITS()->Copy(fESDtrackCutsITS);
6279d59e 264}
265
266//__________________________________________________________________________________________________
267void AliRsnAnalysisPhi7TeV::UserExec(Option_t *)
268{
269//
270// Main execution function.
271// Fills the fHEvents data member with the following legenda:
272// 0 -- event OK, prim vertex with tracks
273// 1 -- event OK, prim vertex with SPD
274// 2 -- event OK but vz large
275// 3 -- event bad
276//
277
6279d59e 278 // retrieve ESD event and related stack (if available)
279 AliESDEvent *esd = dynamic_cast<AliESDEvent*>(fInputEvent);
280 AliStack *stack = (fMCEvent ? fMCEvent->Stack() : 0x0);
6279d59e 281
4c06ce33 282 // check the event
283 Int_t eval = EventEval(esd);
284 fHEvents->Fill(eval);
285
286 // if the event is good for analysis, process it
287 if (eval == kGoodTracksPrimaryVertex || eval == kGoodSPDPrimaryVertex)
6279d59e 288 {
4c06ce33 289 ProcessESD(esd, stack);
6279d59e 290 }
291
4c06ce33 292 // update histogram container
5faf5a07 293 PostData(1, fOutList);
6279d59e 294}
295
296//__________________________________________________________________________________________________
297void AliRsnAnalysisPhi7TeV::Terminate(Option_t *)
298{
299//
300// Terminate
301//
302}
303
4c06ce33 304//__________________________________________________________________________________________________
305Int_t AliRsnAnalysisPhi7TeV::EventEval(AliESDEvent *esd)
306{
307//
308// Checks if the event is good for analysis.
309// Returns one of the flag values defined in the header
310//
311
312 static Int_t evNum = 0;
313 evNum++;
4c06ce33 314
5faf5a07 315 // reject empty events
316 Int_t ntracks = esd->GetNumberOfTracks();
317 if (!ntracks) return kEmptyEvent;
318
4c06ce33 319 // get the best primary vertex:
320 // first try the one with tracks
321 const AliESDVertex *vTrk = esd->GetPrimaryVertexTracks();
322 const AliESDVertex *vSPD = esd->GetPrimaryVertexSPD();
5faf5a07 323 Double_t vzTrk = 1000000.0;
324 Double_t vzSPD = 1000000.0;
0d73200d 325 Int_t ncTrk = -1;
326 Int_t ncSPD = -1;
327 if (vTrk) ncTrk = (Int_t)vTrk->GetNContributors();
328 if (vSPD) ncSPD = (Int_t)vSPD->GetNContributors();
4c06ce33 329 if (vTrk) vzTrk = TMath::Abs(vTrk->GetZv());
330 if (vSPD) vzSPD = TMath::Abs(vSPD->GetZv());
0d73200d 331 if(vTrk && ncTrk > 0)
4c06ce33 332 {
333 // fill the histograms
334 fVertexX[0]->Fill(vTrk->GetXv());
335 fVertexY[0]->Fill(vTrk->GetYv());
336 fVertexZ[0]->Fill(vTrk->GetZv());
337
338 // check VZ position
339 if (vzTrk <= fMaxVz)
340 return kGoodTracksPrimaryVertex;
341 else
342 return kFarTracksPrimaryVertex;
343 }
0d73200d 344 else if (vSPD && ncSPD > 0)
4c06ce33 345 {
346 // fill the histograms
347 fVertexX[1]->Fill(vSPD->GetXv());
348 fVertexY[1]->Fill(vSPD->GetYv());
349 fVertexZ[1]->Fill(vSPD->GetZv());
350
351 // check VZ position
352 if (vzSPD <= fMaxVz)
353 return kGoodSPDPrimaryVertex;
354 else
355 return kFarSPDPrimaryVertex;
356 }
357 else
358 return kNoGoodPrimaryVertex;
359}
360
6279d59e 361//__________________________________________________________________________________________________
362void AliRsnAnalysisPhi7TeV::ProcessESD
4c06ce33 363(AliESDEvent *esd, AliStack *stack)
6279d59e 364{
365//
366// This function works with the ESD object
367//
368
0d73200d 369 static Int_t lastRun = -1;
5faf5a07 370 static Int_t evnum = 0;
371 evnum++;
372
373 // get current run
6279d59e 374 Int_t run = esd->GetRunNumber();
5faf5a07 375
376 // if absent, initialize ESD pid response
377 if (!fESDpid)
378 {
379 AliITSPIDResponse itsresponse(fUseMC);
380
381 fESDpid = new AliESDpid;
382 fESDpid->GetTPCResponse().SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]);
383 fESDpid->GetITSResponse() = itsresponse;
384 }
385
386 // if the run number has changed, update it now and give a message
0d73200d 387 if (run != lastRun)
388 {
5faf5a07 389 AliInfo("============================================================================================");
390 AliInfo(Form("*** CHANGING RUN NUMBER: PREVIOUS = %d --> CURRENT = %d ***", lastRun, run));
391 AliInfo("============================================================================================");
0d73200d 392 lastRun = run;
5faf5a07 393
394 AliCDBManager::Instance()->SetDefaultStorage("raw://");
395 AliCDBManager::Instance()->SetRun(lastRun);
396
397 if (fTOFmaker) delete fTOFmaker;
398 if (fTOFcalib) delete fTOFcalib;
399
400 fTOFcalib = new AliTOFcalib();
401 if (fTOFcorrectTExp) fTOFcalib->SetCorrectTExp(kTRUE);
0d73200d 402 fTOFcalib->Init();
5faf5a07 403
404 fTOFmaker = new AliTOFT0maker(fESDpid, fTOFcalib);
405 fTOFmaker->SetTimeResolution(fTOFresolution);
0d73200d 406 }
5faf5a07 407
6279d59e 408 if (fTOFcalibrateESD) fTOFcalib->CalibrateESD(esd);
409 if (fTOFtuneMC) fTOFmaker->TuneForMC(esd);
5faf5a07 410 if (fTOFuseT0)
6279d59e 411 {
412 fTOFmaker->ComputeT0TOF(esd);
413 fTOFmaker->ApplyT0TOF(esd);
414 fESDpid->MakePID(esd, kFALSE, 0.);
415 }
5faf5a07 416
417 // RSN event
418 AliRsnEvent event;
419 event.SetRef(esd);
420 event.SetRefMC(fMCEvent);
421 //fRsnCuts.ProcessEvent(esd);
6279d59e 422
6279d59e 423 // loop on all tracks
5faf5a07 424 Int_t i1, i2, label, pdg, ntracks = esd->GetNumberOfTracks();
425 Bool_t okTrack;
426 AliPID pid;
427 Double_t kmass = pid.ParticleMass(AliPID::kKaon);
428 Double_t phimass = 1.019455;
429 Double_t angle, cosangle;
430 AliMCParticle *p1 = 0x0, *p2 = 0x0;
431 AliESDtrack *t1 = 0x0, *t2 = 0x0;
432 TLorentzVector v1, v2, vsum, vref;
433
434 // external loop (T1)
435 for (i1 = 0; i1 < ntracks; i1++)
6279d59e 436 {
5faf5a07 437 t1 = esd->GetTrack(i1);
438 if (!t1) continue;
6aecf4fd 439
5faf5a07 440 // setup RSN
441 fDaughter.SetRef(t1);
442 if (stack)
443 {
444 p1 = (AliMCParticle*)fMCEvent->GetTrack(TMath::Abs(t1->GetLabel()));
445 if (p1) fDaughter.SetRefMC(p1);
446 }
447 fDaughter.SetMass(kmass);
448 v1.SetXYZM(t1->Px(), t1->Py(), t1->Pz(), kmass);
4c06ce33 449
5faf5a07 450 // check track
451 okTrack = OkTrack(t1, AliPID::kKaon);
4c06ce33 452
5faf5a07 453 // internal loop (T2)
454 for (i2 = i1+1; i2 < ntracks; i2++)
6279d59e 455 {
5faf5a07 456 t2 = esd->GetTrack(i2);
457 if (!t2) continue;
4c06ce33 458
5faf5a07 459 // check track
460 if (!OkTrack(t2, AliPID::kKaon)) continue;
461
462 // if unlike pair, check if it is true
463 pdg = 0;
464 if ((t1->Charge() == t2->Charge()) && p1 && p2)
0d73200d 465 {
5faf5a07 466 TParticle *part1 = p1->Particle();
467 TParticle *part2 = p2->Particle();
468 if (TMath::Abs(part1->GetPdgCode()) == 321 && TMath::Abs(part2->GetPdgCode()) == 321 && part1->GetFirstMother() == part2->GetFirstMother())
4c06ce33 469 {
5faf5a07 470 label = part1->GetFirstMother();
471 if (label >= 0 && label < stack->GetNtrack())
0d73200d 472 {
5faf5a07 473 TParticle *mum = stack->Particle(label);
474 pdg = mum->GetPdgCode();
0d73200d 475 }
4c06ce33 476 }
6279d59e 477 }
5faf5a07 478 pdg = TMath::Abs(pdg);
479
480 // combine momenta
481 v1.SetXYZM(t1->Px(), t1->Py(), t1->Pz(), kmass);
482 v2.SetXYZM(t2->Px(), t2->Py(), t2->Pz(), kmass);
483 angle = v1.Angle(v2.Vect());
484 cosangle = TMath::Abs(TMath::Cos(angle));
485 if (cosangle <= 0.02) continue;
486 vsum = v1 + v2;
487 vref.SetXYZM(vsum.X(), vsum.Y(), vsum.Z(), phimass);
488
489 // fill appropriate histogram
490 if (t1->Charge() != t2->Charge())
0d73200d 491 {
5faf5a07 492 fUnlike->Fill(vsum.M(), vsum.Perp(), vref.Rapidity());
493 if (pdg == 333) fTrues->Fill(vsum.M(), vsum.Perp(), vref.Rapidity());
0d73200d 494 }
5faf5a07 495 else if (t1->Charge() > 0)
0d73200d 496 {
5faf5a07 497 fLikePP->Fill(vsum.M(), vsum.Perp(), vref.Rapidity());
0d73200d 498 }
499 else
500 {
5faf5a07 501 fLikeMM->Fill(vsum.M(), vsum.Perp(), vref.Rapidity());
0d73200d 502 }
6aecf4fd 503 }
6279d59e 504 }
6279d59e 505
5faf5a07 506 PostData(1, fOutList);
507}
6279d59e 508
5faf5a07 509//______________________________________________________________________________
510Bool_t AliRsnAnalysisPhi7TeV::OkQuality(AliESDtrack *track)
511{
512//
513// Check track quality parameters.
514// Rejects all tracks which are not either TPC+ITS nor ITS standalone.
515// If tracks of any type are not flagged to be used, they are rejected anyway.
516//
6279d59e 517
5faf5a07 518 if (IsITSTPC(track))
519 return fESDtrackCutsTPC.IsSelected(track);
520 else if (IsITSSA (track))
521 {
522 if (fAddITSSA)
523 return fESDtrackCutsITS.IsSelected(track);
524 else
525 return kFALSE;
526 }
527 else
528 return kFALSE;
529}
6279d59e 530
5faf5a07 531//______________________________________________________________________________
532Bool_t AliRsnAnalysisPhi7TeV::OkITSPID (AliESDtrack *track, AliPID::EParticleType pid)
533{
534//
535// Check ITS particle identification with 3sigma cut
536//
4c06ce33 537
5faf5a07 538 // reject not ITS standalone tracks
539 if (!IsITSSA(track)) return kFALSE;
4c06ce33 540
5faf5a07 541 // count PID layers and reject if they are too few
542 Int_t k, nITSpidLayers = 0;
543 UChar_t itsCluMap = track->GetITSClusterMap();
544 for(k = 2; k < 6; k++) if(itsCluMap & (1 << k)) ++nITSpidLayers;
545 if (nITSpidLayers < 3)
4c06ce33 546 {
5faf5a07 547 AliDebug(AliLog::kDebug+2, "Rejecting track with too few ITS pid layers");
548 return kFALSE;
4c06ce33 549 }
5faf5a07 550
551 // check the track type (ITS+TPC or ITS standalone)
552 // and reject it if it is of none of the allowed types
553 Bool_t isSA = kFALSE;
554 if (IsITSTPC(track)) isSA = kFALSE;
555 else if (IsITSSA(track)) isSA = kTRUE;
556 else
4c06ce33 557 {
5faf5a07 558 AliWarning("Track is neither ITS+TPC nor ITS standalone");
559 return kFALSE;
560 }
561
562 // create the PID response object and compute nsigma
563 AliITSPIDResponse &itsrsp = fESDpid->GetITSResponse();
564 Double_t mom = track->P();
565 Double_t nSigma = itsrsp.GetNumberOfSigmas(mom, track->GetITSsignal(), pid, nITSpidLayers, isSA);
566
567 // evaluate the cut
568 Bool_t ok = (TMath::Abs(nSigma) <= fMaxITSband);
569
570 // debug message
571 AliDebug(AliLog::kDebug + 2, Form("ITS nsigma = %f -- max = %f -- cut %s", nSigma, fMaxITSband, (ok ? "passed" : "failed")));
572
573 // outcome
574 return ok;
575}
4c06ce33 576
5faf5a07 577//______________________________________________________________________________
578Bool_t AliRsnAnalysisPhi7TeV::OkTPCPID (AliESDtrack *track, AliPID::EParticleType pid)
579{
580//
581// Check TPC particle identification with {3|5}sigmacut,
582// depending on the track total momentum.
583//
4c06ce33 584
5faf5a07 585 // reject not TPC tracks
586 if (!IsITSTPC(track)) return kFALSE;
6279d59e 587
5faf5a07 588 // setup TPC PID response
589 AliTPCPIDResponse &tpcrsp = fESDpid->GetTPCResponse();
590 tpcrsp.SetBetheBlochParameters(fTPCpar[0],fTPCpar[1],fTPCpar[2],fTPCpar[3],fTPCpar[4]);
591
592 // get momentum and number of sigmas and choose the reference band
593 Double_t mom = track->GetInnerParam()->P();
594 Double_t nSigma = tpcrsp.GetNumberOfSigmas(mom, track->GetTPCsignal(), track->GetTPCsignalN(), pid);
595 Double_t maxNSigma = fMaxTPCband;
596 if (mom < fTPCpLimit) maxNSigma = fMinTPCband;
597
598 // evaluate the cut
599 Bool_t ok = (TMath::Abs(nSigma) <= maxNSigma);
600
601 // debug message
602 AliDebug(AliLog::kDebug + 2, Form("TPC nsigma = %f -- max = %f -- cut %s", nSigma, maxNSigma, (ok ? "passed" : "failed")));
603
604 // outcome
605 return ok;
6279d59e 606}
607
5faf5a07 608//______________________________________________________________________________
609Bool_t AliRsnAnalysisPhi7TeV::OkTOFPID (AliESDtrack *track, AliPID::EParticleType pid)
0d73200d 610{
611//
5faf5a07 612// Check TOF particle identification if matched there.
0d73200d 613//
614
5faf5a07 615 // reject not TOF-matched tracks
616 if (!MatchTOF(track)) return kFALSE;
0d73200d 617
5faf5a07 618 // setup TOF PID response
619 AliTOFPIDResponse &tofrsp = fESDpid->GetTOFResponse();
0d73200d 620
5faf5a07 621 // get info for computation
622 Double_t momentum = track->P();
623 Double_t time = track->GetTOFsignal();
624 Double_t timeint[AliPID::kSPECIES];
625 tofrsp.GetStartTime(momentum);
626 track->GetIntegratedTimes(timeint);
627
628 // check the cut
629 Double_t timeDiff = time - timeint[(Int_t)pid];
630 Double_t sigmaRef = tofrsp.GetExpectedSigma(momentum, timeint[(Int_t)pid], AliPID::ParticleMass(pid));
631 Double_t nSigma = timeDiff / sigmaRef;
0d73200d 632
5faf5a07 633 // evaluate the cut
634 Bool_t ok = (nSigma >= fMinTOF && nSigma <= fMaxTOF);
0d73200d 635
5faf5a07 636 // debug message
637 AliDebug(AliLog::kDebug + 2, Form("TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed")));
638 //if (print) cout << Form("**PHI** TOF nsigma = %f -- range = %f - %f -- cut %s", nSigma, fMinTOF, fMaxTOF, (ok ? "passed" : "failed")) << endl;
639
640 // outcome
641 return ok;
642}
643
644//______________________________________________________________________________
645Bool_t AliRsnAnalysisPhi7TeV::OkTrack(AliESDtrack *track, AliPID::EParticleType pid)
6279d59e 646{
647//
5faf5a07 648// Global track cut check
6279d59e 649//
650
5faf5a07 651 Bool_t okITS, okTPC, okTOF;
6279d59e 652
5faf5a07 653 // check quality and track type and reject tracks not passing this step
654 if (!OkQuality(track))
6279d59e 655 {
5faf5a07 656 AliDebug(AliLog::kDebug+2, "Failed quality cut");
657 //printf("[PHI] Track %4d: REJECTED\n", i);
658 return kFALSE;
659 }
660
661 // ITS PID can be checked always
662 // if PID is not required, the flag is sed as
663 // if the cut was alsways passed
664 okITS = OkITSPID(track, AliPID::kKaon);
665 if (!fCheckITS) okITS = kTRUE;
666
667 // TPC PID can be checked only for TPC+ITS tracks
668 // if PID is not required, the flag is sed as
669 // if the cut was alsways passed
670 okTPC = kFALSE;
671 if (IsITSTPC(track)) okTPC = OkTPCPID(track, AliPID::kKaon);
672 if (!fCheckTPC) okTPC = kTRUE;
673
674 // TOF PID can be checked only if TOF is matched
675 // if PID is not required, the flag is sed as
676 // if the cut was alsways passed
677 okTOF = kFALSE;
678 if (IsITSTPC(track) && MatchTOF(track)) okTOF = OkTOFPID(track, AliPID::kKaon);
679 if (!fCheckTOF) okTOF = kTRUE;
680
681 // now combine all outcomes according to the different possibilities:
682 // -- ITS standalone:
683 // --> only ITS PID, always
684 // -- ITS + TPC:
685 // --> ITS PID, only for momenta lower than 'fMaxITSPIDmom' and when the ITSpid flag is active
686 // --> TPC PID, always --> MASTER (first to be checked, if fails, track is rejected)
687 // --> TOF PID, only if matched
688 if (IsITSSA(track))
689 {
690 if (!okITS)
6279d59e 691 {
5faf5a07 692 AliDebug(AliLog::kDebug+2, "ITS standalone track --> ITS PID failed");
693 //printf("[PHI] Track %4d: REJECTED\n", i);
694 return kFALSE;
6279d59e 695 }
696 }
5faf5a07 697 else // checking IsITSTPC() is redundant due to OkQuality() cut check
698 {
699 if (!okTPC)
700 {
701 AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TPC PID failed");
702 //printf("[PHI] Track %4d: REJECTED\n", i);
703 return kFALSE;
704 }
705 else if (MatchTOF(track) && !okTOF)
706 {
707 AliDebug(AliLog::kDebug+2, "ITS+TPC track --> TOF matched but TOF PID failed");
708 //printf("[PHI] Track %4d: REJECTED\n", i);
709 return kFALSE;
710 }
711 else if (track->IsOn(AliESDtrack::kITSpid) && track->P() <= fMaxITSmom && !okITS)
712 {
713 AliDebug(AliLog::kDebug+2, Form("ITS+TPC track --> Momentum lower than limit (%.2f) and ITS PID failed", fMaxITSmom));
714 //printf("[PHI] Track %4d: REJECTED\n", i);
715 return kFALSE;
716 }
717 }
718
719 // this point is reached only if function didn't exit before due to somecheck not passed
720 return kTRUE;
6279d59e 721}