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