ROOT logo
#ifndef ALIVERTEXINGHFUTILS_H
#define ALIVERTEXINGHFUTILS_H


/* $Id$ */

///////////////////////////////////////////////////////////////////
//                                                               //
// Class with functions useful for different D2H analyses        //
// - event plane resolution                                      //
// - <pt> calculation with side band subtraction                 //
// - tracklet multiplicity calculation                            //
// Origin: F.Prino, Torino, prino@to.infn.it                     //
//                                                               //
///////////////////////////////////////////////////////////////////

#include "TObject.h"
#include "AliAODTrack.h"
#include "AliAODRecoDecay.h"
#include "AliAODRecoDecayHF.h"
#include "AliAODRecoCascadeHF.h"

class AliStack;
class AliAODMCParticle;
class AliAODMCHeader;
class AliGenEventHeader;
class AliAODEvent;
class TProfile;
class TParticle;
class TClonesArray;
class TH1F;
class TH2F;
class TF1;

class AliVertexingHFUtils : public TObject{
 public:
  AliVertexingHFUtils();
  AliVertexingHFUtils(Int_t k);
  virtual ~AliVertexingHFUtils() {};

  // Significance calculator
  static void ComputeSignificance(Double_t signal, Double_t  errsignal, Double_t  background, Double_t  errbackground, Double_t &significance,Double_t &errsignificance);

  // Functions for Event plane resolution
  void SetK(Int_t k){fK=k;}
  void SetSubEvResol(Double_t res){fSubRes=res;}
  void SetSubEventHisto(const TH1F* hSub){
    fSubRes=GetSubEvResol(hSub);
  }
  Int_t GetK() const  {return fK;}
  Double_t GetSubEvResol() const  {return fSubRes;}
  Double_t Pol(Double_t x) const {return Pol(x,fK);}
  Double_t FindChi() const {return FindChi(fSubRes,fK);}
  Double_t GetFullEvResol() const {return GetFullEvResol(fSubRes,fK);}
  static Double_t FindChi(Double_t res,  Int_t k=1);
  static Double_t Pol(Double_t x, Int_t k);
  static Double_t ResolK1(Double_t x);
  static Double_t GetSubEvResol(const TH1F* hSubEvCorr){
    if(hSubEvCorr) return TMath::Sqrt(hSubEvCorr->GetMean());
    else return 1.;
  }
  static Double_t GetSubEvResolLowLim(const TH1F* hSubEvCorr){
    if(hSubEvCorr) return TMath::Sqrt(hSubEvCorr->GetMean()-hSubEvCorr->GetMeanError());
    else return 1.;
  }
  static Double_t GetSubEvResolHighLim(const TH1F* hSubEvCorr){
    if(hSubEvCorr) return TMath::Sqrt(hSubEvCorr->GetMean()+hSubEvCorr->GetMeanError());
    else return 1.;
  }
  static Double_t GetFullEvResol(Double_t resSub, Int_t k=1);
  static Double_t GetFullEvResol(const TH1F* hSubEvCorr, Int_t k=1);
  static Double_t GetFullEvResolLowLim(const TH1F* hSubEvCorr, Int_t k=1);
  static Double_t GetFullEvResolHighLim(const TH1F* hSubEvCorr, Int_t k=1);
  static TString  GetGenerator(Int_t label, AliAODMCHeader* header); 
  Bool_t IsTrackInjected(AliAODTrack *track,AliAODMCHeader *header,TClonesArray *arrayMC);
  void GetTrackPrimaryGenerator(AliAODTrack *track,AliAODMCHeader *header,TClonesArray *arrayMC,TString &nameGen);
  Bool_t IsCandidateInjected(AliAODRecoDecayHF *cand, AliAODMCHeader *header,TClonesArray *arrayMC);
  Bool_t HasCascadeCandidateAnyDaughInjected(AliAODRecoCascadeHF *cand, AliAODMCHeader *header,TClonesArray *arrayMC);
  // Functions for tracklet multiplcity calculation
  void SetEtaRangeForTracklets(Double_t mineta, Double_t maxeta){
    fMinEtaForTracklets=mineta; 
    fMaxEtaForTracklets=maxeta;
  }
  static Int_t GetNumberOfTrackletsInEtaRange(AliAODEvent* ev, Double_t mineta, Double_t maxeta);
  Int_t GetNumberOfTrackletsInEtaRange(AliAODEvent* ev) const {
    return GetNumberOfTrackletsInEtaRange(ev,fMinEtaForTracklets,fMaxEtaForTracklets);
  }
  static Int_t GetGeneratedMultiplicityInEtaRange(TClonesArray* arrayMC, Double_t mineta, Double_t maxeta);
  static Int_t GetGeneratedPrimariesInEtaRange(TClonesArray* arrayMC, Double_t mineta, Double_t maxeta);
  static Int_t GetGeneratedPhysicalPrimariesInEtaRange(TClonesArray* arrayMC, Double_t mineta, Double_t maxeta);

  // Utilities for V0 multiplicity checks
  static Double_t GetVZEROAEqualizedMultiplicity(AliAODEvent* ev);
  static Double_t GetVZEROCEqualizedMultiplicity(AliAODEvent* ev);

  // Functions for computing average pt 
  static void AveragePt(Float_t& averagePt, Float_t& errorPt, Float_t ptmin, Float_t ptmax, TH2F* hMassD, Float_t massFromFit, Float_t sigmaFromFit, TF1* funcB2, Float_t sigmaRangeForSig=2.5, Float_t sigmaRangeForBkg=4.5, Float_t minMass=0., Float_t maxMass=3., Int_t rebin=1);

  // Functions for processing trigger information
  static Bool_t CheckT0TriggerFired(AliAODEvent* aodEv);

  // Functions for computing true impact parameter of D meson
  static Double_t GetTrueImpactParameterDzero(AliAODMCHeader *mcHeader, TClonesArray* arrayMC, AliAODMCParticle *partDp);
  static Double_t GetTrueImpactParameterDplus(AliAODMCHeader *mcHeader, TClonesArray* arrayMC, AliAODMCParticle *partDp);

  static Double_t GetCorrectedNtracklets(TProfile* estimatorAvg, Double_t uncorrectedNacc, Double_t vtxZ, Double_t refMult);

  static Int_t CheckOrigin(TClonesArray* arrayMC, AliAODMCParticle *mcPart, Bool_t searchUpToQuark=kTRUE);
  static Int_t CheckOrigin(AliStack* stack, TParticle *mcPart, Bool_t searchUpToQuark=kTRUE);
  static Int_t CheckD0Decay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckD0Decay(TClonesArray* arrayMC, AliAODMCParticle *mcPart, Int_t* arrayDauLab);
  static Int_t CheckDplusDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckDplusDecay(TClonesArray* arrayMC, AliAODMCParticle *mcPart, Int_t* arrayDauLab);
  static Int_t CheckDplusKKpiDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckDplusK0spiDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckDsDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckDsDecay(TClonesArray* arrayMC, AliAODMCParticle *mcPart, Int_t* arrayDauLab);
  static Int_t CheckDsK0sKDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
   static Int_t CheckDstarDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckDstarDecay(TClonesArray* arrayMC, AliAODMCParticle *mcPart, Int_t* arrayDauLab);
  static Int_t CheckLcpKpiDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);
  static Int_t CheckLcV0bachelorDecay(AliStack* stack, Int_t label, Int_t* arrayDauLab);


 private:

  Int_t fK;             // ratio of measured harmonic to event plane harmonic
  Double_t fSubRes;     // sub-event resolution = sqrt(<cos[n(phiA-phiB)] >)
  Double_t fMinEtaForTracklets; // min eta for counting tracklets
  Double_t fMaxEtaForTracklets; // min eta for counting tracklets

  ClassDef(AliVertexingHFUtils,0) 
};
#endif
 AliVertexingHFUtils.h:1
 AliVertexingHFUtils.h:2
 AliVertexingHFUtils.h:3
 AliVertexingHFUtils.h:4
 AliVertexingHFUtils.h:5
 AliVertexingHFUtils.h:6
 AliVertexingHFUtils.h:7
 AliVertexingHFUtils.h:8
 AliVertexingHFUtils.h:9
 AliVertexingHFUtils.h:10
 AliVertexingHFUtils.h:11
 AliVertexingHFUtils.h:12
 AliVertexingHFUtils.h:13
 AliVertexingHFUtils.h:14
 AliVertexingHFUtils.h:15
 AliVertexingHFUtils.h:16
 AliVertexingHFUtils.h:17
 AliVertexingHFUtils.h:18
 AliVertexingHFUtils.h:19
 AliVertexingHFUtils.h:20
 AliVertexingHFUtils.h:21
 AliVertexingHFUtils.h:22
 AliVertexingHFUtils.h:23
 AliVertexingHFUtils.h:24
 AliVertexingHFUtils.h:25
 AliVertexingHFUtils.h:26
 AliVertexingHFUtils.h:27
 AliVertexingHFUtils.h:28
 AliVertexingHFUtils.h:29
 AliVertexingHFUtils.h:30
 AliVertexingHFUtils.h:31
 AliVertexingHFUtils.h:32
 AliVertexingHFUtils.h:33
 AliVertexingHFUtils.h:34
 AliVertexingHFUtils.h:35
 AliVertexingHFUtils.h:36
 AliVertexingHFUtils.h:37
 AliVertexingHFUtils.h:38
 AliVertexingHFUtils.h:39
 AliVertexingHFUtils.h:40
 AliVertexingHFUtils.h:41
 AliVertexingHFUtils.h:42
 AliVertexingHFUtils.h:43
 AliVertexingHFUtils.h:44
 AliVertexingHFUtils.h:45
 AliVertexingHFUtils.h:46
 AliVertexingHFUtils.h:47
 AliVertexingHFUtils.h:48
 AliVertexingHFUtils.h:49
 AliVertexingHFUtils.h:50
 AliVertexingHFUtils.h:51
 AliVertexingHFUtils.h:52
 AliVertexingHFUtils.h:53
 AliVertexingHFUtils.h:54
 AliVertexingHFUtils.h:55
 AliVertexingHFUtils.h:56
 AliVertexingHFUtils.h:57
 AliVertexingHFUtils.h:58
 AliVertexingHFUtils.h:59
 AliVertexingHFUtils.h:60
 AliVertexingHFUtils.h:61
 AliVertexingHFUtils.h:62
 AliVertexingHFUtils.h:63
 AliVertexingHFUtils.h:64
 AliVertexingHFUtils.h:65
 AliVertexingHFUtils.h:66
 AliVertexingHFUtils.h:67
 AliVertexingHFUtils.h:68
 AliVertexingHFUtils.h:69
 AliVertexingHFUtils.h:70
 AliVertexingHFUtils.h:71
 AliVertexingHFUtils.h:72
 AliVertexingHFUtils.h:73
 AliVertexingHFUtils.h:74
 AliVertexingHFUtils.h:75
 AliVertexingHFUtils.h:76
 AliVertexingHFUtils.h:77
 AliVertexingHFUtils.h:78
 AliVertexingHFUtils.h:79
 AliVertexingHFUtils.h:80
 AliVertexingHFUtils.h:81
 AliVertexingHFUtils.h:82
 AliVertexingHFUtils.h:83
 AliVertexingHFUtils.h:84
 AliVertexingHFUtils.h:85
 AliVertexingHFUtils.h:86
 AliVertexingHFUtils.h:87
 AliVertexingHFUtils.h:88
 AliVertexingHFUtils.h:89
 AliVertexingHFUtils.h:90
 AliVertexingHFUtils.h:91
 AliVertexingHFUtils.h:92
 AliVertexingHFUtils.h:93
 AliVertexingHFUtils.h:94
 AliVertexingHFUtils.h:95
 AliVertexingHFUtils.h:96
 AliVertexingHFUtils.h:97
 AliVertexingHFUtils.h:98
 AliVertexingHFUtils.h:99
 AliVertexingHFUtils.h:100
 AliVertexingHFUtils.h:101
 AliVertexingHFUtils.h:102
 AliVertexingHFUtils.h:103
 AliVertexingHFUtils.h:104
 AliVertexingHFUtils.h:105
 AliVertexingHFUtils.h:106
 AliVertexingHFUtils.h:107
 AliVertexingHFUtils.h:108
 AliVertexingHFUtils.h:109
 AliVertexingHFUtils.h:110
 AliVertexingHFUtils.h:111
 AliVertexingHFUtils.h:112
 AliVertexingHFUtils.h:113
 AliVertexingHFUtils.h:114
 AliVertexingHFUtils.h:115
 AliVertexingHFUtils.h:116
 AliVertexingHFUtils.h:117
 AliVertexingHFUtils.h:118
 AliVertexingHFUtils.h:119
 AliVertexingHFUtils.h:120
 AliVertexingHFUtils.h:121
 AliVertexingHFUtils.h:122
 AliVertexingHFUtils.h:123
 AliVertexingHFUtils.h:124
 AliVertexingHFUtils.h:125
 AliVertexingHFUtils.h:126
 AliVertexingHFUtils.h:127
 AliVertexingHFUtils.h:128
 AliVertexingHFUtils.h:129
 AliVertexingHFUtils.h:130
 AliVertexingHFUtils.h:131
 AliVertexingHFUtils.h:132
 AliVertexingHFUtils.h:133
 AliVertexingHFUtils.h:134