ROOT logo
#ifndef ALIHFCORRELATIONFDSUBTRACTION_H
#define ALIHFCORRELATIONFDSUBTRACTION_H
/* Copyright(c) 1998-2009, ALICE Experiment at CERN, All rights reserved. *
 * See cxx source for full Copyright notice                               */

/* $Id: $ */

/////////////////////////////////////////////////////////////
// Class for subtracting D-hadron correlations from secondary D from B meson decay from D-hadron correlations of prompt+secondary D mesons
//       n.b. requires the evaluation of the fraction of prompt D mesons using the same receipes used for D meson cross-section and RAA in D2H pag
//       (-> fprompt obtained from FONLL predictions of prompt and secondary D, prompt and secondary D meson efficiencies and a range of hypotheses for
//       RAA(DfromB)/RAA(promptD) (if needed)
//
// Author: A. Rossi, andrea.rossi@cern.ch
/////////////////////////////////////////////////////////////


#include <TH1D.h>
#include <TGraphAsymmErrors.h>
#include <TCanvas.h>

class AliHFCorrelationFDsubtraction : public TNamed {
  
 public:

  AliHFCorrelationFDsubtraction();
  AliHFCorrelationFDsubtraction(const char* name, const char* title);
  ~AliHFCorrelationFDsubtraction();

  void SetUncorrectedHistogram(TH1D *h){fhDataUncorrected=(TH1D*)h->Clone();}
  Bool_t AddTemplateHisto(TH1D *h);
  void SetDptRange(Double_t ptmin,Double_t ptmax){fptmin=ptmin;fptmax=ptmax;}
  Bool_t Init();
  void SetNTemplates(Int_t ntempl){fnTemplates=ntempl;}
  void SetFpromptGraphFc(TGraphAsymmErrors *gr){fgrConservativeFc=(TGraphAsymmErrors*)gr->Clone();}
  void SetFpromptGraphNb(TGraphAsymmErrors *gr){fgrConservativeNb=(TGraphAsymmErrors*)gr->Clone();}
  void SetMethod(Int_t method){fmethod=method;}
  void SetSystOption(Int_t systOpt){fSystUseRMSfromFlatDistr=systOpt;}
  Int_t GetSystOption(){return fSystUseRMSfromFlatDistr;}
  void SubtractFeedDown(TH1D *hFDTempl);

  TGraphAsymmErrors* GetUncGraphFromHistos(TH1D *hRef,TH1D *hMin,TH1D *hMax);
  void CalculateEnvelope();
  TGraphAsymmErrors* GetGraphEnvelope(){return fgrEnvelope;}
  TGraphAsymmErrors* GetGraphEnvelopeRatio(){return fgrEnvelopeRatio;}
  TH1D* GetHistoEnvelopeRatioMin(){return fhEnvelopeMinRatio;}
  TH1D* GetHistoEnvelopeRatioMax(){return fhEnvelopeMaxRatio;}
  TH1D* GetHistoRelSystUncMin();
  TH1D* GetHistoRelSystUncMax();
  TH1D* GetHistoEnvelopeMin(){return fhEnvelopeMin;}
  TH1D* GetHistoEnvelopeMax(){return fhEnvelopeMax;}
  TH1D* GetCentralSubtractedPlot(){return fhDataCorrected[0];}
  TH1D* GetTemplate(Int_t i){       
    if (i>=fLastTemplAdded){Printf("Get Template: Error"); return 0;}
    else return fhTemplates[i];
  }
  TH1D* ReflectHisto(TH1D *h,Double_t scale=1.);
  TH1D* DuplicateHistoTo2piRange(TH1D *h,Double_t scale=0.5);

 private:

  Double_t fptmin;                                      //  min pt (D meson pt range)
  Double_t fptmax;                                      //  max pt (D meson pt range)
  TH1D* fhDataUncorrected;                              // Input correlation histogram
  Int_t fmethod;                                        // method: 1= fc, 2= Nb, 3= both
  TGraphAsymmErrors* fgrConservativeFc;                 // fc graph, fc method
  TGraphAsymmErrors* fgrConservativeNb;                 // fc graph, Nb method
  Int_t fnTemplates;                                   // maximum number of templates that will be included
  Int_t fLastTemplAdded;                                // counter of templates included
  TH1D **fhTemplates;                                  //  Array with template histo, size fnTemplates
  TH1D **fhDataCorrected;                               // Array with corrected histo, size 3*fnTemplates
  TH1D **fhRatioSameTemplate;                            // Array with ratio of histo based on the same template
  TH1D **fhRatioAllToCentralTempl;                                // array with ratio of all histos with respect to the central hypo
  TCanvas **fcCompare;                                            // array of canvases with comparison (template by template)
  TCanvas **fcRatio;                                          // array of canvases with ratio (templ by templ)
  Int_t fCountTempl;                                               // internal counter
  TCanvas *fcAllRatio;                                         // canva with all ratios with respect to central hypo
  TH1D* fhEnvelopeMax;                                         // envelope with max variation
  TH1D* fhEnvelopeMin;                                          // envelope with min variation
  TH1D* fhEnvelopeMaxRatio;                                     // envelope with max relative variation
  TH1D* fhEnvelopeMinRatio;                                      // envelope with min relative variation
  TGraphAsymmErrors* fgrEnvelope;                                // graph with envelope
  TGraphAsymmErrors* fgrEnvelopeRatio;                           // graph with envelope of ratios
  Int_t fSystUseRMSfromFlatDistr;                      // different option to extract the systematic uncertainty. See .cxx, GetHistoRelSystUncMin method for a description
  ClassDef(AliHFCorrelationFDsubtraction,2);
  
};
#endif
 AliHFCorrelationFDsubtraction.h:1
 AliHFCorrelationFDsubtraction.h:2
 AliHFCorrelationFDsubtraction.h:3
 AliHFCorrelationFDsubtraction.h:4
 AliHFCorrelationFDsubtraction.h:5
 AliHFCorrelationFDsubtraction.h:6
 AliHFCorrelationFDsubtraction.h:7
 AliHFCorrelationFDsubtraction.h:8
 AliHFCorrelationFDsubtraction.h:9
 AliHFCorrelationFDsubtraction.h:10
 AliHFCorrelationFDsubtraction.h:11
 AliHFCorrelationFDsubtraction.h:12
 AliHFCorrelationFDsubtraction.h:13
 AliHFCorrelationFDsubtraction.h:14
 AliHFCorrelationFDsubtraction.h:15
 AliHFCorrelationFDsubtraction.h:16
 AliHFCorrelationFDsubtraction.h:17
 AliHFCorrelationFDsubtraction.h:18
 AliHFCorrelationFDsubtraction.h:19
 AliHFCorrelationFDsubtraction.h:20
 AliHFCorrelationFDsubtraction.h:21
 AliHFCorrelationFDsubtraction.h:22
 AliHFCorrelationFDsubtraction.h:23
 AliHFCorrelationFDsubtraction.h:24
 AliHFCorrelationFDsubtraction.h:25
 AliHFCorrelationFDsubtraction.h:26
 AliHFCorrelationFDsubtraction.h:27
 AliHFCorrelationFDsubtraction.h:28
 AliHFCorrelationFDsubtraction.h:29
 AliHFCorrelationFDsubtraction.h:30
 AliHFCorrelationFDsubtraction.h:31
 AliHFCorrelationFDsubtraction.h:32
 AliHFCorrelationFDsubtraction.h:33
 AliHFCorrelationFDsubtraction.h:34
 AliHFCorrelationFDsubtraction.h:35
 AliHFCorrelationFDsubtraction.h:36
 AliHFCorrelationFDsubtraction.h:37
 AliHFCorrelationFDsubtraction.h:38
 AliHFCorrelationFDsubtraction.h:39
 AliHFCorrelationFDsubtraction.h:40
 AliHFCorrelationFDsubtraction.h:41
 AliHFCorrelationFDsubtraction.h:42
 AliHFCorrelationFDsubtraction.h:43
 AliHFCorrelationFDsubtraction.h:44
 AliHFCorrelationFDsubtraction.h:45
 AliHFCorrelationFDsubtraction.h:46
 AliHFCorrelationFDsubtraction.h:47
 AliHFCorrelationFDsubtraction.h:48
 AliHFCorrelationFDsubtraction.h:49
 AliHFCorrelationFDsubtraction.h:50
 AliHFCorrelationFDsubtraction.h:51
 AliHFCorrelationFDsubtraction.h:52
 AliHFCorrelationFDsubtraction.h:53
 AliHFCorrelationFDsubtraction.h:54
 AliHFCorrelationFDsubtraction.h:55
 AliHFCorrelationFDsubtraction.h:56
 AliHFCorrelationFDsubtraction.h:57
 AliHFCorrelationFDsubtraction.h:58
 AliHFCorrelationFDsubtraction.h:59
 AliHFCorrelationFDsubtraction.h:60
 AliHFCorrelationFDsubtraction.h:61
 AliHFCorrelationFDsubtraction.h:62
 AliHFCorrelationFDsubtraction.h:63
 AliHFCorrelationFDsubtraction.h:64
 AliHFCorrelationFDsubtraction.h:65
 AliHFCorrelationFDsubtraction.h:66
 AliHFCorrelationFDsubtraction.h:67
 AliHFCorrelationFDsubtraction.h:68
 AliHFCorrelationFDsubtraction.h:69
 AliHFCorrelationFDsubtraction.h:70
 AliHFCorrelationFDsubtraction.h:71
 AliHFCorrelationFDsubtraction.h:72
 AliHFCorrelationFDsubtraction.h:73
 AliHFCorrelationFDsubtraction.h:74
 AliHFCorrelationFDsubtraction.h:75
 AliHFCorrelationFDsubtraction.h:76
 AliHFCorrelationFDsubtraction.h:77
 AliHFCorrelationFDsubtraction.h:78
 AliHFCorrelationFDsubtraction.h:79
 AliHFCorrelationFDsubtraction.h:80
 AliHFCorrelationFDsubtraction.h:81
 AliHFCorrelationFDsubtraction.h:82
 AliHFCorrelationFDsubtraction.h:83
 AliHFCorrelationFDsubtraction.h:84
 AliHFCorrelationFDsubtraction.h:85
 AliHFCorrelationFDsubtraction.h:86
 AliHFCorrelationFDsubtraction.h:87
 AliHFCorrelationFDsubtraction.h:88