Esempio n. 1
0
// ===  FUNCTION  ============================================================
//         Name:  TPlot::Compare1D
//  Description:  
// ===========================================================================
bool TPlot::Compare1D(std::string histname)
{
  std::vector<PlotID> vth1;

  for(unsigned int i=0; i < plist.size(); ++i)
  {
    PlotID temp;
    temp.name = histname;
    temp.det = plist.at(i).first;
    temp.algo = plist.at(i).second;
    temp.marker = detMark[temp.det];
    temp.color = algColor[temp.algo];
    temp.hist = GetHist1D(histname, temp.det, temp.algo);
    vth1.push_back(temp);
  }

  TCanvas *c1 = new TCanvas("Canvas", "Yes, another Canvas", 10, 10, 800, 600);
  TLegend *leg = new TLegend(0.660804,0.5776614,0.959799,0.9319372,NULL,"brNDC");

  
  TAxis* xaxis = NULL;
  TAxis* yaxis = NULL;
  double Ymax = 0;
  double ingl = 0;
  for(unsigned int i=0; i < vth1.size(); ++i)
  {
    PlotID  plot1D = vth1.at(i);
    
    // Set Marker and Color
    plot1D.hist->SetMarkerStyle(plot1D.marker);
    plot1D.hist->SetMarkerColor(plot1D.color);
    plot1D.hist->SetLineColor(plot1D.color);
    plot1D.hist->SetLineWidth(1);
    plot1D.hist->SetMarkerSize(1);

    /*if (histname.find("TauEta")  != std::string::npos)*/
    /*{*/
      /*plot1D.hist->Rebin(10);*/
    /*}*/


    //if (histname.find("Response")  == std::string::npos &&
        //histname.find("Resolution")  == std::string::npos) {
      ////plot1D.hist->Rebin(2);
      //}
    // Draw
    if (i == 0)
    {
      plot1D.hist->Draw("PE");
      xaxis = plot1D.hist->GetXaxis();
      yaxis = plot1D.hist->GetYaxis();
      ingl =  plot1D.hist->Integral();
    }
    else
    {
      if (histname.find("Response")  == std::string::npos &&
          histname.find("Resolution")  == std::string::npos) {
        /*plot1D.hist->Scale(ingl / plot1D.hist->Integral());*/
      }
      plot1D.hist->Draw("samepe");
    }

    // Add Legend
    std::stringstream ss;
    ss << plot1D.det << " " << plot1D.algo;
    leg->AddEntry(plot1D.hist, ss.str().c_str(), "lp" );

    // Get Yaxis maximun
    Ymax = plot1D.hist->GetMaximum() > Ymax ? plot1D.hist->GetMaximum() : Ymax;
    yaxis->SetRangeUser(0.0, 1.2*Ymax);
  }

  SetPlotStyle(histname, c1, leg, xaxis, yaxis);
  leg->Draw();

  for(std::set<std::string>::const_iterator it=vformat.begin();
    it!=vformat.end(); ++it)
  {
    std::stringstream ss;
    ss << histname <<"." << *it;
    c1->Update();
    c1->SaveAs(ss.str().c_str());
  }

  delete c1;
  delete leg;

  return true;
}       // -----  end of function TPlot::Compare1D  -----
void ComparisonDifferentVertexCut(const char *suffix = "eps", TString meson = "Pi0"){

	TString 	FileDirectory[2];
   TString 	cutNumberAdv[2];
	char* 	Input[256];
	TString 	prefix2;
	Double_t 	nColls[2];

	StyleSettingsThesis();

	SetPlotStyle();

	Bool_t pictDrawingOptions[4] = {kFALSE, kFALSE, kFALSE, kTRUE};

	TString textMeson;
	if (meson.CompareTo("Pi0")==0 || meson.CompareTo("Pi0EtaBinning")==0){
		textMeson = "#pi^{0}";
		pictDrawingOptions[3] = kTRUE;
	} else {
		pictDrawingOptions[3] = kFALSE;
		textMeson = "#eta";
	}
	prefix2 = 			"data";
	pictDrawingOptions[1] = 	kFALSE;

	TString collisionSystem = "pp @ 2.76 TeV";
	
	TString FileNameCorrected[6];
	FileNameCorrected[0] = "/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/0000011002093663003800000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";
	FileNameCorrected[1] = "/home/fredi/Photon/Results/ppAnalysis2760GeVNovSmallerVtxCut/00000100020936630038000000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";
	FileNameCorrected[2] ="/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/0002011002093663003800000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";
	FileNameCorrected[3] ="/home/fredi/Photon/Results/ppAnalysis2760GeVDec/00000100020936630038000000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";		FileNameCorrected[4] ="/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/0001011002093663003800000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";
	FileNameCorrected[5] ="/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/0000012002093663003800000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";

	TFile *Cutcorrfile[6];

	TH1D *histoSpectra2760GeV[6];
	TH1D *histoEffi2760GeV[6];
	TH1D *histoRawYield2760GeV[6];
	TH1D *histoSpectra7TeV[6];
	TH1D *histoEffi7TeV[6];
	TH1D *histoRawYield[6];

	TDirectory *directoryPi02760GeV[6];
	TDirectory *directoryPi07TeV[6];
	TH1D *histoRatioSpectra2760TeVVtx;
	TH1D *histoRatioSpectra2760TeVAddedSig;
	TH1D *histoRatioSpectra2760TeVWithSDD;
	TH1D *histoRatioSpectra2760TeVEffiFitted;
	TH1D *histoRatioSpectra2760TeVV0AND_V0OR;
	TH1D *histoRatioSpectra7TeVV0AND_V0OR;
	TH1D *histoRatioSpectra7TeVNew_Pub;
	TH1D *histoRatioEffiWithSDD;
	TH1D *histoRatioRAWYieldWithSDD;
	
	Float_t nEvt2760GeV[6];
	Float_t nEvt7TeV[6];
	TH1F *histoEventQuality2760GeV;
	TH1F *histoEventQuality7TeV;
	
	for (Int_t i=0; i< 6; i++){
		cout<< FileNameCorrected[i] << endl;
// 		if (i == 4) continue;
		Cutcorrfile[i] = new TFile(FileNameCorrected[i]);
		histoEventQuality2760GeV = (TH1F*)Cutcorrfile[i]->Get("histoNumberOfEvents2.76TeV");
		cout << "here" << endl;
		nEvt2760GeV[i] = histoEventQuality2760GeV->GetBinContent(1);
		cout << "here" << endl;
		directoryPi02760GeV[i] = 	(TDirectory*)Cutcorrfile[i]->Get("Pi02.76TeV"); 
		cout << "here" << endl;
		histoSpectra2760GeV[i] =(TH1D*)directoryPi02760GeV[i]->Get("InvCrossSectionPi0");
		cout << "here" << endl;
		histoEffi2760GeV[i] = (TH1D*)directoryPi02760GeV[i]->Get("EfficiencyPi0");
		histoRawYield2760GeV[i] = (TH1D*)directoryPi02760GeV[i]->Get("RAWYieldPerEventsPi0");
		if (i == 1 || i == 2 || i == 4 || i == 5) continue;
		histoEventQuality7TeV = (TH1F*)Cutcorrfile[i]->Get("histoNumberOfEvents7TeV");
		cout << "here" << endl;
		nEvt7TeV[i] = histoEventQuality7TeV->GetBinContent(1);
		cout << "here" << endl;
		directoryPi07TeV[i] = 	(TDirectory*)Cutcorrfile[i]->Get("Pi07TeV"); 
		cout << "here" << endl;
		histoSpectra7TeV[i] =(TH1D*)directoryPi07TeV[i]->Get("InvCrossSectionPi0");
		cout << "here" << endl;
		histoEffi7TeV[i] = (TH1D*)directoryPi07TeV[i]->Get("EfficiencyPi0");
		histoRawYield[i] = (TH1D*)directoryPi07TeV[i]->Get("RAWYieldPerEventsPi0");
	}
	cout<<"=========================="<<endl;

	histoRatioSpectra2760TeVVtx = (TH1D*) histoSpectra2760GeV[1]->Clone("histoRatioSpectra2760TeVVtx");
	histoRatioSpectra2760TeVVtx->Divide(histoSpectra2760GeV[1], histoSpectra2760GeV[0], 1.,1.,"B");
	histoRatioSpectra2760TeVAddedSig = (TH1D*) histoSpectra2760GeV[5]->Clone("histoRatioSpectra2760TeVAddedSig");
	histoRatioSpectra2760TeVAddedSig->Divide(histoSpectra2760GeV[5], histoSpectra2760GeV[0], 1.,1.,"B");
	
	histoRatioSpectra2760TeVWithSDD = (TH1D*) histoSpectra2760GeV[2]->Clone("histoRatioSpectra2760TeVWithSDD");
	histoRatioSpectra2760TeVWithSDD->Divide(histoSpectra2760GeV[2], histoSpectra2760GeV[0], 1.,1.,"B");
	histoRatioSpectra2760TeVEffiFitted = (TH1D*) histoSpectra2760GeV[3]->Clone("histoRatioSpectra2760TeVEffiFitted");
	histoRatioSpectra2760TeVEffiFitted->Divide(histoSpectra2760GeV[3], histoSpectra2760GeV[0], 1.,1.,"B");
	histoRatioSpectra7TeVNew_Pub = (TH1D*) histoSpectra7TeV[3]->Clone("histoRatioSpectra7TeVNew_Pub");
	histoRatioSpectra7TeVNew_Pub->Divide(histoSpectra7TeV[0], histoSpectra7TeV[3], 1.,1.,"B");

	histoRatioSpectra2760TeVV0AND_V0OR = (TH1D*) histoSpectra2760GeV[4]->Clone("histoRatioSpectra2760TeVV0AND_V0OR");
	histoRatioSpectra2760TeVV0AND_V0OR->Divide(histoSpectra2760GeV[4], histoSpectra2760GeV[0], 1.,1.,"B");
// 	histoRatioSpectra7TeVV0AND_V0OR = (TH1D*) histoSpectra7TeV[4]->Clone("histoRatioSpectra7TeVV0AND_V0OR");
// 	histoRatioSpectra7TeVV0AND_V0OR->Divide(histoSpectra7TeV[4], histoSpectra7TeV[0], 1.,1.,"");
	histoRatioEffiWithSDD = (TH1D*) histoEffi2760GeV[2]->Clone("histoRatioEffiWithSDD");
	histoRatioEffiWithSDD->Divide(histoEffi2760GeV[2], histoEffi2760GeV[0], 1.,1.,"");
	histoRatioRAWYieldWithSDD = (TH1D*) histoRawYield2760GeV[2]->Clone("histoRatioRAWYieldWithSDD");
	histoRatioRAWYieldWithSDD->Divide(histoRawYield2760GeV[2], histoRawYield2760GeV[0], 1.,1.,"B");
	
	cout << "V0OR, Without SDD nominal vertex cut: " << nEvt2760GeV[0] << endl;
	cout << "V0OR, Without SDD tighter vertex cut: " << nEvt2760GeV[1] << endl;
	cout << "V0OR, With SDD nominal vertex cut: " << nEvt2760GeV[2] << endl;
	cout << "V0AND: " << nEvt2760GeV[4] << endl;
	
// 	cout << "V0AND: " << nEvt7TeV[4] << endl;
	cout << "V0OR: " << nEvt7TeV[0] << endl;
	
	
	//**************************************************************************************
	//********************* Plotting RAW-Yield *********************************************
	//**************************************************************************************

	TCanvas* canvasFraction = new TCanvas("canvasFraction","",1550,1200);  // gives the page size
	canvasFraction->SetTickx();
	canvasFraction->SetTicky();
	canvasFraction->SetGridx(0);
	canvasFraction->SetGridy(0);
	canvasFraction->SetLogy(0);
	canvasFraction->SetLeftMargin(0.13);
	canvasFraction->SetRightMargin(0.02);
	canvasFraction->SetTopMargin(0.02);
	canvasFraction->SetFillColor(0);


	DrawGammaSetMarker(histoRatioSpectra2760TeVVtx, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra2760TeVVtx,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},z_{vtx} < 5cm}}{N^{corr}_{#pi^{0},z_{vtx} < 10cm}}, pp @ 2.76TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction->SaveAs(Form("%s_RatioCorrectedYieldDifferentVertexCuts.%s",meson.Data(),suffix));
	delete canvasFraction;

	TCanvas* canvasFraction2 = new TCanvas("canvasFraction2","",1550,1200);  // gives the page size
	canvasFraction2->SetTickx();
	canvasFraction2->SetTicky();
	canvasFraction2->SetGridx(0);
	canvasFraction2->SetGridy(0);
	canvasFraction2->SetLogy(0);
	canvasFraction2->SetLeftMargin(0.13);
	canvasFraction2->SetRightMargin(0.02);
	canvasFraction2->SetTopMargin(0.02);
	canvasFraction2->SetFillColor(0);


	DrawGammaSetMarker(histoRatioSpectra2760TeVWithSDD, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra2760TeVWithSDD,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},with SDD}}{N^{corr}_{#pi^{0},without SDD}}, pp @ 2.76TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioCorrectedYieldWithAndWithoutSDD.%s",meson.Data(),suffix));
// 	delete canvasFraction2;
	
	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioEffiWithSDD, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioEffiWithSDD,
					"", "p_{T} (GeV/c)", "#frac{#epsilon_{#pi^{0},with SDD}}{#epsilon_{#pi^{0},without SDD}}, pp @ 2.76 TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioEffiWithAndWithoutSDD.%s",meson.Data(),suffix));

	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioSpectra2760TeVEffiFitted, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra2760TeVEffiFitted,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},effi not fitted}}{N^{corr}_{#pi^{0},effi fitted}}, pp @ 2.76 TeV ",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioCorrectedYieldEffiFitted.%s",meson.Data(),suffix));


	
	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioSpectra2760TeVAddedSig, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra2760TeVAddedSig,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},add Sig}}{N^{corr}_{#pi^{0}}}, pp @ 2.76 TeV ",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioCorrectedYieldaddedSig.%s",meson.Data(),suffix));

	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioSpectra2760TeVV0AND_V0OR, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra2760TeVV0AND_V0OR,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},V0AND}}{N^{corr}_{#pi^{0},V0OR}}, pp @ 2.76 TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioCorrectedXSectionV0AND_VOOR.%s",meson.Data(),suffix));
// 
// 	canvasFraction2->cd();
// 	DrawGammaSetMarker(histoRatioSpectra7TeVV0AND_V0OR, 20, 1., kBlue+2, kBlue+2);
// 	DrawAutoGammaMesonHistos( histoRatioSpectra7TeVV0AND_V0OR,
// 					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},V0AND}}{N^{corr}_{#pi^{0},V0OR}}, pp @ 7 TeV",
// 					kFALSE, 5., 10e-10, kTRUE,
// 					kTRUE, 0.5, 1.5,
// 					kTRUE, 0., 7.9);
// 	canvasFraction2->Update();
// 	DrawGammaLines(0., 8.,1., 1.,0.1);
// 
// 	canvasFraction2->SaveAs(Form("%s_RatioCorrectedXSectionV0AND_VOOR_7TeV.%s",meson.Data(),suffix));

	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioSpectra7TeVNew_Pub, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioSpectra7TeVNew_Pub,
					"", "p_{T} (GeV/c)", "#frac{N^{corr}_{#pi^{0},new}}{N^{corr}_{#pi^{0},pub}}, pp @ 7 TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 15.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 16.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioCorrectedXSectionNew_Old_7TeV.%s",meson.Data(),suffix));

	
	
	canvasFraction2->cd();
	DrawGammaSetMarker(histoRatioRAWYieldWithSDD, 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoRatioRAWYieldWithSDD,
					"", "p_{T} (GeV/c)", "#frac{N_{#pi^{0},with SDD}^{raw}}{N_{#pi^{0},without SDD}^{raw}}, pp @ 2.76 TeV",
					kFALSE, 5., 10e-10, kTRUE,
					kTRUE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaLines(0., 8.,1., 1.,0.1);

	canvasFraction2->SaveAs(Form("%s_RatioRawYieldWithAndWithoutSDD.%s",meson.Data(),suffix));

	
	canvasFraction2->cd();
	canvasFraction2->SetLeftMargin(0.09);
	canvasFraction2->SetTopMargin(0.03);
	DrawGammaSetMarker(histoEffi2760GeV[0], 20, 1., kBlue+2, kBlue+2);
	DrawAutoGammaMesonHistos( histoEffi2760GeV[0],
					"", "p_{T} (GeV/c)", "#epsilon_{#pi^{0}}",
					kTRUE, 1.5, 10e-10, kTRUE,
					kFALSE, 0.5, 1.5,
					kTRUE, 0., 7.9);
	canvasFraction2->Update();
	DrawGammaSetMarker(histoEffi2760GeV[2], 20, 1., kRed+2, kRed+2);
	histoEffi2760GeV[2]->Draw("same,p2");
// 	DrawGammaLines(0., 8.,1., 1.,0.1);
	DrawGammaSetMarker(histoEffi7TeV[3], 20, 1., kBlack, kBlack);
	histoEffi7TeV[3]->Draw("same,p2");
	TLegend* legendMultDataPP = new TLegend(0.15,0.8,0.4,0.95);
	legendMultDataPP->SetFillColor(0);
	legendMultDataPP->SetLineColor(0);
	legendMultDataPP->SetTextSize(0.04);
	legendMultDataPP->AddEntry(histoEffi2760GeV[0],"2.76TeV without SDD","p");
	legendMultDataPP->AddEntry(histoEffi2760GeV[2],"2.76TeV with SDD","p");
	legendMultDataPP->AddEntry(histoEffi7TeV[3], "7 TeV","p");
	legendMultDataPP->Draw();

	
	canvasFraction2->SaveAs(Form("%s_EffiComp.%s",meson.Data(),suffix));

}
void ComparisonOldAndNewPi0PbPb(TString suffix = "pdf"){
   gROOT->Reset();   
   gROOT->SetStyle("Plain");
   
   
   StyleSettingsThesis();  
   SetPlotStyle();

   Color_t  colorCombPbPb0005          = kRed+1;
   Color_t  colorCombPbPb0010          = kRed+1;
   Color_t  colorCombPbPb0510          = 807;
   Color_t  colorCombPbPb1020          = 800;
   Color_t  colorCombPbPb2040          = kGreen+2;
   Color_t  colorCombPbPb4060          = kCyan+2;
   Color_t  colorCombPbPb6080          = kBlue+1;

   Color_t  colorCombMCPbPb0005           = kRed+3;
   Color_t  colorCombMCPbPb0010           = kRed+3;
   Color_t  colorCombMCPbPb0510           = 807+2;
   Color_t  colorCombMCPbPb1020           = 800+2;
   Color_t  colorCombMCPbPb2040           = kGreen+4;
   Color_t  colorCombMCPbPb4060           = kCyan+4;
   Color_t  colorCombMCPbPb6080           = kBlue+3;

   Style_t  markerStylePbPb0005  = 20 ;
   Style_t  markerStylePbPb0010  = 20 ;
   Style_t  markerStylePbPb0510  = 21 ;
   Style_t  markerStylePbPb1020  = 29 ;
   Style_t  markerStylePbPb2040  = 33 ;
   Style_t  markerStylePbPb4060  = 20 ;
   Style_t  markerStylePbPb6080  = 21 ;

   Style_t  markerStylePbPb0005MC   = 24 ;
   Style_t  markerStylePbPb0010MC   = 24 ;
   Style_t  markerStylePbPb0510MC   = 25 ;
   Style_t  markerStylePbPb1020MC   = 30 ;
   Style_t  markerStylePbPb2040MC   = 27 ;
   Style_t  markerStylePbPb4060MC   = 24 ;
   Style_t  markerStylePbPb6080MC   = 25 ;
   
   Size_t   markerSizePbPb0005   = 2.;
   Size_t   markerSizePbPb0010   = 2.;
   Size_t   markerSizePbPb0510   = 2.;
   Size_t   markerSizePbPb1020   = 2.5;
   Size_t   markerSizePbPb2040   = 2.5;
   Size_t   markerSizePbPb4060   = 2.;
   Size_t   markerSizePbPb6080   = 2.;
    
   TString collisionSystemPbPb0005 = "0-5% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";      
   TString collisionSystemPbPb0510 = "5-10% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb1020 = "10-20% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb0010 = "0-10% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb2040 = "20-40% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb4060 = "40-60% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb6080 = "60-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";    
   TString collisionSystemPbPb0020 = "0-20% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb0080 = "0-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb0040 = "0-40% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
   TString collisionSystemPbPb4080 = "40-80% Pb-Pb #sqrt{#it{s}_{_{NN}}} = 2.76 TeV";     
    
   
   //**************************************************************************************************************************
   //**************************************** Read files before weighting *****************************************************
   //**************************************************************************************************************************
   TFile*   filePCMPbPb0thIteration =              new TFile("/home/fredi/Photon/Results/PbPbTests/data_PCMResults_PbPb_2.76TeV_0thIterationRerun.root");
   cout << "0-5%" << endl;
   TDirectory* directory0thIterationPi0PbPb0005 =  (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo0thIterationTrueEffiPt0005 =        (TH1D*)directory0thIterationPi0PbPb0005->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0005 =     (TH1D*)directory0thIterationPi0PbPb0005->Get("Pi0_EfficiencyFitted");

   cout << "0-10%" << endl;
   TDirectory* directory0thIterationPi0PbPb0010 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo0thIterationTrueEffiPt0010 =        (TH1D*)directory0thIterationPi0PbPb0010->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0010 =     (TH1D*)directory0thIterationPi0PbPb0010->Get("Pi0_EfficiencyFitted");
   
   cout << "5-10%" << endl;
   TDirectory* directory0thIterationPi0PbPb0510 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo0thIterationTrueEffiPt0510 =        (TH1D*)directory0thIterationPi0PbPb0510->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit0510 =     (TH1D*)directory0thIterationPi0PbPb0510->Get("Pi0_EfficiencyFitted");
   
   cout << "10-20%" << endl;
   TDirectory* directory0thIterationPi0PbPb1020 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo0thIterationTrueEffiPt1020 =        (TH1D*)directory0thIterationPi0PbPb1020->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit1020 =     (TH1D*)directory0thIterationPi0PbPb1020->Get("Pi0_EfficiencyFitted");
   
   cout << "20-40%" << endl;
   TDirectory* directory0thIterationPi0PbPb2040 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo0thIterationTrueEffiPt2040 =        (TH1D*)directory0thIterationPi0PbPb2040->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit2040 =     (TH1D*)directory0thIterationPi0PbPb2040->Get("Pi0_EfficiencyFitted");
   
   cout << "40-60%" << endl;
   TDirectory* directory0thIterationPi0PbPb4060 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo0thIterationTrueEffiPt4060 =        (TH1D*)directory0thIterationPi0PbPb4060->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit4060 =     (TH1D*)directory0thIterationPi0PbPb4060->Get("Pi0_EfficiencyFitted");
   
   cout << "60-80%" << endl;
   TDirectory* directory0thIterationPi0PbPb6080 =           (TDirectory*)filePCMPbPb0thIteration->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo0thIterationTrueEffiPt6080 =        (TH1D*)directory0thIterationPi0PbPb6080->Get("Pi0_Efficiency");
   TH1D* histo0thIterationTrueEffiPtFit6080 =     (TH1D*)directory0thIterationPi0PbPb6080->Get("Pi0_EfficiencyFitted");

   TFile*   filePCMPbPb0thIterationNewMC =              new TFile("/home/fredi/Photon/Results/PbPbNewMCTest/0thIteration/data_PCMResults_PbPb_2.76TeV_TPCMultNewMCWeighted0thIteration.root");
   cout << "0-5%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0005 =  (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo0thIterationNewMCTrueEffiPt0005 =        (TH1D*)directory0thIterationNewMCPi0PbPb0005->Get("Pi0_Efficiency");

   cout << "0-10%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0010 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt0010 =        (TH1D*)directory0thIterationNewMCPi0PbPb0010->Get("Pi0_Efficiency");
   
   cout << "5-10%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb0510 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt0510 =        (TH1D*)directory0thIterationNewMCPi0PbPb0510->Get("Pi0_Efficiency");
   
   cout << "10-20%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb1020 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt1020 =        (TH1D*)directory0thIterationNewMCPi0PbPb1020->Get("Pi0_Efficiency");
   
   cout << "20-40%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb2040 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt2040 =        (TH1D*)directory0thIterationNewMCPi0PbPb2040->Get("Pi0_Efficiency");
   
   cout << "40-60%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb4060 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo0thIterationNewMCTrueEffiPt4060 =        (TH1D*)directory0thIterationNewMCPi0PbPb4060->Get("Pi0_Efficiency");
   
   cout << "60-80%" << endl;
   TDirectory* directory0thIterationNewMCPi0PbPb6080 =           (TDirectory*)filePCMPbPb0thIterationNewMC->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo0thIterationNewMCTrueEffiPt6080 =        (TH1D*)directory0thIterationNewMCPi0PbPb6080->Get("Pi0_Efficiency");
  

   
   //**************************************************************************************************************************
   //**************************************** Read files after weighting *****************************************************
   //**************************************************************************************************************************
   
   TFile*   filePCMPbPb2ndIteration =              new TFile("/home/fredi/Photon/Results/PbPbNewMCTest/data_PCMResults_PbPb_2.76TeV_TPCMultNewMCWeighted2ndIteration.root");
   cout << "0-5%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0005 =  (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_0-5%");   
   TH1D* histo2ndIterationTrueEffiPt0005 =        (TH1D*)directory2ndIterationPi0PbPb0005->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0005 = (TH1D*)directory2ndIterationPi0PbPb0005->Get("Pi0_HIJING_Weights");
   
   cout << "0-10%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0010 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_0-10%"); 
   TH1D* histo2ndIterationTrueEffiPt0010 =        (TH1D*)directory2ndIterationPi0PbPb0010->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0010 = (TH1D*)directory2ndIterationPi0PbPb0010->Get("Pi0_HIJING_Weights");
   
   cout << "5-10%" << endl;
   TDirectory* directory2ndIterationPi0PbPb0510 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_5-10%"); 
   TH1D* histo2ndIterationTrueEffiPt0510 =        (TH1D*)directory2ndIterationPi0PbPb0510->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights0510 = (TH1D*)directory2ndIterationPi0PbPb0510->Get("Pi0_HIJING_Weights");
   cout << "10-20%" << endl;
   TDirectory* directory2ndIterationPi0PbPb1020 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_10-20%"); 
   TH1D* histo2ndIterationTrueEffiPt1020 =        (TH1D*)directory2ndIterationPi0PbPb1020->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights1020 = (TH1D*)directory2ndIterationPi0PbPb1020->Get("Pi0_HIJING_Weights");
   cout << "20-40%" << endl;
   TDirectory* directory2ndIterationPi0PbPb2040 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_20-40%"); 
   TH1D* histo2ndIterationTrueEffiPt2040 =        (TH1D*)directory2ndIterationPi0PbPb2040->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights2040 = (TH1D*)directory2ndIterationPi0PbPb2040->Get("Pi0_HIJING_Weights");
   cout << "40-60%" << endl;
   TDirectory* directory2ndIterationPi0PbPb4060 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_40-60%"); 
   TH1D* histo2ndIterationTrueEffiPt4060 =        (TH1D*)directory2ndIterationPi0PbPb4060->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights4060 = (TH1D*)directory2ndIterationPi0PbPb4060->Get("Pi0_HIJING_Weights");
   cout << "60-80%" << endl;
   TDirectory* directory2ndIterationPi0PbPb6080 =           (TDirectory*)filePCMPbPb2ndIteration->Get("Pi0_PbPb_2.76TeV_60-80%");
   TH1D* histo2ndIterationTrueEffiPt6080 =        (TH1D*)directory2ndIterationPi0PbPb6080->Get("Pi0_Efficiency");
   TH1D* histoPi02ndIterationWeights6080 = (TH1D*)directory2ndIterationPi0PbPb6080->Get("Pi0_HIJING_Weights");
   
   TFile*   filePCMPbPb2ndIterationAddSig0005 =              new TFile("601000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_601000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig0005 = (TH1D*)filePCMPbPb2ndIterationAddSig0005->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig0510 =              new TFile("612000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_612000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig0510 = (TH1D*)filePCMPbPb2ndIterationAddSig0510->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig1020 =              new TFile("512000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_512000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig1020 = (TH1D*)filePCMPbPb2ndIterationAddSig1020->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig2040 =              new TFile("524000104209297002322000000_01522045009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_524000104209297002322000000_01522045009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig2040 = (TH1D*)filePCMPbPb2ndIterationAddSig2040->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig4060 =              new TFile("546000104209297002322000000_01522065009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_546000104209297002322000000_01522065009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig4060 = (TH1D*)filePCMPbPb2ndIterationAddSig4060->Get("MC_Meson_genPt_Weights");
   TFile*   filePCMPbPb2ndIterationAddSig6080 =              new TFile("568000104209297002322000000_01522065009000/PbPb_2.76TeV/Pi0_MC_GammaConvV1CorrectionHistosAddSig_568000104209297002322000000_01522065009000.root");
   TH1D* histoPi02ndIterationWeightsAddSig6080 = (TH1D*)filePCMPbPb2ndIterationAddSig6080->Get("MC_Meson_genPt_Weights");
   
      
   TCanvas* canvasFraction2 = new TCanvas("canvasFraction2","",1550,1200);  // gives the page size
   canvasFraction2->SetTickx();
   canvasFraction2->SetTicky();
   canvasFraction2->SetGridx(0);
   canvasFraction2->SetGridy(0);
   canvasFraction2->SetLogy(0);
   canvasFraction2->SetLeftMargin(0.13);
   canvasFraction2->SetRightMargin(0.02);
   canvasFraction2->SetTopMargin(0.02);
   canvasFraction2->SetFillColor(0);
   canvasFraction2->cd();
   
   TH1D* histoRatioEffi2ndIteDiv0thIte0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatioEffi2ndIteDiv0thIte0005");
   histoRatioEffi2ndIteDiv0thIte0005->Divide(histo2ndIterationTrueEffiPt0005, histo0thIterationNewMCTrueEffiPt0005, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatioEffi2ndIteDiv0thIte0510");
   histoRatioEffi2ndIteDiv0thIte0510->Divide(histo2ndIterationTrueEffiPt0510, histo0thIterationNewMCTrueEffiPt0510, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatioEffi2ndIteDiv0thIte1020");
   histoRatioEffi2ndIteDiv0thIte1020->Divide(histo2ndIterationTrueEffiPt1020, histo0thIterationNewMCTrueEffiPt1020, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatioEffi2ndIteDiv0thIte2040");
   histoRatioEffi2ndIteDiv0thIte2040->Divide(histo2ndIterationTrueEffiPt2040, histo0thIterationNewMCTrueEffiPt2040, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatioEffi2ndIteDiv0thIte4060");
   histoRatioEffi2ndIteDiv0thIte4060->Divide(histo2ndIterationTrueEffiPt4060, histo0thIterationNewMCTrueEffiPt4060, 1. ,1., "");
   TH1D* histoRatioEffi2ndIteDiv0thIte6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatioEffi2ndIteDiv0thIte6080");
   histoRatioEffi2ndIteDiv0thIte6080->Divide(histo2ndIterationTrueEffiPt6080, histo0thIterationNewMCTrueEffiPt6080, 1. ,1., "");
 
   
   canvasFraction2->cd();
   if (histoRatioEffi2ndIteDiv0thIte6080) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoRatioEffi2ndIteDiv0thIte0005) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoRatioEffi2ndIteDiv0thIte0510) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoRatioEffi2ndIteDiv0thIte1020) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoRatioEffi2ndIteDiv0thIte2040) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoRatioEffi2ndIteDiv0thIte4060) DrawGammaSetMarker(histoRatioEffi2ndIteDiv0thIte4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoRatioEffi2ndIteDiv0thIte6080,
               "", "p_{T} (GeV/c)", "Effi 2nd Iteration of weighting/ no weighting, New MC",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0.5, 1.5,
               kTRUE, 0., 7.9);
   if (histoRatioEffi2ndIteDiv0thIte0005)histoRatioEffi2ndIteDiv0thIte0005->Draw("same,e,p");
//    if (histoRatioEffi2ndIteDiv0thIte0510)histoRatioEffi2ndIteDiv0thIte0510->Draw("same,e,p");  
   if (histoRatioEffi2ndIteDiv0thIte1020)histoRatioEffi2ndIteDiv0thIte1020->Draw("same,e,p");  
//    if (histoRatioEffi2ndIteDiv0thIte2040)histoRatioEffi2ndIteDiv0thIte2040->Draw("same,e,p");  
//    if (histoRatioEffi2ndIteDiv0thIte4060)histoRatioEffi2ndIteDiv0thIte4060->Draw("same,e,p");  
   
   TLegend* legendCompEffiDifferentWeighting = new TLegend(0.16,0.11,0.4,0.3);
   legendCompEffiDifferentWeighting->SetFillColor(0);
   legendCompEffiDifferentWeighting->SetLineColor(0);
   legendCompEffiDifferentWeighting->SetTextSize(0.025);
//    legendCompEffiDifferentWeighting->SetNColumns(3);
   legendCompEffiDifferentWeighting->SetMargin(0.2);
   if (histoRatioEffi2ndIteDiv0thIte0005)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte0510)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoRatioEffi2ndIteDiv0thIte1020)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte2040)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioEffi2ndIteDiv0thIte4060)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoRatioEffi2ndIteDiv0thIte6080)legendCompEffiDifferentWeighting->AddEntry(histoRatioEffi2ndIteDiv0thIte6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendCompEffiDifferentWeighting->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("RatioEffiFinalWeightsDivNoWeights.%s",suffix.Data()));

   TH1D* histoRatioEffiNewMCDivOldMC0005= (TH1D*)histo0thIterationNewMCTrueEffiPt0005->Clone("histoRatioEffiNewMCDivOldMC0005");
   histoRatioEffiNewMCDivOldMC0005->Divide(histo0thIterationNewMCTrueEffiPt0005, histo0thIterationTrueEffiPt0005, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC0510= (TH1D*)histo0thIterationNewMCTrueEffiPt0510->Clone("histoRatioEffiNewMCDivOldMC0510");
   histoRatioEffiNewMCDivOldMC0510->Divide(histo0thIterationNewMCTrueEffiPt0510, histo0thIterationTrueEffiPt0510, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC1020= (TH1D*)histo0thIterationNewMCTrueEffiPt1020->Clone("histoRatioEffiNewMCDivOldMC1020");
   histoRatioEffiNewMCDivOldMC1020->Divide(histo0thIterationNewMCTrueEffiPt1020, histo0thIterationTrueEffiPt1020, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC2040= (TH1D*)histo0thIterationNewMCTrueEffiPt2040->Clone("histoRatioEffiNewMCDivOldMC2040");
   histoRatioEffiNewMCDivOldMC2040->Divide(histo0thIterationNewMCTrueEffiPt2040, histo0thIterationTrueEffiPt2040, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC4060= (TH1D*)histo0thIterationNewMCTrueEffiPt4060->Clone("histoRatioEffiNewMCDivOldMC4060");
   histoRatioEffiNewMCDivOldMC4060->Divide(histo0thIterationNewMCTrueEffiPt4060, histo0thIterationTrueEffiPt4060, 1. ,1., "");
   TH1D* histoRatioEffiNewMCDivOldMC6080= (TH1D*)histo0thIterationNewMCTrueEffiPt6080->Clone("histoRatioEffiNewMCDivOldMC6080");
   histoRatioEffiNewMCDivOldMC6080->Divide(histo0thIterationNewMCTrueEffiPt6080, histo0thIterationTrueEffiPt6080, 1. ,1., "");
 
   
   canvasFraction2->cd();
   if (histoRatioEffiNewMCDivOldMC6080) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoRatioEffiNewMCDivOldMC0005) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoRatioEffiNewMCDivOldMC0510) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoRatioEffiNewMCDivOldMC1020) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoRatioEffiNewMCDivOldMC2040) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoRatioEffiNewMCDivOldMC4060) DrawGammaSetMarker(histoRatioEffiNewMCDivOldMC4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoRatioEffiNewMCDivOldMC6080,
               "", "p_{T} (GeV/c)", "Effi New MC/ Old MC, wo weighting",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0.5, 1.5,
               kTRUE, 0., 7.9);
   if (histoRatioEffiNewMCDivOldMC0005)histoRatioEffiNewMCDivOldMC0005->Draw("same,e,p");
//    if (histoRatioEffiNewMCDivOldMC0510)histoRatioEffiNewMCDivOldMC0510->Draw("same,e,p");  
   if (histoRatioEffiNewMCDivOldMC1020)histoRatioEffiNewMCDivOldMC1020->Draw("same,e,p");  
//    if (histoRatioEffiNewMCDivOldMC2040)histoRatioEffiNewMCDivOldMC2040->Draw("same,e,p");  
//    if (histoRatioEffiNewMCDivOldMC4060)histoRatioEffiNewMCDivOldMC4060->Draw("same,e,p");  
   
   TLegend* legendCompEffiDifferentMC = new TLegend(0.16,0.11,0.4,0.3);
   legendCompEffiDifferentMC->SetFillColor(0);
   legendCompEffiDifferentMC->SetLineColor(0);
   legendCompEffiDifferentMC->SetTextSize(0.025);
//    legendCompEffiDifferentMC->SetNColumns(3);
   legendCompEffiDifferentMC->SetMargin(0.2);
   if (histoRatioEffiNewMCDivOldMC0005)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC0510)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoRatioEffiNewMCDivOldMC1020)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC2040)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioEffiNewMCDivOldMC4060)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoRatioEffiNewMCDivOldMC6080)legendCompEffiDifferentMC->AddEntry(histoRatioEffiNewMCDivOldMC6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendCompEffiDifferentMC->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("RatioEffiNewDivOldMC.%s",suffix.Data()));

   
//    TH1D* histoRatioNewDivOld0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatioNewDivOld0005");
//    histoRatioNewDivOld0005->Divide(histo2ndIterationTrueEffiPt0005, histo0thIterationTrueEffiPtFit0005, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatioNewDivOld0510");
//    histoRatioNewDivOld0510->Divide(histo2ndIterationTrueEffiPt0510, histo0thIterationTrueEffiPtFit0510, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatioNewDivOld1020");
//    histoRatioNewDivOld1020->Divide(histo2ndIterationTrueEffiPt1020, histo0thIterationTrueEffiPtFit1020, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatioNewDivOld2040");
//    histoRatioNewDivOld2040->Divide(histo2ndIterationTrueEffiPt2040, histo0thIterationTrueEffiPtFit2040, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatioNewDivOld4060");
//    histoRatioNewDivOld4060->Divide(histo2ndIterationTrueEffiPt4060, histo0thIterationTrueEffiPtFit4060, 1. ,1., "B");
//    TH1D* histoRatioNewDivOld6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatioNewDivOld6080");
//    histoRatioNewDivOld6080->Divide(histo2ndIterationTrueEffiPt6080, histo0thIterationTrueEffiPtFit6080, 1. ,1., "B");
//    
//    
//    canvasFraction2->cd();
//    if (histoRatioNewDivOld6080) DrawGammaSetMarker(histoRatioNewDivOld6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
//    if (histoRatioNewDivOld0005) DrawGammaSetMarker(histoRatioNewDivOld0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
//    if (histoRatioNewDivOld0510) DrawGammaSetMarker(histoRatioNewDivOld0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
//    if (histoRatioNewDivOld1020) DrawGammaSetMarker(histoRatioNewDivOld1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
//    if (histoRatioNewDivOld2040) DrawGammaSetMarker(histoRatioNewDivOld2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
//    if (histoRatioNewDivOld4060) DrawGammaSetMarker(histoRatioNewDivOld4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
//    DrawAutoGammaMesonHistos( histoRatioNewDivOld6080,
//                "", "p_{T} (GeV/c)", "Effi final/ fitted no weighting",
//                kFALSE, 1.5, 0, kTRUE,
//                kTRUE, 0.5, 1.5,
//                kTRUE, 0., 7.9);
//    if (histoRatioNewDivOld0005)histoRatioNewDivOld0005->Draw("same,e,p");
//    if (histoRatioNewDivOld0510)histoRatioNewDivOld0510->Draw("same,e,p");  
//    if (histoRatioNewDivOld1020)histoRatioNewDivOld1020->Draw("same,e,p");  
//    if (histoRatioNewDivOld2040)histoRatioNewDivOld2040->Draw("same,e,p");  
//    if (histoRatioNewDivOld4060)histoRatioNewDivOld4060->Draw("same,e,p");  
//    
//    TLegend* legendCompEffiFinalDivOld = new TLegend(0.16,0.11,0.4,0.3);
//    legendCompEffiFinalDivOld->SetFillColor(0);
//    legendCompEffiFinalDivOld->SetLineColor(0);
//    legendCompEffiFinalDivOld->SetTextSize(0.025);
// //    legendCompEffiFinalDivOld->SetNColumns(3);
//    legendCompEffiFinalDivOld->SetMargin(0.2);
//    if (histoRatioNewDivOld0005)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatioNewDivOld0510)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
//    if (histoRatioNewDivOld1020)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatioNewDivOld2040)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatioNewDivOld4060)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
//    if (histoRatioNewDivOld6080)legendCompEffiFinalDivOld->AddEntry(histoRatioNewDivOld6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
//    legendCompEffiFinalDivOld->Draw();
//    
//    DrawGammaLines(0., 30.,1., 1.,0.1);
//    canvasFraction2->Update();
//    canvasFraction2->SaveAs(Form("RatioEffiFinalDivNoWeightsFitted.%s",suffix.Data()));
   
   canvasFraction2->cd();
   if (histoPi02ndIterationWeights6080) DrawGammaSetMarker(histoPi02ndIterationWeights6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoPi02ndIterationWeights0005) DrawGammaSetMarker(histoPi02ndIterationWeights0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoPi02ndIterationWeights0510) DrawGammaSetMarker(histoPi02ndIterationWeights0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoPi02ndIterationWeights1020) DrawGammaSetMarker(histoPi02ndIterationWeights1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoPi02ndIterationWeights2040) DrawGammaSetMarker(histoPi02ndIterationWeights2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoPi02ndIterationWeights4060) DrawGammaSetMarker(histoPi02ndIterationWeights4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoPi02ndIterationWeights6080,
               "", "p_{T} (GeV/c)", "Weights",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 0., 3.,
               kTRUE, 0., 7.9);
   if (histoPi02ndIterationWeights0005)histoPi02ndIterationWeights0005->Draw("same,e,p");
   if (histoPi02ndIterationWeights0510)histoPi02ndIterationWeights0510->Draw("same,e,p");  
   if (histoPi02ndIterationWeights1020)histoPi02ndIterationWeights1020->Draw("same,e,p");  
   if (histoPi02ndIterationWeights2040)histoPi02ndIterationWeights2040->Draw("same,e,p");  
   if (histoPi02ndIterationWeights4060)histoPi02ndIterationWeights4060->Draw("same,e,p");  
   
   TLegend* legendWeights = new TLegend(0.56,0.71,0.95,0.95);
   legendWeights->SetFillColor(0);
   legendWeights->SetLineColor(0);
   legendWeights->SetTextSize(0.025);
//    legendWeights->SetNColumns(3);
   legendWeights->SetMargin(0.2);
   if (histoPi02ndIterationWeights0005)legendWeights->AddEntry(histoPi02ndIterationWeights0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
   if (histoPi02ndIterationWeights0510)legendWeights->AddEntry(histoPi02ndIterationWeights0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoPi02ndIterationWeights1020)legendWeights->AddEntry(histoPi02ndIterationWeights1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
   if (histoPi02ndIterationWeights2040)legendWeights->AddEntry(histoPi02ndIterationWeights2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
   if (histoPi02ndIterationWeights4060)legendWeights->AddEntry(histoPi02ndIterationWeights4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoPi02ndIterationWeights6080)legendWeights->AddEntry(histoPi02ndIterationWeights6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendWeights->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("Weights2ndIteration.%s",suffix.Data()));
   
   canvasFraction2->cd();
   canvasFraction2->SetLogy();
   if (histoPi02ndIterationWeightsAddSig6080) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
   if (histoPi02ndIterationWeightsAddSig0005) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
   if (histoPi02ndIterationWeightsAddSig0510) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
   if (histoPi02ndIterationWeightsAddSig1020) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
   if (histoPi02ndIterationWeightsAddSig2040) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
   if (histoPi02ndIterationWeightsAddSig4060) DrawGammaSetMarker(histoPi02ndIterationWeightsAddSig4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
   DrawAutoGammaMesonHistos( histoPi02ndIterationWeightsAddSig6080,
               "", "p_{T} (GeV/c)", "Weights Added Signals",
               kFALSE, 1.5, 0, kTRUE,
               kTRUE, 1e-3, 1e5,
               kTRUE, 0., 7.9);
   if (histoPi02ndIterationWeightsAddSig0005)histoPi02ndIterationWeightsAddSig0005->Draw("same,e,p");
   if (histoPi02ndIterationWeightsAddSig0510)histoPi02ndIterationWeightsAddSig0510->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig1020)histoPi02ndIterationWeightsAddSig1020->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig2040)histoPi02ndIterationWeightsAddSig2040->Draw("same,e,p");  
   if (histoPi02ndIterationWeightsAddSig4060)histoPi02ndIterationWeightsAddSig4060->Draw("same,e,p");  
   
   TLegend* legendWeightsAddSig = new TLegend(0.56,0.71,0.95,0.95);
   legendWeightsAddSig->SetFillColor(0);
   legendWeightsAddSig->SetLineColor(0);
   legendWeightsAddSig->SetTextSize(0.025);
//    legendWeights->SetNColumns(3);
   legendWeightsAddSig->SetMargin(0.2);
   if (histoPi02ndIterationWeightsAddSig0005)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig0510)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig1020)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig2040)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig4060)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
   if (histoPi02ndIterationWeightsAddSig6080)legendWeightsAddSig->AddEntry(histoPi02ndIterationWeightsAddSig6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
   legendWeightsAddSig->Draw();
   
   DrawGammaLines(0., 30.,1., 1.,0.1);
   canvasFraction2->Update();
   canvasFraction2->SaveAs(Form("Weights2ndIterationAddSig.%s",suffix.Data()));
   
   
//    TH1D* histoRatio5thDiv2ndIte0005= (TH1D*)histo2ndIterationTrueEffiPt0005->Clone("histoRatio5thDiv2ndIte0005");
//    histoRatio5thDiv2ndIte0005->Divide(histo5thIterationTrueEffiPt0005, histo2ndIterationTrueEffiPtFit0005, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte0510= (TH1D*)histo2ndIterationTrueEffiPt0510->Clone("histoRatio5thDiv2ndIte0510");
//    histoRatio5thDiv2ndIte0510->Divide(histo5thIterationTrueEffiPt0510, histo2ndIterationTrueEffiPtFit0510, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte1020= (TH1D*)histo2ndIterationTrueEffiPt1020->Clone("histoRatio5thDiv2ndIte1020");
//    histoRatio5thDiv2ndIte1020->Divide(histo5thIterationTrueEffiPt1020, histo2ndIterationTrueEffiPtFit1020, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte2040= (TH1D*)histo2ndIterationTrueEffiPt2040->Clone("histoRatio5thDiv2ndIte2040");
//    histoRatio5thDiv2ndIte2040->Divide(histo5thIterationTrueEffiPt2040, histo2ndIterationTrueEffiPtFit2040, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte4060= (TH1D*)histo2ndIterationTrueEffiPt4060->Clone("histoRatio5thDiv2ndIte4060");
//    histoRatio5thDiv2ndIte4060->Divide(histo5thIterationTrueEffiPt4060, histo2ndIterationTrueEffiPtFit4060, 1. ,1., "B");
//    TH1D* histoRatio5thDiv2ndIte6080= (TH1D*)histo2ndIterationTrueEffiPt6080->Clone("histoRatio5thDiv2ndIte6080");
//    histoRatio5thDiv2ndIte6080->Divide(histo5thIterationTrueEffiPt6080, histo2ndIterationTrueEffiPtFit6080, 1. ,1., "B");
//    
//    
//    canvasFraction2->cd();
//    if (histoRatio5thDiv2ndIte6080) DrawGammaSetMarker(histoRatio5thDiv2ndIte6080, markerStylePbPb6080MC,markerSizePbPb6080, colorCombPbPb6080 , colorCombPbPb6080 );
//    if (histoRatio5thDiv2ndIte0005) DrawGammaSetMarker(histoRatio5thDiv2ndIte0005, markerStylePbPb0005MC,markerSizePbPb0005, colorCombPbPb0005 , colorCombPbPb0005 );
//    if (histoRatio5thDiv2ndIte0510) DrawGammaSetMarker(histoRatio5thDiv2ndIte0510, markerStylePbPb0510MC,markerSizePbPb0510, colorCombPbPb0510 , colorCombPbPb0510 );
//    if (histoRatio5thDiv2ndIte1020) DrawGammaSetMarker(histoRatio5thDiv2ndIte1020, markerStylePbPb1020MC,markerSizePbPb1020, colorCombPbPb1020 , colorCombPbPb1020 );
//    if (histoRatio5thDiv2ndIte2040) DrawGammaSetMarker(histoRatio5thDiv2ndIte2040, markerStylePbPb2040MC,markerSizePbPb2040, colorCombPbPb2040 , colorCombPbPb2040 );
//    if (histoRatio5thDiv2ndIte4060) DrawGammaSetMarker(histoRatio5thDiv2ndIte4060, markerStylePbPb4060MC,markerSizePbPb4060, colorCombPbPb4060 , colorCombPbPb4060 );
//    DrawAutoGammaMesonHistos( histoRatio5thDiv2ndIte6080,
//                "", "p_{T} (GeV/c)", "possible additional systematic error",
//                kFALSE, 1.5, 0, kTRUE,
//                kTRUE, 0.5, 1.5,
//                kTRUE, 0., 7.9);
//    if (histoRatio5thDiv2ndIte0005)histoRatio5thDiv2ndIte0005->Draw("same,e,p");
//    if (histoRatio5thDiv2ndIte0510)histoRatio5thDiv2ndIte0510->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte1020)histoRatio5thDiv2ndIte1020->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte2040)histoRatio5thDiv2ndIte2040->Draw("same,e,p");  
//    if (histoRatio5thDiv2ndIte4060)histoRatio5thDiv2ndIte4060->Draw("same,e,p");  
//    
//    TLegend* legendPossAddSyst = new TLegend(0.16,0.11,0.4,0.3);
//    legendPossAddSyst->SetFillColor(0);
//    legendPossAddSyst->SetLineColor(0);
//    legendPossAddSyst->SetTextSize(0.025);
// //    legendPossAddSyst->SetNColumns(3);
//    legendPossAddSyst->SetMargin(0.2);
//    if (histoRatio5thDiv2ndIte0005)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte0005,Form("%s",collisionSystemPbPb0005.Data()),"p");
//    if (histoRatio5thDiv2ndIte0510)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte0510,Form("%s",collisionSystemPbPb0510.Data()),"p");
//    if (histoRatio5thDiv2ndIte1020)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte1020,Form("%s",collisionSystemPbPb1020.Data()),"p");
//    if (histoRatio5thDiv2ndIte2040)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte2040,Form("%s",collisionSystemPbPb2040.Data()),"p");
//    if (histoRatio5thDiv2ndIte4060)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte4060,Form("%s",collisionSystemPbPb4060.Data()),"p");
//    if (histoRatio5thDiv2ndIte6080)legendPossAddSyst->AddEntry(histoRatio5thDiv2ndIte6080,Form("%s",collisionSystemPbPb6080.Data()),"p");
//    legendPossAddSyst->Draw();
//    
//    DrawGammaLines(0., 30.,1., 1.,0.1);
//    canvasFraction2->Update();
//    canvasFraction2->SaveAs(Form("RatioOf5thDiv2ndIteration.%s",suffix.Data()));
   
  
//    Double_t fMesonPlotRange[2] = {0., 0.2};
//    
//    
//   TCanvas *c1 = new TCanvas("PCM","InvMass",0,0,600*1.2,600);
//   c1->SetRightMargin(0.03);
//   c1->SetTopMargin(0.05);
//   c1->SetLeftMargin(0.12);
//   c1->SetBottomMargin(0.13);
//   c1->cd();
//   
//   DrawGammaHisto( histoPi00thIterationInvMassBin9_0005,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//   histoPi02ndIterationInvMassBin9_0005->SetLineColor(kRed+2);
//   histoPi02ndIterationInvMassBin9_0005->Draw("hist,e,same");
//   
//   TLatex *labelMassPi00005 = new TLatex(0.15,0.88,collisionSystemPbPb0005.Data());
//    SetStyleTLatex( labelMassPi00005, 0.035,4);
//    labelMassPi00005->Draw();
//    TLegend* legendInvMass = new TLegend(0.15,0.76,0.35,0.84);
//    legendInvMass->SetFillColor(0);
//    legendInvMass->SetLineColor(0);
//    legendInvMass->SetTextSize(0.025);
// //    legendInvMass->SetNColumns(3);
//    legendInvMass->SetMargin(0.2);
//    legendInvMass->AddEntry((TObject*)0, "2.0 GeV/c < p_{T} < 2.2 GeV/c","");
//    legendInvMass->AddEntry(histoPi00thIterationInvMassBin9_0005,"no weighting","l");
//    legendInvMass->AddEntry(histoPi02ndIterationInvMassBin9_0005,"2nd iteration reweighted","l");
//    legendInvMass->Draw();
//   
// 
//   c1->SaveAs(Form("InvMass_2000MeV-2200MeV_0005.%s",suffix.Data()));
//   
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_0510,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_0510->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_0510->Draw("hist,e,same");
//   
//    TLatex *labelMassPi00510 = new TLatex(0.15,0.88,collisionSystemPbPb0510.Data());
//    SetStyleTLatex( labelMassPi00510, 0.035,4);
//    labelMassPi00510->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_0510.%s",suffix.Data()));
//   
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_1020,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_1020->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_1020->Draw("hist,e,same");
//   
//    TLatex *labelMassPi01020 = new TLatex(0.15,0.88,collisionSystemPbPb1020.Data());
//    SetStyleTLatex( labelMassPi01020, 0.035,4);
//    labelMassPi01020->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_1020.%s",suffix.Data()));
// 
//       c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_2040,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_2040->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_2040->Draw("hist,e,same");
//    TLatex *labelMassPi02040 = new TLatex(0.15,0.88,collisionSystemPbPb2040.Data());
//    SetStyleTLatex( labelMassPi02040, 0.035,4);
//    labelMassPi02040->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_2040.%s",suffix.Data()));
// 
//    
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_4060,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_4060->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_4060->Draw("hist,e,same");
// 
//    TLatex *labelMassPi04060 = new TLatex(0.15,0.88,collisionSystemPbPb4060.Data());
//    SetStyleTLatex( labelMassPi04060, 0.035,4);
//    labelMassPi04060->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_4060.%s",suffix.Data()));
// 
//       c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin9_6080,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin9_6080->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin9_6080->Draw("hist,e,same");
//   
//    TLatex *labelMassPi06080 = new TLatex(0.15,0.88,collisionSystemPbPb6080.Data());
//    SetStyleTLatex( labelMassPi06080, 0.035,4);
//    labelMassPi06080->Draw();
//    legendInvMass->Draw();
//    c1->SaveAs(Form("InvMass_2000MeV-2200MeV_6080.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_0005,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_0005->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_0005->Draw("hist,e,same");
//   
//    labelMassPi00005->Draw();
//    TLegend* legendInvMass2 = new TLegend(0.15,0.76,0.35,0.84);
//    legendInvMass2->SetFillColor(0);
//    legendInvMass2->SetLineColor(0);
//    legendInvMass2->SetTextSize(0.025);
// //    legendInvMass->SetNColumns(3);
//    legendInvMass2->SetMargin(0.2);
//    legendInvMass2->AddEntry((TObject*)0, "2.2 GeV/c < p_{T} < 2.4 GeV/c","");
//    legendInvMass2->AddEntry(histoPi00thIterationInvMassBin10_0005,"no weighting","l");
//    legendInvMass2->AddEntry(histoPi02ndIterationInvMassBin10_0005,"2nd iteration reweighted","l");
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_0005.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_0510,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_0510->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_0510->Draw("hist,e,same");
//   
//    labelMassPi00510->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_0510.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_1020,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_1020->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_1020->Draw("hist,e,same");
//   
//    labelMassPi01020->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_1020.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_2040,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_2040->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_2040->Draw("hist,e,same");
//   
//    labelMassPi02040->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_2040.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_4060,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_4060->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_4060->Draw("hist,e,same");
//   
//    labelMassPi04060->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_4060.%s",suffix.Data()));
// 
//    c1->cd();
//    DrawGammaHisto( histoPi00thIterationInvMassBin10_6080,
//              "2.0 GeV/c < p_{T} < 2.2 GeV/c",
//              "M_{#gamma#gamma} (GeV/c^{2})","dN_{#gamma#gamma}/dM_{#gamma#gamma}",
//              fMesonPlotRange[0],fMesonPlotRange[1],0);
//    histoPi02ndIterationInvMassBin10_6080->SetLineColor(kRed+2);
//    histoPi02ndIterationInvMassBin10_6080->Draw("hist,e,same");
//   
//    labelMassPi06080->Draw();
//    legendInvMass2->Draw();
// 
//    c1->SaveAs(Form("InvMass_2200MeV-2400MeV_6080.%s",suffix.Data()));
   
}
void CompareChargedAndNeutralPionDataALICEpPb_MB(TString outputDir = "pdf/CombineMesonMeasurementspPbX", TString suffix = "pdf"){

   gROOT->Reset();   
   gROOT->SetStyle("Plain");
   
   StyleSettingsThesis();  
   SetPlotStyle();
   
   Double_t xSection2760GeVpp =     55.416*1e-3;
   Double_t xSection2760GeVErrpp =  3.9;
   Double_t xSection2760GeVppINEL = 62.8*1e9;
   Double_t xSection900GeVppINEL = 52.5*1e9;
   Double_t xSection7TeVppINEL = 73.2*1e9;   
   Double_t recalcBarn =         1e12; //NLO in pbarn!!!!

   gSystem->Exec("mkdir -p "+outputDir);
   Color_t  colorComb0005           = kRed+1;
   Color_t  colorComb0510           = 807;
   Color_t  colorComb1020           = 800;
   Color_t  colorComb2040           = kGreen+2;
   Color_t  colorComb4060           = kCyan+2;
   Color_t  colorComb6080           = kBlue+1;

   Style_t  markerStyleCommmonSpectrum0005   = 20 ;
   Style_t  markerStyleCommmonSpectrum0510   = 21 ;
   Style_t  markerStyleCommmonSpectrum1020   = 29 ;
   Style_t  markerStyleCommmonSpectrum2040   = 33 ;
   Style_t  markerStyleCommmonSpectrum4060   = 20 ;
   Style_t  markerStyleCommmonSpectrum6080   = 21 ;

   Size_t   markerSizeCommonSpectrum0005  = 2.;
   Size_t   markerSizeCommonSpectrum0510  = 2.;
   Size_t   markerSizeCommonSpectrum1020  = 2.5;
   Size_t   markerSizeCommonSpectrum2040  = 2.5;
   Size_t   markerSizeCommonSpectrum4060  = 2.;
   Size_t   markerSizeCommonSpectrum6080  = 2.;
   
   Width_t  widthLinesBoxes;

   TString collisionSystem0020 = "0-20% p-Pb #sqrt{#it{s}_{_{NN}}} = 5.02 TeV";     
   
   TString collisionSystempPb = "p-Pb #sqrt{#it{s}_{_{NN}}} = 5.02 TeV";     
   
   Size_t markerSizeComparison = 1.5;
   TString nameHistoPCM = "CorrectedYieldPi0";
   TString nameGraphPCM = "Pi0SystError";
   

   //    TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_20130618_fwdrap.root");
   //  TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_20130618_fulleta.root");
   // TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_midrap_MB_newprimaries.root");
   //   TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("dca_correction_800000008209317200329000000_01629045000000_LHC13bc.root");
   //   TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_dcacorrection_midrap_MB.root");
   //   TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_chargedPionrange_MB.root");
   TFile* fileNeutralPionPCMDatapPbForwardRap = new TFile("data_PCMResults_pPb_mid_MB_seccorrection.root");
   TDirectory* directoryPCMForwardPi0pPb =             (TDirectory*)fileNeutralPionPCMDatapPbForwardRap->Get("Pi0_pPb_5.023TeV_0-100%"); 
   TH1D* histoPCMForwardYieldPi0pPb =            (TH1D*)directoryPCMForwardPi0pPb->Get(nameHistoPCM.Data());
   TGraphAsymmErrors* graphPCMForwardYieldPi0SysErrpPb=    (TGraphAsymmErrors*)directoryPCMForwardPi0pPb->Get(nameGraphPCM.Data()); 
   
   //     TFile* fileNeutralPionPCMDatapPbMidRap = new TFile("data_GammaConversionResultsFullCorrection_pPb_MidRap_CentBinning_Lego.root");
       TFile* fileNeutralPionPCMDatapPbMidRap = new TFile("data_PCMResults_pPb_mid_Legotrain-v5-05-20-AN_allcent.root");
       // TFile* fileNeutralPionPCMDatapPbMidRap = new TFile("data_PCMResults_pPb_midrap_0-100_MB.root");
    //    TFile* fileNeutralPionPCMDatapPbMidRap = new TFile("data_PCMResults_pPb_20130618_midrap.root");
      //  TFile* fileNeutralPionPCMDatapPbMidRap = new TFile("dca_nocorrection_800000008209317200329000000_01629045000000_LHC13bc.root"); 
   TDirectory* directoryPCMMidPi0pPb =             (TDirectory*)fileNeutralPionPCMDatapPbMidRap->Get("Pi0_pPb_5.023TeV_0-100%"); 
   TH1D* histoPCMMidYieldPi0pPb =            (TH1D*)directoryPCMMidPi0pPb->Get(nameHistoPCM.Data());
   TGraphAsymmErrors* graphPCMMidYieldPi0SysErrpPb=    (TGraphAsymmErrors*)directoryPCMMidPi0pPb->Get(nameGraphPCM.Data()); 
   
   
   TFile*   filePHOSpPb =       new TFile("ExternalInputpPb/data_PHOSResultsFullCorrection_pPb_20130826.root");
   TDirectory *directoryPHOSPi0pPb = 	(TDirectory*)filePHOSpPb->Get("Pi0_pPb_5.023TeV_0-100%"); 
   TH1D* histoPHOSYieldPi0pPb = 	(TH1D*)directoryPHOSPi0pPb->Get(nameHistoPCM.Data());    
   
//    TFile* fileChargedPionpPb = new TFile("ExternalInputpPb/ChargedPionSpectrapPb_10_Apr_2013.root");
   
//    TH1D* histoChargedPionSpecLowPtSyspPb= (TH1D*)fileChargedPionpPb->Get("histoChargedPionSpecLowPtSyspPb");
//    TH1D* histoChargedPionSpecLowPtStatpPb= (TH1D*)fileChargedPionpPb->Get("histoChargedPionSpecLowPtStatpPb");
    TFile* fileChargedPionpPb = new TFile("ExternalInputpPb/20130723_CombinedSpectra_pA_ITSsa_TPCTOF_TOF.root");
   // positive pions  
   TH1D* histoChargedPionSpecLowPtSyspPbcent0= (TH1D*)fileChargedPionpPb->Get("sys_cent0_pion_plus"); //0-5% 
   TH1D* histoChargedPionSpecLowPtStatpPbcent0= (TH1D*)fileChargedPionpPb->Get("stat_cent0_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent1= (TH1D*)fileChargedPionpPb->Get("sys_cent1_pion_plus"); //5-10%
   TH1D* histoChargedPionSpecLowPtStatpPbcent1= (TH1D*)fileChargedPionpPb->Get("stat_cent1_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent2= (TH1D*)fileChargedPionpPb->Get("sys_cent2_pion_plus");//10-20%
   TH1D* histoChargedPionSpecLowPtStatpPbcent2= (TH1D*)fileChargedPionpPb->Get("stat_cent2_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent3= (TH1D*)fileChargedPionpPb->Get("sys_cent3_pion_plus");//20-40%
   TH1D* histoChargedPionSpecLowPtStatpPbcent3= (TH1D*)fileChargedPionpPb->Get("stat_cent3_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent4= (TH1D*)fileChargedPionpPb->Get("sys_cent4_pion_plus");//40-60%
   TH1D* histoChargedPionSpecLowPtStatpPbcent4= (TH1D*)fileChargedPionpPb->Get("stat_cent4_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent5= (TH1D*)fileChargedPionpPb->Get("sys_cent5_pion_plus");//60-80%
   TH1D* histoChargedPionSpecLowPtStatpPbcent5= (TH1D*)fileChargedPionpPb->Get("stat_cent5_pion_plus");

   TH1D* histoChargedPionSpecLowPtSyspPbcent6= (TH1D*)fileChargedPionpPb->Get("sys_cent6_pion_plus");//80-100%
   TH1D* histoChargedPionSpecLowPtStatpPbcent6= (TH1D*)fileChargedPionpPb->Get("stat_cent6_pion_plus");
   // negative pions
   TH1D* histoChargedPionSpecLowPtSyspPbnegcent0= (TH1D*)fileChargedPionpPb->Get("sys_cent0_pion_minus"); //0-5% 
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent0= (TH1D*)fileChargedPionpPb->Get("stat_cent0_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent1= (TH1D*)fileChargedPionpPb->Get("sys_cent1_pion_minus"); //5-10%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent1= (TH1D*)fileChargedPionpPb->Get("stat_cent1_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent2= (TH1D*)fileChargedPionpPb->Get("sys_cent2_pion_minus");//10-20%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent2= (TH1D*)fileChargedPionpPb->Get("stat_cent2_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent3= (TH1D*)fileChargedPionpPb->Get("sys_cent3_pion_minus");//20-40%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent3= (TH1D*)fileChargedPionpPb->Get("stat_cent3_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent4= (TH1D*)fileChargedPionpPb->Get("sys_cent4_pion_minus");//40-60%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent4= (TH1D*)fileChargedPionpPb->Get("stat_cent4_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent5= (TH1D*)fileChargedPionpPb->Get("sys_cent5_pion_minus");//60-80%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent5= (TH1D*)fileChargedPionpPb->Get("stat_cent5_pion_minus");

   TH1D* histoChargedPionSpecLowPtSyspPbnegcent6= (TH1D*)fileChargedPionpPb->Get("sys_cent6_pion_minus");//80-100%
   TH1D* histoChargedPionSpecLowPtStatpPbnegcent6= (TH1D*)fileChargedPionpPb->Get("stat_cent6_pion_minus");

   histoChargedPionSpecLowPtSyspPbcent0->Add(histoChargedPionSpecLowPtSyspPbnegcent0);
   histoChargedPionSpecLowPtStatpPbcent0->Add(histoChargedPionSpecLowPtStatpPbnegcent0);

   histoChargedPionSpecLowPtSyspPbcent1->Add(histoChargedPionSpecLowPtSyspPbnegcent1);
   histoChargedPionSpecLowPtStatpPbcent1->Add(histoChargedPionSpecLowPtStatpPbnegcent1);

   histoChargedPionSpecLowPtSyspPbcent2->Add(histoChargedPionSpecLowPtSyspPbnegcent2);
   histoChargedPionSpecLowPtStatpPbcent2->Add(histoChargedPionSpecLowPtStatpPbnegcent2);

   histoChargedPionSpecLowPtSyspPbcent3->Add(histoChargedPionSpecLowPtSyspPbnegcent3);
   histoChargedPionSpecLowPtStatpPbcent3->Add(histoChargedPionSpecLowPtStatpPbnegcent3);

   histoChargedPionSpecLowPtSyspPbcent4->Add(histoChargedPionSpecLowPtSyspPbnegcent4);
   histoChargedPionSpecLowPtStatpPbcent4->Add(histoChargedPionSpecLowPtStatpPbnegcent4);

   histoChargedPionSpecLowPtSyspPbcent5->Add(histoChargedPionSpecLowPtSyspPbnegcent5);
   histoChargedPionSpecLowPtStatpPbcent5->Add(histoChargedPionSpecLowPtStatpPbnegcent5);

   histoChargedPionSpecLowPtSyspPbcent6->Add(histoChargedPionSpecLowPtSyspPbnegcent6);
   histoChargedPionSpecLowPtStatpPbcent6->Add(histoChargedPionSpecLowPtStatpPbnegcent6);

   histoChargedPionSpecLowPtSyspPbcent0->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent0->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent1->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent1->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent2->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent2->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent3->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent3->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent4->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent4->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent5->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent5->Sumw2();
   histoChargedPionSpecLowPtSyspPbcent6->Sumw2();
   histoChargedPionSpecLowPtStatpPbcent6->Sumw2();
   // divide pos and neg pions by 2
   histoChargedPionSpecLowPtSyspPbcent0->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent0->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent1->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent1->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent2->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent2->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent3->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent3->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent4->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent4->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent5->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent5->Scale(0.5);
   histoChargedPionSpecLowPtSyspPbcent6->Scale(0.5);
   histoChargedPionSpecLowPtStatpPbcent6->Scale(0.5);

   for (int i=0; i<histoChargedPionSpecLowPtSyspPbcent0->GetNbinsX();i++){ // divide by pT

     histoChargedPionSpecLowPtSyspPbcent0->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent0->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent0->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent1->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent1->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent1->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent2->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent2->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent2->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent3->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent3->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent3->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent4->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent4->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent4->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent5->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent5->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent5->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtSyspPbcent6->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent6->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent6->GetBinCenter(i+1)));

     histoChargedPionSpecLowPtStatpPbcent0->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent0->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent0->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent1->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent1->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent1->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent2->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent2->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent2->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent3->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent3->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent3->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent4->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent4->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent4->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent5->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent5->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent5->GetBinCenter(i+1)));
     histoChargedPionSpecLowPtStatpPbcent6->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent6->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent6->GetBinCenter(i+1)));

   }
   //0-100%
   TH1D *histoChargedPionSpecLowPtSyspPb=(TH1D*)histoChargedPionSpecLowPtSyspPbcent0->Clone() ;
   TH1D *histoChargedPionSpecLowPtStatpPb =(TH1D*)histoChargedPionSpecLowPtStatpPbcent0->Clone();

   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent0,histoChargedPionSpecLowPtSyspPbcent1,0.05,0.05); //weight with the centrality bin width
   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent2,0.1);
   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent3,0.2);
   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent4,0.2);
   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent5,0.2);
   histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent6,0.2);
   
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent0,histoChargedPionSpecLowPtStatpPbcent1,0.05,0.05);
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent2,0.1);
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent3,0.2);
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent4,0.2);
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent5,0.2);
   histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent6,0.2);

   histoChargedPionSpecLowPtSyspPb->Scale(1/(2*TMath::Pi())); // divide by 2*pi
   histoChargedPionSpecLowPtStatpPb->Scale(1/(2*TMath::Pi()));
//    //0-20% 
//    TFile* fileChargedPionpPb = new TFile("ExternalInputpPb/20130723_CombinedSpectra_pA_ITSsa_TPCTOF_TOF.root");
   
//    TH1D* histoChargedPionSpecLowPtSyspPbcent0= (TH1D*)fileChargedPionpPb->Get("sys_cent0_pion_plus"); //0-5% 
//    TH1D* histoChargedPionSpecLowPtStatpPbcent0= (TH1D*)fileChargedPionpPb->Get("stat_cent0_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent1= (TH1D*)fileChargedPionpPb->Get("sys_cent1_pion_plus"); //5-10%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent1= (TH1D*)fileChargedPionpPb->Get("stat_cent1_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent2= (TH1D*)fileChargedPionpPb->Get("sys_cent2_pion_plus");//10-20%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent2= (TH1D*)fileChargedPionpPb->Get("stat_cent2_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent3= (TH1D*)fileChargedPionpPb->Get("sys_cent3_pion_plus");//20-40%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent3= (TH1D*)fileChargedPionpPb->Get("stat_cent3_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent4= (TH1D*)fileChargedPionpPb->Get("sys_cent4_pion_plus");//40-60%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent4= (TH1D*)fileChargedPionpPb->Get("stat_cent4_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent5= (TH1D*)fileChargedPionpPb->Get("sys_cent5_pion_plus");//60-80%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent5= (TH1D*)fileChargedPionpPb->Get("stat_cent5_pion_plus");

//    TH1D* histoChargedPionSpecLowPtSyspPbcent6= (TH1D*)fileChargedPionpPb->Get("sys_cent6_pion_plus");//80-100%
//    TH1D* histoChargedPionSpecLowPtStatpPbcent6= (TH1D*)fileChargedPionpPb->Get("stat_cent6_pion_plus");
 
//    histoChargedPionSpecLowPtSyspPbcent0->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent0->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent1->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent1->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent2->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent2->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent3->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent3->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent4->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent4->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent5->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent5->Sumw2();
//    histoChargedPionSpecLowPtSyspPbcent6->Sumw2();
//    histoChargedPionSpecLowPtStatpPbcent6->Sumw2();


//    for (int i=0; i<histoChargedPionSpecLowPtSyspPbcent0->GetNbinsX();i++){ // divide by pT

//      histoChargedPionSpecLowPtSyspPbcent0->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent0->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent0->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent1->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent1->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent1->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent2->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent2->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent2->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent3->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent3->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent3->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent4->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent4->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent4->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent5->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent5->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent5->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtSyspPbcent6->SetBinContent(i+1,(histoChargedPionSpecLowPtSyspPbcent6->GetBinContent(i+1)/histoChargedPionSpecLowPtSyspPbcent6->GetBinCenter(i+1)));

//      histoChargedPionSpecLowPtStatpPbcent0->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent0->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent0->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent1->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent1->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent1->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent2->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent2->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent2->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent3->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent3->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent3->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent4->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent4->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent4->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent5->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent5->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent5->GetBinCenter(i+1)));
//      histoChargedPionSpecLowPtStatpPbcent6->SetBinContent(i+1,(histoChargedPionSpecLowPtStatpPbcent6->GetBinContent(i+1)/histoChargedPionSpecLowPtStatpPbcent6->GetBinCenter(i+1)));

//    }

//    TH1D *histoChargedPionSpecLowPtSyspPb=(TH1D*)histoChargedPionSpecLowPtSyspPbcent0->Clone() ;
//    TH1D *histoChargedPionSpecLowPtStatpPb =(TH1D*)histoChargedPionSpecLowPtStatpPbcent0->Clone();

//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent0,histoChargedPionSpecLowPtSyspPbcent1,0.05,0.05); //weight with the centrality bin width
//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent2,0.1);
//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent3,0.2);
//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent4,0.2);
//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent5,0.2);
//    histoChargedPionSpecLowPtSyspPb->Add(histoChargedPionSpecLowPtSyspPbcent6,0.2);
   
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent0,histoChargedPionSpecLowPtStatpPbcent1,0.05,0.05);
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent2,0.1);
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent3,0.2);
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent4,0.2);
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent5,0.2);
//    histoChargedPionSpecLowPtStatpPb->Add(histoChargedPionSpecLowPtStatpPbcent6,0.2);

//    histoChargedPionSpecLowPtSyspPb->Scale(1/(2*TMath::Pi())); // divide by 2*pi
//    histoChargedPionSpecLowPtStatpPb->Scale(1/(2*TMath::Pi()));

   
   cout << "*************************************************************************"<< endl;  
   cout << "******************************  pPb *************************************"<< endl;
   cout << "*************************************************************************"<< endl;
   
   TGraphAsymmErrors* graphPCMForwardYieldPi0SysErrpPbCopy = (TGraphAsymmErrors*) graphPCMForwardYieldPi0SysErrpPb->Clone("graphPCMForwardYieldPi0SysErrpPbCopy");

   TGraphAsymmErrors* graphPCMMidYieldPi0SysErrpPbCopy = (TGraphAsymmErrors*) graphPCMMidYieldPi0SysErrpPb->Clone("graphPCMMidYieldPi0SysErrpPbCopy");

   cout << "*************************************************************************"<< endl;  
   cout << "******************************  pPb MinBias *****************************"<< endl;
   cout << "*************************************************************************"<< endl;

   TCanvas *can= new TCanvas("can","can",800,600);
   histoChargedPionSpecLowPtStatpPb->Draw();
   histoChargedPionSpecLowPtStatpPb->Draw("same");
   histoPCMForwardYieldPi0pPb->Draw("same");

   can->Update();

   cout << "PCM Spectrum forward - low Pt" << endl;



   TGraphErrors* graphRatioLowPtChargedPionsPCMForwardpPb = CalculateRatioBetweenSpectraWithDifferentBinning(histoPCMForwardYieldPi0pPb, graphPCMForwardYieldPi0SysErrpPbCopy, histoChargedPionSpecLowPtStatpPb, histoChargedPionSpecLowPtSyspPb,  kTRUE,  kTRUE)  ;
   graphRatioLowPtChargedPionsPCMForwardpPb->Print();
   cout << "PCM Spectrum mid - low Pt" << endl;
   TGraphErrors* graphRatioLowPtChargedPionsPCMMidpPb = CalculateRatioBetweenSpectraWithDifferentBinning(histoPCMMidYieldPi0pPb, graphPCMMidYieldPi0SysErrpPbCopy, histoChargedPionSpecLowPtStatpPb, histoChargedPionSpecLowPtSyspPb,  kTRUE,  kTRUE)  ;
   graphRatioLowPtChargedPionsPCMMidpPb->Print();
   
   cout << "PHOS Spectrum forward - low Pt" << endl;
   TGraphErrors* graphRatioLowPtChargedPionsPHOSpPb = CalculateRatioBetweenSpectraWithDifferentBinning(histoPHOSYieldPi0pPb, histoPHOSYieldPi0pPb, histoChargedPionSpecLowPtStatpPb, histoChargedPionSpecLowPtSyspPb,  kTRUE,  kTRUE)  ;
   graphRatioLowPtChargedPionsPHOSpPb->Print();
   

   
   //************************************************************************************************************
   //******************************  plotting just minBias individual measurements ******************************
   //************************************************************************************************************

   TCanvas* canvasCompYieldpPbInd = new TCanvas("canvasCompYieldpPbInd","",200,10,700,500);  // gives the page size
   DrawGammaCanvasSettings( canvasCompYieldpPbInd,  0.12, 0.02, 0.02, 0.12);
   
   canvasCompYieldpPbInd->SetLogx();
   TH2F * histo2DCompCombinedRatio2;
   histo2DCompCombinedRatio2 = new TH2F("histo2DCompCombinedRatio2","histo2DCompCombinedRatio2",1000,0.3,20.,1000,0.2,4.   );
   SetStyleHistoTH2ForGraphs(histo2DCompCombinedRatio2, "p_{T} (GeV/c)","#pi^{0}/#pi^{#pm}", 0.05,0.064, 0.05,0.06, 0.8,0.9, 512, 505);
   histo2DCompCombinedRatio2->GetXaxis()->SetRangeUser(0.,15.);
   histo2DCompCombinedRatio2->GetYaxis()->SetRangeUser(0.1,2.1);
   histo2DCompCombinedRatio2->DrawCopy();

      DrawGammaSetMarkerTGraphErr(graphRatioLowPtChargedPionsPCMForwardpPb,20,markerSizeComparison, kBlue+2, kBlue+2);
      graphRatioLowPtChargedPionsPCMForwardpPb->Draw("E1psame");
      DrawGammaSetMarkerTGraphErr(graphRatioLowPtChargedPionsPCMMidpPb,25,markerSizeComparison, kBlue+2, kBlue+2);
      graphRatioLowPtChargedPionsPCMMidpPb->Draw("E1psame");

//       DrawGammaSetMarkerTGraphErr(graphRatioLowPtChargedPionsPHOSpPb,20,markerSizeComparison,  kMagenta+1, kMagenta+1);
//       graphRatioLowPtChargedPionsPHOSpPb->Draw("E1psame");

      TLatex *labelRatioPi0pPb = new TLatex(0.16,0.9,collisionSystempPb.Data());
      SetStyleTLatex( labelRatioPi0pPb, 0.06,4);
      labelRatioPi0pPb->Draw();

      TLegend* legendPi0CompIndChargedPionspPb = new TLegend(0.13,0.15,0.98,0.25);
      legendPi0CompIndChargedPionspPb->SetFillColor(0);
      legendPi0CompIndChargedPionspPb->SetLineColor(0);
      legendPi0CompIndChargedPionspPb->SetNColumns(1);
      legendPi0CompIndChargedPionspPb->SetTextSize(0.038);
      legendPi0CompIndChargedPionspPb->SetMargin(0.14);
      legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPCMForwardpPb,"#pi^{0}/#pi^{#pm} low pt (PCM, 0.165 < y < 0.765)","p");
      //legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPHOSpPb,"#pi^{0}/#pi^{#pm} low pt (PHOS)","p");
       legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPCMMidpPb,"#pi^{0}/#pi^{#pm} low pt (PCM, |y| < 0.4)","p");
       // legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPCMForwardpPb,"#pi^{0}/#pi^{#pm} low pt midrapidity with pile up subtraction","p");
      //  legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPHOSpPb,"#pi^{0}/#pi^{#pm} low pt (PHOS) - 2013-08-26","p");
       //  legendPi0CompIndChargedPionspPb->AddEntry(graphRatioLowPtChargedPionsPCMMidpPb,"#pi^{0}/#pi^{#pm} low pt midrapidity without subtraction","p");
      legendPi0CompIndChargedPionspPb->Draw();

      legendPi0CompIndChargedPionspPb->Draw();
      DrawGammaLines(0., 19.5 , 1, 1 ,1,kGray);
   
   DrawGammaLines(0., 20.,1., 1.,0.1,kGray,2);
   
   
   canvasCompYieldpPbInd->Update();
   canvasCompYieldpPbInd->Print(Form("%s/ComparisonChargedToNeutralInd_pPb.%s",outputDir.Data(),suffix.Data()));


}
Esempio n. 5
0
void combine()
{
   gROOT->SetBatch(1);

   SetPlotStyle();

   std::string tag = "CSVM";
   std::string tagName = "CSVv2M";
//   std::string tag = "CMVAT";
//   std::string tagName = "cMVAv2T";

//   const int nPT = 15;
/*   const int nPT = 14;
   std::string pt[nPT] = 
     {
	"pt20t30",
	"pt30t40",
	"pt40t50",
	"pt50t60",
	"pt60t70",
	"pt70t80",
	"pt80t100",
	"pt100t120",
	"pt120t160",
	"pt160t210",
	"pt210t260",
	"pt260t320",
	"pt320t400",
	"pt400t500"
//	"pt500t670"
     };*/
   
/*   const int nPT = 7;
   std::string pt[nPT] =
     {
	"pt30t50",
	"pt50t70",
	"pt70t100",
	"pt100t140",
	"pt140t200",
	"pt200t300",
	"pt300t670"
     };*/

/*   const int nPT = 5;
   std::string pt[nPT] =
     {
	"pt200t220",
	"pt220t250",
	"pt250t300",
	"pt300t400",
	"pt400t650"
     };*/

   const int nPT = 5;
   std::string pt[nPT] =
     {
	"pt30t80",
	"pt80t140",
	"pt140t180",
	"pt180t240",
	"pt240t420"
     };

/*   int ptb[nPT+1] =
     {
	30,50,70,100,140,200,300,670
     };*/

/*   int ptb[nPT+1] =
     {
	200,220,250,300,400,650
     };*/

   int ptb[nPT+1] =
     {
	30,80,140,180,240,420
     };
   
   float xbins[nPT];
   for(int j=0;j<=nPT;j++)
     {
	xbins[j] = ptb[j]/1000.;
     }
   
   TH1F *h_SF = new TH1F("h_SF","h_SF",nPT,xbins);
   TH1F *h_SF_TOTAL_UP = new TH1F("h_SF_TOTAL_UP","h_SF_TOTAL_UP",nPT,xbins);
   TH1F *h_SF_TOTAL_DOWN = new TH1F("h_SF_TOTAL_DOWN","h_SF_TOTAL_DOWN",nPT,xbins);
   
   TH1F *h_frb = new TH1F("h_frb","h_frb",nPT,xbins);
   TH1F *h_frb_TOTAL_UP = new TH1F("h_frb_TOTAL_UP","h_frb_TOTAL_UP",nPT,xbins);
   TH1F *h_frb_TOTAL_DOWN = new TH1F("h_frb_TOTAL_DOWN","h_frb_TOTAL_DOWN",nPT,xbins);
   TH1F *h_frc = new TH1F("h_frc","h_frc",nPT,xbins);
   TH1F *h_frc_TOTAL_UP = new TH1F("h_frc_TOTAL_UP","h_frc_TOTAL_UP",nPT,xbins);
   TH1F *h_frc_TOTAL_DOWN = new TH1F("h_frc_TOTAL_DOWN","h_frc_TOTAL_DOWN",nPT,xbins);
   TH1F *h_frl = new TH1F("h_frl","h_frl",nPT,xbins);
   TH1F *h_frl_TOTAL_UP = new TH1F("h_frl_TOTAL_UP","h_frl_TOTAL_UP",nPT,xbins);
   TH1F *h_frl_TOTAL_DOWN = new TH1F("h_frl_TOTAL_DOWN","h_frl_TOTAL_DOWN",nPT,xbins);
   
   TH1F *h_frb_tag = new TH1F("h_frb_tag","h_frb_tag",nPT,xbins);
   TH1F *h_frb_tag_TOTAL_UP = new TH1F("h_frb_tag_TOTAL_UP","h_frb_tag_TOTAL_UP",nPT,xbins);
   TH1F *h_frb_tag_TOTAL_DOWN = new TH1F("h_frb_tag_TOTAL_DOWN","h_frb_tag_TOTAL_DOWN",nPT,xbins);
   TH1F *h_frc_tag = new TH1F("h_frc_tag","h_frc_tag",nPT,xbins);
   TH1F *h_frc_tag_TOTAL_UP = new TH1F("h_frc_tag_TOTAL_UP","h_frc_tag_TOTAL_UP",nPT,xbins);
   TH1F *h_frc_tag_TOTAL_DOWN = new TH1F("h_frc_tag_TOTAL_DOWN","h_frc_tag_TOTAL_DOWN",nPT,xbins);
   TH1F *h_frl_tag = new TH1F("h_frl_tag","h_frl_tag",nPT,xbins);
   TH1F *h_frl_tag_TOTAL_UP = new TH1F("h_frl_tag_TOTAL_UP","h_frl_tag_TOTAL_UP",nPT,xbins);
   TH1F *h_frl_tag_TOTAL_DOWN = new TH1F("h_frl_tag_TOTAL_DOWN","h_frl_tag_TOTAL_DOWN",nPT,xbins);
   
   std::string head = "CSV;OperatingPoint,measurementType,sysType,jetFlavor,etaMin,etaMax,ptMin,ptMax,discrMin,discrMax,formula";
   std::string fname = "results/CSV_13TEV_"+SFver+"_"+tagName+"_LT.csv";
   std::ofstream sfComb(fname.c_str());
   sfComb << head << std::endl;

   std::vector<std::vector<float> > Comb_sigma_syst;
   std::vector<std::vector<std::string> > Comb_sigma_syst_name;
   std::vector<float> Comb_sf;
   std::vector<int> Comb_op;
   std::vector<std::string> Comb_type;
   std::vector<int> Comb_flav;
   std::vector<float> Comb_etaMin;
   std::vector<float> Comb_etaMax;
   std::vector<float> Comb_discMin;
   std::vector<float> Comb_discMax;
   std::vector<int> Comb_ptMin;
   std::vector<int> Comb_ptMax;
   
   for(int ipt=0;ipt<nPT;ipt++)
     {
	if( tag == "CSVL" || tag == "CMVAL" ) Comb_op.push_back(0);
	else if( tag == "CSVM" || tag == "CMVAM" ) Comb_op.push_back(1);
	else if( tag == "CSVT" || tag == "CMVAT" ) Comb_op.push_back(2);
	
	Comb_type.push_back("lt");
	Comb_flav.push_back(0);
	Comb_etaMin.push_back(0.0);
	Comb_etaMax.push_back(2.4);
	Comb_discMin.push_back(0.0);
	Comb_discMax.push_back(1.0);
	
	std::vector<int> run;
	std::vector<float> sf;
	std::vector<float> frb;
	std::vector<float> frbTag;
	std::vector<float> frc;
	std::vector<float> frcTag;
	std::vector<float> frl;
	std::vector<float> frlTag;
	
	int idxNom = -666;

	for(int is=0;is<=2;is++) // FIXME !!!
	  {
	     std::string prefix;
	     if( is == 0 ) prefix = "results_"+tag+"_MJBOOSTS1_SUB/";
	     else if( is == 1 ) prefix = "results_"+tag+"_MJBOOSTS2_SUB/";
//	     if( is == 0 ) prefix = "results/";
//	     if( is == 0 ) prefix = "results_"+tag+"_MJ/";
//	     else if( is == 1 ) prefix = "results_"+tag+"_MJAWAY/";
//	     else if( is == 2 ) prefix = "results_"+tag+"_MJ1/";
//	     else if( is == 2 ) prefix = "results_"+tag+"_MJIAWAY/";
	     else continue;
	     
	     // read result files
	     std::string fname = prefix+pt[ipt]+"_"+tag+".csv";
	     std::ifstream f(fname.c_str());
	     if( !f.is_open() ) continue;
	     std::cout << fname << std::endl;
	     
	     int iline = 0;
	     while( !f.eof() )
	       {	     
		  std::string line;
		  f >> line;
		  if( iline == 0 ) {iline++; continue;}
		  std::stringstream ss(line);
		  std::string item;
		  int idx = 0;
		  while( std::getline(ss,item,',') )
		    {
		       int run_v = -1;
		       if( idx == 3 ) run_v = atoi(item.c_str());
		       
		       if( is == 0 && idx == 3 && run_v == 0 ) idxNom = iline-1;

		       if( (iline == 1 && is == 1) || 
			   (iline == 1 && is == 2) ||
			   (iline == 1 && is == 3) ||
			   is == 0 )
			 {			    
			    if( is == 1 ) run_v = 200;
			    if( is == 2 ) run_v = 201;
			    if( is == 3 ) run_v = 202;
			    
			    if( idx == 3 ) run.push_back(run_v);
			    
			    if( idx == 24 ) 
			      {
				 sf.push_back(atof(item.c_str())); // FIXME IF FORMAT CHANGES
			      }

			    if( idx == 14 ) frb.push_back(atof(item.c_str()));
			    if( idx == 15 ) frbTag.push_back(atof(item.c_str()));
			    if( idx == 16 ) frc.push_back(atof(item.c_str()));
			    if( idx == 17 ) frcTag.push_back(atof(item.c_str()));
			    if( idx == 18 ) frl.push_back(atof(item.c_str()));
			    if( idx == 19 ) frlTag.push_back(atof(item.c_str()));
			    
			    if( iline == 1 && is == 0 && (run_v < 100 || run_v >= 666) )
			      {
				 if( idx == 0 ) Comb_ptMin.push_back(atoi(item.c_str()));
				 if( idx == 1 ) Comb_ptMax.push_back(atoi(item.c_str()));
			      }		  
			 }		       
		       
		       idx++;
		    }
		  
		  iline++;
	       }
	     
	     f.close();
	  }	
	
	// do calculations
	int nRES = run.size();
	
	float sigma_syst_up = 0.;
	float sigma_syst_down = 0.;
	float sigma_total_up = 0.;
	float sigma_total_down = 0.;
	float sigma_stat = 0.;
	float sf_stat_sum = 0.;
	float istat = 0;

	float frb_sigma_total_up = 0.;
	float frb_sigma_total_down = 0.;
	float frc_sigma_total_up = 0.;
	float frc_sigma_total_down = 0.;
	float frl_sigma_total_up = 0.;
	float frl_sigma_total_down = 0.;
	
	float frb_sigma_syst_up = 0.;
	float frb_sigma_syst_down = 0.;
	float frc_sigma_syst_up = 0.;
	float frc_sigma_syst_down = 0.;
	float frl_sigma_syst_up = 0.;
	float frl_sigma_syst_down = 0.;

	float frb_tag_sigma_total_up = 0.;
	float frb_tag_sigma_total_down = 0.;
	float frc_tag_sigma_total_up = 0.;
	float frc_tag_sigma_total_down = 0.;
	float frl_tag_sigma_total_up = 0.;
	float frl_tag_sigma_total_down = 0.;
	
	float frb_tag_sigma_syst_up = 0.;
	float frb_tag_sigma_syst_down = 0.;
	float frc_tag_sigma_syst_up = 0.;
	float frc_tag_sigma_syst_down = 0.;
	float frl_tag_sigma_syst_up = 0.;
	float frl_tag_sigma_syst_down = 0.;
	
	float frb_stat_sum = 0.;
	float sigma_frb_stat = 0.;
	float frc_stat_sum = 0.;
	float sigma_frc_stat = 0.;
	float frl_stat_sum = 0.;
	float sigma_frl_stat = 0.;

	float frbTag_stat_sum = 0.;
	float sigma_frbTag_stat = 0.;
	float frcTag_stat_sum = 0.;
	float sigma_frcTag_stat = 0.;
	float frlTag_stat_sum = 0.;
	float sigma_frlTag_stat = 0.;
	
	std::vector<float> sigma_syst_sep;
	std::vector<std::string> sigma_syst_name;
	float sigma_syst_add = 0.;
	float frb_sigma_syst_add = 0.;
	float frc_sigma_syst_add = 0.;
	float frl_sigma_syst_add = 0.;

	float frb_tag_sigma_syst_add = 0.;
	float frc_tag_sigma_syst_add = 0.;
	float frl_tag_sigma_syst_add = 0.;
	
	std::vector<float> frb_sigma_syst_sep;
	std::vector<float> frc_sigma_syst_sep;
	std::vector<float> frl_sigma_syst_sep;

	std::vector<float> frb_tag_sigma_syst_sep;
	std::vector<float> frc_tag_sigma_syst_sep;
	std::vector<float> frl_tag_sigma_syst_sep;
	
	std::vector<std::string> frb_sigma_syst_name;
	std::vector<std::string> frc_sigma_syst_name;
	std::vector<std::string> frl_sigma_syst_name;

	std::vector<std::string> frb_tag_sigma_syst_name;
	std::vector<std::string> frc_tag_sigma_syst_name;
	std::vector<std::string> frl_tag_sigma_syst_name;
	
	for(int i=0;i<nRES;i++)
	  {
	     if( i == idxNom )
	       {
		  sigma_syst_sep.push_back(sf[idxNom]);
		  sigma_syst_name.push_back(getSysName(run[i]));
		  continue;
	       }	     
	     
	     if( run[i] < 666 )
	       {	
		  float delta = sf[idxNom]-sf[i];
		  bool isUp = (delta < 0);
		  float err = delta*delta;
		  if( run[i] < 100 )
		    {		       
		       if( isUp ) sigma_syst_up += err;		  
		       else sigma_syst_down += err;
		    }
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       sigma_syst_up += pow(delta,2);
		       sigma_syst_down += pow(delta,2);
		    }		  

		  if( run[i] < 100 )
		    {		       
		       if( isUp ) sigma_syst_sep.push_back(sf[idxNom]+sqrt(err));
		       else sigma_syst_sep.push_back(sf[idxNom]-sqrt(err));
		       sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       sigma_syst_add += pow(delta,2);
		    }	
		  
		  // frb
		  float delta_frb = frb[idxNom]-frb[i];
		  bool isUp_frb = (delta_frb < 0);
		  float err_frb = delta_frb*delta_frb;
		  if( isUp_frb ) frb_sigma_syst_up += err_frb;
		  else frb_sigma_syst_down += err_frb;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frb ) frb_sigma_syst_sep.push_back(frb[idxNom]+sqrt(err_frb));
		       else frb_sigma_syst_sep.push_back(frb[idxNom]-sqrt(err_frb));
		       frb_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frb_sigma_syst_add += pow(delta_frb,2);
		    }	

		  // frbTag
		  float delta_frb_tag = frbTag[idxNom]-frbTag[i];
		  bool isUp_frb_tag = (delta_frb_tag < 0);
		  float err_frb_tag = delta_frb_tag*delta_frb_tag;
		  if( isUp_frb_tag ) frb_tag_sigma_syst_up += err_frb_tag;
		  else frb_tag_sigma_syst_down += err_frb_tag;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frb_tag ) frb_tag_sigma_syst_sep.push_back(frbTag[idxNom]+sqrt(err_frb_tag));
		       else frb_tag_sigma_syst_sep.push_back(frbTag[idxNom]-sqrt(err_frb_tag));
		       frb_tag_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frb_tag_sigma_syst_add += pow(delta_frb_tag,2);
		    }	
		  
		  // frc
		  float delta_frc = frc[idxNom]-frc[i];
		  bool isUp_frc = (delta_frc < 0);
		  float err_frc = delta_frc*delta_frc;
		  if( isUp_frc ) frc_sigma_syst_up += err_frc;
		  else frc_sigma_syst_down += err_frc;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frc ) frc_sigma_syst_sep.push_back(frc[idxNom]+sqrt(err_frc));
		       else frc_sigma_syst_sep.push_back(frc[idxNom]-sqrt(err_frc));
		       frc_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frc_sigma_syst_add += pow(delta_frc,2);
		    }	

		  // frcTag
		  float delta_frc_tag = frcTag[idxNom]-frcTag[i];
		  bool isUp_frc_tag = (delta_frc_tag < 0);
		  float err_frc_tag = delta_frc_tag*delta_frc_tag;
		  if( isUp_frc_tag ) frc_tag_sigma_syst_up += err_frc_tag;
		  else frc_tag_sigma_syst_down += err_frc_tag;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frc_tag ) frc_tag_sigma_syst_sep.push_back(frcTag[idxNom]+sqrt(err_frc_tag));
		       else frc_tag_sigma_syst_sep.push_back(frcTag[idxNom]-sqrt(err_frc_tag));
		       frc_tag_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frc_tag_sigma_syst_add += pow(delta_frc_tag,2);
		    }	
		  
		  // frl
		  float delta_frl = frl[idxNom]-frl[i];
		  bool isUp_frl = (delta_frl < 0);
		  float err_frl = delta_frl*delta_frl;
		  if( isUp_frl ) frl_sigma_syst_up += err_frl;
		  else frl_sigma_syst_down += err_frl;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frl ) frl_sigma_syst_sep.push_back(frl[idxNom]+sqrt(err_frl));
		       else frl_sigma_syst_sep.push_back(frl[idxNom]-sqrt(err_frl));
		       frl_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frl_sigma_syst_add += pow(delta_frl,2);
		    }	

		  // frlTag
		  float delta_frl_tag = frlTag[idxNom]-frlTag[i];
		  bool isUp_frl_tag = (delta_frl_tag < 0);
		  float err_frl_tag = delta_frl_tag*delta_frl_tag;
		  if( isUp_frl_tag ) frl_tag_sigma_syst_up += err_frl_tag;
		  else frl_tag_sigma_syst_down += err_frl_tag;
		  if( run[i] < 100 )
		    {		       
		       if( isUp_frl_tag ) frl_tag_sigma_syst_sep.push_back(frlTag[idxNom]+sqrt(err_frl_tag));
		       else frl_tag_sigma_syst_sep.push_back(frlTag[idxNom]-sqrt(err_frl_tag));
		       frl_tag_sigma_syst_name.push_back(getSysName(run[i]));
		    }		  		  
		  if( run[i] >= 100 && run[i] <= 202 )
		    {
		       frl_tag_sigma_syst_add += pow(delta_frl_tag,2);
		    }	
	       }
	     else
	       {
		  sf_stat_sum += sf[i];
		  frb_stat_sum += frb[i];
		  frc_stat_sum += frc[i];
		  frl_stat_sum += frl[i];
		  frbTag_stat_sum += frbTag[i];
		  frcTag_stat_sum += frcTag[i];
		  frlTag_stat_sum += frlTag[i];
		  istat++;
	       }	     
	  }
	sigma_syst_add = sqrt(sigma_syst_add);
	frb_sigma_syst_add = sqrt(frb_sigma_syst_add);
	frc_sigma_syst_add = sqrt(frc_sigma_syst_add);
	frl_sigma_syst_add = sqrt(frl_sigma_syst_add);

	frb_tag_sigma_syst_add = sqrt(frb_tag_sigma_syst_add);
	frc_tag_sigma_syst_add = sqrt(frc_tag_sigma_syst_add);
	frl_tag_sigma_syst_add = sqrt(frl_tag_sigma_syst_add);
	
	Comb_sf.push_back(sf[idxNom]);
	
	sf_stat_sum /= istat;	
	frb_stat_sum /= istat;
	frc_stat_sum /= istat;
	frl_stat_sum /= istat;
	frbTag_stat_sum /= istat;
	frcTag_stat_sum /= istat;
	frlTag_stat_sum /= istat;

	float sfcbsys = 0.;
	// add Cb systematics
	if( inclCB )
	  {	     
	     float cb = getCb(tag,"bjet",ipt+1);
//	     float cb = getCb(tag,"bjet",ipt+1+1); //FIXME if include 20-30 bin
	     float cbsys = (1-cb)*0.5/cb;
	     sfcbsys = pow(cbsys*sf[idxNom],2);
	     
	     sigma_syst_up += sfcbsys;
	     sigma_syst_down += sfcbsys;
	  }
	
	// add add
//	sigma_syst_up += sigma_syst_add*sigma_syst_add;
//	sigma_syst_down += sigma_syst_add*sigma_syst_add;
	
	for(int i=0;i<istat;i++)
	  {	     
	     sigma_stat += pow(sf_stat_sum-sf[i],2)/istat;
	     sigma_frb_stat += pow(frb_stat_sum-frb[i],2)/istat;
	     sigma_frc_stat += pow(frc_stat_sum-frc[i],2)/istat;
	     sigma_frl_stat += pow(frl_stat_sum-frl[i],2)/istat;
	     sigma_frbTag_stat += pow(frbTag_stat_sum-frbTag[i],2)/istat;
	     sigma_frcTag_stat += pow(frcTag_stat_sum-frcTag[i],2)/istat;
	     sigma_frlTag_stat += pow(frlTag_stat_sum-frlTag[i],2)/istat;
	  }
	sigma_stat = sqrt(sigma_stat);
	sigma_frb_stat = sqrt(sigma_frb_stat);
	sigma_frc_stat = sqrt(sigma_frc_stat);
	sigma_frl_stat = sqrt(sigma_frl_stat);
	sigma_frbTag_stat = sqrt(sigma_frbTag_stat);
	sigma_frcTag_stat = sqrt(sigma_frcTag_stat);
	sigma_frlTag_stat = sqrt(sigma_frlTag_stat);
	
	sigma_syst_up = sqrt(sigma_syst_up);
	sigma_syst_down = sqrt(sigma_syst_down);

	frb_sigma_syst_up = sqrt(frb_sigma_syst_up);
	frb_sigma_syst_down = sqrt(frb_sigma_syst_down);
	frc_sigma_syst_up = sqrt(frc_sigma_syst_up);
	frc_sigma_syst_down = sqrt(frc_sigma_syst_down);
	frl_sigma_syst_up = sqrt(frl_sigma_syst_up);
	frl_sigma_syst_down = sqrt(frl_sigma_syst_down);

	frb_tag_sigma_syst_up = sqrt(frb_tag_sigma_syst_up);
	frb_tag_sigma_syst_down = sqrt(frb_tag_sigma_syst_down);
	frc_tag_sigma_syst_up = sqrt(frc_tag_sigma_syst_up);
	frc_tag_sigma_syst_down = sqrt(frc_tag_sigma_syst_down);
	frl_tag_sigma_syst_up = sqrt(frl_tag_sigma_syst_up);
	frl_tag_sigma_syst_down = sqrt(frl_tag_sigma_syst_down);
	
	sigma_total_up = sqrt(sigma_stat*sigma_stat+sigma_syst_up*sigma_syst_up);
	sigma_total_down = sqrt(sigma_stat*sigma_stat+sigma_syst_down*sigma_syst_down);

	frb_sigma_total_up = sqrt(sigma_frb_stat*sigma_frb_stat+frb_sigma_syst_up*frb_sigma_syst_up);
	frb_sigma_total_down = sqrt(sigma_frb_stat*sigma_frb_stat+frb_sigma_syst_down*frb_sigma_syst_down);
	frc_sigma_total_up = sqrt(sigma_frc_stat*sigma_frc_stat+frc_sigma_syst_up*frc_sigma_syst_up);
	frc_sigma_total_down = sqrt(sigma_frc_stat*sigma_frc_stat+frc_sigma_syst_down*frc_sigma_syst_down);
	frl_sigma_total_up = sqrt(sigma_frl_stat*sigma_frl_stat+frl_sigma_syst_up*frl_sigma_syst_up);
	frl_sigma_total_down = sqrt(sigma_frl_stat*sigma_frl_stat+frl_sigma_syst_down*frl_sigma_syst_down);

	frb_tag_sigma_total_up = sqrt(sigma_frbTag_stat*sigma_frbTag_stat+frb_tag_sigma_syst_up*frb_tag_sigma_syst_up);
	frb_tag_sigma_total_down = sqrt(sigma_frbTag_stat*sigma_frbTag_stat+frb_tag_sigma_syst_down*frb_tag_sigma_syst_down);
	frc_tag_sigma_total_up = sqrt(sigma_frcTag_stat*sigma_frcTag_stat+frc_tag_sigma_syst_up*frc_tag_sigma_syst_up);
	frc_tag_sigma_total_down = sqrt(sigma_frcTag_stat*sigma_frcTag_stat+frc_tag_sigma_syst_down*frc_tag_sigma_syst_down);
	frl_tag_sigma_total_up = sqrt(sigma_frlTag_stat*sigma_frlTag_stat+frl_tag_sigma_syst_up*frl_tag_sigma_syst_up);
	frl_tag_sigma_total_down = sqrt(sigma_frlTag_stat*sigma_frlTag_stat+frl_tag_sigma_syst_down*frl_tag_sigma_syst_down);
	
	float SF = sf[idxNom];
	float SF_STAT = SF+sigma_stat;
	float SF_SYST_UP = SF+sigma_syst_up;
	float SF_SYST_DOWN = SF-sigma_syst_down;
	float SF_TOTAL_UP = SF+sigma_total_up;
	float SF_TOTAL_DOWN = SF-sigma_total_down;
	
	h_SF->SetBinContent(ipt+1,SF);
	h_SF->SetBinError(ipt+1,sigma_stat);
	
	h_SF_TOTAL_UP->SetBinContent(ipt+1,SF_TOTAL_UP);
	h_SF_TOTAL_DOWN->SetBinContent(ipt+1,SF_TOTAL_DOWN);

	float FRB = frb[idxNom];
	float FRB_STAT = FRB+sigma_frb_stat;
	float FRB_SYST_UP = FRB+frb_sigma_syst_up;
	float FRB_SYST_DOWN = FRB-frb_sigma_syst_down;
	float FRB_TOTAL_UP = FRB+frb_sigma_total_up;
	float FRB_TOTAL_DOWN = FRB-frb_sigma_total_down;
	
	h_frb->SetBinContent(ipt+1,FRB);
	h_frb->SetBinError(ipt+1,sigma_frb_stat);
	h_frb_TOTAL_UP->SetBinContent(ipt+1,FRB_TOTAL_UP);
	h_frb_TOTAL_DOWN->SetBinContent(ipt+1,FRB_TOTAL_DOWN);

	float FRC = frc[idxNom];
	float FRC_STAT = FRC+sigma_frc_stat;
	float FRC_SYST_UP = FRC+frc_sigma_syst_up;
	float FRC_SYST_DOWN = FRC-frc_sigma_syst_down;
	float FRC_TOTAL_UP = FRC+frc_sigma_total_up;
	float FRC_TOTAL_DOWN = FRC-frc_sigma_total_down;
	
	h_frc->SetBinContent(ipt+1,FRC);
	h_frc->SetBinError(ipt+1,sigma_frc_stat);
	h_frc_TOTAL_UP->SetBinContent(ipt+1,FRC_TOTAL_UP);
	h_frc_TOTAL_DOWN->SetBinContent(ipt+1,FRC_TOTAL_DOWN);

	float FRL = frl[idxNom];
	float FRL_STAT = FRL+sigma_frl_stat;
	float FRL_SYST_UP = FRL+frl_sigma_syst_up;
	float FRL_SYST_DOWN = FRL-frl_sigma_syst_down;
	float FRL_TOTAL_UP = FRL+frl_sigma_total_up;
	float FRL_TOTAL_DOWN = FRL-frl_sigma_total_down;
	
	h_frl->SetBinContent(ipt+1,FRL);
	h_frl->SetBinError(ipt+1,sigma_frl_stat);
	h_frl_TOTAL_UP->SetBinContent(ipt+1,FRL_TOTAL_UP);
	h_frl_TOTAL_DOWN->SetBinContent(ipt+1,FRL_TOTAL_DOWN);

	float FRB_TAG = frbTag[idxNom];
	float FRB_TAG_STAT = FRB_TAG+sigma_frbTag_stat;
	float FRB_TAG_SYST_UP = FRB_TAG+frb_tag_sigma_syst_up;
	float FRB_TAG_SYST_DOWN = FRB_TAG-frb_tag_sigma_syst_down;
	float FRB_TAG_TOTAL_UP = FRB_TAG+frb_tag_sigma_total_up;
	float FRB_TAG_TOTAL_DOWN = FRB_TAG-frb_tag_sigma_total_down;
	
	h_frb_tag->SetBinContent(ipt+1,FRB_TAG);
	h_frb_tag->SetBinError(ipt+1,sigma_frbTag_stat);
	h_frb_tag_TOTAL_UP->SetBinContent(ipt+1,FRB_TAG_TOTAL_UP);
	h_frb_tag_TOTAL_DOWN->SetBinContent(ipt+1,FRB_TAG_TOTAL_DOWN);

	float FRC_TAG = frcTag[idxNom];
	float FRC_TAG_STAT = FRC_TAG+sigma_frcTag_stat;
	float FRC_TAG_SYST_UP = FRC_TAG+frc_tag_sigma_syst_up;
	float FRC_TAG_SYST_DOWN = FRC_TAG-frc_tag_sigma_syst_down;
	float FRC_TAG_TOTAL_UP = FRC_TAG+frc_tag_sigma_total_up;
	float FRC_TAG_TOTAL_DOWN = FRC_TAG-frc_tag_sigma_total_down;
	
	h_frc_tag->SetBinContent(ipt+1,FRC_TAG);
	h_frc_tag->SetBinError(ipt+1,sigma_frcTag_stat);
	h_frc_tag_TOTAL_UP->SetBinContent(ipt+1,FRC_TAG_TOTAL_UP);
	h_frc_tag_TOTAL_DOWN->SetBinContent(ipt+1,FRC_TAG_TOTAL_DOWN);

	float FRL_TAG = frlTag[idxNom];
	float FRL_TAG_STAT = FRL_TAG+sigma_frlTag_stat;
	float FRL_TAG_SYST_UP = FRL_TAG+frl_tag_sigma_syst_up;
	float FRL_TAG_SYST_DOWN = FRL_TAG-frl_tag_sigma_syst_down;
	float FRL_TAG_TOTAL_UP = FRL_TAG+frl_tag_sigma_total_up;
	float FRL_TAG_TOTAL_DOWN = FRL_TAG-frl_tag_sigma_total_down;
	
	h_frl_tag->SetBinContent(ipt+1,FRL_TAG);
	h_frl_tag->SetBinError(ipt+1,sigma_frlTag_stat);
	h_frl_tag_TOTAL_UP->SetBinContent(ipt+1,FRL_TAG_TOTAL_UP);
	h_frl_tag_TOTAL_DOWN->SetBinContent(ipt+1,FRL_TAG_TOTAL_DOWN);
	
	// additional uncertainties
	
	// stat
	sigma_syst_name.push_back("up_statistic");
	sigma_syst_sep.push_back(SF+sigma_stat);
	sigma_syst_name.push_back("down_statistic");
	sigma_syst_sep.push_back(SF-sigma_stat);
	
	// cb
	sigma_syst_name.push_back("up_cb");
	sigma_syst_sep.push_back(SF+sqrt(sfcbsys));
	sigma_syst_name.push_back("down_cb");
	sigma_syst_sep.push_back(SF-sqrt(sfcbsys));

	// add
	sigma_syst_name.push_back("up_add");
	sigma_syst_sep.push_back(SF+sigma_syst_add);
	sigma_syst_name.push_back("down_add");
	sigma_syst_sep.push_back(SF-sigma_syst_add);

	// total
	sigma_syst_name.push_back("up");
	sigma_syst_sep.push_back(SF_TOTAL_UP);
	sigma_syst_name.push_back("down");
	sigma_syst_sep.push_back(SF_TOTAL_DOWN);
	
	Comb_sigma_syst.push_back(sigma_syst_sep);
	Comb_sigma_syst_name.push_back(sigma_syst_name);
     }
   
   // draw SF
   TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500);
   c1->SetGrid(1);
   
   std::string csv = "#bf{"+tagName+"}";
   
   const int np = 2*(nPT+2)+1;
   double xp_sysTot_SF[np];
   double yp_sysTot_SF[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_SF->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_SF->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_SF[k] = addw + h_SF->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_SF[k] = h_SF_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_SF[nPT+2+k] = h_SF_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_SF[nPT+2+k] = xp_sysTot_SF[nPT+2-k-1];
     }	
   xp_sysTot_SF[np-1] = xp_sysTot_SF[0];   
   yp_sysTot_SF[np-1] = yp_sysTot_SF[0];
   
   TPolyLine *sysTot_SF = new TPolyLine(np,xp_sysTot_SF,yp_sysTot_SF);
   sysTot_SF->SetFillColor(kYellow);
	
   if( !doSFc ) h_SF->GetYaxis()->SetTitle("SF_{b}");
   else h_SF->GetYaxis()->SetTitle("SF_{c}");
   h_SF->GetXaxis()->SetTitle("p_{T} [TeV]");
   h_SF->SetMarkerSize(0.8);

   h_SF->Draw("e1p");
	
   h_SF->GetXaxis()->SetMoreLogLabels();
   h_SF->GetXaxis()->SetNoExponent();
   h_SF->GetYaxis()->SetRangeUser(0.40,1.30);
	
   sysTot_SF->Draw("fSAME");
   h_SF->Draw("e1p same");
   
   TLegend *leg;
   leg = new TLegend(0.35,0.45,0.70,0.20);
   leg->SetFillColor(253);
   leg->SetBorderSize(0);
   
   TLatex *legl = new TLatex();
   legl->SetNDC();
   legl->SetTextAlign(22);
   legl->SetTextFont(63);
   legl->SetTextSizePixels(30);
   legl->DrawLatex(0.55,0.82,csv.c_str());
   
   leg->AddEntry(h_SF,"Scale factor","p");
   leg->AddEntry(h_SF,"stat","l");
   leg->AddEntry(sysTot_SF,"stat #oplus syst","f");
   
   c1->RedrawAxis("g");
   
   leg->Draw();
   
//   c1->SetLogx(1);
//   TLatex *lab = CMSLABEL();
//   lab->Draw("same");
   
   TLatex *tex = new TLatex(0.1969,0.906825,"CMS");
   tex->SetNDC();
   tex->SetTextAlign(13);
   tex->SetTextFont(61);
   tex->SetTextSize(0.07475);
   tex->SetLineWidth(2);
   tex->Draw();

   TLatex *tex2 = new TLatex(0.1969,0.817125,"Preliminary");
   tex2->SetNDC();
   tex2->SetTextAlign(13);
   tex2->SetTextFont(52);
   tex2->SetTextSize(0.05681);
   tex2->SetLineWidth(2);
   tex2->Draw();

   TLatex *text1 = new TLatex(0.98,0.95125,"#sqrt{s} = 13 TeV, 25 ns");
   text1->SetNDC();
   text1->SetTextAlign(31);
   text1->SetTextFont(42);
   text1->SetTextSize(0.04875);
   text1->SetLineWidth(2);
   text1->Draw();
   
   std::string picname = "pics/SF_"+tag+".eps";
   c1->Print(picname.c_str());
   c1->Clear();
   
   delete sysTot_SF;
   
   delete c1;
   delete leg;
   delete legl;

   // draw fractions noTag
   TCanvas *c2 = new TCanvas("c2","c2",0,0,600,500);
   c2->SetGrid(1);

   // frb
   double xp_sysTot_FRB[np];
   double yp_sysTot_FRB[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frb->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frb->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRB[k] = addw + h_frb->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRB[k] = h_frb_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRB[nPT+2+k] = h_frb_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRB[nPT+2+k] = xp_sysTot_FRB[nPT+2-k-1];
     }	
   xp_sysTot_FRB[np-1] = xp_sysTot_FRB[0];
   yp_sysTot_FRB[np-1] = yp_sysTot_FRB[0];
   
   TPolyLine *sysTot_FRB = new TPolyLine(np,xp_sysTot_FRB,yp_sysTot_FRB);
   sysTot_FRB->SetFillColor(kRed);
   sysTot_FRB->SetLineColor(kRed);
//   sysTot_FRB->SetFillStyle(0);
   
   // frc
   double xp_sysTot_FRC[np];
   double yp_sysTot_FRC[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frc->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frc->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRC[k] = addw + h_frc->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRC[k] = h_frc_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRC[nPT+2+k] = h_frc_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRC[nPT+2+k] = xp_sysTot_FRC[nPT+2-k-1];
     }	
   xp_sysTot_FRC[np-1] = xp_sysTot_FRC[0];
   yp_sysTot_FRC[np-1] = yp_sysTot_FRC[0];
   
   TPolyLine *sysTot_FRC = new TPolyLine(np,xp_sysTot_FRC,yp_sysTot_FRC);
   sysTot_FRC->SetFillColor(kGreen);
   sysTot_FRC->SetLineColor(kGreen);
//   sysTot_FRC->SetFillStyle(0);

   // frl
   double xp_sysTot_FRL[np];
   double yp_sysTot_FRL[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frl->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frl->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRL[k] = addw + h_frl->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRL[k] = h_frl_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRL[nPT+2+k] = h_frl_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRL[nPT+2+k] = xp_sysTot_FRL[nPT+2-k-1];
     }	
   xp_sysTot_FRL[np-1] = xp_sysTot_FRL[0];
   yp_sysTot_FRL[np-1] = yp_sysTot_FRL[0];
   
   TPolyLine *sysTot_FRL = new TPolyLine(np,xp_sysTot_FRL,yp_sysTot_FRL);
   sysTot_FRL->SetFillColor(kBlue);
   sysTot_FRL->SetLineColor(kBlue);
   
   h_frb->GetYaxis()->SetTitle("Fit fraction");
   h_frb->GetXaxis()->SetTitle("p_{T} [TeV]");
   
   h_frb->SetMarkerSize(1.0);
   h_frc->SetMarkerSize(1.0);
   h_frl->SetMarkerSize(1.0);

   h_frb->SetMarkerStyle(20);
   h_frc->SetMarkerStyle(22);
   h_frl->SetMarkerStyle(24);
   
   h_frb->SetMarkerColor(0);
   h_frc->SetMarkerColor(0);
   h_frl->SetMarkerColor(0);

   h_frb->SetLineColor(0);
   h_frc->SetLineColor(0);
   h_frl->SetLineColor(0);
   
   h_frb->Draw("e1p");
   h_frc->Draw("e1p same");
   h_frl->Draw("e1p same");
	
   h_frb->GetXaxis()->SetMoreLogLabels();
   h_frb->GetXaxis()->SetNoExponent();
   h_frb->GetYaxis()->SetRangeUser(0.00,1.50);

   sysTot_FRB->Draw("fSAME");
   sysTot_FRC->Draw("fSAME");
   sysTot_FRL->Draw("fSAME");
   h_frb->Draw("e1p same");
   h_frc->Draw("e1p same");
   h_frl->Draw("e1p same");
   
   TLegend *leg2;
   leg2 = new TLegend(0.70,0.85,0.95,0.70);
   leg2->SetFillColor(253);
   leg2->SetBorderSize(0);
   
   TLatex *legl2 = new TLatex();
   legl2->SetNDC();
   legl2->SetTextAlign(22);
   legl2->SetTextFont(63);
   legl2->SetTextSizePixels(30);
//   legl2->DrawLatex(0.55,0.82,csv.c_str());
   legl2->DrawLatex(0.55,0.82,"Pre-tag");
   
   TH1D *h_frb_clone = (TH1D*)h_frb->Clone("h_frb_clone");
   TH1D *h_frc_clone = (TH1D*)h_frc->Clone("h_frc_clone");
   TH1D *h_frl_clone = (TH1D*)h_frl->Clone("h_frl_clone");
   
   h_frb_clone->SetMarkerColor(2);
   h_frc_clone->SetMarkerColor(3);
   h_frl_clone->SetMarkerColor(4);
  
   h_frb_clone->SetLineColor(2);
   h_frc_clone->SetLineColor(3);
   h_frl_clone->SetLineColor(4);

   leg2->AddEntry(h_frb_clone,"b-jets","lp");
   leg2->AddEntry(h_frc_clone,"c-jets","lp");
   leg2->AddEntry(h_frl_clone,"udsg-jets","lp");
   
   c2->RedrawAxis("g");
   
   leg2->Draw();
   
   c2->SetLogx(1);

   tex->Draw();
   tex2->Draw();
   text1->Draw();
   
   picname = "pics/Fr_noTag.eps";
   c2->Print(picname.c_str());
   c2->Clear();

   // draw fractions Tag
   TCanvas *c3 = new TCanvas("c3","c3",0,0,600,500);
   c3->SetGrid(1);

   // frb
   double xp_sysTot_FRB_TAG[np];
   double yp_sysTot_FRB_TAG[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frb_tag->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frb_tag->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRB_TAG[k] = addw + h_frb_tag->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRB_TAG[k] = h_frb_tag_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRB_TAG[nPT+2+k] = h_frb_tag_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRB_TAG[nPT+2+k] = xp_sysTot_FRB_TAG[nPT+2-k-1];
     }	
   xp_sysTot_FRB_TAG[np-1] = xp_sysTot_FRB_TAG[0];
   yp_sysTot_FRB_TAG[np-1] = yp_sysTot_FRB_TAG[0];
   
   TPolyLine *sysTot_FRB_TAG = new TPolyLine(np,xp_sysTot_FRB_TAG,yp_sysTot_FRB_TAG);
   sysTot_FRB_TAG->SetFillColor(kRed);
   sysTot_FRB_TAG->SetLineColor(kRed);
   
   // frc
   double xp_sysTot_FRC_TAG[np];
   double yp_sysTot_FRC_TAG[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frc_tag->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frc_tag->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRC_TAG[k] = addw + h_frc_tag->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRC_TAG[k] = h_frc_tag_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRC_TAG[nPT+2+k] = h_frc_tag_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRC_TAG[nPT+2+k] = xp_sysTot_FRC_TAG[nPT+2-k-1];
     }	
   xp_sysTot_FRC_TAG[np-1] = xp_sysTot_FRC_TAG[0];
   yp_sysTot_FRC_TAG[np-1] = yp_sysTot_FRC_TAG[0];
   
   TPolyLine *sysTot_FRC_TAG = new TPolyLine(np,xp_sysTot_FRC_TAG,yp_sysTot_FRC_TAG);
   sysTot_FRC_TAG->SetFillColor(kGreen);
   sysTot_FRC_TAG->SetLineColor(kGreen);

   // frl
   double xp_sysTot_FRL_TAG[np];
   double yp_sysTot_FRL_TAG[np];
   for(int k=0;k<nPT+2;k++)
     {
	float addw = h_frl_tag->GetBinWidth(k)/2.0;
	if( k == 0 ) addw = 0.0;
	if( k == nPT+1 ) addw = h_frl_tag->GetBinWidth(k-1);
	
	int ib = k+1;
	if( k > 0 ) ib--;
	if( k == nPT+1 ) ib--;
	
	xp_sysTot_FRL_TAG[k] = addw + h_frl_tag->GetXaxis()->GetBinLowEdge(ib);
	yp_sysTot_FRL_TAG[k] = h_frl_tag_TOTAL_UP->GetBinContent(ib);
	yp_sysTot_FRL_TAG[nPT+2+k] = h_frl_tag_TOTAL_DOWN->GetBinContent(nPT-(ib-1));
     }      
   for(int k=0;k<nPT+2;k++)
     {
	xp_sysTot_FRL_TAG[nPT+2+k] = xp_sysTot_FRL_TAG[nPT+2-k-1];
     }	
   xp_sysTot_FRL_TAG[np-1] = xp_sysTot_FRL_TAG[0];
   yp_sysTot_FRL_TAG[np-1] = yp_sysTot_FRL_TAG[0];
   
   TPolyLine *sysTot_FRL_TAG = new TPolyLine(np,xp_sysTot_FRL_TAG,yp_sysTot_FRL_TAG);
   sysTot_FRL_TAG->SetFillColor(kBlue);
   sysTot_FRL_TAG->SetLineColor(kBlue);
   
   h_frb_tag->GetYaxis()->SetTitle("Fit fraction");
   h_frb_tag->GetXaxis()->SetTitle("p_{T} [TeV]");
   
   h_frb_tag->SetMarkerSize(1.0);
   h_frc_tag->SetMarkerSize(1.0);
   h_frl_tag->SetMarkerSize(1.0);

   h_frb_tag->SetMarkerStyle(20);
   h_frc_tag->SetMarkerStyle(22);
   h_frl_tag->SetMarkerStyle(24);
   
   h_frb_tag->SetMarkerColor(0);
   h_frc_tag->SetMarkerColor(0);
   h_frl_tag->SetMarkerColor(0);

   h_frb_tag->SetLineColor(0);
   h_frc_tag->SetLineColor(0);
   h_frl_tag->SetLineColor(0);
   
   h_frb_tag->Draw("e1p");
   h_frc_tag->Draw("e1p same");
   h_frl_tag->Draw("e1p same");
	
   h_frb_tag->GetXaxis()->SetMoreLogLabels();
   h_frb_tag->GetXaxis()->SetNoExponent();
   h_frb_tag->GetYaxis()->SetRangeUser(0.00,1.50);

   sysTot_FRB_TAG->Draw("fSAME");
   sysTot_FRC_TAG->Draw("fSAME");
   sysTot_FRL_TAG->Draw("fSAME");
   h_frb_tag->Draw("e1p same");
   h_frc_tag->Draw("e1p same");
   h_frl_tag->Draw("e1p same");
   
   TLegend *leg3;
   leg3 = new TLegend(0.70,0.85,0.95,0.70);
   leg3->SetFillColor(253);
   leg3->SetBorderSize(0);
   
   TLatex *legl3 = new TLatex();
   legl3->SetNDC();
   legl3->SetTextAlign(22);
   legl3->SetTextFont(63);
   legl3->SetTextSizePixels(30);
   legl3->DrawLatex(0.55,0.82,csv.c_str());

   TH1D *h_frb_tag_clone = (TH1D*)h_frb_tag->Clone("h_frb_tag_clone");
   TH1D *h_frc_tag_clone = (TH1D*)h_frc_tag->Clone("h_frc_tag_clone");
   TH1D *h_frl_tag_clone = (TH1D*)h_frl_tag->Clone("h_frl_tag_clone");
   
   h_frb_tag_clone->SetMarkerColor(2);
   h_frc_tag_clone->SetMarkerColor(3);
   h_frl_tag_clone->SetMarkerColor(4);
  
   h_frb_tag_clone->SetLineColor(2);
   h_frc_tag_clone->SetLineColor(3);
   h_frl_tag_clone->SetLineColor(4);
   
   leg3->AddEntry(h_frb_tag_clone,"b-jets","lp");
   leg3->AddEntry(h_frc_tag_clone,"c-jets","lp");
   leg3->AddEntry(h_frl_tag_clone,"udsg-jets","lp");
   
   c3->RedrawAxis("g");
   
   leg3->Draw();
   
   c3->SetLogx(1);

   tex->Draw();
   tex2->Draw();
   text1->Draw();
   
   picname = "pics/Fr_"+tag+".eps";
   c3->Print(picname.c_str());
   c3->Clear();
   
   std::ofstream fsf("results/SFSYS.tex");

   std::string header = "\n \
\\begin{tabular}{|c|c|c|c|c|c|c|c|c|c|c|c|c|c|c|} \n \
void ComparisonPrelim2760GeV(const char *suffix = "eps"){

	TString 	FileDirectory[2];
   TString 	cutNumberAdv[2];
	char* 	Input[256];
	TString 	prefix2;
	Double_t 	nColls[2];

	StyleSettingsThesis();

	SetPlotStyle();

	Bool_t pictDrawingOptions[4] = {kFALSE, kFALSE, kFALSE, kTRUE};

	prefix2 = 			"data";
	pictDrawingOptions[1] = 	kFALSE;
   TString dateForOutput = ReturnDateStringForOutput();
   
	TString collisionSystem = "pp @ 2.76 TeV";
	
	TString FileNameCorrectedCombined[3];
	FileNameCorrectedCombined[0] = "/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/CombinedResultsPaperX.root";
	FileNameCorrectedCombined[1] = "/home/fredi/Photon/Results/PbPbAnalysisFinerCentOnlyMinBias/FinalResults/CombinedResultsPaperX_IncludingPP2760YShifted.root";
   FileNameCorrectedCombined[2] = "/home/fredi/Photon/Results/PbPbNewMCTest/CombinedResultsPaperX_19_Sep_2013.root";
	TFile *Cutcorrfile[3];
	TFile *Cutuncorrfile[3];
   TString FileNameCorrectedPCM[3];
   FileNameCorrectedPCM[0] = "/home/fredi/Photon/Results/ppAnalysis2760GeVFeb2013/0000011002093663003800000_01631031009/data_GammaConversionResultsFullCorrectionNoBinShifting.root";
   FileNameCorrectedPCM[1] = "/home/fredi/Photon/Results/PbPbAnalysisFinerCentOnlyMinBias/FinalResults/data_GammaConversionResultsFullCorrection_110521_PreliminaryQM2011.root";
   FileNameCorrectedPCM[2] = "/home/fredi/Photon/Results/PbPbNewMCTest/000001100209366300380000000_01631031009000/data_PCMResultsFullCorrection_PP_NoBinShifting.root";

	TGraphAsymmErrors *finalSpectraComb[3];
	TGraphAsymmErrors *finalSpectraStatErr[3];
	TGraphAsymmErrors *finalSpectraSysErr[3];
	TGraphAsymmErrors *finalSpectraPCMStatErr[3];
	TGraphAsymmErrors *finalSpectraPCMSysErr[3];	
	TGraphAsymmErrors *finalSpectraPHOSStatErr[3];
	TGraphAsymmErrors *finalSpectraPHOSSysErr[3];
	
	TH1D *histoEffi[3];
	TH1D *histoRawYield[3];
	TDirectory *directoryPi02760GeV[3];
	TH1D* histoInvCrossSectionPi02760GeV[3];
	TGraphAsymmErrors* graphInvCrossSectionSysAPi02760GeV[3];
	TFile* CutcorrfilePCM[3];
	
	cout<< FileNameCorrectedCombined[0] << endl;
	Cutcorrfile[0] = new TFile( FileNameCorrectedCombined[0].Data());
	cout << "here" << endl;
	finalSpectraComb[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0Comb2760GeV");
	cout << "here" << endl;
	finalSpectraStatErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0Comb2760GeVStatErr");
	cout << "here" << endl;
	finalSpectraSysErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0Comb2760GeVSysErr");
	finalSpectraPCMStatErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0PCM2760GeVStatErr");
	cout << "here" << endl;
	finalSpectraPCMSysErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0PCM2760GeVSysErr");
   finalSpectraPCMSysErr[0]->Print();
	finalSpectraPHOSStatErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0PHOS2760GeVStatErr");
	cout << "here" << endl;
	finalSpectraPHOSSysErr[0] = (TGraphAsymmErrors*)Cutcorrfile[0]->Get("graphInvCrossSectionPi0PHOS2760GeVSysErr");
	
   cout << FileNameCorrectedPCM[0] << endl;
   CutcorrfilePCM[0] = new TFile( FileNameCorrectedPCM[0].Data());
   directoryPi02760GeV[0] =         (TDirectory*)CutcorrfilePCM[0]->Get("Pi02.76TeV");    
   histoInvCrossSectionPi02760GeV[0]=        (TH1D*)directoryPi02760GeV[0]->Get("InvCrossSectionPi0");
   graphInvCrossSectionSysAPi02760GeV[0]=       (TGraphAsymmErrors*)directoryPi02760GeV[0]->Get("InvCrossSectionPi0SysA");
   
	cout << "here" << endl;
	cout<<"=========================="<<endl;

	cout<< FileNameCorrectedCombined[1] << endl;
// 	Cutcorrfile[1] = new TFile("/home/fredi/Photon/Results/ppAnalysis2760GeVDec/FinalResults/CombinedResultsPaperX_IncludingPP2760YShifted.root");
// 	finalSpectraComb[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0Comb2760GeV_PrelimQM2011");
// 	finalSpectraStatErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0Comb2760GeVStatErr_PrelimQM2011");
// 	cout << "here" << endl;
// 	finalSpectraSysErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0Comb2760GeVSysErr_PrelimQM2011");
// 	cout << "here" << endl;
	Cutcorrfile[1] = new TFile(FileNameCorrectedCombined[1].Data());
	finalSpectraComb[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0Comb2760GeV_PrelimQM2011");
	finalSpectraPCMStatErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0PCMStat2760GeV_PrelimQM2011_YShifted");
	cout << "here" << endl;
	finalSpectraPCMSysErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0PCMSys2760GeV_PrelimQM2011_YShifted");
	finalSpectraPHOSStatErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0PHOSSys2760GeV_PrelimQM2011_YShifted");
	cout << "here" << endl;
	finalSpectraPHOSSysErr[1] = (TGraphAsymmErrors*)Cutcorrfile[1]->Get("graphInvCrossSectionPi0PHOSSys2760GeV_PrelimQM2011_YShifted");
	
   cout << FileNameCorrectedPCM[1] << endl;
   CutcorrfilePCM[1] = new TFile( FileNameCorrectedPCM[1].Data());
   directoryPi02760GeV[1] =         (TDirectory*)CutcorrfilePCM[1]->Get("Pi02.76TeV");    
   histoInvCrossSectionPi02760GeV[1]=        (TH1D*)directoryPi02760GeV[1]->Get("InvCrossSectionPi0");
   graphInvCrossSectionSysAPi02760GeV[1]=       (TGraphAsymmErrors*)directoryPi02760GeV[1]->Get("InvCrossSectionPi0SysA");

	cout<<"=========================="<<endl;

   cout<< FileNameCorrectedCombined[2] << endl;
   Cutcorrfile[2] = new TFile( FileNameCorrectedCombined[2].Data());
   cout << "here" << endl;
   finalSpectraComb[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0Comb2760GeV");
   cout << "here" << endl;
   finalSpectraStatErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0Comb2760GeVStatErr");
   cout << "here" << endl;
   finalSpectraSysErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0Comb2760GeVSysErr");
   finalSpectraPCMStatErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0PCM2760GeVStatErr");
   cout << "here" << endl;
   finalSpectraPCMSysErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0PCM2760GeVSysErr");
   finalSpectraPCMSysErr[2]->Print();
   finalSpectraPHOSStatErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0PHOS2760GeVStatErr");
   cout << "here" << endl;
   finalSpectraPHOSSysErr[2] = (TGraphAsymmErrors*)Cutcorrfile[2]->Get("graphInvCrossSectionPi0PHOS2760GeVSysErr");

   cout << FileNameCorrectedPCM[2] << endl;
   CutcorrfilePCM[2] = new TFile( FileNameCorrectedPCM[2].Data());
   directoryPi02760GeV[2] =         (TDirectory*)CutcorrfilePCM[2]->Get("Pi02.76TeV");    
   histoInvCrossSectionPi02760GeV[2]=        (TH1D*)directoryPi02760GeV[2]->Get("InvCrossSectionPi0");
   graphInvCrossSectionSysAPi02760GeV[2]=       (TGraphAsymmErrors*)directoryPi02760GeV[2]->Get("InvCrossSectionPi0SysA");

   cout << "here" << endl;
   cout<<"=========================="<<endl;

   
	Double_t paramGraph[3] = {1.0e12,7.,0.13};
	TF1*	fitInvCrossSectionPi02760GeV = FitObject("l","fitInvCrossSectionPi02760GeV","Pi0",finalSpectraComb[1],0.4,12.,paramGraph);
	cout << WriteParameterToFile(fitInvCrossSectionPi02760GeV)<< endl;

	TGraphAsymmErrors *graphRatioFinalToPrelimStat = CalculateGraphErrRatioToFit (finalSpectraStatErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalToPrelimSys = CalculateGraphErrRatioToFit (finalSpectraSysErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPCMToPrelimStat = CalculateGraphErrRatioToFit (finalSpectraPCMStatErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPCMToPrelimSys = CalculateGraphErrRatioToFit (finalSpectraPCMSysErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPHOSToPrelimStat = CalculateGraphErrRatioToFit (finalSpectraPHOSStatErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPHOSToPrelimSys = CalculateGraphErrRatioToFit (finalSpectraPHOSSysErr[2], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPCMPrelimToPrelimStat = CalculateGraphErrRatioToFit (finalSpectraPCMStatErr[1], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPCMPrelimToPrelimSys = CalculateGraphErrRatioToFit (finalSpectraPCMSysErr[1], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPHOSPrelimToPrelimStat = CalculateGraphErrRatioToFit (finalSpectraPHOSStatErr[1], fitInvCrossSectionPi02760GeV); 
	TGraphAsymmErrors *graphRatioFinalPHOSPrelimToPrelimSys = CalculateGraphErrRatioToFit (finalSpectraPHOSSysErr[1], fitInvCrossSectionPi02760GeV); 
	
   TGraphAsymmErrors* graphRatioFinalUpdatedPCMToFinalSys = CalculateGraphAsymErrRatioToGraphErr (finalSpectraStatErr[2],finalSpectraStatErr[0],kTRUE);
   TH1D* histoRatioFinalUpdatedPCMToFinalStat = (TH1D*)histoInvCrossSectionPi02760GeV[2]->Clone("histoRatioFinalUpdatedPCMToFinalStat");
   histoRatioFinalUpdatedPCMToFinalStat->Divide(histoRatioFinalUpdatedPCMToFinalStat,histoInvCrossSectionPi02760GeV[0],1.,1.,"B");
   
	//**************************************************************************************
	//********************* Plotting RAW-Yield *********************************************
	//**************************************************************************************

	TCanvas* canvasFraction = new TCanvas("canvasFraction","",1550,1200);  // gives the page size
	canvasFraction->SetTickx();
	canvasFraction->SetTicky();
	canvasFraction->SetGridx(0);
	canvasFraction->SetGridy(0);
	canvasFraction->SetLogy(0);
	canvasFraction->SetLogx(1);
	canvasFraction->SetLeftMargin(0.09);
	canvasFraction->SetRightMargin(0.02);
	canvasFraction->SetTopMargin(0.02);
	canvasFraction->SetFillColor(0);

	TH2F * ratio2DInvXSectionOnlyPi0;
	ratio2DInvXSectionOnlyPi0 = new TH2F("ratio2DInvXSectionOnlyPi0","ratio2DInvXSectionOnlyPi0",1000,0.33,15.,1000,0.5,2.1);
	SetStyleHistoTH2ForGraphs(ratio2DInvXSectionOnlyPi0, "p_{T} (GeV/c)","Final/Fit to Prelim", 0.03,0.042, 0.03,0.042, 0.9,0.82, 512, 505);
// 	ratio2DInvXSectionOnlyPi0->GetXaxis()->SetLabelOffset(-0.015);
// 	ratio2DInvXSectionOnlyPi0->GetYaxis()->SetLabelOffset(0.01);
	ratio2DInvXSectionOnlyPi0->DrawCopy(); 
	
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalToPrelimSys, 20,1.5, kBlue+2 , kBlue+2, 1., kTRUE);
	graphRatioFinalToPrelimSys->Draw("E2same");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPCMToPrelimSys, 20,1.5, kBlack , kBlack, 1., kTRUE);
	graphRatioFinalPCMToPrelimSys->Draw("E2same");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPHOSToPrelimSys, 20,1.5, kRed+2 , kRed+2, 1., kTRUE);
	graphRatioFinalPHOSToPrelimSys->Draw("E2same");
	
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalToPrelimStat, 20,2., kBlue+2 , kBlue+2);
 	graphRatioFinalToPrelimStat->Draw("p,same,e1");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPCMToPrelimStat, 20,2., kBlack , kBlack);
 	graphRatioFinalPCMToPrelimStat->Draw("p,same,e1");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPHOSToPrelimStat, 20,2., kRed+2 , kRed+2);
 	graphRatioFinalPHOSToPrelimStat->Draw("p,same,e1");

	TLegend* legendPrelim = new TLegend(0.18,0.83,0.4,0.95);
		legendPrelim->SetFillColor(0);
		legendPrelim->SetLineColor(0);
// 		legendPrelim->SetNColumns(2);
		legendPrelim->SetTextSize(0.045);
		legendPrelim->AddEntry(graphRatioFinalToPrelimSys,"#pi^{0} combined/ fit to combined prelim #pi^{0}","p");
		legendPrelim->AddEntry(graphRatioFinalPCMToPrelimSys,"#pi^{0} PCM/ fit to combined prelim #pi^{0}","p");
		legendPrelim->AddEntry(graphRatioFinalPHOSToPrelimSys,"#pi^{0} PHOS/ fit to combined prelim #pi^{0}","p");
		legendPrelim->Draw();

		legendPrelim->Draw();
	
	canvasFraction->Update();
	DrawGammaLines(0., 15.,1., 1.,0.1);

	canvasFraction->SaveAs(Form("Pi0_Ratio2760GeVFinalDivPrelim_%s.%s",dateForOutput.Data(),suffix));


	canvasFraction->cd();
	ratio2DInvXSectionOnlyPi0->DrawCopy(); 
	
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPCMPrelimToPrelimSys, 20,1.5, kBlack , kBlack, 1., kTRUE);
	graphRatioFinalPCMPrelimToPrelimSys->Draw("E2same");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPHOSPrelimToPrelimSys, 20,1.5, kRed+2 , kRed+2, 1., kTRUE);
	graphRatioFinalPHOSPrelimToPrelimSys->Draw("E2same");
	
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPCMPrelimToPrelimStat, 20,2., kBlack , kBlack);
 	graphRatioFinalPCMPrelimToPrelimStat->Draw("p,same,e1");
	DrawGammaSetMarkerTGraphAsym(graphRatioFinalPHOSPrelimToPrelimStat, 20,2., kRed+2 , kRed+2);
 	graphRatioFinalPHOSPrelimToPrelimStat->Draw("p,same,e1");

	TLegend* legendPi0PrelimQM2011 = new TLegend(0.18,0.83,0.4,0.95);
		legendPi0PrelimQM2011->SetFillColor(0);
		legendPi0PrelimQM2011->SetLineColor(0);
// 		legendPi0PrelimQM2011->SetNColumns(2);
		legendPi0PrelimQM2011->SetTextSize(0.045);
		legendPi0PrelimQM2011->AddEntry(graphRatioFinalPCMToPrelimSys,"#pi^{0} PCM prelim/ fit to combined prelim #pi^{0}","p");
		legendPi0PrelimQM2011->AddEntry(graphRatioFinalPHOSToPrelimSys,"#pi^{0} PHOS prelim / fit to combined prelim #pi^{0}","p");
		legendPi0PrelimQM2011->Draw();

		legendPi0PrelimQM2011->Draw();
	
	canvasFraction->Update();
	DrawGammaLines(0., 15.,1., 1.,0.1);

	canvasFraction->SaveAs(Form("Pi0_Ratio2760GeVPrelimDivPrelim.%s",suffix));
   
   
   canvasFraction->cd();
   TH2F * ratio2DInvXSectionOnlyPi02;
   ratio2DInvXSectionOnlyPi02 = new TH2F("ratio2DInvXSectionOnlyPi02","ratio2DInvXSectionOnlyPi02",1000,0.33,15.,1000,0.5,2.1);
   SetStyleHistoTH2ForGraphs(ratio2DInvXSectionOnlyPi02, "p_{T} (GeV/c)","Final/Prelim", 0.03,0.042, 0.03,0.042, 0.9,0.82, 512, 505);
//    ratio2DInvXSectionOnlyPi0->GetXaxis()->SetLabelOffset(-0.015);
//    ratio2DInvXSectionOnlyPi0->GetYaxis()->SetLabelOffset(0.01);
   ratio2DInvXSectionOnlyPi02->DrawCopy(); 
   
    TH1D* histoRatioPCM_FinalOverPrelimStat = (TH1D*)histoInvCrossSectionPi02760GeV[1]->Clone("histoRatioPCM_FinalOverPrelimStat");
//    histoRatioPCM_FinalOverPrelimStat->Divide(histoRatioPCM_FinalOverPrelimStat,histoInvCrossSectionPi02760GeV[1],1.,1.,"B");
//    
   for (Int_t i = 2; i < histoInvCrossSectionPi02760GeV[1]->GetNbinsX()+1; i++){
     cout <<  i << "\t" << histoInvCrossSectionPi02760GeV[1]->GetBinCenter(i)-histoInvCrossSectionPi02760GeV[1]->GetBinWidth(i)/2 << endl;
     histoRatioPCM_FinalOverPrelimStat->SetBinContent(i,histoInvCrossSectionPi02760GeV[2]->GetBinContent(i)/histoInvCrossSectionPi02760GeV[1]->GetBinContent(i));
     Double_t error =  TMath::Sqrt( pow(histoInvCrossSectionPi02760GeV[2]->GetBinError(i)/histoInvCrossSectionPi02760GeV[1]->GetBinContent(i),2)  + pow( histoInvCrossSectionPi02760GeV[1]->GetBinError(i)*histoInvCrossSectionPi02760GeV[2]->GetBinContent(i)/pow(histoInvCrossSectionPi02760GeV[1]->GetBinContent(i),2),2) );
     histoRatioPCM_FinalOverPrelimStat->SetBinError(i,error);
     cout <<  i << "\t" << histoRatioPCM_FinalOverPrelimStat->GetBinContent(i) << "\t +- " << histoRatioPCM_FinalOverPrelimStat->GetBinError(i) << endl;
   }
   for (Int_t i = 1; i < histoInvCrossSectionPi02760GeV[2]->GetNbinsX()+1; i++){
     cout <<  i << "\t" << histoInvCrossSectionPi02760GeV[2]->GetBinCenter(i)-histoInvCrossSectionPi02760GeV[2]->GetBinWidth(i)/2 << endl;
   }
   
   
   TGraphAsymmErrors *graphRatioPCM_FinalOverPrelimSys = CalculateGraphAsymErrRatioToGraphErr (graphInvCrossSectionSysAPi02760GeV[2], graphInvCrossSectionSysAPi02760GeV[1]);
   
   DrawGammaSetMarkerTGraphAsym(graphRatioPCM_FinalOverPrelimSys, 20,1.5, kBlack , kBlack, 1., kTRUE);
   graphRatioPCM_FinalOverPrelimSys->Draw("E2same");
  
   DrawGammaSetMarker(histoRatioPCM_FinalOverPrelimStat, 20,2., kBlack , kBlack);
   histoRatioPCM_FinalOverPrelimStat->Draw("p,same,e1");
   
   TLatex *labelPi0PCM = new TLatex(0.15,0.93,"PCM current/ PCM preliminary, removed mat. error from systematics");
   SetStyleTLatex( labelPi0PCM, 0.036,4);
   labelPi0PCM->Draw();
   TLatex *labelPi0PCM2 = new TLatex(0.15,0.89,"Material error old: +8.3%, -4.8%");
   SetStyleTLatex( labelPi0PCM2, 0.036,4);
   labelPi0PCM2->Draw();
   TLatex *labelPi0PCM3 = new TLatex(0.15,0.85,"Material error new: #pm 9.0%");
   SetStyleTLatex( labelPi0PCM3, 0.036,4);
   labelPi0PCM3->Draw();

   canvasFraction->Update();
   DrawGammaLines(0., 15.,1., 1.,0.1);

   canvasFraction->SaveAs(Form("Pi0_Ratio2760GeVFinalDivPrelimPCMPoints_%s.%s",dateForOutput.Data(),suffix));
   
   canvasFraction->cd();
   ratio2DInvXSectionOnlyPi0->GetYaxis()->SetTitle("Final/FinalUpdatedStat");
   ratio2DInvXSectionOnlyPi0->GetYaxis()->SetRangeUser(0.9,1.1);
   ratio2DInvXSectionOnlyPi0->DrawCopy(); 
   
   /*DrawGammaSetMarkerTGraphAsym(graphRatioFinalUpdatedPCMToFinalStat, 20,1.5, kBlack , kBlack, 1., kTRUE);
   graphRatioFinalUpdatedPCMToFinalStat->Draw("Epsame");
   */
   DrawGammaSetMarker(histoRatioFinalUpdatedPCMToFinalStat, 20,1., kBlue , kBlue);
   histoRatioFinalUpdatedPCMToFinalStat->Draw("E1psame");
   canvasFraction->Update();
   DrawGammaLines(0., 15.,1., 1.,0.1);

   canvasFraction->SaveAs(Form("Pi0_Ratio2760GeVFinalDivFinalUpdatedStat_%s.%s",dateForOutput.Data(),suffix));   
	delete canvasFraction;
   
   

}