AliPhysics  ff0b22e (ff0b22e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
HFPtSpectrumRaa.C
Go to the documentation of this file.
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include "TFile.h"
3 #include "TH1.h"
4 #include "TH1D.h"
5 #include "TH2.h"
6 #include "TH2D.h"
7 #include "TH3.h"
8 #include "TH3D.h"
9 #include "TNtuple.h"
10 #include "TGraphAsymmErrors.h"
11 #include "TMath.h"
12 #include "TCanvas.h"
13 #include "TLegend.h"
14 #include "TROOT.h"
15 #include "TStyle.h"
16 #include "TLine.h"
17 #include "TLatex.h"
18 
19 #include "AliHFSystErr.h"
20 #include <Riostream.h>
21 #endif
22 
23 /* $Id$ */
25 //
26 // Macro to compute the Raa, taking as inputs the output of the corrected yields
27 // and the pp reference
28 //
29 // R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
30 //
31 //
32 // Parameters:
33 // 1. ppfile = reference pp in the same pt binning
34 // 2. ABfile = corrected AB yields
35 // 3. outfile = output file name
36 // 4. decay = decay as in HFSystErr class
37 // 5. sigmaABCINT1B = cross section for normalization (**USE THE SAME AS ON 2.**)
38 // 6. fdMethod = feed-down subtraction method (kNb, kfc)
39 // 7. cc = centrality class
40 // 8. Energy = colliding energy (k276,k55)
41 // 9. MinHypo = minimum energy loss hypothesis (Default 1./3.)
42 // 10. MaxHypo = maximum energy loss hypothesis (Default 3.0)
43 // 11. MaxRb = maximum Raa(b) hypothesis (Default 6.0, won't do anything)
44 // 12. RbHypo : flag to decide whether the Eloss hypothesis is Rb or Rb/Rc
45 // 13. CentralHypo = central energy loss hypothesis, DEFAULT TO 1.0
46 // 14. isRaavsEP = flag to compute the Raa IN/OUT of plane, divides the reference by 2.0
47 // 15. ScaledAndExtrapRef: flag to tag scaled+reference pp-scaled-data
48 //
49 // Complains to : Zaida Conesa del Valle
50 //
52 
55 enum energy{ k276, k5dot023, k55 };
60 
61 
62 Bool_t printout = false;
63 Double_t ptprintout = 1.5;
64 Double_t NormPPUnc = 0.035;
65 Double_t NormABUnc = 0.037;
66 Bool_t elossFDQuadSum = true;
67 
68 //____________________________________________________________
69 Bool_t PbPbDataSyst(AliHFSystErr *syst, Double_t pt, Int_t cc, Double_t &dataSystUp, Double_t &dataSystDown);
70 
71 //____________________________________________________________
72 Double_t ExtractFDSyst(Double_t total, Double_t fd) {
73  // total^2 = data^2 + fd^2
74  Double_t data2 = total*total - fd*fd ;
75  return TMath::Sqrt( data2 );
76 }
77 
78 //____________________________________________________________
79 Int_t FindGraphBin(TGraphAsymmErrors *gr, Double_t pt)
80 {
81  Int_t istart =0;
82  Int_t npoints = gr->GetN();
83  for(Int_t i=0; i<=npoints; i++){
84  Double_t x=0.,y=0.;
85  gr->GetPoint(i,x,y);
86  if ( TMath::Abs ( x - pt ) < 0.4 ) {
87  istart = i;
88  break;
89  }
90  }
91  return istart;
92 }
93 
94 
95 //
96 //
97 // R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
98 //
99 //
100 //____________________________________________________________
101 void HFPtSpectrumRaa(const char *ppfile="HFPtSpectrum_D0Kpi_method2_rebinnedth_230311_newsigma.root",
102  const char *ABfile="HFPtSpectrum_D0Kpi_PbPbcuts_method2_rebinnedth_230311_newsigma.root",
103  const char *outfile="HFPtSpectrumRaa.root",
104  Int_t decay=1,
105  Double_t sigmaABCINT1B=54.e9,
106  Int_t fdMethod = kNb, Int_t cc=kpp, Int_t Energy=k276,
107  Double_t MinHypo=1./3., Double_t MaxHypo=3.0, Double_t MaxRb=6.0,
108  Bool_t isRbHypo=false, Double_t CentralHypo = 1.0,
109  Int_t ccestimator = kV0M,
110  Bool_t isUseTaaForRaa=true, const char *shadRbcFile="", Int_t nSigmaShad=3.0,
111  Int_t isRaavsEP=kPhiIntegrated, Bool_t isScaledAndExtrapRef=kFALSE,
112  Int_t rapiditySlice=kdefault, Int_t analysisSpeciality=kTopological)
113 {
114 
115  gROOT->Macro("$ALICE_PHYSICS/PWGHF/vertexingHF/macros/LoadLibraries.C");
116 
117  //
118  // Defining the TAB values for the given centrality class
119  //
120  Double_t Tab = 1., TabSyst = 0., A=207.2, B=207.2;
121  if ( Energy!=k276 && Energy!=k5dot023) {
122  printf("\n The Tab values for this cms energy have not yet been implemented, please do it ! \n");
123  return;
124  }
125  if ( cc == kpp ){
126  Tab = 1.;
127  }
128  // Values from Alberica's twiki:
129  // https://twiki.cern.ch/twiki/bin/viewauth/ALICE/CentStudies
130  if( ccestimator == kV0M ) {
131  if ( cc == k07half ) {
132  Tab = 24.81; TabSyst = 0.8037;
133  } else if ( cc == k010 ) {
134  Tab = 23.48; TabSyst = 0.97;
135  } else if ( cc == k1020 ) {
136  Tab = 14.4318; TabSyst = 0.5733;
137  } else if ( cc == k020 ) {
138  Tab = 18.93; TabSyst = 0.74;
139  } else if ( cc == k2040 ) {
140  Tab = 6.86; TabSyst = 0.28;
141  } else if ( cc == k2030 ) {
142  Tab = 8.73769; TabSyst = 0.370219;
143  } else if ( cc == k3040 ) {
144  Tab = 5.02755; TabSyst = 0.22099;
145  } else if ( cc == k4050 ) {
146  Tab = 2.68327; TabSyst = 0.137073;
147  } else if ( cc == k3050 ) {
148  Tab = 3.87011; TabSyst = 0.183847;
149  } else if ( cc == k4060 ) {
150  Tab = 2.00; TabSyst= 0.11;
151  } else if ( cc == k4080 ) {
152  Tab = 1.20451; TabSyst = 0.071843;
153  } else if ( cc == k5060 ) {
154  Tab = 1.32884; TabSyst = 0.0929536;
155  } else if ( cc == k6080 ) {
156  Tab = 0.419; TabSyst = 0.033;
157  } else if ( cc == k5080 ) {
158  Tab = 0.719; TabSyst = 0.054;
159  } else if ( cc == k80100 ){
160  Tab = 0.0690; TabSyst = 0.0062;
161  }
162  }
163 
164  // pPb Glauber (A. Toia)
165  // https://twiki.cern.ch/twiki/bin/viewauth/ALICE/PACentStudies#Glauber_Calculations_with_sigma
166  if( cc == kpPb0100 ){
167  Tab = 0.098334; TabSyst = 0.0070679;
168  A=207.2; B=1.;
169  }
170  else if( ccestimator == kV0A ){
171  if ( cc == kpPb020 ) {
172  Tab = 0.183; TabSyst = 0.006245;
173  } else if ( cc == kpPb2040 ) {
174  Tab = 0.134; TabSyst = 0.004899;
175  } else if ( cc == kpPb4060 ) {
176  Tab = 0.092; TabSyst = 0.004796;
177  } else if ( cc == kpPb60100 ) {
178  Tab = 0.041; TabSyst = 0.008832;
179  }
180  }
181  else if( ccestimator == kZNA ){
182  if ( cc == kpPb020 ) {
183  Tab = 0.164; TabSyst = 0.010724;
184  } else if ( cc == kpPb2040 ) {
185  Tab = 0.137; TabSyst = 0.005099;
186  } else if ( cc == kpPb4060 ) {
187  Tab = 0.1011; TabSyst = 0.006;
188  } else if ( cc == kpPb60100 ) {
189  Tab = 0.0459; TabSyst = 0.003162;
190  }
191  }
192  else if( ccestimator == kCL1 ){
193  if ( cc == kpPb020 ) {
194  Tab = 0.19; TabSyst = 0.007;
195  } else if ( cc == kpPb2040 ) {
196  Tab = 0.136; TabSyst = 0.005;
197  } else if ( cc == kpPb4060 ) {
198  Tab = 0.088; TabSyst = 0.005;
199  } else if ( cc == kpPb60100 ) {
200  Tab = 0.0369; TabSyst = 0.0085;
201  }
202  }
203 
204  //
205  // Reading the pp file
206  //
207  TFile * ppf = new TFile(ppfile,"read");
208  TH1D * hSigmaPP;
209  TGraphAsymmErrors * gSigmaPPSyst;
210  TGraphAsymmErrors * gSigmaPPSystData = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystData");
211  TGraphAsymmErrors * gSigmaPPSystTheory = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystExtrap");
212  TGraphAsymmErrors * gSigmaPPSystFeedDown = (TGraphAsymmErrors*)ppf->Get("gScaledDataSystFeedDown");
213  TH1I * hCombinedReferenceFlag;
214  TGraphAsymmErrors * gReferenceFdSyst;
215  if(isScaledAndExtrapRef){
216  hCombinedReferenceFlag = (TH1I*)ppf->Get("hCombinedReferenceFlag");
217  hSigmaPP = (TH1D*)ppf->Get("hReference");
218  gSigmaPPSyst = (TGraphAsymmErrors*)ppf->Get("gReferenceSyst");
219  gReferenceFdSyst = (TGraphAsymmErrors*)ppf->Get("gReferenceFdSyst");
220  } else {
221  hSigmaPP = (TH1D*)ppf->Get("fhScaledData");
222  gSigmaPPSyst = (TGraphAsymmErrors*)ppf->Get("gScaledData");
223  }
224  Double_t scalePPRefToMatchRapidityBin = 1.0;
225 
226 
227  // Call the systematics uncertainty class for a given decay
228  AliHFSystErr *systematicsPP = new AliHFSystErr();
229  if(analysisSpeciality==kLowPt){
230  systematicsPP->SetIsLowPtAnalysis(true);
231  }
232  systematicsPP->Init(decay);
233 
234  //
235  // Reading the AB collisions file
236  //
237  TFile * ABf = new TFile(ABfile,"read");
238  TH1D *hSigmaAB = (TH1D*)ABf->Get("histoSigmaCorr");
239  // TH2D *hSigmaABRcb = (TH2D*)ABf->Get("histoSigmaCorrRcb");
240  // TGraphAsymmErrors * gSigmaABSyst = (TGraphAsymmErrors*)ABf->Get("gSigmaCorr");
241  TGraphAsymmErrors * gSigmaABSystFeedDown = (TGraphAsymmErrors*)ABf->Get("gSigmaCorrConservative");
242  TNtuple * nSigmaAB = (TNtuple*)ABf->Get("fnSigma");
243  //
244  TH1D *hMassAB = (TH1D*)ABf->Get("hRECpt");
245  TH1D *hDirectEffptAB = (TH1D*)ABf->Get("hDirectEffpt");
246  TH1D *histofcAB = (TH1D*)ABf->Get("histofc");
247  //
248  TH1D* fhStatUncEffcSigmaAB = (TH1D*)ABf->Get("fhStatUncEffcSigma");
249  TH1D* fhStatUncEffbSigmaAB = (TH1D*)ABf->Get("fhStatUncEffbSigma");
250  TH1D* fhStatUncEffcFDAB = (TH1D*)ABf->Get("fhStatUncEffcFD");
251  TH1D* fhStatUncEffbFDAB = (TH1D*)ABf->Get("fhStatUncEffbFD");
252  //
253  TH1D* fhStatUncEffcSigmaAB_Raa = (TH1D*)fhStatUncEffcSigmaAB->Clone("fhStatUncEffcSigmaAB_Raa");
254  TH1D* fhStatUncEffbSigmaAB_Raa = (TH1D*)fhStatUncEffbSigmaAB->Clone("fhStatUncEffbSigmaAB_Raa");
255  TH1D* fhStatUncEffcFDAB_Raa = (TH1D*)fhStatUncEffcFDAB->Clone("fhStatUncEffcFDAB_Raa");
256  TH1D* fhStatUncEffbFDAB_Raa = (TH1D*)fhStatUncEffbFDAB->Clone("fhStatUncEffbFDAB_Raa");
257  fhStatUncEffcSigmaAB_Raa->Reset();
258  fhStatUncEffbSigmaAB_Raa->Reset();
259  fhStatUncEffcFDAB_Raa->Reset();
260  fhStatUncEffbFDAB_Raa->Reset();
261  fhStatUncEffcSigmaAB_Raa->SetName("fhStatUncEffcSigmaAB_Raa");
262  fhStatUncEffbSigmaAB_Raa->SetName("fhStatUncEffbSigmaAB_Raa");
263  fhStatUncEffcFDAB_Raa->SetName("fhStatUncEffcFDAB_Raa");
264  fhStatUncEffbFDAB_Raa->SetName("fhStatUncEffvFDAB_Raa");
265 
266 
267  //
268  // Call the systematics uncertainty class for a given decay
269  AliHFSystErr *systematicsAB = new AliHFSystErr();
270  systematicsAB->SetCollisionType(1);
271  if ( cc == k07half ) systematicsAB->SetCentrality("07half");
272  else if ( cc == k010 ) systematicsAB->SetCentrality("010");
273  else if ( cc == k1020 ) systematicsAB->SetCentrality("1020");
274  else if ( cc == k020 ) systematicsAB->SetCentrality("020");
275  else if ( cc == k2040 || cc == k2030 || cc == k3040 ) {
276  systematicsAB->SetCentrality("2040");
277  systematicsAB->SetIsPbPb2010EnergyScan(true);
278  }
279  else if ( cc == k4060 || cc == k4050 || cc == k5060 ) systematicsAB->SetCentrality("4060");
280  else if ( cc == k6080 || cc == k5080 ) systematicsAB->SetCentrality("6080");
281  else if ( cc == k4080 ) systematicsAB->SetCentrality("4080");
282  else if ( cc == k3050 ) {
283  if (isRaavsEP == kPhiIntegrated) systematicsAB->SetCentrality("4080");
284  else if (isRaavsEP == kInPlane) systematicsAB->SetCentrality("3050InPlane");
285  else if (isRaavsEP == kOutOfPlane) systematicsAB->SetCentrality("3050OutOfPlane");
286  }
287  //
288  else if ( cc == kpPb0100 || cc == kpPb020 || cc == kpPb2040 || cc == kpPb4060 || cc == kpPb60100 ) {
289  systematicsAB->SetCollisionType(2);
290  // Rapidity slices
291  if(rapiditySlice!=kdefault){
292  systematicsAB->SetIspPb2011RapidityScan(true);
293  TString rapidity="";
294  switch(rapiditySlice) {
295  case k08to04: rapidity="0804"; scalePPRefToMatchRapidityBin=(0.093+0.280)/1.0; break;
296  case k07to04: rapidity="0804"; scalePPRefToMatchRapidityBin=0.280/1.0; break;
297  case k04to01: rapidity="0401"; scalePPRefToMatchRapidityBin=0.284/1.0; break;
298  case k01to01: rapidity="0101"; scalePPRefToMatchRapidityBin=0.191/1.0; break;
299  case k01to04: rapidity="0104"; scalePPRefToMatchRapidityBin=0.288/1.0; break;
300  case k04to07: rapidity="0408"; scalePPRefToMatchRapidityBin=0.288/1.0; break;
301  case k04to08: rapidity="0408"; scalePPRefToMatchRapidityBin=(0.288+0.096)/1.0; break;
302  case k01to05: rapidity="0401"; scalePPRefToMatchRapidityBin=0.4; break;
303  }
304  systematicsAB->SetRapidity(rapidity);
305  }
306  // Centrality slices
307  if(ccestimator==kV0A) {
308  if(cc == kpPb020) systematicsAB->SetCentrality("020V0A");
309  else if(cc == kpPb2040) systematicsAB->SetCentrality("2040V0A");
310  else if(cc == kpPb4060) systematicsAB->SetCentrality("4060V0A");
311  else if(cc == kpPb60100) systematicsAB->SetCentrality("60100V0A");
312  } else if (ccestimator==kZNA) {
313  if(cc == kpPb020) systematicsAB->SetCentrality("020ZNA");
314  else if(cc == kpPb2040) systematicsAB->SetCentrality("2040ZNA");
315  else if(cc == kpPb4060) systematicsAB->SetCentrality("4060ZNA");
316  else if(cc == kpPb60100) systematicsAB->SetCentrality("60100ZNA");
317  } else if (ccestimator==kCL1) {
318  if(cc == kpPb020) systematicsAB->SetCentrality("020CL1");
319  else if(cc == kpPb2040) systematicsAB->SetCentrality("2040CL1");
320  else if(cc == kpPb4060) systematicsAB->SetCentrality("4060CL1");
321  else if(cc == kpPb60100) systematicsAB->SetCentrality("60100CL1");
322  }else {
323  if(!(cc == kpPb0100)) {
324  cout <<" Error on the pPb options"<<endl;
325  return;
326  }
327  }
328  }
329  else {
330  cout << " Systematics not yet implemented " << endl;
331  return;
332  }
333  if(analysisSpeciality==kLowPt){
334  systematicsAB->SetIsLowPtAnalysis(true);
335  }
336  //
337  systematicsAB->Init(decay);
338 
339  //
340  Int_t entries = nSigmaAB->GetEntries();
341  Float_t pt=0., signal=0., Rb=0., Rcb=0., fcAB=0., yieldAB=0., sigmaAB=0., statUncSigmaAB=0., sigmaABMin=0.,sigmaABMax=0.;
342  nSigmaAB->SetBranchAddress("pt",&pt);
343  nSigmaAB->SetBranchAddress("Signal",&signal);
344  if (fdMethod==kNb) nSigmaAB->SetBranchAddress("Rb",&Rb);
345  else if (fdMethod==kfc) nSigmaAB->SetBranchAddress("Rcb",&Rcb);
346  nSigmaAB->SetBranchAddress("fc",&fcAB);
347  nSigmaAB->SetBranchAddress("Yield",&yieldAB);
348  nSigmaAB->SetBranchAddress("Sigma",&sigmaAB);
349  nSigmaAB->SetBranchAddress("SigmaStatUnc",&statUncSigmaAB);
350  nSigmaAB->SetBranchAddress("SigmaMax",&sigmaABMax);
351  nSigmaAB->SetBranchAddress("SigmaMin",&sigmaABMin);
352 
353 
354  // define the binning
355  Int_t nbins = hSigmaAB->GetNbinsX();
356  Double_t binwidth = hSigmaAB->GetBinWidth(1);
357  Double_t *limits = new Double_t[nbins+1];
358  Double_t *binwidths = new Double_t[nbins];
359  Double_t xlow=0.;
360  for (Int_t i=1; i<=nbins; i++) {
361  binwidth = hSigmaAB->GetBinWidth(i);
362  xlow = hSigmaAB->GetBinLowEdge(i);
363  limits[i-1] = xlow;
364  binwidths[i-1] = binwidth;
365  }
366  limits[nbins] = xlow + binwidth;
367 
368 
369  //
370  // Read the shadowing file if given as input
371  //
372  Double_t centralRbcShad[nbins+1], minRbcShad[nbins+1], maxRbcShad[nbins+1];
373  for(Int_t i=0; i<=nbins; i++) { centralRbcShad[i]=1.0; minRbcShad[i]=6.0; maxRbcShad[i]=0.0; }
374  Bool_t isShadHypothesis = false;
375  if( strcmp(shadRbcFile,"")!=0 ) {
376  isShadHypothesis = true;
377  cout<<endl<<">> Beware, using the shadowing prediction file with an "<<nSigmaShad<<"*sigma <<"<<endl<<endl;
378  TFile *fshad = new TFile(shadRbcFile,"read");
379  if(!fshad){ cout <<" >> Shadowing file not properly opened!!!"<<endl<<endl; return;}
380  // TH1D *hRbcShadCentral = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_central");
381  // TH1D *hRbcShadMin = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_upper");
382  // TH1D *hRbcShadMax = (TH1D*)fshad->Get("hDfromBoverPromptD_Shadowing_lower");
383  TH1D *hRbcShadCentral = (TH1D*)fshad->Get("hDfromBoverDfromc_L0");
384  TH1D *hRbcShadMin = (TH1D*)fshad->Get("hDfromBoverDfromc_L0");
385  TH1D *hRbcShadMax = (TH1D*)fshad->Get("hDfromBoverDfromc_L1");
386  if(!hRbcShadCentral || !hRbcShadMin || !hRbcShadMax) {
387  cout<< endl <<">> Shadowing input histograms are not ok !! "<<endl<<endl;
388  return;
389  }
390  // nSigmaShad
391  // nSigmaShad
392  for(Int_t i=1; i<=nbins; i++) {
393  Double_t xpt = hSigmaAB->GetBinCenter(i);
394  if(xpt>24) xpt = 20;
395  centralRbcShad[i] = hRbcShadCentral->GetBinContent( hRbcShadCentral->FindBin(xpt) );
396  Double_t minValue0 = hRbcShadMin->GetBinContent( hRbcShadMin->FindBin(xpt) );
397  Double_t maxValue0 = hRbcShadMax->GetBinContent( hRbcShadMax->FindBin(xpt) );
398  Double_t arrayEl[3] = {minValue0,maxValue0, centralRbcShad[i]};
399  Double_t minValue = TMath::MinElement(3,arrayEl);
400  Double_t maxValue = TMath::MaxElement(3,arrayEl);
401  cout<<">> Shadowing pt="<<xpt<<" central="<<centralRbcShad[i]<<" min="<<minValue<<" max="<<maxValue<<endl;
402  if(minValue>centralRbcShad[i]){ minValue = centralRbcShad[i]; }
403  if(maxValue<centralRbcShad[i]){ maxValue = centralRbcShad[i]; }
404  minRbcShad[i] = centralRbcShad[i] - nSigmaShad*(centralRbcShad[i] - minValue);
405  maxRbcShad[i] = centralRbcShad[i] + nSigmaShad*(maxValue - centralRbcShad[i]);
406  cout<<">> Shadowing hypothesis pt="<<xpt<<" central="<<centralRbcShad[i]<<" min="<<minRbcShad[i]<<" max="<<maxRbcShad[i]<<endl;
407  }
408  }
409 
410  //
411  // define the bins correspondence bw histos/files/graphs
412  //
413  //
414  TH2D * hRABvsRcb = new TH2D("hRABvsRcb"," R_{AB}(c) vs Rcb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(c) ; Rcb Eloss hypothesis ",nbins,limits,800,0.,4.);
415  TH2D * hRABvsRb = new TH2D("hRABvsRb"," R_{AB}(c) vs Rb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(c) ; Rb Eloss hypothesis ",nbins,limits,800,0.,4.);
416  // TH2D * hRABBeautyvsRCharm = new TH2D("hRABBeautyvsRCharm"," R_{AB}(c) vs Rb Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(b) ; R_{AB}(c) ",nbins,limits,800,0.,4.);
417  Int_t nbinsHypo=800;//200;
418  Double_t *limitsHypo = new Double_t[nbinsHypo+1];
419  for(Int_t i=1; i<=nbinsHypo+1; i++) limitsHypo[i-1]= i*4./800.;
420  TH3D * hRABCharmVsRBeautyVsPt = new TH3D("hRABCharmVsRBeautyVsPt"," R_{AB}(c) vs Rb vs p_{T} Eloss hypothesis; p_{T} [GeV/c] ; R_{AB}(b) ; R_{AB}(c) ",nbins,limits,nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
421  TH2D *hRCharmVsRBeauty[nbins+1];
422  for(Int_t i=0; i<=nbins; i++) hRCharmVsRBeauty[i] = new TH2D(Form("hRCharmVsRBeauty_%i",i),Form("RAB(c) vs RAB(b) for pt bin %i ; R_{AB}(b) ; R_{AB}(c)",i),nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
423  TH2D *hRCharmVsElossHypo[nbins+1];
424  for(Int_t i=0; i<=nbins; i++) hRCharmVsElossHypo[i] = new TH2D(Form("hRCharmVsElossHypo_%i",i),Form("RAB(c) vs ElossHypo for pt bin %i ; Eloss Hypothesis (c/b) ; R_{AB}(c)",i),nbinsHypo,limitsHypo,nbinsHypo,limitsHypo);
425  //
426  TH1D *hRABEloss00= new TH1D("hRABEloss00","hRABEloss00",nbins,limits);
427  TH1D *hRABEloss05= new TH1D("hRABEloss05","hRABEloss05",nbins,limits);
428  TH1D *hRABEloss10= new TH1D("hRABEloss10","hRABEloss10",nbins,limits);
429  TH1D *hRABEloss15= new TH1D("hRABEloss15","hRABEloss15",nbins,limits);
430  TH1D *hRABEloss20= new TH1D("hRABEloss20","hRABEloss20",nbins,limits);
431  //
432  TH2D * hRABvsRbFDlow = new TH2D("hRABvsRbFDlow"," R_{AB}(c) vs Rb Eloss hypothesis (FD low); p_{T} [GeV/c] ; Rb Eloss hypothesis ; R_{AB}(c) ",nbins,limits,800,0.,4.);
433  TH2D * hRABvsRbFDhigh = new TH2D("hRABvsRbFDhigh"," R_{AB}(c) vs Rb Eloss hypothesis (FD high); p_{T} [GeV/c] ; Rb Eloss hypothesis ; R_{AB}(c) ",nbins,limits,800,0.,4.);
434  //
435  TH1D * hRABvsRbFDhigh_proj = new TH1D("hRABvsRbFDhigh_proj","hRABvsRbFDhigh_proj",nbins,limits);
436  TH1D * hRABvsRbFDlow_proj = new TH1D("hRABvsRbFDlow_proj","hRABvsRbFDlow_proj",nbins,limits);
437  //
438  TNtuple *ntupleRAB=0x0 ;
439  if (fdMethod==kNb) {
440  ntupleRAB = new TNtuple("ntupleRAB","ntupleRAB (Nb)","pt:TAB:sigmaPP:sigmaAB:invyieldAB:invyieldABFDHigh:invyieldABFDLow:RABCharm:RABCharmFDHigh:RABCharmFDLow:RABBeauty:fc",100000);
441  } else if (fdMethod==kfc) {
442  ntupleRAB = new TNtuple("ntupleRAB","ntupleRAB (fc)","pt:TAB:sigmaPP:sigmaAB:invyieldAB:invyieldABFDHigh:invyieldABFDLow:Rcb:RABCharm:RABCharmFDHigh:RABCharmFDLow:RABBeauty:RABBeautyFDHigh:RABBeautyFDLow:fc",100000);
443  }
444  if(!ntupleRAB) printf("ERROR: Wrong method option");
445 
446  TH1D * hYieldABvsPt = new TH1D("hYieldABvsPt"," Yield_{AB}(c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; Yield_{charm} ",nbins,limits);
447  TH1D * hRABvsPt = new TH1D("hRABvsPt"," R_{AB}(c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; R_{charm} ",nbins,limits);
448  TH1D * hRABvsPt_DataSystematics = new TH1D("hRABvsPt_DataSystematics"," Systematics of R_{AB} (c) vs p_{T} (no Eloss hypothesis); p_{T} [GeV/c] ; R_{charm} ",nbins,limits);
449  TGraphAsymmErrors *gRAB_ElossHypothesis = new TGraphAsymmErrors(nbins+1);
450  gRAB_ElossHypothesis->SetNameTitle("gRAB_ElossHypothesis","RAB Eloss systematics");
451  TGraphAsymmErrors *gRAB_FeedDownSystematics = new TGraphAsymmErrors(nbins+1);
452  gRAB_FeedDownSystematics->SetNameTitle("gRAB_FeedDownSystematics","RAB Feed-Down systematics");
453  TGraphAsymmErrors *gRAB_fcFeedDownOnly = new TGraphAsymmErrors(nbins+1);
454  gRAB_fcFeedDownOnly->SetNameTitle("gRAB_fcFeedDownOnly","RAB fc Feed-Down Only");
455  TGraphAsymmErrors *gRAB_FeedDownSystematicsElossHypothesis = new TGraphAsymmErrors(nbins+1);
456  gRAB_FeedDownSystematicsElossHypothesis->SetNameTitle("gRAB_FeedDownSystematicsElossHypothesis","RAB Feed-Down systematics considering Eloss hypothesis");
457  TGraphAsymmErrors *gRAB_DataSystematics = new TGraphAsymmErrors(nbins+1);
458  gRAB_DataSystematics->SetNameTitle("gRAB_DataSystematics","RAB Measurement (no FD, no Eloss) systematics");
459  TGraphAsymmErrors *gRAB_DataSystematicsPP = new TGraphAsymmErrors(nbins+1);
460  gRAB_DataSystematicsPP->SetNameTitle("gRAB_DataSystematicsPP","RAB Measurement PP meas. systematics (data+scaling)");
461  TGraphAsymmErrors *gRAB_DataSystematicsAB = new TGraphAsymmErrors(nbins+1);
462  gRAB_DataSystematicsAB->SetNameTitle("gRAB_DataSystematicsAB","RAB Measurement AB (no FD, no Eloss, no PP data) systematics");
463  TGraphAsymmErrors *gRAB_GlobalSystematics = new TGraphAsymmErrors(nbins+1);
464  gRAB_GlobalSystematics->SetNameTitle("gRAB_GlobalSystematics","RAB Measurement global (data, FD, Eloss) systematics");
465  Double_t ElossMax[nbins+1], ElossMin[nbins+1];
466  for(Int_t i=0; i<=nbins; i++) { ElossMax[i]=0.; ElossMin[i]=6.; }
467  Double_t fcElossMax[nbins+1], fcElossMin[nbins+1];
468  for(Int_t i=0; i<=nbins; i++) { fcElossMax[i]=0.; fcElossMin[i]=6.; }
469  Double_t FDElossMax[nbins+1], FDElossMin[nbins+1];
470  for(Int_t i=0; i<=nbins; i++) { FDElossMax[i]=0.; FDElossMin[i]=6.; }
471 
472  TGraphAsymmErrors *gRAB_Norm = new TGraphAsymmErrors(1);
473  gRAB_Norm->SetNameTitle("gRAB_Norm","RAB Normalization systematics (pp norm + Tab)");
474  Double_t normUnc = TMath::Sqrt ( NormPPUnc*NormPPUnc + (TabSyst/Tab)*(TabSyst/Tab) );
475  if(!isUseTaaForRaa) normUnc = TMath::Sqrt ( NormPPUnc*NormPPUnc + NormABUnc*NormABUnc );
476  gRAB_Norm->SetPoint(1,0.5,1.);
477  gRAB_Norm->SetPointError(1,0.25,0.25,normUnc,normUnc);
478 
479  //
480  // R_AB = ( dN/dpt )_AB / <Ncoll_AB> * ( dN/dpt )_pp ; <Ncoll> = <Tab> * sigma_NN^inel
481  // R_AB = [ ( dsigma/dpt )_AB / sigma_AB ] / <TAB> * ( dsigma/dpt )_pp
482  //
483  Int_t istartPPfd=0, istartPPsyst=0, istartABfd=0, istartPPextr=0;
484  Double_t yPPh=0., yPPl=0., yABh=0., yABl=0.;
485  Double_t RaaCharm =0., RaaBeauty=0.;
486  Double_t RaaCharmFDhigh = 0., RaaCharmFDlow = 0.;
487  Double_t RaaBeautyFDhigh = 0., RaaBeautyFDlow = 0.;
488  Double_t systUp=0., systLow=0., systPPUp=0., systPPLow=0., systABUp=0., systABLow=0.;
489  //
490  //
491  // Search the central value of the energy loss hypothesis Rb = Rc (bin)
492  //
493  Double_t ElossCentral[nbins+1];
494  for(Int_t i=0; i<=nbins; i++) { ElossCentral[i]=0.; }
495  //
496  for(Int_t ientry=0; ientry<=entries; ientry++){
497 
498  nSigmaAB->GetEntry(ientry);
499  // cout << " pt="<< pt<<" sigma-AB="<<sigmaAB<<endl;
500  if ( !(sigmaAB>0.) ) continue;
501  //if(decay==2 && pt<2.) continue;
502 
503  // Compute RAB and the statistical uncertainty
504  Int_t hppbin = hSigmaPP->FindBin( pt );
505  Int_t hABbin = hSigmaAB->FindBin( pt );
506  Double_t sigmapp = hSigmaPP->GetBinContent( hppbin );
507  sigmapp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
508  // cout << " pt="<< pt<<", sigma-pp="<< sigmapp<<endl;
509  if (isRaavsEP>0.) sigmapp = 0.5*sigmapp;
510  if ( !(sigmapp>0.) ) continue;
511 
512  RaaCharm = ( sigmaAB / sigmaABCINT1B ) / ((Tab*1e3) * sigmapp *1e-12 ) ;
513  if(!isUseTaaForRaa) {
514  RaaCharm = ( sigmaAB ) / ( (A*B) * sigmapp ) ;
515  }
516 
517  if (fdMethod==kNb) {
518  RaaBeauty = Rb ;
519  }
520  else if (fdMethod==kfc) {
521  RaaBeauty = ( RaaCharm / Rcb ) ;
522  }
523 
524  Double_t ElossHypo = 0.;
525  if (fdMethod==kfc) { ElossHypo = 1. / Rcb; }
526  else { ElossHypo = 1. / (RaaCharm / RaaBeauty) ; }
527  if(isRbHypo) ElossHypo = RaaBeauty;
528 
529  // If using shadowing hypothesis, change the central hypothesis too
530  if(isShadHypothesis) CentralHypo = centralRbcShad[hABbin];
531 
532  // cout <<" pt "<< pt << " Raa charm " << RaaCharm << " Raa beauty " << RaaBeauty << " eloss hypo "<< ElossHypo<<endl;
533  //
534  // Find the bin for the central Eloss hypo
535  //
536  if( TMath::Abs( ElossHypo - CentralHypo ) < 0.075 ){
537  Double_t DeltaIni = TMath::Abs( ElossCentral[ hABbin ] - CentralHypo );
538  Double_t DeltaV = TMath::Abs( ElossHypo - CentralHypo );
539  // cout << " pt " << pt << " ECentral " << ElossCentral[ hABbin ] << " Ehypo "<< ElossHypo ;
540  if ( DeltaV < DeltaIni ) ElossCentral[ hABbin ] = ElossHypo;
541  // cout << " final ECentral " << ElossCentral[ hABbin ] << endl;
542  }
543  }
544  //
545  // Calculation of the Raa and its uncertainties
546  //
547  for(Int_t ientry=0; ientry<entries; ientry++){
548 
549  nSigmaAB->GetEntry(ientry);
550  if ( !(sigmaAB>0.) ) continue;
551  // if ( pt<2 || pt>16) continue;
552 
553 
554  // Compute RAB and the statistical uncertainty
555  Int_t hppbin = hSigmaPP->FindBin( pt );
556  Double_t sigmapp = hSigmaPP->GetBinContent( hppbin );
557  if (isRaavsEP>0.) sigmapp = 0.5*sigmapp;
558  sigmapp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
559  if ( !(sigmapp>0.) ) continue;
560 
561  RaaCharm = ( sigmaAB / sigmaABCINT1B ) / ((Tab*1e3) * sigmapp *1e-12 );
562  if(!isUseTaaForRaa) {
563  RaaCharm = ( sigmaAB ) / ( (A*B) * sigmapp ) ;
564  }
565 
566  // Flag to know if it is an scaled or extrapolated point of the pp reference
567  Bool_t isExtrapolatedBin = kFALSE;
568  if(isScaledAndExtrapRef) isExtrapolatedBin = hCombinedReferenceFlag->GetBinContent( hppbin );
569  istartPPsyst = -1;
570  istartPPsyst = FindGraphBin(gSigmaPPSyst,pt);
571 
572  //
573  // FONLL Feed-Down systematics
574  //
575  istartPPfd = -1;
576  if(!isExtrapolatedBin) istartPPfd = FindGraphBin(gSigmaPPSystFeedDown,pt);
577  istartABfd = -1;
578  istartABfd = FindGraphBin(gSigmaABSystFeedDown,pt);
579 
580  // cout << " Starting bin for pp is "<< istartPPfd <<", for AA is "<<istartABfd << endl;
581  if(isExtrapolatedBin){
582  Int_t ibinfd = FindGraphBin(gReferenceFdSyst,pt);
583  yPPh = gReferenceFdSyst->GetErrorYhigh(ibinfd);
584  yPPl = gReferenceFdSyst->GetErrorYlow(ibinfd);
585  } else {
586  yPPh = gSigmaPPSystFeedDown->GetErrorYhigh(istartPPfd);
587  yPPl = gSigmaPPSystFeedDown->GetErrorYlow(istartPPfd);
588  }
589  if (isRaavsEP>0.) {
590  yPPh = yPPh*0.5;
591  yPPl = yPPl*0.5;
592  }
593  yPPh *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
594  yPPl *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
595 
596  yABh = gSigmaABSystFeedDown->GetErrorYhigh(istartABfd);
597  yABl = gSigmaABSystFeedDown->GetErrorYlow(istartABfd);
598 
599 
600  RaaCharmFDhigh = ( sigmaABMax / sigmaABCINT1B ) / ((Tab*1e3) * (sigmapp+yPPh) *1e-12 ) ;
601  RaaCharmFDlow = ( sigmaABMin / sigmaABCINT1B ) / ((Tab*1e3) * (sigmapp-yPPl) *1e-12 ) ;
602  if(printout && TMath::Abs(ptprintout-pt)<0.1 ) cout << endl<<" pt "<< pt << " Raa " << RaaCharm <<" high "<< RaaCharmFDhigh << " low "<< RaaCharmFDlow<<endl;
603  if(!isUseTaaForRaa) {
604  RaaCharmFDhigh = ( sigmaABMax ) / ( (A*B)* (sigmapp+yPPh) ) ;
605  RaaCharmFDlow = ( sigmaABMin ) / ( (A*B)* (sigmapp-yPPl) ) ;
606  }
607 
608 
609  if (fdMethod==kNb) {
610  RaaBeauty = Rb ;
611  RaaBeautyFDlow = Rb ;
612  RaaBeautyFDhigh = Rb ;
613  ntupleRAB->Fill( pt, Tab*1e3, sigmapp*1e-12, sigmaAB*1e-12, sigmaAB/sigmaABCINT1B,
614  sigmaABMax / sigmaABCINT1B, sigmaABMin / sigmaABCINT1B,
615  RaaCharm, RaaCharmFDhigh, RaaCharmFDlow, RaaBeauty, fcAB );
616  }
617  else if (fdMethod==kfc) {
618  RaaBeauty = ( RaaCharm / Rcb ) ;
619  RaaBeautyFDlow = ( RaaCharmFDlow / Rcb ) ;
620  RaaBeautyFDhigh = ( RaaCharmFDhigh / Rcb ) ;
621  hRABvsRcb->Fill( pt, RaaCharm, RaaBeauty );
622  ntupleRAB->Fill( pt, Tab*1e3, sigmapp*1e-12, sigmaAB*1e-12, sigmaAB/sigmaABCINT1B,
623  sigmaABMax / sigmaABCINT1B, sigmaABMin / sigmaABCINT1B,
624  Rcb, RaaCharm, RaaCharmFDhigh, RaaCharmFDlow, RaaBeauty, RaaBeautyFDhigh, RaaBeautyFDlow, fcAB );
625  }
626  hRABvsRb->Fill( pt, RaaCharm, RaaBeauty );
627  hRABvsRbFDlow->Fill( pt, RaaCharmFDlow, RaaBeautyFDlow );
628  hRABvsRbFDhigh->Fill( pt, RaaCharmFDhigh, RaaBeautyFDhigh );
629  if(printout && TMath::Abs(ptprintout-pt)<0.1) cout << " pt "<< pt << " Rb " << RaaBeauty <<" high "<< RaaBeautyFDhigh << " low "<< RaaBeautyFDlow <<endl;
630 
631  hRABCharmVsRBeautyVsPt->Fill( pt, RaaBeauty, RaaCharm );
632  Int_t ptbin = hRABvsPt->FindBin( pt );
633  hRCharmVsRBeauty[ptbin]->Fill( RaaBeauty, RaaCharm );
634  hRCharmVsRBeauty[ptbin]->Fill( RaaBeautyFDlow, RaaCharmFDlow );
635  hRCharmVsRBeauty[ptbin]->Fill( RaaBeautyFDhigh, RaaCharmFDhigh );
636 
637 
638  if (fdMethod==kfc) {
639  if( TMath::Abs(Rcb-0.015)<0.009 ) hRABEloss00->Fill(pt,RaaCharm);
640  if( TMath::Abs(Rcb-0.5)<0.009 ) hRABEloss05->Fill(pt,RaaCharm);
641  if( TMath::Abs(Rcb-1.0)<0.009 ) {
642  hRABEloss10->Fill(pt,RaaCharm);
643  hRABvsRbFDhigh_proj->Fill(pt,RaaCharmFDhigh);
644  hRABvsRbFDlow_proj->Fill(pt,RaaCharmFDlow);
645  }
646  if( TMath::Abs(Rcb-1.5)<0.009 ) hRABEloss15->Fill(pt,RaaCharm);
647  if( TMath::Abs(Rcb-2.0)<0.009 ) hRABEloss20->Fill(pt,RaaCharm);
648  }
649  else if (fdMethod==kNb) {
650  if( TMath::Abs(RaaBeauty-0.015)<0.009 ) hRABEloss00->Fill(pt,RaaCharm);
651  if( TMath::Abs(RaaBeauty-0.5)<0.009 ) hRABEloss05->Fill(pt,RaaCharm);
652  if( TMath::Abs(RaaBeauty-1.0)<0.009 ) {
653  hRABEloss10->Fill(pt,RaaCharm);
654  hRABvsRbFDhigh_proj->Fill(pt,RaaCharmFDhigh);
655  hRABvsRbFDlow_proj->Fill(pt,RaaCharmFDlow);
656  }
657  if( TMath::Abs(RaaBeauty-1.5)<0.009 ) hRABEloss15->Fill(pt,RaaCharm);
658  if( TMath::Abs(RaaBeauty-2.0)<0.009 ) hRABEloss20->Fill(pt,RaaCharm);
659  }
660 
661 
662  Int_t hABbin = hMassAB->FindBin( pt );
663  if(isShadHypothesis) CentralHypo = centralRbcShad[hABbin];
664 
665  if(printout && TMath::Abs(ptprintout-pt)<0.1)
666  if ( fdMethod==kNb && TMath::Abs(Rb -CentralHypo)< 0.05) {
667  cout << " pt "<< pt <<", at bin "<<hABbin<<endl;
668  cout<<" entries "<<entries<<", i="<<ientry<<", pt="<<pt<<", Rb="<<Rb<<", Tab="<<Tab<<", sigmaAB="<<sigmaAB<<", sigmapp="<<sigmapp<<", Raacharm="<<RaaCharm<<", RaaBeauty="<<RaaBeauty<<endl;
669  cout << " AB basis: mass "<< hMassAB->GetBinContent(hABbin)<<", eff "<< hDirectEffptAB->GetBinContent(hABbin)<<endl;
670  cout<<" FD low, err low AB "<< (sigmaAB-sigmaABMin)<<" err low PP "<< yPPl<<" Raacharm="<<RaaCharmFDlow<<", RaaBeauty="<<RaaBeautyFDlow<<endl;
671  cout<<" FD high, err high AB "<< (sigmaABMax-sigmaAB)<<" err high PP "<< yPPh<<" Raacharm="<<RaaCharmFDhigh<<", RaaBeauty="<<RaaBeautyFDhigh<<endl;
672  }
673  if(printout && TMath::Abs(ptprintout-pt)<0.1)
674  if ( fdMethod==kfc) if(TMath::Abs(Rcb -CentralHypo)< 0.05 ){
675  cout << " pt "<< pt <<", at bin "<<hABbin<<endl;
676  cout<<" entries "<<entries<<", i="<<ientry<<", pt="<<pt<<", Rcb="<<Rcb<<", Tab="<<Tab<<", sigmaAB="<<sigmaAB<<", sigmapp="<<sigmapp<<", Raacharm="<<RaaCharm<<", RaaBeauty="<<RaaBeauty<<endl;
677  cout << " AB basis: mass "<< hMassAB->GetBinContent(hABbin)<<", eff "<< hDirectEffptAB->GetBinContent(hABbin)<<", fc "<<histofcAB->GetBinContent(hABbin)<< endl;
678  cout<<" FD low, err low AB "<< (sigmaAB-sigmaABMin)<<" err low PP "<< yPPl<<" Raacharm="<<RaaCharmFDlow<<", RaaBeauty="<<RaaBeautyFDlow<<endl;
679  cout<<" FD high, err high AB "<< (sigmaABMax-sigmaAB)<<" err high PP "<< yPPh<<" Raacharm="<<RaaCharmFDhigh<<", RaaBeauty="<<RaaBeautyFDhigh<<endl;
680  }
681 
682 
683  //
684  // Fill in the global properties ?
685  //
686  Double_t ElossHypo = 0.;
687  if (fdMethod==kfc) { ElossHypo = 1./ Rcb; }
688  else { ElossHypo = 1. / (RaaCharm / RaaBeauty); }
689  if(isRbHypo) ElossHypo = RaaBeauty;
690  hRCharmVsElossHypo[ptbin]->Fill( ElossHypo, RaaCharm );
691 
692  // If using shadowing hypothesis, change the limit hypothesis too
693  if(isShadHypothesis) {
694  MinHypo = minRbcShad[ hABbin ];
695  MaxHypo = maxRbcShad[ hABbin ];
696  }
697 
698  // cout <<" pt "<< pt << " Raa charm " << RaaCharm << " Raa beauty " << RaaBeauty << " eloss hypo "<< ElossHypo
699  if(ientry==0) cout<<" pt"<< pt<< " ElossCentral "<< ElossCentral[hABbin] << " min-hypo "<<MinHypo << " max-hypo "<<MaxHypo<<endl;
700 
701  //
702  // Fill in histos charm (null Eloss hypothesis)
703  //
704  Double_t minFdSyst = 0., maxFdSyst = 0.;
705  if ( ElossHypo == ElossCentral[ hABbin ] ) {
706 
707  //
708  // Data stat uncertainty
709  //
710  Double_t sigmappStat = hSigmaPP->GetBinError( hppbin );
711  if (isRaavsEP>0.) sigmappStat = sigmappStat*0.5;
712  sigmappStat *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
713  Int_t hRABbin = hRABvsPt->FindBin( pt );
714  Double_t stat = RaaCharm * TMath::Sqrt( (statUncSigmaAB/sigmaAB)*(statUncSigmaAB/sigmaAB) +
715  (sigmappStat/sigmapp)*(sigmappStat/sigmapp) ) ;
716  if ( RaaCharm==0 ) stat =0.;
717  if ( RaaCharm>0 ) {
718  hRABvsPt->SetBinContent( hRABbin, RaaCharm );
719  hRABvsPt->SetBinError( hRABbin, stat );
720  hYieldABvsPt->SetBinContent( hRABbin, sigmaAB/sigmaABCINT1B );
721  hYieldABvsPt->SetBinError( hRABbin, statUncSigmaAB/sigmaABCINT1B );
722 
723  cout << "pt="<< pt<< " Raa " << RaaCharm << " stat unc. "<< stat <<
724  " sigma-pp "<< sigmapp <<" sigma-AB "<< sigmaAB<<endl;
725  if(printout && TMath::Abs(ptprintout-pt)<0.1) {
726  cout << " Raa " << RaaCharm << " stat unc. "<< stat << " is "<< stat/RaaCharm * 100. <<
727  "%, stat-pp "<< sigmappStat/sigmapp*100. <<"% stat-AB "<< statUncSigmaAB/sigmaAB*100.<<"%"<<endl;
728  }
729 
730  Double_t errstatEff = fhStatUncEffcSigmaAB->GetBinError( hRABbin );
731  fhStatUncEffcSigmaAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
732  errstatEff = fhStatUncEffbSigmaAB->GetBinError( hRABbin );
733  fhStatUncEffbSigmaAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
734  errstatEff = fhStatUncEffcFDAB->GetBinError( hRABbin );
735  fhStatUncEffcFDAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
736  errstatEff = fhStatUncEffbFDAB->GetBinError( hRABbin );
737  fhStatUncEffbFDAB_Raa->SetBinError( hRABbin, errstatEff*RaaCharm );
738  }
739 
740 
741  //
742  //
743  // Data systematics (sigma syst-but FD + extrap) syst
744  //
745  //
746  // Data syst: a) Syst in p-p
747  //
748  Double_t ptwidth = hSigmaAB->GetBinWidth(hABbin) / 2. ;
749  istartPPextr = -1;
750  if(!isExtrapolatedBin) istartPPextr = FindGraphBin(gSigmaPPSystTheory,pt);
751 
752  Double_t dataPPUp=0., dataPPLow=0.;
753  if(isExtrapolatedBin) {
754  dataPPUp = gSigmaPPSyst->GetErrorYhigh(istartPPsyst);
755  dataPPLow = gSigmaPPSyst->GetErrorYlow(istartPPsyst);
756  systPPUp = dataPPUp;
757  systPPLow = dataPPLow;
758  } else {
759  dataPPUp = ExtractFDSyst( gSigmaPPSystData->GetErrorYhigh(istartPPextr), gSigmaPPSystFeedDown->GetErrorYhigh(istartPPfd) );
760  dataPPLow = ExtractFDSyst( gSigmaPPSystData->GetErrorYlow(istartPPextr), gSigmaPPSystFeedDown->GetErrorYlow(istartPPfd) );
761  systPPUp = TMath::Sqrt( dataPPUp*dataPPUp + gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr) );
762  systPPLow = TMath::Sqrt( dataPPLow*dataPPLow + gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*gSigmaPPSystTheory->GetErrorYlow(istartPPextr) );
763  }
764  if (isRaavsEP>0.) {
765  dataPPUp = dataPPUp*0.5;
766  dataPPLow = dataPPLow*0.5;
767  if(isExtrapolatedBin) {
768  systPPUp = dataPPUp;
769  systPPLow = dataPPLow;
770  } else {
771  systPPUp = TMath::Sqrt( dataPPUp*dataPPUp + 0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr) );
772  systPPLow = TMath::Sqrt( dataPPLow*dataPPLow + 0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr) );
773  }
774  }
775  systPPUp *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
776  systPPLow *= scalePPRefToMatchRapidityBin; // scale to the proper rapidity bin width
777 
778 
779  if(printout && TMath::Abs(ptprintout-pt)<0.1) {
780  cout << " pt : "<< pt<<" Syst-pp-data "<< dataPPUp/sigmapp << "%, ";
781  if(!isExtrapolatedBin){
782  if (isRaavsEP>0.) cout <<" extr unc + "<< 0.5*gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)/sigmapp <<" - "<< 0.5*gSigmaPPSystTheory->GetErrorYlow(istartPPextr)/sigmapp <<" %";
783  else cout <<" extr unc + "<< (gSigmaPPSystTheory->GetErrorYhigh(istartPPextr)*scalePPRefToMatchRapidityBin)/sigmapp <<" - "<< (gSigmaPPSystTheory->GetErrorYlow(istartPPextr)*scalePPRefToMatchRapidityBin)/sigmapp <<" %";
784  }
785  cout << endl;
786  }
787 
788  //
789  // Data syst: b) Syst in PbPb
790  //
791  Double_t dataSystUp=0., dataSystDown=0.;
792  Bool_t PbPbDataSystOk = PbPbDataSyst(systematicsAB,pt,cc,dataSystUp,dataSystDown);
793  if (!PbPbDataSystOk) { cout <<" There is some issue with the PbPb data systematics, please check and rerun"<<endl; return; }
794  systABUp = sigmaAB * TMath::Sqrt( dataSystUp*dataSystUp +
795  (hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin))*(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin)) );
796 
797  systABLow = sigmaAB * TMath::Sqrt( dataSystDown*dataSystDown +
798  (hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin))*(hDirectEffptAB->GetBinError(hABbin)/hDirectEffptAB->GetBinContent(hABbin)) );
799  //
800  // Data syst : c) combine pp & PbPb
801  //
802  systLow = sigmapp>0. ?
803  RaaCharm * TMath::Sqrt( (systABLow/sigmaAB)*(systABLow/sigmaAB) + (systPPUp/sigmapp)*(systPPUp/sigmapp) )
804  : 0.;
805 
806  systUp = sigmapp>0. ?
807  RaaCharm * TMath::Sqrt( (systABUp/sigmaAB)*(systABUp/sigmaAB) + (systPPLow/sigmapp)*(systPPLow/sigmapp) )
808  : 0.;
809  if ( RaaCharm==0 ) { systPPUp =0.; systPPLow =0.; }
810 
811  // if(printout)
812  cout << " Syst-pp-up "<< systPPUp/sigmapp <<"%, syst-pp-low "<< systPPLow/sigmapp <<"%, syst-AB-up "<<systABUp/sigmaAB<<"%, syst-AB-low "<<systABLow/sigmaAB<<"%, tot-syst-up "<<systUp/RaaCharm<<"%, tot-syst-low "<<systLow/RaaCharm<<"%"<<endl;
813 
814  if ( RaaCharm>0 ) {
815  hRABvsPt_DataSystematics->SetBinContent( hRABbin, RaaCharm );
816  hRABvsPt_DataSystematics->SetBinError( hRABbin, systUp );
817  gRAB_DataSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
818  gRAB_DataSystematics->SetPointError( hABbin, ptwidth, ptwidth, systLow, systUp );
819  gRAB_DataSystematics->SetPointEXlow(hABbin, 0.4); gRAB_DataSystematics->SetPointEXhigh(hABbin,0.4);
820  gRAB_DataSystematicsPP->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
821  gRAB_DataSystematicsPP->SetPointError( hABbin, ptwidth, ptwidth, RaaCharm *(systPPUp/sigmapp), RaaCharm *systPPLow/sigmapp );
822  gRAB_DataSystematicsAB->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
823  gRAB_DataSystematicsAB->SetPointError( hABbin, ptwidth, ptwidth, RaaCharm *systABLow/sigmaAB, RaaCharm *systABUp/sigmaAB );
824  }
825 
826  //
827  // Feed-down Systematics
828  //
829  Double_t FDL=0., FDH=0.;
830  if ( RaaCharmFDhigh > RaaCharmFDlow ){
831  FDH = RaaCharmFDhigh; FDL = RaaCharmFDlow;
832  } else {
833  FDL = RaaCharmFDhigh; FDH = RaaCharmFDlow;
834  }
835 
836  if(printout && TMath::Abs(ptprintout-pt)<0.1) cout<<" Raa "<<RaaCharm<<", Raa-fd-low "<<RaaCharmFDlow <<", Raa-fd-high "<<RaaCharmFDhigh <<endl;
837  maxFdSyst = TMath::Abs(FDH - RaaCharm);
838  minFdSyst = TMath::Abs(RaaCharm - FDL);
839  if ( RaaCharm>0 ) {
840  gRAB_FeedDownSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
841  gRAB_FeedDownSystematics->SetPointError( hABbin, 0.3, 0.3, minFdSyst, maxFdSyst ); // i, x, y
842  gRAB_fcFeedDownOnly->SetPoint( hABbin, pt,fcAB );
843  gRAB_fcFeedDownOnly->SetPointError(hABbin, 0.3, 0.3, fcAB-(sigmaABMin/sigmaAB*fcAB), (sigmaABMax/sigmaAB*fcAB)-fcAB );
844  }
845 
846  // if(printout) {
847  cout<<" FD syst +"<< maxFdSyst/RaaCharm <<" - "<<minFdSyst/RaaCharm<<endl;
848  cout<<" fc = "<<fcAB<<", ("<< sigmaABMax/sigmaAB * fcAB <<","<< sigmaABMin/sigmaAB * fcAB <<")"<<endl;
849  // }
850 
851  //
852  // Filling part of the Eloss scenarii information
853  //
854  if(RaaCharm>0 ) {
855  gRAB_ElossHypothesis->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
856  gRAB_ElossHypothesis->SetPointEXlow( hABbin, ptwidth);
857  gRAB_ElossHypothesis->SetPointEXhigh( hABbin, ptwidth);
858  gRAB_FeedDownSystematicsElossHypothesis->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
859  gRAB_FeedDownSystematicsElossHypothesis->SetPointEXlow( hABbin, ptwidth);
860  gRAB_FeedDownSystematicsElossHypothesis->SetPointEXhigh( hABbin, ptwidth);
861  gRAB_GlobalSystematics->SetPoint( hABbin, pt, RaaCharm ); // i, x, y
862  gRAB_GlobalSystematics->SetPointEXlow(hABbin,0.4); gRAB_GlobalSystematics->SetPointEXhigh(hABbin,0.4);
863  }
864  }
865 
866  //
867  // Filling Eloss scenarii information
868  //
869  // trick in case not fine enough Rb hypothesis to cope with the min/max range
870  // if( RaaCharm>0 && ( (ElossHypo >= MinHypo && ElossHypo <=MaxHypo) || ElossHypo == ElossCentral[ hABbin ] ) && RaaBeauty<=MaxRb ) {
871  // by default better not use it, to monitor when this happens (could affect results)
872  if( RaaCharm>0 && ElossHypo >= MinHypo && ElossHypo <=MaxHypo && RaaBeauty<=MaxRb ) {
873 
874  Double_t Ehigh = ElossMax[ hABbin ] ;
875  Double_t Elow = ElossMin[ hABbin ] ;
876  if ( RaaCharm > Ehigh ) ElossMax[ hABbin ] = RaaCharm ;
877  if ( RaaCharm < Elow ) ElossMin[ hABbin ] = RaaCharm ;
878  if(printout && TMath::Abs(ptprintout-pt)<0.1) {
879  cout<<" Hypothesis " << ElossHypo << " sigma-AB "<< sigmaAB <<", Raa "<< RaaCharm <<", Raa Eloss max "<< ElossMax[hABbin] <<" Raa Eloss min "<< ElossMin[hABbin] << " Rb="<< RaaBeauty <<endl;
880  cout<<" Rb="<< RaaBeauty <<" max "<< RaaBeautyFDhigh <<" min "<< RaaBeautyFDlow <<endl;
881  }
882  Double_t fcEhigh = fcElossMax[ hABbin ] ;
883  Double_t fcElow = fcElossMin[ hABbin ] ;
884  if ( fcAB > fcEhigh ) fcElossMax[ hABbin ] = fcAB ;
885  if ( fcAB < fcElow ) fcElossMin[ hABbin ] = fcAB ;
886  Double_t FDEhigh = FDElossMax[ hABbin ];
887  Double_t FDEmin = FDElossMin[ hABbin ];
888  Double_t RFDhigh = RaaCharmFDhigh>RaaCharmFDlow ? RaaCharmFDhigh : RaaCharmFDlow;
889  Double_t RFDlow = RaaCharmFDlow<RaaCharmFDhigh ? RaaCharmFDlow : RaaCharmFDhigh;
890  if ( RFDhigh > FDEhigh ) FDElossMax[ hABbin ] = RFDhigh ;
891  if ( RFDlow < FDEmin ) FDElossMin[ hABbin ] = RFDlow ;
892  if(printout && TMath::Abs(ptprintout-pt)<0.1)
893  cout<<" Hypothesis " << ElossHypo << " sigma-AB "<< sigmaAB <<", Raa FD-max Eloss max "<< FDElossMax[hABbin] <<" Raa FD-min Eloss min "<< FDElossMin[hABbin] <<endl;
894  }
895 
896 
897  }
898 
899 
900  // Finish filling the y-uncertainties of the Eloss scenarii
901  for (Int_t ibin=0; ibin<=nbins; ibin++){
902  Double_t ipt=0., value =0.;
903  gRAB_ElossHypothesis->GetPoint(ibin,ipt,value);
904  if(ipt<=0) continue;
905  //
906  // Uncertainty on Raa due to the Eloss hypothesis
907  Double_t elossYhigh = TMath::Abs( ElossMax[ibin] - value );
908  Double_t elossYlow = TMath::Abs( value - ElossMin[ibin] );
909  gRAB_ElossHypothesis->SetPointEYhigh(ibin, elossYhigh );
910  gRAB_ElossHypothesis->SetPointEYlow(ibin, elossYlow );
911  gRAB_ElossHypothesis->SetPointEXhigh(ibin, 0.2);
912  gRAB_ElossHypothesis->SetPointEXlow(ibin, 0.2);
913  cout << " pt "<< ipt << " Raa "<< value <<" max "<< ElossMax[ibin] << " min " <<ElossMin[ibin] <<endl;
914  cout<<" Eloss syst +"<< elossYhigh <<" - "<< elossYlow <<endl;
915  // cout << " fc max "<< fcElossMax[ibin] << " fc min " <<fcElossMin[ibin] <<endl;
916  //
917  // Uncertainty on Raa due to the FD unc & Eloss hypothesis
918  Double_t fdElossEYhigh = TMath::Abs( FDElossMax[ibin] - value );
919  Double_t fdElossEYlow = TMath::Abs( value - FDElossMin[ibin] );
920  if(elossFDQuadSum){
921  Double_t fdEYhigh = gRAB_FeedDownSystematics->GetErrorYhigh(ibin);
922  fdElossEYhigh = TMath::Sqrt( elossYhigh*elossYhigh + fdEYhigh*fdEYhigh );
923  Double_t fdEYlow = gRAB_FeedDownSystematics->GetErrorYlow(ibin);
924  fdElossEYlow = TMath::Sqrt( elossYlow*elossYlow + fdEYlow*fdEYlow );
925  }
926  gRAB_FeedDownSystematicsElossHypothesis->SetPointEYhigh(ibin, fdElossEYhigh );
927  gRAB_FeedDownSystematicsElossHypothesis->SetPointEYlow(ibin, fdElossEYlow );
928  gRAB_FeedDownSystematicsElossHypothesis->SetPointEXhigh(ibin, 0.25);
929  gRAB_FeedDownSystematicsElossHypothesis->SetPointEXlow(ibin, 0.25);
930  cout<<" FD & Eloss syst +"<< fdElossEYhigh <<" - "<< fdElossEYlow
931  <<" = + "<< fdElossEYhigh/value <<" - "<< fdElossEYlow/value <<" %" <<endl;
932  //
933  // All uncertainty on Raa (FD unc & Eloss + data)
934  Double_t systdatal = gRAB_DataSystematics->GetErrorYlow(ibin);
935  Double_t systdatah = gRAB_DataSystematics->GetErrorYhigh(ibin);
936  Double_t systgbhUnc = TMath::Sqrt( systdatah*systdatah + fdElossEYhigh*fdElossEYhigh );
937  Double_t systgblUnc = TMath::Sqrt( systdatal*systdatal + fdElossEYlow*fdElossEYlow );
938  gRAB_GlobalSystematics->SetPointEYhigh(ibin,systgbhUnc);
939  gRAB_GlobalSystematics->SetPointEYlow(ibin,systgblUnc);
940  cout<<" Data syst +"<< systdatah <<" - "<< systdatal <<" = + "<< systdatah/value <<" - " << systdatal/value << " % "<<endl;
941  cout<<" Global syst +"<< systgbhUnc <<" - "<< systgblUnc << " = + "<< systgbhUnc/value <<" - "<< systgblUnc/value << " %" <<endl;
942  //
943  }
944 
945 
946  gROOT->SetStyle("Plain");
947  gStyle->SetPalette(1);
948  gStyle->SetOptStat(0);
949 
950 
951  TCanvas *cRABvsRb = new TCanvas("RABvsRb","RAB vs Rb");
952  hRABvsRb->Draw("colz");
953  cRABvsRb->Update();
954 
955  TCanvas *cRABvsRbvsPt = new TCanvas("cRABvsRbvsPt","RAB vs Rb vs pt");
956  hRABCharmVsRBeautyVsPt->Draw("lego3z");
957  cRABvsRbvsPt->Update();
958 
959 
960  TCanvas *cRABvsRbFDl = new TCanvas("RABvsRbFDl","RAB vs Rb (FD low)");
961  hRABvsRbFDlow->Draw("cont4z");
962  cRABvsRbFDl->Update();
963  TCanvas *cRABvsRbFDh = new TCanvas("RABvsRbFDh","RAB vs Rb (FD high)");
964  hRABvsRbFDhigh->Draw("cont4z");
965  cRABvsRbFDh->Update();
966 
967  TCanvas * cSigmaABptEloss = new TCanvas("cSigmaABptEloss","SigmaAB vs pt, Eloss hypothesis");
968  TH1D *hSigmaABEloss00= new TH1D("hSigmaABEloss00","hSigmaABEloss00",nbins,limits);
969  TH1D *hSigmaABEloss05= new TH1D("hSigmaABEloss05","hSigmaABEloss05",nbins,limits);
970  TH1D *hSigmaABEloss10= new TH1D("hSigmaABEloss10","hSigmaABEloss10",nbins,limits);
971  TH1D *hSigmaABEloss15= new TH1D("hSigmaABEloss15","hSigmaABEloss15",nbins,limits);
972  TH1D *hSigmaABEloss20= new TH1D("hSigmaABEloss20","hSigmaABEloss20",nbins,limits);
973 
974  delete [] limits;
975  delete [] binwidths;
976 
977  for (Int_t i=0; i<=nSigmaAB->GetEntriesFast(); i++) {
978  nSigmaAB->GetEntry(i);
979  if (fdMethod==kfc) {
980  if( TMath::Abs(Rcb-0.015)<0.009 ) hSigmaABEloss00->Fill(pt,sigmaAB);
981  if( TMath::Abs(Rcb-0.5)<0.009 ) hSigmaABEloss05->Fill(pt,sigmaAB);
982  if( TMath::Abs(Rcb-1.0)<0.009 ) hSigmaABEloss10->Fill(pt,sigmaAB);
983  if( TMath::Abs(Rcb-1.5)<0.009 ) hSigmaABEloss15->Fill(pt,sigmaAB);
984  if( TMath::Abs(Rcb-2.0)<0.009 ) hSigmaABEloss20->Fill(pt,sigmaAB);
985  }
986  else if (fdMethod==kNb) {
987  if( TMath::Abs(Rb-0.015)<0.009 ) hSigmaABEloss00->Fill(pt,sigmaAB);
988  if( TMath::Abs(Rb-0.5)<0.009 ) hSigmaABEloss05->Fill(pt,sigmaAB);
989  if( TMath::Abs(Rb-1.0)<0.009 ) hSigmaABEloss10->Fill(pt,sigmaAB);
990  if( TMath::Abs(Rb-1.5)<0.009 ) hSigmaABEloss15->Fill(pt,sigmaAB);
991  if( TMath::Abs(Rb-2.0)<0.009 ) hSigmaABEloss20->Fill(pt,sigmaAB);
992  }
993  }
994  hSigmaABEloss00->SetLineColor(2);
995  hSigmaABEloss05->SetLineColor(3);
996  hSigmaABEloss10->SetLineColor(4);
997  hSigmaABEloss15->SetLineColor(kMagenta+1);
998  hSigmaABEloss20->SetLineColor(kGreen+2);
999  hSigmaABEloss00->SetMarkerStyle(22);
1000  hSigmaABEloss05->SetMarkerStyle(26);
1001  hSigmaABEloss10->SetMarkerStyle(20);
1002  hSigmaABEloss15->SetMarkerStyle(25);
1003  hSigmaABEloss20->SetMarkerStyle(21);
1004  if (fdMethod==kNb) {
1005  hSigmaABEloss05->Draw("ph");
1006  hSigmaABEloss10->Draw("phsame");
1007  hSigmaABEloss15->Draw("phsame");
1008  hSigmaABEloss20->Draw("phsame");
1009  }
1010  else {
1011  hSigmaABEloss20->Draw("p");
1012  hSigmaABEloss00->Draw("phsame");
1013  hSigmaABEloss05->Draw("phsame");
1014  hSigmaABEloss10->Draw("phsame");
1015  hSigmaABEloss15->Draw("phsame");
1016  hSigmaABEloss20->Draw("phsame");
1017  }
1018  TLegend *legrcb = new TLegend(0.8,0.8,0.95,0.9);
1019  legrcb->SetFillColor(0);
1020  legrcb->AddEntry(hSigmaABEloss00,"Rc/b=0.0","lp");
1021  legrcb->AddEntry(hSigmaABEloss05,"Rc/b=0.5","lp");
1022  legrcb->AddEntry(hSigmaABEloss10,"Rc/b=1.0","lp");
1023  legrcb->AddEntry(hSigmaABEloss15,"Rc/b=1.5","lp");
1024  legrcb->AddEntry(hSigmaABEloss20,"Rc/b=2.0","lp");
1025  legrcb->Draw();
1026  cSigmaABptEloss->Update();
1027 
1028 
1029  TCanvas * cRABptEloss = new TCanvas("cRABptEloss","RAB vs pt, Eloss hypothesis");
1030  hRABEloss00->SetLineColor(2);
1031  hRABEloss05->SetLineColor(3);
1032  hRABEloss10->SetLineColor(4);
1033  hRABEloss15->SetLineColor(kMagenta+1);
1034  hRABEloss20->SetLineColor(kGreen+2);
1035  hRABEloss00->SetMarkerStyle(22);
1036  hRABEloss05->SetMarkerStyle(26);
1037  hRABEloss10->SetMarkerStyle(20);
1038  hRABEloss15->SetMarkerStyle(25);
1039  hRABEloss20->SetMarkerStyle(21);
1040  if (fdMethod==kNb) {
1041  hRABEloss05->Draw("ph");
1042  hRABEloss10->Draw("phsame");
1043  hRABEloss15->Draw("phsame");
1044  hRABEloss20->Draw("phsame");
1045  }
1046  else {
1047  hRABEloss20->Draw("p");
1048  hRABEloss00->Draw("phsame");
1049  hRABEloss05->Draw("phsame");
1050  hRABEloss10->Draw("phsame");
1051  hRABEloss15->Draw("phsame");
1052  hRABEloss20->Draw("phsame");
1053  }
1054  legrcb = new TLegend(0.8,0.8,0.95,0.9);
1055  legrcb->SetFillColor(0);
1056  if (fdMethod==kfc) {
1057  legrcb->AddEntry(hRABEloss00,"Rc/b=0.0","lp");
1058  legrcb->AddEntry(hRABEloss05,"Rc/b=0.5","lp");
1059  legrcb->AddEntry(hRABEloss10,"Rc/b=1.0","lp");
1060  legrcb->AddEntry(hRABEloss15,"Rc/b=0.5","lp");
1061  legrcb->AddEntry(hRABEloss20,"Rc/b=2.0","lp");
1062  }
1063  else if (fdMethod==kNb) {
1064  legrcb->AddEntry(hRABEloss00,"Rb=0.0","lp");
1065  legrcb->AddEntry(hRABEloss05,"Rb=0.5","lp");
1066  legrcb->AddEntry(hRABEloss10,"Rb=1.0","lp");
1067  legrcb->AddEntry(hRABEloss15,"Rb=0.5","lp");
1068  legrcb->AddEntry(hRABEloss20,"Rb=2.0","lp");
1069  }
1070  legrcb->Draw();
1071  cRABptEloss->Update();
1072 
1073 
1074  TCanvas * cRABpt = new TCanvas("cRABpt","RAB vs pt, no hypothesis");
1075  hRABEloss10->Draw("");
1076  cRABpt->Update();
1077 
1078  TCanvas * cRABptFDUnc = new TCanvas("cRABptFDUnc","RAB vs pt, FD Uncertainties");
1079  hRABvsRbFDlow_proj->Draw("");
1080  hRABEloss10->Draw("phsame");
1081  hRABvsRbFDhigh_proj->SetLineColor(kMagenta+1);
1082  hRABvsRbFDhigh_proj->Draw("same");
1083  hRABvsRbFDlow_proj->SetLineColor(kGreen+2);
1084  hRABvsRbFDlow_proj->Draw("same");
1085  legrcb = new TLegend(0.8,0.8,0.95,0.9);
1086  legrcb->SetFillColor(0);
1087  legrcb->AddEntry(hRABEloss10,"FD Central","lp");
1088  legrcb->AddEntry(hRABvsRbFDhigh_proj,"FD Upper unc.","l");
1089  legrcb->AddEntry(hRABvsRbFDlow_proj,"FD Lower unc.","l");
1090  legrcb->Draw();
1091  cRABptFDUnc->Update();
1092 
1093  TCanvas *RaaPlot = new TCanvas("RaaPlot","RAB vs pt, plot all");
1094  RaaPlot->SetTopMargin(0.085);
1095  RaaPlot->SetBottomMargin(0.1);
1096  RaaPlot->SetTickx();
1097  RaaPlot->SetTicky();
1098  TH2D *hRaaCanvas = new TH2D("hRaaCanvas"," R_{AB}(c) vs p_{T} (no Eloss hypothesis); p_{t} [GeV/c] ; R_{AA} prompt D",40,0.,40.,100,0.,3.0);
1099  hRaaCanvas->GetXaxis()->SetTitleSize(0.05);
1100  hRaaCanvas->GetXaxis()->SetTitleOffset(0.9);
1101  hRaaCanvas->GetYaxis()->SetTitleSize(0.05);
1102  hRaaCanvas->GetYaxis()->SetTitleOffset(0.9);
1103  hRaaCanvas->Draw();
1104  gRAB_Norm->SetFillStyle(1001);
1105  gRAB_Norm->SetFillColor(kGray+2);
1106  gRAB_Norm->Draw("2");
1107  TLine *line = new TLine(0.0172415,1.0,40.,1.0);
1108  line->SetLineStyle(2);
1109  line->Draw();
1110  hRABvsPt->SetMarkerColor(kBlue);
1111  hRABvsPt->SetMarkerColor(kBlue);
1112  hRABvsPt->SetMarkerStyle(21);
1113  hRABvsPt->SetMarkerSize(1.1);
1114  hRABvsPt->SetLineWidth(2);
1115  hRABvsPt->Draw("psame");
1116  gRAB_DataSystematics->SetLineColor(kBlue);
1117  gRAB_DataSystematics->SetLineWidth(3);
1118  gRAB_DataSystematics->SetLineWidth(2);
1119  gRAB_DataSystematics->SetFillColor(kRed);
1120  gRAB_DataSystematics->SetFillStyle(0);
1121  gRAB_DataSystematics->Draw("2");
1122  gRAB_FeedDownSystematics->SetFillColor(kViolet+1);
1123  gRAB_FeedDownSystematics->SetFillStyle(1001);
1124  gRAB_FeedDownSystematics->Draw("2");
1125  gRAB_ElossHypothesis->SetLineColor(kMagenta-7);
1126  gRAB_ElossHypothesis->SetFillColor(kMagenta-7);
1127  gRAB_ElossHypothesis->SetFillStyle(1001);
1128  gRAB_ElossHypothesis->Draw("2");
1129  hRABvsPt->Draw("psame");
1130  gRAB_DataSystematics->Draw("2");
1131  legrcb = new TLegend(0.5517241,0.6504237,0.8520115,0.8728814,NULL,"brNDC");
1132  legrcb->SetBorderSize(0);
1133  legrcb->SetTextSize(0.03389831);
1134  legrcb->SetLineColor(1);
1135  legrcb->SetLineStyle(1);
1136  legrcb->SetLineWidth(1);
1137  legrcb->SetFillColor(0);
1138  legrcb->SetFillStyle(1001);
1139  if(cc==k020) legrcb->AddEntry(hRABvsPt,"R_{AA} 0-20% CC","pe");
1140  else if(cc==k4080) legrcb->AddEntry(hRABvsPt,"R_{AA} 40-80% CC","pe");
1141  else legrcb->AddEntry(hRABvsPt,"R_{AA} and stat. unc.","pe");
1142  legrcb->AddEntry(gRAB_DataSystematics,"Syst. from data","f");
1143  legrcb->AddEntry(gRAB_ElossHypothesis,"Syst. from R_{AA}(B)","f");
1144  legrcb->AddEntry(gRAB_FeedDownSystematics,"Syst. from B feed-down","f");
1145  legrcb->Draw();
1146  TLatex* tc;
1147  TString system = "Pb-Pb #sqrt{s_{NN}}=2.76 TeV";
1148  if( cc==kpPb0100 || cc==kpPb020 || cc==kpPb2040 || cc==kpPb4060 || cc==kpPb60100 ) system = "p-Pb #sqrt{s_{NN}}=5.023 TeV";
1149  if(decay==1) tc =new TLatex(0.18,0.82,Form("D^{0}, %s ",system.Data()));
1150  else if(decay==2) tc =new TLatex(0.18,0.82,Form("D^{+}, %s ",system.Data()));
1151  else if(decay==3) tc =new TLatex(0.18,0.82,Form("D^{*+}, %s ",system.Data()));
1152  else if(decay==4) tc =new TLatex(0.18,0.82,Form("D_{s}^{+}, %s ",system.Data()));
1153  else tc =new TLatex(0.18,0.82,Form("any (?) D meson, %s ",system.Data()));
1154  tc->SetNDC();
1155  tc->SetTextSize(0.038);
1156  tc->SetTextFont(42);
1157  tc->Draw();
1158  RaaPlot->Update();
1159 
1160 
1161  TCanvas *RaaPlotFDEloss = new TCanvas("RaaPlotFDEloss","RAB vs pt, plot FD & ElossUnc");
1162  RaaPlotFDEloss->SetTopMargin(0.085);
1163  RaaPlotFDEloss->SetBottomMargin(0.1);
1164  hRaaCanvas->Draw();
1165  line->Draw();
1166  hRABvsPt->Draw("psame");
1167  gRAB_FeedDownSystematics->SetFillColor(kViolet+1);
1168  gRAB_FeedDownSystematics->SetFillStyle(1001);
1169  gRAB_FeedDownSystematics->Draw("2");
1170  gRAB_ElossHypothesis->SetLineColor(kMagenta-7);
1171  gRAB_ElossHypothesis->SetFillColor(kMagenta-7);
1172  gRAB_ElossHypothesis->SetFillStyle(1001);
1173  gRAB_ElossHypothesis->Draw("2");
1174  gRAB_FeedDownSystematicsElossHypothesis->SetLineColor(kBlack);
1175  gRAB_FeedDownSystematicsElossHypothesis->SetFillStyle(0);
1176  gRAB_FeedDownSystematicsElossHypothesis->SetFillColor(kViolet+1);
1177  gRAB_FeedDownSystematicsElossHypothesis->Draw("2");
1178  hRABvsPt->Draw("psame");
1179  legrcb = new TLegend(0.6,0.6,0.9,0.9);
1180  legrcb->SetBorderSize(0);
1181  legrcb->SetTextSize(0.03389831);
1182  legrcb->SetLineColor(1);
1183  legrcb->SetLineStyle(1);
1184  legrcb->SetLineWidth(1);
1185  legrcb->SetFillColor(0);
1186  legrcb->SetFillStyle(1001);
1187  legrcb->AddEntry(hRABvsPt,"R_{PbPb} and stat. unc.","pe");
1188  legrcb->AddEntry(gRAB_ElossHypothesis,"Energy loss syst.","f");
1189  legrcb->AddEntry(gRAB_FeedDownSystematics,"Feed down syst.","f");
1190  legrcb->AddEntry(gRAB_FeedDownSystematicsElossHypothesis,"Feed down & Eloss syst.","f");
1191  legrcb->Draw();
1192  RaaPlotFDEloss->Update();
1193 
1194 
1195  TCanvas *RaaPlotGlob = new TCanvas("RaaPlotGlob","RAB vs pt, plot Global unc");
1196  RaaPlotGlob->SetTopMargin(0.085);
1197  RaaPlotGlob->SetBottomMargin(0.1);
1198  RaaPlotGlob->SetTickx();
1199  RaaPlotGlob->SetTicky();
1200  hRaaCanvas->Draw();
1201  line->Draw();
1202  hRABvsPt->Draw("psame");
1203  gRAB_DataSystematics->Draw("2");
1204  gRAB_FeedDownSystematicsElossHypothesis->Draw("2");
1205  gRAB_GlobalSystematics->SetLineColor(kRed);
1206  gRAB_GlobalSystematics->SetLineWidth(2);
1207  gRAB_GlobalSystematics->SetFillColor(kRed);
1208  gRAB_GlobalSystematics->SetFillStyle(3002);
1209  gRAB_GlobalSystematics->Draw("2");
1210  hRABvsPt->Draw("psame");
1211  legrcb = new TLegend(0.6,0.6,0.9,0.9);
1212  legrcb->SetBorderSize(0);
1213  legrcb->SetTextSize(0.03389831);
1214  legrcb->SetLineColor(1);
1215  legrcb->SetLineStyle(1);
1216  legrcb->SetLineWidth(1);
1217  legrcb->SetFillColor(0);
1218  legrcb->SetFillStyle(1001);
1219  legrcb->AddEntry(hRABvsPt,"R_{PbPb} and stat. unc.","pe");
1220  legrcb->AddEntry(gRAB_DataSystematics,"Data syst.","f");
1221  legrcb->AddEntry(gRAB_FeedDownSystematicsElossHypothesis,"Feed down & Eloss syst.","f");
1222  legrcb->AddEntry(gRAB_GlobalSystematics,"Global syst.","f");
1223  legrcb->Draw();
1224  RaaPlotGlob->Update();
1225 
1226 
1227 
1228  TCanvas *RaaPlotSimple = new TCanvas("RaaPlotSimple","RAB vs pt, plot Simple unc");
1229  RaaPlotSimple->SetTopMargin(0.085);
1230  RaaPlotSimple->SetBottomMargin(0.1);
1231  RaaPlotSimple->SetTickx();
1232  RaaPlotSimple->SetTicky();
1233  hRaaCanvas->Draw();
1234  line->Draw();
1235  hRABvsPt->Draw("psame");
1236  gRAB_GlobalSystematics->SetLineColor(kBlue);
1237  gRAB_GlobalSystematics->SetLineWidth(2);
1238  gRAB_GlobalSystematics->SetFillStyle(0);
1239  gRAB_GlobalSystematics->Draw("2");
1240  gRAB_Norm->Draw("2");
1241  hRABvsPt->Draw("psame");
1242  legrcb = new TLegend(0.5991379,0.6949153,0.8534483,0.8559322,NULL,"brNDC");
1243  legrcb->SetBorderSize(0);
1244  legrcb->SetTextSize(0.03389831);
1245  legrcb->SetLineColor(1);
1246  legrcb->SetLineStyle(1);
1247  legrcb->SetLineWidth(1);
1248  legrcb->SetFillColor(0);
1249  legrcb->SetFillStyle(1001);
1250  if(cc==k020) legrcb->AddEntry(hRABvsPt,"R_{AA} 0-20% CC","pe");
1251  else if(cc==k4080) legrcb->AddEntry(hRABvsPt,"R_{AA} 40-80% CC","pe");
1252  else legrcb->AddEntry(hRABvsPt,"R_{AA} and stat. unc.","pe");
1253  legrcb->AddEntry(gRAB_GlobalSystematics,"Systematics","f");
1254  legrcb->Draw();
1255  tc->Draw();
1256  RaaPlotSimple->Update();
1257 
1258 
1259  TCanvas *c = new TCanvas("c","");
1260  systematicsAB->DrawErrors();
1261  c->Update();
1262 
1263  TCanvas *cStatUnc = new TCanvas("cStatUnc","stat unc");
1264  cStatUnc->Divide(2,2);
1265  cStatUnc->cd(1);
1266  fhStatUncEffcSigmaAB_Raa->Draw("e");
1267  cStatUnc->cd(2);
1268  fhStatUncEffbSigmaAB_Raa->Draw("e");
1269  cStatUnc->cd(3);
1270  fhStatUncEffcFDAB_Raa->Draw("e");
1271  cStatUnc->cd(4);
1272  fhStatUncEffbFDAB_Raa->Draw("e");
1273  cStatUnc->Update();
1274 
1275  //
1276  // Write the information to a file
1277  //
1278  TFile * out = new TFile(outfile,"recreate");
1279 
1280  ntupleRAB->Write();
1281  hRABvsRcb->Write();
1282  hRABvsRb->Write();
1283  hRABCharmVsRBeautyVsPt->Write();
1284  for(Int_t j=0; j<=nbins; j++) hRCharmVsRBeauty[j]->Write();
1285  // for(Int_t j=0; j<=nbins; j++) hRCharmVsElossHypo[j]->Write();
1286  hRABvsPt->Write();
1287  hRABvsPt_DataSystematics->Write();
1288  gRAB_ElossHypothesis->Write();
1289  gRAB_FeedDownSystematics->Write();
1290  gRAB_fcFeedDownOnly->Write();
1291  gRAB_DataSystematics->Write();
1292  gRAB_DataSystematicsPP->Write();
1293  gSigmaPPSystTheory->Write();
1294  gRAB_DataSystematicsAB->Write();
1295  gRAB_Norm->Write();
1296  gRAB_FeedDownSystematicsElossHypothesis->Write();
1297  gRAB_GlobalSystematics->Write();
1298  if(isScaledAndExtrapRef) hCombinedReferenceFlag->Write();
1299 
1300  out->Write();
1301 
1302 }
1303 
1304 //____________________________________________________________
1305 Bool_t PbPbDataSyst(AliHFSystErr *syst, Double_t pt, Int_t cc, Double_t &dataSystUp, Double_t &dataSystDown)
1306 {
1307 
1308  Double_t err=0., errUp=1., errDown=1.;
1309  Bool_t isOk=false;
1310  Double_t pidunc=0.;
1311 
1312  err = syst->GetTotalSystErr(pt)*syst->GetTotalSystErr(pt);
1313  errUp = err ;
1314  errDown = err ;
1315 
1316  // Apply an asymetric PID uncertainty for 2010 PbPb data only
1317  if( syst->GetRunNumber()==10 && syst->GetCollisionType()==1 ) {
1318  if( cc==k07half || cc==k020 || cc==k010 || cc==k1020 || cc==k2040 ) {
1319  if(pt<6) pidunc = 0.15;
1320  else pidunc = 0.05;
1321  errUp = err + pidunc*pidunc - syst->GetPIDEffErr(pt)*syst->GetPIDEffErr(pt);
1322  isOk = true;
1323  }
1324  else if ( cc==k3050 || cc==k4080 || cc==k4060 || cc==k6080 ){
1325  if(pt<3.1) pidunc = 0.10;
1326  else pidunc = 0.05;
1327  errUp = err + pidunc*pidunc - syst->GetPIDEffErr(pt)*syst->GetPIDEffErr(pt);
1328  isOk = true;
1329  }
1330  }
1331  else { isOk = true; }
1332 
1333  dataSystUp = TMath::Sqrt(errUp);
1334  dataSystDown = TMath::Sqrt(errDown);
1335 
1336  return isOk;
1337 }
particularity
Definition: HFPtSpectrum.C:47
BFDSubtrMethod
Definition: HFPtSpectrum.C:44
centrality
void SetCentrality(TString centrality)
Definition: AliHFSystErr.h:60
void SetIsPbPb2010EnergyScan(Bool_t flag)
Definition: AliHFSystErr.h:77
Bool_t elossFDQuadSum
Int_t GetRunNumber() const
Definition: AliHFSystErr.h:48
RaavsEP
Definition: HFPtSpectrum.C:45
centestimator
rapidity
Definition: HFPtSpectrum.C:46
void HFPtSpectrumRaa(const char *ppfile="HFPtSpectrum_D0Kpi_method2_rebinnedth_230311_newsigma.root", const char *ABfile="HFPtSpectrum_D0Kpi_PbPbcuts_method2_rebinnedth_230311_newsigma.root", const char *outfile="HFPtSpectrumRaa.root", Int_t decay=1, Double_t sigmaABCINT1B=54.e9, Int_t fdMethod=kNb, Int_t cc=kpp, Int_t Energy=k276, Double_t MinHypo=1./3., Double_t MaxHypo=3.0, Double_t MaxRb=6.0, Bool_t isRbHypo=false, Double_t CentralHypo=1.0, Int_t ccestimator=kV0M, Bool_t isUseTaaForRaa=true, const char *shadRbcFile="", Int_t nSigmaShad=3.0, Int_t isRaavsEP=kPhiIntegrated, Bool_t isScaledAndExtrapRef=kFALSE, Int_t rapiditySlice=kdefault, Int_t analysisSpeciality=kTopological)
Double_t GetTotalSystErr(Double_t pt, Double_t feeddownErr=0) const
energy
void SetIsLowPtAnalysis(Bool_t flag)
Definition: AliHFSystErr.h:68
Double_t ExtractFDSyst(Double_t total, Double_t fd)
Double_t ptprintout
decay
Definition: HFPtSpectrum.C:41
void Init(Int_t decay)
Function to initialize the variables/histograms.
void SetIspPb2011RapidityScan(Bool_t flag)
Definition: AliHFSystErr.h:87
Bool_t printout
void SetCollisionType(Int_t type)
Definition: AliHFSystErr.h:51
Double_t NormABUnc
Bool_t PbPbDataSyst(AliHFSystErr *syst, Double_t pt, Int_t cc, Double_t &dataSystUp, Double_t &dataSystDown)
const Int_t nbins
void DrawErrors(TGraphAsymmErrors *grErrFeeddown=0) const
Int_t FindGraphBin(TGraphAsymmErrors *gr, Double_t pt)
void SetRapidity(TString rapidity)
Settings of rapidity ranges for pPb 0-100% CC.
Definition: AliHFSystErr.h:83
Int_t GetCollisionType() const
Definition: AliHFSystErr.h:57
Double_t NormPPUnc
Double_t GetPIDEffErr(Double_t pt) const