ROOT logo
// Dihadron correlations task - simple task to read ESD or AOD input,
// calculate same- and mixed-event correlations, and fill THnSparse
// output. -A. Adare, Apr 2011, updated Mar 2012

#ifndef AliDhcTask_cxx
#define AliDhcTask_cxx

#include "AliAnalysisTaskSE.h"
#include "AliPool.h"
#include "PWG/muon/AliMuonTrackCuts.h"

class TFormula;
class TH1;
class TH2;
class TH3;
class THn;
class TAxis;
class TObjArray;
class TObject;
class TProfile2D;
class AliAODEvent;
class AliAODTrack;
class AliAnalysisUtils;
class AliESDEvent;
class AliESDMuonTrack;
class AliESDtrackCuts;
class AliEvtPoolManager;

class AliDhcTask : public AliAnalysisTaskSE {
 public:
  AliDhcTask();
  AliDhcTask(const char *name, Bool_t def=kFALSE);
  virtual ~AliDhcTask();
  
  void         SetAllTAHists(Bool_t b)                { fAllTAHists = b;          }
  void         SetAnaMode(Int_t iAna);
  void         SetCentBins(TAxis *bins)               { fBCent=bins;              }
  void         SetCentMethod(const char *name)        { fCentMethod = name;       }
  void         SetCentMixBins(TAxis *bins)            { fMixBCent=bins;           }
  void         SetCheckVertex(Bool_t b)               { fCheckVertex = b;         }
  void         SetClassName(const char *n)            { fClassName = n;           }
  void         SetDEtaDPhiBins(Int_t nbe, Int_t nbp)  { fNBdeta=nbe; fNBdphi=nbp; }
  void         SetDoFillSame(Bool_t b)                { fDoFillSame = b;          }
  void         SetDoMassCut(Bool_t b)                 { fDoMassCut = b;           }
  void         SetDoWeights(Bool_t b)                 { fDoWeights = b;           }
  void         SetEtaMax(Double_t eta)                { fEtaMax = eta;            }
  void         SetEtaTRange(Double_t eL, Double_t eH) { fEtaTLo=eL; fEtaTHi=eH;   }
  void         SetEtaARange(Double_t eL, Double_t eH) { fEtaALo=eL; fEtaAHi=eH;   }
  void         SetFillMuons(Bool_t b)                 { fFillMuons = b;           }
  void         SetHEffA(THnF *h)                      { fHEffA=h;                 }
  void         SetHEffT(THnF *h)                      { fHEffT=h;                 }
  void         SetMixInEtaT(Bool_t b)                 { fMixInEtaT = b;           }
  void         SetMuonUtils(Bool_t b = kTRUE,
                            UInt_t mask = AliMuonTrackCuts::kMuEta | AliMuonTrackCuts::kMuThetaAbs | AliMuonTrackCuts::kMuPdca | AliMuonTrackCuts::kMuMatchApt ) {
    fUseMuonUtils = b;
    fMuonCutMask = mask;
  }
  void         SetOmitFirstEv(Bool_t b)               { fOmitFirstEv = b;         }
  void         SetPoolSize(Int_t p)                   { fPoolSize = p;            }
  void         SetPtABins(TAxis *bins)                { fBPtA=bins;               }
  void         SetPtRange(Double_t min, Double_t max) { fPtMin=min; fPtMax=max;   }
  void         SetPtTACrit(Bool_t b)                  { fPtTACrit = b;            }
  void         SetPtTBins(TAxis *bins)                { fBPtT=bins;               }
  void         SetRequireMuon(Bool_t b, Double_t l=0.5, Double_t h=4.0) {
    fRequireMuon = b;
    fReqPtLo = l;
    fReqPtHi = h;
  }
  void         SetTrackDepth(Int_t t)                 { fTrackDepth = t;          }
  void         SetTracksName(const char *n)           { fTracksName = n;          }
  void         SetTriggerMatch(Bool_t b)              { fTriggerMatch = b;        }
  void         SetVerbosity(Int_t v)                  { fVerbosity = v;           }
  void         SetZVtxBins(TAxis *bins)               { fBZvtx=bins;              }
  void         SetZVtxMixBins(TAxis *bins)            { fMixBZvtx=bins;           }
  void         SetZvtx(Double_t zvtx)                 { fZVtxMax = zvtx;          }
  void         PrintDhcSettings();

  enum eAnaMode       {kHH=1, kMuH, kHMu, kMuMu, kPSide, kASide};

 protected:
  enum ePairingScheme {kSameEvt, kDiffEvt};
  enum eDataType      {kESD, kAOD};

  void         BookHistos();
  void         InitEventMixer();
  void         GetESDTracks(MiniEvent*);
  void         GetAODTracks(MiniEvent*);
  Bool_t       VertexOk() const;
  Bool_t       HasMuonESD();
  Bool_t       HasMuonAOD();
  Bool_t       IsGoodMUONtrack(AliESDMuonTrack &track);
  Bool_t       IsGoodMUONtrack(AliAODTrack &track);
  Bool_t       IsTrigger(Double_t eta, Double_t pt);
  Bool_t       IsAssociated(Double_t eta, Double_t pt);
  Double_t     DeltaPhi(Double_t phia, Double_t phib,
			Double_t rangeMin = -TMath::Pi()/2, 
			Double_t rangeMax = 3*TMath::Pi()/2) const;
  Int_t        Correlate(const MiniEvent &arr1, const MiniEvent &arr2, Int_t pairing = kSameEvt);
  void         UserCreateOutputObjects();
  void         UserExec(Option_t *option);
  void         Terminate(Option_t *);

 private:
  Int_t              fVerbosity;       //  0 = silence
  Double_t           fEtaMax;          //  Max |eta| cut for standard ESD or AOD analysis
  Double_t           fZVtxMax;         //  Max |z| cut (cm)
  Double_t           fPtMin;           //  Min pt cut
  Double_t           fPtMax;           //  Max pt cut
  Int_t              fTrackDepth;      //  #tracks to fill pool
  Int_t              fPoolSize;        //  Maximum number of events
  TString            fTracksName;      //  name of track collection
  Bool_t             fDoWeights;       //  if true weight with 1/N per event
  Bool_t             fFillMuons;       //  fill the muon tracks into the mini event
  Bool_t             fRequireMuon;     //  only run on events with a muon track
  Double_t           fReqPtLo;         //  require a muon above this pt
  Double_t           fReqPtHi;         //  and below this pt
  Bool_t             fPtTACrit;        //  use the pTT > pTA criterion?
  Bool_t             fAllTAHists;      //  create all pTT,pTA combination hists, even t<a?
  Bool_t             fMixInEtaT;       //  mix in bins of eta_T instead of z_vertex
  Bool_t             fUseMuonUtils;    //  use muon cuts from PWG/muon/AliMuonTrackCuts ?
  UInt_t             fMuonCutMask;     //  muon cut mask for above
  AliMuonTrackCuts  *fMuonTrackCuts;   //  muon track cut object
  Double_t           fEtaTLo;          //  Min eta for triggers
  Double_t           fEtaTHi;          //  Max eta for triggers
  Double_t           fEtaALo;          //  Min eta for associated
  Double_t           fEtaAHi;          //  Max eta for associated
  Bool_t             fOmitFirstEv;     //  if true skip first event in chunk
  Bool_t             fDoFillSame;      //  If true fill same event immediately (not waiting for pool)
  Bool_t             fDoMassCut;       //  If true cut on invariant mass
  Bool_t             fCheckVertex;     //  switch to flase for MC generator-level analysis
  TString            fClassName;       //  If not null only process events with given class
  TString            fCentMethod;      //  centrality selection method
  Int_t              fNBdeta;          //  no. deta bins
  Int_t              fNBdphi;          //  no. dphi bins
  Bool_t             fTriggerMatch;    //  muon trigger match
  TAxis             *fBPtT;            //  ptt binning
  TAxis             *fBPtA;            //  pta binning
  TAxis             *fBCent;           //  centrality binning
  TAxis             *fBZvtx;           //  zvtx binning
  TAxis             *fMixBCent;        //  centrality binning for mixing
  TAxis             *fMixBZvtx;        //  zvtx binning for mixing
  THnF              *fHEffT;           //  efficiency for trigger particles
  THnF              *fHEffA;           //  efficiency for associate particles
  AliESDEvent       *fESD;             //! ESD object
  AliAODEvent       *fAOD;             //! AOD object
  TList             *fOutputList;      //! Output list
  TH2               *fHEvt;            //! Cent vs vtx.
  TH2               *fHEvtWTr;         //! Cent vs vtx. for events with at least one track
  TH2               *fHTrk;            //! Phi vs Eta
  TH2               *fHPoolReady;      //! Check how many Jobs start mixing
  TH1               *fHPtAss;          //! Pt ass
  TH1               *fHPtTrg;          //! Pt trg
  TH1               *fHPtTrgEvt;       //! Pt trg per event for weighting
  TH3               *fHPtTrgNorm1S;    //! Pt trg same events in cent. and zvtx bins, method 1
  TH3               *fHPtTrgNorm1M;    //! Pt trg mixed events in cent. and zvtx bins, method 1
  TH3               *fHPtTrgNorm2S;    //! Pt trg same events in cent. and zvtx bins, method 2
  TH3               *fHPtTrgNorm2M;    //! Pt trg mixed events in cent. and zvtx bins, method 2
  TH1               *fHCent;           //! Centrality
  TH1               *fHZvtx;           //! Zvertex
  Int_t              fNbins;           //! Number of histogram bins
  TH2              **fHSs;             //! Same-evt correlations
  TH2              **fHMs;             //! Diff-evt correlations
  TH1              **fHPts;            //! Pt distributions
  TH1              **fHSMass;          //! Mass distributions same
  TH1              **fHMMass;          //! Mass distributions mixed
  TH3               *fHQATp;           //! positive trigger particle distribution for QA
  TH3               *fHQAAp;           //! associated particle distribution for QA
  TH3               *fHQATpCorr;       //! correction applied trigger distribution
  TH3               *fHQAApCorr;       //! correction applied associated distribution
  TH3               *fHQATm;           //! the same for negative particles
  TH3               *fHQAAm;           //!
  TH3               *fHQATmCorr;       //!
  TH3               *fHQAAmCorr;       //!
  TH2               *fHPtCentT;        //! trigger pT vs centrality
  TH2               *fHPtCentA;        //! associated pT vs centrality
  TFormula          *fIndex;           //! index for histograms
  Double_t           fCentrality;      //! centrality of current event
  Double_t           fZVertex;         //! z vertex of current event
  AliESDtrackCuts   *fEsdTPCOnly;      //! track cuts
  AliEvtPoolManager *fPoolMgr;         //! event mixer
  AliAnalysisUtils  *fUtils;           //! analysis utils

  AliDhcTask(const AliDhcTask&);            // not implemented
  AliDhcTask &operator=(const AliDhcTask&); // not implemented

  ClassDef(AliDhcTask, 9)
};

#endif
 AliDhcTask.h:1
 AliDhcTask.h:2
 AliDhcTask.h:3
 AliDhcTask.h:4
 AliDhcTask.h:5
 AliDhcTask.h:6
 AliDhcTask.h:7
 AliDhcTask.h:8
 AliDhcTask.h:9
 AliDhcTask.h:10
 AliDhcTask.h:11
 AliDhcTask.h:12
 AliDhcTask.h:13
 AliDhcTask.h:14
 AliDhcTask.h:15
 AliDhcTask.h:16
 AliDhcTask.h:17
 AliDhcTask.h:18
 AliDhcTask.h:19
 AliDhcTask.h:20
 AliDhcTask.h:21
 AliDhcTask.h:22
 AliDhcTask.h:23
 AliDhcTask.h:24
 AliDhcTask.h:25
 AliDhcTask.h:26
 AliDhcTask.h:27
 AliDhcTask.h:28
 AliDhcTask.h:29
 AliDhcTask.h:30
 AliDhcTask.h:31
 AliDhcTask.h:32
 AliDhcTask.h:33
 AliDhcTask.h:34
 AliDhcTask.h:35
 AliDhcTask.h:36
 AliDhcTask.h:37
 AliDhcTask.h:38
 AliDhcTask.h:39
 AliDhcTask.h:40
 AliDhcTask.h:41
 AliDhcTask.h:42
 AliDhcTask.h:43
 AliDhcTask.h:44
 AliDhcTask.h:45
 AliDhcTask.h:46
 AliDhcTask.h:47
 AliDhcTask.h:48
 AliDhcTask.h:49
 AliDhcTask.h:50
 AliDhcTask.h:51
 AliDhcTask.h:52
 AliDhcTask.h:53
 AliDhcTask.h:54
 AliDhcTask.h:55
 AliDhcTask.h:56
 AliDhcTask.h:57
 AliDhcTask.h:58
 AliDhcTask.h:59
 AliDhcTask.h:60
 AliDhcTask.h:61
 AliDhcTask.h:62
 AliDhcTask.h:63
 AliDhcTask.h:64
 AliDhcTask.h:65
 AliDhcTask.h:66
 AliDhcTask.h:67
 AliDhcTask.h:68
 AliDhcTask.h:69
 AliDhcTask.h:70
 AliDhcTask.h:71
 AliDhcTask.h:72
 AliDhcTask.h:73
 AliDhcTask.h:74
 AliDhcTask.h:75
 AliDhcTask.h:76
 AliDhcTask.h:77
 AliDhcTask.h:78
 AliDhcTask.h:79
 AliDhcTask.h:80
 AliDhcTask.h:81
 AliDhcTask.h:82
 AliDhcTask.h:83
 AliDhcTask.h:84
 AliDhcTask.h:85
 AliDhcTask.h:86
 AliDhcTask.h:87
 AliDhcTask.h:88
 AliDhcTask.h:89
 AliDhcTask.h:90
 AliDhcTask.h:91
 AliDhcTask.h:92
 AliDhcTask.h:93
 AliDhcTask.h:94
 AliDhcTask.h:95
 AliDhcTask.h:96
 AliDhcTask.h:97
 AliDhcTask.h:98
 AliDhcTask.h:99
 AliDhcTask.h:100
 AliDhcTask.h:101
 AliDhcTask.h:102
 AliDhcTask.h:103
 AliDhcTask.h:104
 AliDhcTask.h:105
 AliDhcTask.h:106
 AliDhcTask.h:107
 AliDhcTask.h:108
 AliDhcTask.h:109
 AliDhcTask.h:110
 AliDhcTask.h:111
 AliDhcTask.h:112
 AliDhcTask.h:113
 AliDhcTask.h:114
 AliDhcTask.h:115
 AliDhcTask.h:116
 AliDhcTask.h:117
 AliDhcTask.h:118
 AliDhcTask.h:119
 AliDhcTask.h:120
 AliDhcTask.h:121
 AliDhcTask.h:122
 AliDhcTask.h:123
 AliDhcTask.h:124
 AliDhcTask.h:125
 AliDhcTask.h:126
 AliDhcTask.h:127
 AliDhcTask.h:128
 AliDhcTask.h:129
 AliDhcTask.h:130
 AliDhcTask.h:131
 AliDhcTask.h:132
 AliDhcTask.h:133
 AliDhcTask.h:134
 AliDhcTask.h:135
 AliDhcTask.h:136
 AliDhcTask.h:137
 AliDhcTask.h:138
 AliDhcTask.h:139
 AliDhcTask.h:140
 AliDhcTask.h:141
 AliDhcTask.h:142
 AliDhcTask.h:143
 AliDhcTask.h:144
 AliDhcTask.h:145
 AliDhcTask.h:146
 AliDhcTask.h:147
 AliDhcTask.h:148
 AliDhcTask.h:149
 AliDhcTask.h:150
 AliDhcTask.h:151
 AliDhcTask.h:152
 AliDhcTask.h:153
 AliDhcTask.h:154
 AliDhcTask.h:155
 AliDhcTask.h:156
 AliDhcTask.h:157
 AliDhcTask.h:158
 AliDhcTask.h:159
 AliDhcTask.h:160
 AliDhcTask.h:161
 AliDhcTask.h:162
 AliDhcTask.h:163
 AliDhcTask.h:164
 AliDhcTask.h:165
 AliDhcTask.h:166
 AliDhcTask.h:167
 AliDhcTask.h:168
 AliDhcTask.h:169
 AliDhcTask.h:170
 AliDhcTask.h:171
 AliDhcTask.h:172
 AliDhcTask.h:173
 AliDhcTask.h:174
 AliDhcTask.h:175
 AliDhcTask.h:176
 AliDhcTask.h:177
 AliDhcTask.h:178
 AliDhcTask.h:179
 AliDhcTask.h:180
 AliDhcTask.h:181
 AliDhcTask.h:182
 AliDhcTask.h:183
 AliDhcTask.h:184
 AliDhcTask.h:185
 AliDhcTask.h:186
 AliDhcTask.h:187
 AliDhcTask.h:188
 AliDhcTask.h:189