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