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