AliPhysics  608b256 (608b256)
AliFlowEventCuts.cxx
Go to the documentation of this file.
1  /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
2  * *
3  * Author: The ALICE Off-line Project. *
4  * Contributors are mentioned in the code where appropriate. *
5  * *
6  * Permission to use, copy, modify and distribute this software and its *
7  * documentation strictly for non-commercial purposes is hereby granted *
8  * without fee, provided that the above copyright notice appears in all *
9  * copies and that both the copyright notice and this permission notice *
10  * appear in the supporting documentation. The authors make no claims *
11  * about the suitability of this software for any purpose. It is *
12  * provided "as is" without express or implied warranty. *
13  **************************************************************************/
14 
15 /* $Id$ */
16 
17 // AliFlowEventCuts:
18 // An event cut class for the flow framework
19 //
20 // origin: Mikolaj Krzewicki (mikolaj.krzewicki@cern.ch)
21 
22 #include <limits.h>
23 #include <float.h>
24 #include <TList.h>
25 #include <TH1F.h>
26 #include <TH2F.h>
27 #include <TBrowser.h>
28 #include "TMath.h"
29 #include "TNamed.h"
30 #include "AliVVertex.h"
31 #include "AliVEvent.h"
32 #include "AliESDEvent.h"
33 #include "AliAODEvent.h"
34 #include "AliVAODHeader.h"
35 #include "AliAODHeader.h"
36 #include "AliCentrality.h"
37 #include "AliMultSelection.h" // available from November 2015
38 #include "AliESDVZERO.h"
39 #include "AliMultiplicity.h"
40 #include "AliMCEvent.h"
41 #include "AliFlowEventCuts.h"
42 #include "AliFlowTrackCuts.h"
43 #include "AliTriggerAnalysis.h"
44 #include "AliCollisionGeometry.h"
45 #include "AliGenEventHeader.h"
46 #include "AliAnalysisUtils.h"
47 #include "AliMultSelection.h"
48 #include "AliNanoAODTrack.h"
49 #include "AliNanoAODHeader.h"
50 #include <iostream>
51 using namespace std;
52 
53 ClassImp(AliFlowEventCuts)
54 
55 //-----------------------------------------------------------------------
58  fQA(NULL),
59  fCutNumberOfTracks(kFALSE),
60  fNumberOfTracksMax(INT_MAX),
61  fNumberOfTracksMin(INT_MIN),
62  fCutRefMult(kFALSE),
63  fRefMultMethod(kTPConly),
64  fUseAliESDtrackCutsRefMult(kFALSE),
65  fRefMultMethodAliESDtrackCuts(AliESDtrackCuts::kTrackletsITSTPC),
66  fRefMultMax(INT_MAX),
67  fRefMultMin(INT_MIN),
68  fRefMultCuts(NULL),
69  fMeanPtCuts(NULL),
70  fStandardTPCcuts(NULL),
71  fStandardGlobalCuts(NULL),
72  fUtils(NULL),
73  fMultSelection(NULL),
74  fCutPrimaryVertexX(kFALSE),
75  fPrimaryVertexXmax(INT_MAX),
76  fPrimaryVertexXmin(INT_MIN),
77  fCutPrimaryVertexY(kFALSE),
78  fPrimaryVertexYmax(INT_MAX),
79  fPrimaryVertexYmin(INT_MIN),
80  fCutPrimaryVertexZ(kFALSE),
81  fPrimaryVertexZmax(INT_MAX),
82  fPrimaryVertexZmin(INT_MIN),
83  fCutNContributors(kFALSE),
84  fNContributorsMax(INT_MAX),
85  fNContributorsMin(INT_MIN),
86  fCutMeanPt(kFALSE),
87  fMeanPtMax(-DBL_MAX),
88  fMeanPtMin(DBL_MAX),
89  fCutSPDvertexerAnomaly(kFALSE),
90  fCutSPDTRKVtxZ(kFALSE),
91  fCutTPCmultiplicityOutliers(kFALSE),
92  fCutTPCmultiplicityOutliersAOD(kFALSE),
93  fUseCentralityUnchecked(kFALSE),
94  fCentralityPercentileMethod(kTPConly),
95  fCutZDCtiming(kFALSE),
96  fTrigAna(),
97  fCutImpactParameter(kFALSE),
98  fImpactParameterMin(0.0),
99  fImpactParameterMax(100.0),
100  fhistTPCvsGlobalMult(0),
101  fData2011(kFALSE),
102  fCheckPileUp(kFALSE),
103  fSphericityMin(-999.),
104  fSphericityMax(999.),
105  fUseSphericityCut(kFALSE),
106  fMinPtOfTrigger(0.0),
107  fUseMinPtOfTrigger(kFALSE)
108 {
109  //constructor
110 }
111 
112 //-----------------------------------------------------------------------
113 AliFlowEventCuts::AliFlowEventCuts(const char* name, const char* title):
114  AliFlowEventSimpleCuts(name, title),
115  fQA(NULL),
116  fCutNumberOfTracks(kFALSE),
117  fNumberOfTracksMax(INT_MAX),
118  fNumberOfTracksMin(INT_MIN),
119  fCutRefMult(kFALSE),
120  fRefMultMethod(kTPConly),
121  fUseAliESDtrackCutsRefMult(kFALSE),
122  fRefMultMethodAliESDtrackCuts(AliESDtrackCuts::kTrackletsITSTPC),
123  fRefMultMax(INT_MAX),
124  fRefMultMin(INT_MIN),
125  fRefMultCuts(NULL),
126  fMeanPtCuts(NULL),
127  fStandardTPCcuts(AliFlowTrackCuts::GetStandardTPCStandaloneTrackCuts2010()),
128  fStandardGlobalCuts(AliFlowTrackCuts::GetStandardGlobalTrackCuts2010()),
129  fUtils(NULL),
130  fMultSelection(NULL),
131  fCutPrimaryVertexX(kFALSE),
132  fPrimaryVertexXmax(INT_MAX),
133  fPrimaryVertexXmin(INT_MIN),
134  fCutPrimaryVertexY(kFALSE),
135  fPrimaryVertexYmax(INT_MAX),
136  fPrimaryVertexYmin(INT_MIN),
137  fCutPrimaryVertexZ(kFALSE),
138  fPrimaryVertexZmax(INT_MAX),
139  fPrimaryVertexZmin(INT_MIN),
140  fCutNContributors(kFALSE),
141  fNContributorsMax(INT_MAX),
142  fNContributorsMin(INT_MIN),
143  fCutMeanPt(kFALSE),
144  fMeanPtMax(-DBL_MAX),
145  fMeanPtMin(DBL_MAX),
146  fCutSPDvertexerAnomaly(kFALSE),
147  fCutSPDTRKVtxZ(kFALSE),
148  fCutTPCmultiplicityOutliers(kFALSE),
149  fCutTPCmultiplicityOutliersAOD(kFALSE),
150  fUseCentralityUnchecked(kFALSE),
151  fCentralityPercentileMethod(kTPConly),
152  fCutZDCtiming(kFALSE),
153  fTrigAna(),
154  fCutImpactParameter(kFALSE),
155  fImpactParameterMin(0.0),
156  fImpactParameterMax(100.0),
157  fhistTPCvsGlobalMult(0),
158  fData2011(kFALSE),
159  fCheckPileUp(kFALSE),
160  fSphericityMin(-999.),
161  fSphericityMax(999.),
162  fUseSphericityCut(kFALSE),
163  fMinPtOfTrigger(0.0),
164  fUseMinPtOfTrigger(kFALSE)
165 {
166  //constructor
167 }
168 
172  fQA(NULL),
176  fCutRefMult(that.fCutRefMult),
180  fRefMultMax(that.fRefMultMax),
181  fRefMultMin(that.fRefMultMin),
182  fRefMultCuts(NULL),
183  fMeanPtCuts(NULL),
184  fStandardTPCcuts(NULL),
185  fStandardGlobalCuts(NULL),
186  fUtils(NULL),
187  fMultSelection(NULL),
200  fCutMeanPt(that.fCutMeanPt),
201  fMeanPtMax(that.fMeanPtMax),
202  fMeanPtMin(that.fMeanPtMin),
210  fTrigAna(),
215  fData2011(that.fData2011),
222 {
223  if (that.fQA) DefineHistograms();
224  //copy constructor
225  if (that.fRefMultCuts)
227  if (that.fMeanPtCuts)
231 
232  if (that.fUtils) {
233  fUtils = new AliAnalysisUtils();
234  fUtils->SetUseMVPlpSelection(kTRUE);
235  fUtils->SetUseOutOfBunchPileUp(kTRUE);
236  }
237 }
238 
241 {
242  //dtor
243  delete fMeanPtCuts;
244  delete fRefMultCuts;
245  delete fStandardGlobalCuts;
246  delete fStandardTPCcuts;
247  if(fUtils) {
248  delete fUtils;
249  fUtils = NULL;
250  }
251  if (fQA) { fQA->SetOwner(); fQA->Delete(); delete fQA; }
252 }
253 
256 {
257  //assignment
258  if (this==&that) return *this;
259 
260  if (that.fQA)
261  {
262  if (fQA)
263  {
264  fQA->Delete();
265  delete fQA;
266  }
267  fQA = static_cast<TList*>(that.fQA->Clone());
268  }
269  else
270  {
271  fQA->Delete();
272  delete fQA;
273  fQA=NULL;
274  }
275 
285  if (that.fRefMultCuts) *fRefMultCuts=*(that.fRefMultCuts);
286  if (that.fMeanPtCuts) *fMeanPtCuts=*(that.fMeanPtCuts);
289  if (that.fUtils) {
290  fUtils = new AliAnalysisUtils();
291  fUtils->SetUseMVPlpSelection(kTRUE);
292  fUtils->SetUseOutOfBunchPileUp(kTRUE);
293  }
294 
307  fCutMeanPt=that.fCutMeanPt;
308  fMeanPtMax=that.fMeanPtMax;
309  fMeanPtMin=that.fMeanPtMin;
318  fData2011=that.fData2011;
320  return *this;
321 }
322 
323 //-----------------------------------------------------------------------
325 {
326  //check cuts
327  AliVEvent* vevent = dynamic_cast<AliVEvent*>(obj);
328  AliMCEvent* mcevent = dynamic_cast<AliMCEvent*>(objmc);
329  if (vevent) return PassesCuts(vevent,mcevent);;
330  return kFALSE; //when passed wrong type of object
331 }
332 //-----------------------------------------------------------------------
333 Bool_t AliFlowEventCuts::PassesCuts(AliVEvent *event, AliMCEvent *mcevent)
334 {
336  const AliVVertex* pvtx=event->GetPrimaryVertex();
337  Double_t pvtxx = 0.;
338  Double_t pvtxy = 0.;
339  Double_t pvtxz = 0.;
340  Int_t ncontrib = 0;
341 
342  if(pvtx){
343  pvtxx = pvtx->GetX();
344  pvtxy = pvtx->GetY();
345  pvtxz = pvtx->GetZ();
346  ncontrib = pvtx->GetNContributors();
347  }
348 
349  Bool_t pass=kTRUE;
350  AliESDEvent* esdevent = dynamic_cast<AliESDEvent*>(event);
351  AliAODEvent* aodevent = dynamic_cast<AliAODEvent*>(event);
352 
353  //Variables for the calculation of sphericity
354  Double_t sT = -999.;
355  Double_t s00 = 0., s11 = 0., s10 = 0.;
356  Double_t sumPt = 0.;
357  Double_t lambda1 = 0., lambda2 = 0.;
358  Int_t nAcceptedTracks = 0;
359 
360  //Variable for the min pT of the trigger per event
361  Int_t nTriggerParticlesAboveThreshold = 0;
362 
363  Int_t multTPC = 0;
364  Int_t multGlobal = 0;
365  AliVAODHeader* header = (aodevent) ? static_cast<AliVAODHeader*>(aodevent->GetHeader()) : 0x0;
366 
367  //NanoAOD cuts
368  if(header && header->InheritsFrom("AliNanoAODStorage")){
369  AliNanoAODHeader *nanoAodHeader = (AliNanoAODHeader*) header;
370 
371  if(fCheckPileUp){
372  Int_t pilepIndex = nanoAodHeader->GetVarIndex("cstPileUp");
373  if(nanoAodHeader->GetVar(pilepIndex)==0) pass = kTRUE;
374  if(nanoAodHeader->GetVar(pilepIndex)==1) pass = kFALSE;
375  }
376 
377  if (fCutPrimaryVertexZ)
378  {
379  if (pvtxz < fPrimaryVertexZmin || pvtxz >= fPrimaryVertexZmax)
380  pass=kFALSE;
381  }
382 
384 
385  Int_t nTracks(aodevent->GetNumberOfTracks());
386  for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
387  AliNanoAODTrack* track = dynamic_cast<AliNanoAODTrack*>(aodevent->GetTrack(iTracks));
388 
389  if(!track) continue;
390  if (!track || TMath::Abs(track->Eta()) > .8 || track->GetTPCNcls() < 70 || track->GetTPCsignal() < 10.0) continue;
391  if (track->TestFilterBit(1) && track->Chi2perNDF() > 0.2) multTPC++;
392  if (!track->TestFilterBit(16) || track->Chi2perNDF() < 0.1) continue;
393 
394  if(track->Pt() > fMinPtOfTrigger)
395  nTriggerParticlesAboveThreshold += 1;
396 
397  if((track->Pt() < 0.2)||(track->Pt() > 5.0)) continue;
398 
399  //sphericity variables
400  sumPt += track->Pt();
401  if(track->Pt() != 0.) {
402  s00 += TMath::Power(track->Px(),2)/track->Pt();
403  s11 += TMath::Power(track->Py(),2)/track->Pt();
404  s10 += track->Px()*track->Py()/track->Pt();
405  }
406 
407  Double_t b[2] = {-99., -99.};
408  Double_t bCov[3] = {-99., -99., -99.};
409 
410  AliNanoAODTrack copy(*track);
411  Double_t magField = nanoAodHeader->GetMagneticField();
412 
413  if (magField!=0){
414 
415  if (track->PropagateToDCA(aodevent->GetPrimaryVertex(), magField, 100., b, bCov) && TMath::Abs(b[0]) < 0.3 && TMath::Abs(b[1]) < 0.3) multGlobal++;
416 
417  }
418  nAcceptedTracks += 1;
419  }
420 
422  {
423  if(nanoAodHeader->GetRunNumber() < 209122) {
424  if(!fData2011 && (multTPC < (-40.3+1.22*multGlobal) || multTPC > (32.1+1.59*multGlobal))) {
425  pass = kFALSE;
426  }
427  else if(fData2011 && (multTPC < (-36.73 + 1.48*multGlobal) || multTPC > (62.87 + 1.78*multGlobal))) pass = kFALSE;
428  } else {
429  if(multTPC < (-18.5+1.15*multGlobal) || multTPC > (200.+1.45*multGlobal)) {
430  pass = kFALSE;
431  }
432  }
433  }
434 
435  //==================================================//
436  //sphericity calculation:
437  //currently for events with nAcceptedTracks >= 2
438  if(nAcceptedTracks >= 2) {
439  if(sumPt != 0.) {
440  s00 /= sumPt;
441  s11 /= sumPt;
442  s10 /= sumPt;
443 
444  if((TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))) >= 0.) {
445  lambda1 = (s00 + s11 + TMath::Sqrt(TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))))/2.;
446  lambda2 = (s00 + s11 - TMath::Sqrt(TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))))/2.;
447 
448  if((lambda1 + lambda2) != 0.) {
449  sT = 2.*TMath::Min(lambda1,lambda2)/(lambda1 + lambda2);
450  }
451  }
452  }
453  }
454 
455  if (fQA) {
456  QAbefore(0)->Fill(pvtxz);
457  QAbefore(1)->Fill(multGlobal,multTPC);
458  if(fUseSphericityCut) {
459  QAbefore(2)->Fill(sT);
460  QAbefore(3)->Fill(nAcceptedTracks,sT);
461  }
462  }
463 
464  //Use sphericity cut
465  if(fUseSphericityCut) {
466  if((fSphericityMin > sT)||(sT > fSphericityMax)) {
467  pass = kFALSE;
468  }
469  }
470 
471  if(fUseMinPtOfTrigger) {
472  if(nTriggerParticlesAboveThreshold == 0) {
473  pass = kFALSE;
474  }
475  }
476 
478  AliCentrality* centr = ((AliVAODHeader*)aodevent->GetHeader())->GetCentralityP();
480  Double_t v0Centr = nanoAodHeader->GetCentr("V0M");
481  Double_t trkCentr = nanoAodHeader->GetCentr("TRK");
482 
483  if(TMath::Abs(v0Centr-trkCentr) > 5) pass = kFALSE;
484  }
485 
488  if (!centr->IsEventInCentralityClassUnchecked( fCentralityPercentileMin,
491  pass = kFALSE;
492  }
493  } else {
494  if (!centr->IsEventInCentralityClass( fCentralityPercentileMin,
497  pass = kFALSE;
498  }
499  }
500  }
501  }else {
503  Float_t lPercentile = nanoAodHeader->GetCentr(CentrMethName(fCentralityPercentileMethod));
504 
505  if(!(fCentralityPercentileMin <= lPercentile && lPercentile < fCentralityPercentileMax))
506  {
507  pass=kFALSE;
508  }
509  }
510  }
511  }
512 
513  if (fQA&&pass) {
514  QAafter(0)->Fill(pvtxz);
515  QAafter(1)->Fill(multGlobal,multTPC);
516  if(fUseSphericityCut) {
517  QAafter(2)->Fill(sT);
518  QAafter(3)->Fill(nAcceptedTracks,sT);
519  }
520  }
521 
522  }else{
523  if(fCheckPileUp){
524  // pile-up rejection
525  if(!fUtils) {
526  fUtils = new AliAnalysisUtils();
527  fUtils->SetUseMVPlpSelection(kTRUE);
528  fUtils->SetUseOutOfBunchPileUp(kTRUE);
529  }
530  if(fUtils->IsPileUpEvent(aodevent)) pass = kFALSE;
531  }
532 
533 
534  // to remove multiplicity outliers, an explicit cut on the correlation
535  // between global and tpc only tracks can be made by counting the two
536  // sets. as counting is expensive, only count when qa is requested or cut is enabeled
537  // the cut criteria are different for different data takign periods
538  // and (of course) cut criteria, specific routines exist for 10h, 11h data
539  // and esds (by calling AliFlowTrackCuts) or aods (evaluated here explicitely)
540  if(esdevent && (fQA || fCutTPCmultiplicityOutliers)) {
541  //this is pretty slow as we check the event track by track twice
542  //this cut will work for 2010 PbPb data and is dependent on
543  //TPC and ITS reco efficiency (e.g. geometry, calibration etc)
544  multTPC = fStandardTPCcuts->Count(event);
545  multGlobal = fStandardGlobalCuts->Count(event);
547  if (multTPC > ( 23+1.216*multGlobal)) pass = kFALSE;
548  if (multTPC < (-20+1.087*multGlobal)) pass = kFALSE;
549  }
550  }
551 
552  if(aodevent && (fQA || fCutTPCmultiplicityOutliersAOD)) {
553  //similar (slow) cut for aod's. will work for both 2010 and 2010 pbpb data
554  //but the user is responsible that this object is configured
555  //correctly to select the dataset
556  //FIXME data could dynamically be determined by this class via the
557  //runnumber
558  Int_t nTracks(aodevent->GetNumberOfTracks());
559  for(Int_t iTracks = 0; iTracks < nTracks; iTracks++) {
560  AliAODTrack* track = dynamic_cast<AliAODTrack*>(aodevent->GetTrack(iTracks));
561  if(!track) continue;
562  if (!track || TMath::Abs(track->Eta()) > .8 || track->GetTPCNcls() < 70 || !track->GetDetPid() || track->GetDetPid()->GetTPCsignal() < 10.0) continue; // general quality cut
563  if (track->TestFilterBit(1) && track->Chi2perNDF() > 0.2) multTPC++;
564  if (!track->TestFilterBit(16) || track->Chi2perNDF() < 0.1) continue;
565 
566  if(track->Pt() > fMinPtOfTrigger)
567  nTriggerParticlesAboveThreshold += 1;
568 
569  if((track->Pt() < 0.2)||(track->Pt() > 5.0))
570  continue;
571 
572  //sphericity variables
573  sumPt += track->Pt();
574  if(track->Pt() != 0.) {
575  s00 += TMath::Power(track->Px(),2)/track->Pt();
576  s11 += TMath::Power(track->Py(),2)/track->Pt();
577  s10 += track->Px()*track->Py()/track->Pt();
578  }
579 
580  Double_t b[2] = {-99., -99.};
581  Double_t bCov[3] = {-99., -99., -99.};
582  AliAODTrack copy(*track);
583  if (copy.PropagateToDCA(event->GetPrimaryVertex(), event->GetMagneticField(), 100., b, bCov) && TMath::Abs(b[0]) < 0.3 && TMath::Abs(b[1]) < 0.3) multGlobal++;
584 
585  nAcceptedTracks += 1;
586  }
587 
589  if(event->GetRunNumber() < 209122) {
590  if(!fData2011 && (multTPC < (-40.3+1.22*multGlobal) || multTPC > (32.1+1.59*multGlobal))) pass = kFALSE;
591  else if(fData2011 && (multTPC < (-36.73 + 1.48*multGlobal) || multTPC > (62.87 + 1.78*multGlobal))) pass = kFALSE;
592  } else {
593  if(multTPC < (-18.5+1.15*multGlobal) || multTPC > (200.+1.45*multGlobal)) pass = kFALSE;
594  }
595  }
596  }
597 
598  //==================================================//
599  //MC kine only
600  if(mcevent) {
601  for (Int_t iParticle = 0; iParticle < mcevent->GetNumberOfTracks(); iParticle++) {
602  AliMCParticle* gParticle = dynamic_cast<AliMCParticle *>(mcevent->GetTrack(iParticle));
603  if (!gParticle) {
604  Printf(Form("Could not receive particle %d", iParticle));
605  continue;
606  }
607 
608  //exclude non stable particles
609  if(!(mcevent->IsPhysicalPrimary(iParticle))) continue;
610 
611  //kinematic cuts cuts
612  Float_t pX = gParticle->Px();
613  Float_t pY = gParticle->Py();
614  Float_t pT = gParticle->Pt();
615  Float_t eta = gParticle->Eta();
616 
617  // Kinematics cuts from ESD track cuts
618  if( pT < 0.2 || pT > 5.) continue;
619  if( eta < -0.8 || eta > 0.8) continue;
620 
621  sumPt += pT;
622  if(pT != 0.) {
623  s00 += TMath::Power(pX,2)/pT;
624  s11 += TMath::Power(pY,2)/pT;
625  s10 += pX*pY/pT;
626  }
627 
628  nAcceptedTracks += 1;
629  } //particle loop
630  }//MC event
631 
632  //==================================================//
633  //sphericity calculation:
634  //currently for events with nAcceptedTracks >= 2
635  if(nAcceptedTracks >= 2) {
636  if(sumPt != 0.) {
637  s00 /= sumPt;
638  s11 /= sumPt;
639  s10 /= sumPt;
640 
641  if((TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))) >= 0.) {
642  lambda1 = (s00 + s11 + TMath::Sqrt(TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))))/2.;
643  lambda2 = (s00 + s11 - TMath::Sqrt(TMath::Power((s00 + s11),2) - 4.*(s00*s11 - TMath::Power(s10,2))))/2.;
644 
645  if((lambda1 + lambda2) != 0.) {
646  sT = 2.*TMath::Min(lambda1,lambda2)/(lambda1 + lambda2);
647  }
648  }
649  }
650  }
651 
652 
653  if (fQA) {
654  QAbefore(0)->Fill(pvtxz);
655  QAbefore(1)->Fill(multGlobal,multTPC);
656  if(fUseSphericityCut) {
657  QAbefore(2)->Fill(sT);
658  QAbefore(3)->Fill(nAcceptedTracks,sT);
659  }
660  }
661 
662  if (fCutNContributors) {
663  if (ncontrib < fNContributorsMin || ncontrib >= fNContributorsMax) pass=kFALSE;
664  }
665  if (fCutPrimaryVertexX) {
666  if (pvtxx < fPrimaryVertexXmin || pvtxx >= fPrimaryVertexXmax) pass=kFALSE;
667  }
668  if (fCutPrimaryVertexY) {
669  if (pvtxy < fPrimaryVertexYmin || pvtxy >= fPrimaryVertexYmax) pass=kFALSE;
670  }
671  if (fCutPrimaryVertexZ) {
672  if (pvtxz < fPrimaryVertexZmin || pvtxz >= fPrimaryVertexZmax)
673  pass=kFALSE;
674  }
675 
676  //Use sphericity cut
677  if(fUseSphericityCut) {
678  if((fSphericityMin > sT)||(sT > fSphericityMax)) {
679  pass = kFALSE;
680  }
681  }
682 
683  if(fUseMinPtOfTrigger) {
684  if(nTriggerParticlesAboveThreshold == 0) {
685  pass = kFALSE;
686  }
687  }
688 
689  // Handles ESD event
690  if (fCutCentralityPercentile&&esdevent) {
692  AliCentrality* centr = esdevent->GetCentrality();
694  if (!centr->IsEventInCentralityClassUnchecked( fCentralityPercentileMin,
697  pass=kFALSE;
698  }
699  }
700  else {
701  if (!centr->IsEventInCentralityClass( fCentralityPercentileMin,
704  {
705  pass=kFALSE;
706  }
707  }
708  } // if(!fUseNewCentralityFramework)
709  else {
710  fMultSelection = (AliMultSelection *) esdevent->FindListObject("MultSelection");
711  Float_t lPercentile = fMultSelection->GetMultiplicityPercentile(CentrMethName(fCentralityPercentileMethod));
712  if(!(fCentralityPercentileMin <= lPercentile && lPercentile < fCentralityPercentileMax)) {
713  pass=kFALSE;
714  }
715  } // else
716  }
717  if (fCutSPDvertexerAnomaly&&esdevent) {
718  const AliESDVertex* sdpvertex = esdevent->GetPrimaryVertexSPD();
719  if (sdpvertex->GetNContributors()<1) pass=kFALSE;
720  if (sdpvertex->GetDispersion()>0.04) pass=kFALSE;
721  if (sdpvertex->GetZRes()>0.25) pass=kFALSE;
722  const AliESDVertex* tpcvertex = esdevent->GetPrimaryVertexTPC();
723  if (tpcvertex->GetNContributors()<1) pass=kFALSE;
724  const AliMultiplicity* tracklets = esdevent->GetMultiplicity();
725  if (tpcvertex->GetNContributors()<(-10.0+0.25*tracklets->GetNumberOfITSClusters(0))) {
726  pass=kFALSE;
727  }
728  }
729  if (fCutZDCtiming&&esdevent) {
730  if (!fTrigAna.ZDCTimeTrigger(esdevent)) {
731  pass=kFALSE;
732  }
733  }
734  if(fCutNumberOfTracks) {if ( event->GetNumberOfTracks() < fNumberOfTracksMin ||
735  event->GetNumberOfTracks() >= fNumberOfTracksMax ) pass=kFALSE;}
736  if((fCutRefMult&&mcevent)||(fCutRefMult&&esdevent)) {
737  //reference multiplicity still to be defined
738  Double_t refMult = RefMult(event,mcevent);
739  if (refMult < fRefMultMin || refMult >= fRefMultMax ) {
740  pass=kFALSE;
741  }
742  }
743 
744  // Handles AOD event
745  if(aodevent) {
746  if(fCutSPDTRKVtxZ) {
747  Double_t tVtxZ = aodevent->GetPrimaryVertex()->GetZ();
748  Double_t tSPDVtxZ = aodevent->GetPrimaryVertexSPD()->GetZ();
749  if( TMath::Abs(tVtxZ-tSPDVtxZ) > 0.5 ) pass = kFALSE;
750  }
752  AliCentrality* centr = ((AliVAODHeader*)aodevent->GetHeader())->GetCentralityP();
754  Double_t v0Centr = centr->GetCentralityPercentile("V0M");
755  Double_t trkCentr = centr->GetCentralityPercentile("TRK");
756  if(TMath::Abs(v0Centr-trkCentr) > 5) pass = kFALSE;
757  }
760  if (!centr->IsEventInCentralityClassUnchecked( fCentralityPercentileMin,
763  pass = kFALSE;
764  }
765  } else {
766  if (!centr->IsEventInCentralityClass( fCentralityPercentileMin,
769  pass = kFALSE;
770  }
771  }
772  }
773  }
774  else {
776  fMultSelection = (AliMultSelection *) aodevent->FindListObject("MultSelection");
777  Float_t lPercentile = fMultSelection->GetMultiplicityPercentile(CentrMethName(fCentralityPercentileMethod));
778  if(!fMultSelection){
779  AliWarning("AliMultSelection not found, did you Run AliMultSelectionTask? \n");
780  }
781  if(!(fCentralityPercentileMin <= lPercentile && lPercentile < fCentralityPercentileMax)) {
782  pass=kFALSE;
783  }
784  }
785  }
786  }
787 
788  if (fCutMeanPt) {
789  Float_t meanpt=0.0;
790  Int_t ntracks=event->GetNumberOfTracks();
791  Int_t nselected=0;
792  for (Int_t i=0; i<ntracks; i++) {
793  AliVParticle* track = event->GetTrack(i);
794  if (!track) continue;
795  Bool_t localpass=kTRUE;
796  if (fMeanPtCuts) localpass=fMeanPtCuts->IsSelected(track);
797  if (localpass) {
798  meanpt += track->Pt();
799  nselected++;
800  }
801  }
802  if (nselected) meanpt=meanpt/nselected;
803  if (meanpt<fMeanPtMin || meanpt >= fMeanPtMax) pass=kFALSE;
804  }
805 
806  //impact parameter cut
807  if(fCutImpactParameter) {
808  Double_t gImpactParameter = 0.;
809  if(mcevent) {
810  AliCollisionGeometry* headerH = dynamic_cast<AliCollisionGeometry*>(dynamic_cast<AliMCEvent*>(mcevent)->GenEventHeader());
811  if(headerH)
812  gImpactParameter = headerH->ImpactParameter();
813  }
814  if ((gImpactParameter < fImpactParameterMin) || (gImpactParameter >= fImpactParameterMax ))
815  pass=kFALSE;
816  }
817 
818  if (fQA&&pass) {
819  QAafter(1)->Fill(multGlobal,multTPC);
820  QAafter(0)->Fill(pvtxz);
821  if(fUseSphericityCut) {
822  QAafter(2)->Fill(sT);
823  QAafter(3)->Fill(nAcceptedTracks,sT);
824  }
825  }
826  }
827  return pass;
828 }
829 
830 //-----------------------------------------------------------------------
831 Float_t AliFlowEventCuts::GetCentrality(AliVEvent* event, AliMCEvent* /*mcEvent*/)
832 {
833  //get the centrality percentile of the event
834  AliESDEvent* esdEvent = dynamic_cast<AliESDEvent*>(event);
835  AliAODEvent* aodEvent = dynamic_cast<AliAODEvent*>(event);
836 
837  Float_t centrality=-1.;
838 
840  {
841  AliCentrality* centr = NULL;
842  if (esdEvent)
843  centr = esdEvent->GetCentrality();
844  if (aodEvent)
845  centr = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentralityP();
846 
847  if (!centr) return -1.;
848 
850  centrality=centr->GetCentralityPercentileUnchecked(CentrMethName(fCentralityPercentileMethod));
851  else
852  centrality=centr->GetCentralityPercentile(CentrMethName(fCentralityPercentileMethod));
853  }
854  else // if(!fUseNewCentralityFramework)
855  {
856  if (esdEvent)
857  {
858  fMultSelection = (AliMultSelection *) esdEvent->FindListObject("MultSelection");
859  Float_t lPercentile = fMultSelection->GetMultiplicityPercentile(CentrMethName(fCentralityPercentileMethod));
860  centrality = lPercentile;
861  }
862  else if (aodEvent)
863  {
864  fMultSelection = (AliMultSelection *) aodEvent->FindListObject("MultSelection");
865  Float_t lPercentile = fMultSelection->GetMultiplicityPercentile(CentrMethName(fCentralityPercentileMethod));
866  if(!fMultSelection){
867  AliWarning("AliMultSelection not found, did you Run AliMultSelectionTask? \n");
868  }
869  centrality = lPercentile;
870  } // else if (aodEvent)
871  } // else // if(!fUseNewCentralityFramework)
872 
873  return centrality;
874 }
875 
876 //-----------------------------------------------------------------------
878 {
879  //get the string for refmultmethod, for use with AliCentrality in
880  //the cut on centrality percentile
881  switch (method)
882  {
883  case kSPDtracklets:
884  return "TKL";
885  case kSPD1clusters:
886  return "CL1";
887  case kTPConly:
888  return "TRK";
889  case kVZERO:
890  return "V0M";
891  case kV0C:
892  return "V0C";
893  case kV0A:
894  return "V0A";
895  case kZDC:
896  return "ZDC";
897  default:
898  return "";
899  }
900 }
901 //-----------------------------------------------------------------------
903 {
904  //make a set of standard event cuts, caller becomes owner
905  AliFlowEventCuts* cuts = new AliFlowEventCuts();
906  return cuts;
907 }
908 
909 //-----------------------------------------------------------------------
910 Int_t AliFlowEventCuts::RefMult(AliVEvent* event, AliMCEvent *mcEvent)
911 {
912  //calculate the reference multiplicity, if all fails return 0
913  AliESDVZERO* vzero = NULL;
914  AliESDEvent* esdevent = dynamic_cast<AliESDEvent*>(event);
915 
916  if (fUseAliESDtrackCutsRefMult && esdevent)
917  {
918  //use the standard ALICE reference multiplicity with the default eta range
919  return AliESDtrackCuts::GetReferenceMultiplicity(esdevent, fRefMultMethodAliESDtrackCuts);
920  }
921 
923  {
925  fRefMultCuts->SetEtaRange(-0.8,0.8);
926  fRefMultCuts->SetPtMin(0.15);
927  }
929  {
930  fRefMultCuts = new AliFlowTrackCuts("tracklet refmult cuts");
932  fRefMultCuts->SetEtaRange(-0.8,0.8);
933  }
934  else if (fRefMultMethod==kVZERO)
935  {
936  if (!esdevent) return 0;
937  vzero=esdevent->GetVZEROData();
938  if (!vzero) return 0;
939  return TMath::Nint(vzero->GetMTotV0A()+vzero->GetMTotV0C());
940  }
941  else if (fRefMultMethod==kSPD1clusters)
942  {
943  if (!esdevent) return 0;
944  const AliMultiplicity* mult = esdevent->GetMultiplicity();
945  if (!mult) return 0;
946  return mult->GetNumberOfITSClusters(1);
947  }
948 
949  Int_t refmult=0;
950  fRefMultCuts->SetEvent(event,mcEvent);
951  Int_t numberOfInputObjects = fRefMultCuts->GetNumberOfInputObjects();
952  for (Int_t i=0; i<numberOfInputObjects; i++) {
954  refmult++;
955  }
956  return refmult;
957 }
958 //_____________________________________________________________________________
960 {
961  //define QA histos
962  if (fQA) return;
963 
964  Bool_t adddirstatus = TH1::AddDirectoryStatus();
965  TH1::AddDirectory(kFALSE);
966  fQA = new TList(); fQA->SetOwner();
967  fQA->SetName(Form("%s QA",GetName()));
968  TList* before = new TList(); before->SetOwner();
969  before->SetName("before");
970  TList* after = new TList(); after->SetOwner();
971  after->SetName("after");
972  fQA->Add(before);
973  fQA->Add(after);
974  before->Add(new TH1F("zvertex",";z;event cout",500,-15.,15.)); //0
975  after->Add(new TH1F("zvertex",";z;event cout",500,-15.,15.)); //0
976  before->Add(new TH2F("fTPCvsGlobalMult","TPC only vs Global track multiplicity;global;TPC only",600,0,3000,600,0,4000));//1
977  after->Add(new TH2F("fTPCvsGlobalMult","TPC only vs Global track multiplicity;global;TPC only",600,0,3000,600,0,4000));//1
978  before->Add(new TH1F("fHistSphericity",";S_{T};Counts",501,-0.05,1.05)); //2
979  after->Add(new TH1F("fHistSphericity",";S_{T};Counts",501,-0.05,1.05)); //2
980  before->Add(new TH2F("fHistMultiplicityVsSphericity",";N_{acc.};S_{T};Counts",500,-0.5,499.5,501,-0.05,1.05));//3
981  after->Add(new TH2F("fHistMultiplicityVsSphericity",";N_{acc.};S_{T};Counts",500,-0.5,499.5,501,-0.05,1.05));//3
982  TH1::AddDirectory(adddirstatus);
983 }
984 
985 //---------------------------------------------------------------//
986 void AliFlowEventCuts::Browse(TBrowser* b)
987 {
988  //some browsing capabilities
989  if (fQA) b->Add(fQA);
990 }
991 
992 //---------------------------------------------------------------//
994 {
995  //merge
996  Int_t number=0;
997  AliFlowEventCuts* obj;
998  if (!list) return 0;
999  if (list->GetEntries()<1) return 0;
1000  TIter next(list);
1001  while ( (obj = dynamic_cast<AliFlowEventCuts*>(next())) )
1002  {
1003  if (obj==this) continue;
1004  TList listwrapper;
1005  listwrapper.Add(obj->GetQA());
1006  fQA->Merge(&listwrapper);
1007  number++;
1008  }
1009  return number;
1010 }
1011 
1012 
Double_t fPrimaryVertexZmax
AliESDtrackCuts::MultEstTrackType fRefMultMethodAliESDtrackCuts
Float_t GetCentrality(AliVEvent *event, AliMCEvent *mcEvent)
double Double_t
Definition: External.C:58
Double_t fPrimaryVertexXmax
Bool_t fData2011
correlation between TPCMult and GlobalMult
TObject * GetInputObject(Int_t i)
Definition: External.C:236
const char * title
Definition: MakeQAPdf.C:27
Long64_t Merge(TCollection *list)
TH1 * QAbefore(Int_t i)
long long Long64_t
Definition: External.C:43
Bool_t fCutTPCmultiplicityOutliersAOD
static AliFlowTrackCuts * GetStandardGlobalTrackCuts2010()
AliFlowTrackCuts * fStandardTPCcuts
AliFlowTrackCuts * fMeanPtCuts
centrality
Double_t fPrimaryVertexYmin
Double_t fPrimaryVertexYmax
TH1 * QAafter(Int_t i)
AliFlowEventCuts & operator=(const AliFlowEventCuts &someCuts)
Int_t Count(AliVEvent *event=NULL)
AliAnalysisUtils * fUtils
virtual Bool_t IsSelected(TObject *obj, Int_t id=-666)
void SetParamType(trackParameterType paramType)
const char * CentrMethName(refMultMethod method) const
refMultMethod fRefMultMethod
Bool_t PassesCuts(AliVEvent *event, AliMCEvent *mcevent)
Int_t GetNumberOfInputObjects() const
int Int_t
Definition: External.C:63
static AliFlowTrackCuts * GetStandardTPCStandaloneTrackCuts()
float Float_t
Definition: External.C:68
Int_t RefMult(AliVEvent *event, AliMCEvent *mcEvent=0x0)
static AliFlowTrackCuts * GetStandardTPCStandaloneTrackCuts2010()
Int_t method
refMultMethod fCentralityPercentileMethod
void Browse(TBrowser *b)
Bool_t fCutPrimaryVertexX
new centrality framework
AliTriggerAnalysis fTrigAna
Double_t fPrimaryVertexZmin
AliMultSelection * fMultSelection
analysis utils object
Bool_t fUseAliESDtrackCutsRefMult
Double_t fImpactParameterMax
void SetEvent(AliVEvent *event, AliMCEvent *mcEvent=NULL)
AliFlowTrackCuts * fStandardGlobalCuts
Bool_t fUseCentralityUnchecked
AliFlowTrackCuts * fRefMultCuts
TList * GetQA() const
static AliFlowEventCuts * StandardCuts()
Double_t fImpactParameterMin
Double_t fPrimaryVertexXmin
bool Bool_t
Definition: External.C:53
virtual Bool_t IsSelected(TObject *obj, TObject *objmc)
Bool_t fCutTPCmultiplicityOutliers
void SetEtaRange(Float_t r1, Float_t r2)