void PlotAll_DATA_PREAPP()
{

    gROOT->LoadMacro("invar_yield_ana_v9.C");

    char dir[100];
    char dir_corr[100];

    bool GEN = false;
    bool CORRECT = false;
    bool REBIN = true;
    bool MC = false;
    bool multcrct =false;
    bool seccrct = false;
    bool cross = false;
    bool loose = false;
    bool jet_based_correction = true;
    bool entire_range = true;
    bool zerobin = false;
    bool onetwothreebin = false;
    bool evteffcorr = false;
    bool full_eta =true;
    bool oneoverpt=true;
    bool minpt=true;

    double eta_max;
    float pt_max;
    float ymin, ymax;
    float ymin_r, ymax_r;

    if(entire_range) {
        if(MC) pt_max = 55,  ymin = 3e-13, ymax = 9e1, ymin_r = 0.30, ymax_r = 1.65;
        else pt_max = 100, ymin = 3e-14, ymax = 9e1, ymin_r = 0.6, ymax_r = 1.65;
    } else {
        if(MC) pt_max = 10, ymin = 5e-7, ymax = 2e1, ymin_r = 0.7, ymax_r = 1.4;
        //else pt_max = 10, ymin = 5e-7, ymax = 5e1, ymin_r = 0.97, ymax_r = 1.03;
        else pt_max = 10, ymin = 5e-7, ymax = 5e1, ymin_r = 0.5, ymax_r = 1.5;
    }

    if(full_eta) eta_max = 2.4;
    else eta_max = 1.0;


    char file1[100], file2[100], file3[100], file4[100], file5[100], file6[100], file7[100];

    sprintf(file1,"../root_files/MB-C10-A20RR-TRKANASKIM-MERGED.root");
    //sprintf(file1,"../root_files/MB-C10-MERGED.root");
    //sprintf(file1,"../root_files/MB-C10-A20PR_proc0531.root");
    //sprintf(file2,"../root_files/TrkHistMC_june04_10Mv2.root");
    //sprintf(file3,"../root_files/TrkHistMC_june04_10Mv2.root");
    sprintf(file2,"../root_files/TrkHistMC_june04_QCD_10Mv6.root");
    sprintf(file3,"../root_files/TrkHistMC_june04_QCD_10Mv6.root");
    sprintf(file4,"../root_files/TrkHistMCv10_QCD_Pt15v3.root");
    sprintf(file5,"../root_files/TrkHistMCv11_qcdPt30.root");
    sprintf(file6,"../root_files/TrkHistMCv11_qcdPt80.root");
    sprintf(file7,"../root_files/TrkHistMCv11_qcdPt170v2.root");

    MC = false, GEN = false, CORRECT = true, multcrct = true, seccrct = true, evteffcorr = true, zerobin = true, onetwothreebin = true;
    sprintf(dir,"trackAna_STD");
    sprintf(dir_corr,"trkEffAnalyzer");

    invar_yield_ana_v9_data spec_rec_tight =
        invar_yield_ana_v9_graph(file1,file2,file3,file4,file5,file6,file7,
                                 dir,dir_corr,GEN,CORRECT,multcrct,seccrct,MC,jet_based_correction,
                                 evteffcorr,zerobin,onetwothreebin,cross,oneoverpt,0,eta_max);


    //sprintf(file1,"../root_files/TrkHistMC_june04_10Mv2.root");
    //sprintf(file2,"../root_files/TrkHistMC_june04_10Mv2.root");
    //sprintf(file3,"../root_files/TrkHistMC_june04_10Mv2.root");
    sprintf(file1,"../root_files/TrkHistMC_june04_QCD_10Mv6.root");
    sprintf(file2,"../root_files/TrkHistMC_june04_QCD_10Mv6.root");
    sprintf(file3,"../root_files/TrkHistMC_june04_QCD_10Mv6.root");
    sprintf(file4,"../root_files/TrkHistMCv10_QCD_Pt15v3.root");
    sprintf(file5,"../root_files/TrkHistMCv11_qcdPt30.root");
    sprintf(file6,"../root_files/TrkHistMCv11_qcdPt80.root");
    sprintf(file7,"../root_files/TrkHistMCv11_qcdPt170v2.root");

    // GEN MC
    MC = true, GEN = true, CORRECT = false, multcrct = false, seccrct = false, evteffcorr = false, zerobin = false, onetwothreebin = false;
    sprintf(dir,"preTrackAna");
    sprintf(dir_corr,"trkEffAnalyzer");

    invar_yield_ana_v9_data spec_rec_tight_MC =
        invar_yield_ana_v9_graph(file1,file2,file3,file4,file5,file6,file7,
                                 dir,dir_corr,GEN,CORRECT,multcrct,seccrct,MC,jet_based_correction,
                                 evteffcorr,zerobin,onetwothreebin,cross,oneoverpt,0,eta_max);




    //--------------------------- CMS measurement ---------------------------
    TGraphErrors* cms_7000GeV = (TGraphErrors*) CMS_7TEV(1);

    TF1 *f2 = new TF1("f2","[0]*(1+(sqrt(0.1396**2+x**2)-0.1396)/([1]*[2]))**(-[2])",0,6);
    f2->SetParameters(2*TMath::Pi(),0.13,7.7);
    cms_7000GeV->Fit(f2,"RN");
    f2->SetLineColor(kRed);


    //--------------------------------------------------- PYTHIA truth GEN------------------------
    gROOT->LoadMacro("invar_yield_ana_GEN_v9.C");

    char file1_GEN[100], file2_GEN[100], file3_GEN[100], file4_GEN[100], file5_GEN[100], file6_GEN[100], file7_GEN[100];
    char file8_GEN[100], file9_GEN[100], file10_GEN[100];

    sprintf(file1_GEN,"../root_files/TrkHistMC_june04_qcdPt0To15v3cFix.root");
    sprintf(file2_GEN,"../root_files/TrkHistMC_june04_qcdPt15to20v2.root");
    sprintf(file3_GEN,"../root_files/TrkHistMC_june04_qcdPt20to30v2.root");
    sprintf(file4_GEN,"../root_files/TrkHistMC_june04_qcdPt30to50v2.root");
    sprintf(file5_GEN,"../root_files/TrkHistMC_june04_qcdPt50to80v2.root");
    sprintf(file6_GEN,"../root_files/TrkHistMC_june04_qcdPt80to120v2.root");
    sprintf(file7_GEN,"../root_files/TrkHistMC_june04_qcdPt120to170v2.root");
    sprintf(file8_GEN,"../root_files/TrkHistMC_june04_qcdPt170to230v2.root");
    sprintf(file9_GEN,"../root_files/TrkHistMC_june04_qcdPt230to300v2.root");
    sprintf(file10_GEN,"../root_files/TrkHistMC_june04_qcdPt300to380v2.root");

    invar_yield_ana_GEN_v9_data  gen_nsd_spect  =
        invar_yield_ana_GEN_v9_graph(file1_GEN,file2_GEN,file3_GEN,file4_GEN,
                                     file5_GEN,file6_GEN,file7_GEN,file8_GEN,
                                     file9_GEN,file10_GEN,true,117.,0,eta_max);

    //--------------------------------------------------- PYTHIA truth GEN------------------------

    double intLum;
    if(REBIN) {
        TH1D *dndpt_rec_tight = spec_rec_tight.hRInvX;
        intLum = spec_rec_tight.integratedLum;
        dndpt_rec_tight->Scale(1./intLum);
        TH1D *dndpt_rec_tight_MC = spec_rec_tight_MC.hRInvX;
        intLum = spec_rec_tight_MC.integratedLum;
        dndpt_rec_tight_MC->Scale(1./intLum);
        TH1D *dndpt_gen_nsd = gen_nsd_spect.hRInvX;
        TGraphErrors *dndpt_gen_nsd_tg = gen_nsd_spect.RInvX;
    } else {
    }


    // Basic canvas and dummy histogram
    TCanvas *call = new TCanvas("call","call",510,670);
    call->cd();
    //if(entire_range) call->SetLogx();

    // ------------------------------- Pad settings
    pp1 = new TPad("p1","p1",0,0.34,1,1,0,0,0);
    pp1->SetBottomMargin(0.0);
    pp1->SetTopMargin(0.05*(1/0.72));

    pp1->Draw();
    pp1->cd();
    pp1->SetNumber(1);

    call->cd();

    pp1_1 = new TPad("p1_1","p1_1",0,0.0,1,0.34,0,0,0);
    pp1_1->SetTopMargin(0);
    pp1_1->SetBottomMargin(0.14*(1/0.34));
    pp1_1->Draw();
    pp1_1->cd();
    pp1_1->SetNumber(2);


    // ----- pad 1
    pp1->cd();
    pp1->SetLogy();
    if(entire_range) pp1->SetLogx();

    Char_t xTitle[100],yTitle[100];


    if(!cross) sprintf(yTitle,"Ed^{3}N/d^{3}p [GeV^{-2}c^{3}]");
    else sprintf(yTitle,"Ed^{3}#sigma/d^{3}p [mb GeV^{-2}c^{3}]");
    sprintf(xTitle,"p_{T} [GeV/c]");
    TH1D *dum = GetDummyHist(pt_max,ymin,ymax,xTitle,yTitle);

    dum->Draw();
    dum->GetXaxis()->SetNdivisions(908);
    dum->GetYaxis()->SetNdivisions(407);

    TPad *call_pd = (TPad*)gPad;
    call_pd->cd();
    gPad->SetLogy();

    if(minpt) {
        dndpt_rec_tight->GetXaxis()->SetRange(3,dndpt_rec_tight->GetXaxis()->GetLast());
        dndpt_rec_tight_MC->GetXaxis()->SetRange(3,dndpt_rec_tight_MC->GetXaxis()->GetLast());
        dndpt_gen_nsd->GetXaxis()->SetRange(3,dndpt_gen_nsd->GetXaxis()->GetLast());
    }


    //plotting
    th1Style1(cms_7000GeV,13,30,1.0,13,1,1,1);
    //th1Style1(dndpt_gen_nsd,96,20,1,96,2,1,2);
    th1Style1(dndpt_gen_nsd_tg,96,20,1,96,2,1,2);
    //th1Style1(dndpt_rec_tight_MC,2,20,1.0,2,1.5,1,3);
    th1Style1(dndpt_rec_tight,1,20,1.0,1,1.5,1,1);


    if(entire_range) TLegend *leg2 = new TLegend(0.21,0.09,0.58,0.47);
    else TLegend *leg2 = new TLegend(0.37,0.47,0.74,0.85);
    leg2->SetMargin(0.3);
    leg2->SetBorderSize(0);
    leg2->SetFillColor(kWhite);
    leg2->SetFillStyle(0);
    leg2->SetTextSize(0.039);
    leg2->SetMargin(0.3);


    if(full_eta) leg2->SetHeader("pp #rightarrow h+X, 7 TeV DATA, |#eta|<2.4");
    else leg2->SetHeader("pp #rightarrow h+X, 7 TeV DATA, |#eta|<1.0");
    leg2->AddEntry(dndpt_rec_tight,"RECO (TRK+EVT corrected)","pl");
    leg2->AddEntry(cms_7000GeV,"CMS 7 TeV |#eta|<2.4","pl");
    leg2->AddEntry(dndpt_gen_nsd_tg,"PYTHIA D6T","l");
    leg2->Draw();



    TLatex * tex;
    tex = new TLatex(0.69,0.88,"CMS Preliminary");
    tex->SetTextSize(0.04);
    tex->SetLineWidth(2);
    tex->SetNDC();
    tex->Draw();



    // ------ pad2
    pp1_1->cd();
    if(entire_range) pp1_1->SetLogx();

    sprintf(yTitle,"Ratio");

    //TH1D *dum2 = GetDummyHist(-0.1,2.3,xTitle,yTitle);
    TH1D *dum2 = GetDummyHist(pt_max,ymin_r,ymax_r,xTitle,yTitle);

    dum2->GetYaxis()->SetLabelSize(0.07);
    dum2->GetYaxis()->SetTitleSize(0.10);
    dum2->GetYaxis()->SetTitleOffset(0.75);

    dum2->GetXaxis()->SetLabelSize(0.09);
    dum2->GetXaxis()->SetLabelOffset(0.05);
    dum2->GetXaxis()->SetTitleSize(0.11);
    dum2->GetXaxis()->SetTitleOffset(1.47);

    dum2->GetYaxis()->SetNdivisions(405);
    dum2->GetYaxis()-> SetDecimals(true);
    dum2->Draw();

    TLine *line = new TLine(0,1,pt_max,1);
    line->SetLineStyle(2);
    line->SetLineWidth(2);
    line->Draw();



    TH1D *dndpt_rec_tight_dum = (TH1D*) dndpt_rec_tight->Clone("dndpt_rec_tight_dum");
    TH1D *dndpt_rec_tight_dum2 = (TH1D*) dndpt_rec_tight->Clone("dndpt_rec_tight_dum2");
    TH1D *dndpt_rec_tight_MC_dum = (TH1D*) dndpt_rec_tight_MC->Clone("dndpt_rec_tight_MC_dum");
    TH1D *dndpt_gen_nsd_dum = (TH1D*) dndpt_gen_nsd->Clone("dndpt_gen_nsd_dum");
    TH1D *dndpt1_dum_div_cms7000 = (TH1D*) ratio_hist_to_func(dndpt_rec_tight_dum,
                                   f2->GetParameter(0),
                                   f2->GetParameter(1),
                                   f2->GetParameter(2));
    dndpt_gen_nsd_dum->Sumw2();
    dndpt_rec_tight_dum->Sumw2();
    dndpt_rec_tight_MC_dum->Sumw2();
    dndpt_rec_tight_dum->Divide(dndpt_gen_nsd_dum);
    //dndpt_rec_tight_dum2->Divide(dndpt_rec_tight_MC_dum);


    if(minpt) {
        dndpt_rec_tight_dum->GetXaxis()->SetRange(3,dndpt_rec_tight_dum->GetXaxis()->GetLast());
        //dndpt_rec_tight_dum2->GetXaxis()->SetRange(3,dndpt_rec_tight_dum2->GetXaxis()->GetLast());
    }

    th1Style1(dndpt_rec_tight_dum,96,20,1,96,2,1,3);
    //th1Style1(dndpt_rec_tight_dum2,2,24,1.0,2,1.5,1,1);
    th1Style1(dndpt1_dum_div_cms7000,13,30,1.0,13,1.5,1,1);

    // Print the values!!
    //PrintXsection(dndpt_rec_tight,117.);
    PrintXsection(dndpt_rec_tight,1.);

    if(entire_range) {
        if(full_eta) printCanvases(call,"spectra_DATA_PREAPP_fullEta",2,1);
        else printCanvases(call,"spectra_DATA_PREAPP",2,1);
    } else {
        if(full_eta) printCanvases(call,"spectra_DATA_PREAPP_narrow_fullEta",1,1);
        else printCanvases(call,"spectra_DATA_PREAPP_narrow",1,1);
    }

}
void PlotPASFigFourAllSysErrorV2(bool save=false){

   bool lowpT = false;
   bool atlas = false;

   float pt_min, pt_max;
   float ymin, ymax;
   float ymin_r, ymax_r;

   //57.38
   //double sigma_nsd = 57.38;
   //double sigma_nsd = 71.3;
   //double sigma_nsd = 57.38; // M6RR
   double sigma_nsd =  56.47; // M6RR + PR9
   

   if(lowpT){
      pt_min = 0.5, pt_max = 7;
      ymin = 6E-6, ymax = 5E+1;
      ymin_r = 0.7, ymax_r = 1.3;
   }else{
     //pt_min = 0.4, pt_max = 365;
     pt_min = 0.4, pt_max = 220; 
      ymin = 2E-18, ymax = 5E+1;
      //ymin_r = 0.24, ymax_r = 1.56;
      ymin_r = 0.44, ymax_r = 1.56;
   }
   
   setSysErrorFunction();
   
   // file loading -----------------------------------------
   file1 = (TFile*) loadFile(file1,
			     "./../rootOutput_postApp_3rd/feb072011/MergedAll_MBproc0710_Jet15Uproc0111_Jet50Uproc0111_eta2.4_feb07011_V2.root");
			     //"./../rootOutput_postApp_3rd/feb072011/MergedAll_MBproc0710_Jet15Uproc0111_Jet50Uproc0111_eta1.0_feb07011_V2.root"); 
   //"./../rootOutput_postApp_3rd/feb072011/MergedAll_MBproc0710_Jet15Uproc0111_Jet50Uproc0111_eta2.4_feb07011_V2.root");
			     //"./../rootOutput_postApp_3rd/feb072011/MergedAll_MBproc0710_Jet15Uproc0111_Jet50Uproc0111_eta1.0_feb07011.root");
   //"./../rootOutput_postApp_2nd/jan122011/MergedAll_MBproc0710_Jet15Uproc0111_Jet50Uproc0111_eta2.4_jan122011.root");
			     //"./../rootOutput_postApp_2nd/dec222010/MergedAll_MBproc0710_Jet15Uproc0710_Jet50Uproc1022_eta2.4_dec222010_scen_v2.root");
			     //"./../rootOutput_postApp_2nd/dec222010/MergedAll_MBproc0710_Jet15Uproc0710_Jet50Uproc1022_eta2.4_dec222010.root");
			     //"./../rootOutput_postApp_2nd/dec222010/MergedAll_MBproc0710_Jet15Uproc0710_Jet50Uproc1022_eta1.0_dec222010.root");
			     //"./../rootOutput_postApp_2nd/dec172010/MergedAll_MBproc0710_Jet15Uproc0710_Jet50Uproc1022_eta1.0_dec172010.root");
			     //"../corrections/rootOutput_aug3/CORR_TEST1_MB-C10-PR9-M6RR-JTMskim_Merged_0to2.4_proc0710.root"); // this has a shorter name because it's merged files
			     //"./rootOutput/CORR_All_Merged_witScale.root");
   
   hdndpt1 = (TH1D*) file1->Get("corrTypeTwo/hInvCorrTwoLev2R");
   TH1D *hdndpt1_temp = 0;
   hdndpt1_temp = (TH1D*) hdndpt1->Clone("hdndpt1_temp");
   hdndpt1_temp = (TH1D*) resetSysStatError(hdndpt1_temp);
   tasydndpt1 =  (TGraphAsymmErrors*) TGraphAsyErrIt(hdndpt1_temp);
   //tdndpt1 = (TGraphErrors*) TgraphIt(hdndpt1_temp, true);
   //tdndpt1 = (TGraphErrors*) file1->Get("corrTypeTwo/tInvCorrTwoLev2R");

   if(hdndpt1==0) {
      Error("[HistLoading]","could not get histogram");
      return;
   }

   // D6T
   file2 = (TFile*) loadFile(file2,
     "./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_D6T_Pt0to20_eta_0.0to2.4_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
     //"./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_D6T_Pt0to20_eta_0.0to1.0_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
			     //"../corrections//rootOutput/GEN_TrkHistGEN_july28_d6tv2_qcdPt0to20V2_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
                             //"./rootOutput/GEN_TrkHistGEN_july19_qcdPt0to15_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
			     
   hdndpt2 = (TH1D*) file2->Get("corrTypeTwoGEN/hInvCorrR");
   tdndpt2 = (TGraphErrors*) file2->Get("corrTypeTwoGEN/tInvCorr");
   if(hdndpt2==0 || tdndpt2==0) {
     Error("[HistLoading]","could not get histogram");
     return;
   }

   // P0
   file3 = (TFile*) loadFile(file3,
    "./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_P0_Pt0to20_eta_0.0to2.4_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
   //"./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_P0_Pt0to20_eta_0.0to1.0_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
			     //"../corrections/rootOutput/GEN_TrkHistGEN_july28_p0_qcdPt0to20V2_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
			     //"./rootOutput/GEN_TrkHistGEN_july19_p0_qcdPt0to15_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
			     //"./rootOutput/GEN_TrkHistGEN_july19_p0v2_qcdPt0to15V2_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
			     //"./rootOutput/GEN_TrkHistGEN_july19_p0v3_qcdPt0to15_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");

   hdndpt3 = (TH1D*) file3->Get("corrTypeTwoGEN/hInvCorrR");
   tdndpt3 = (TGraphErrors*) file3->Get("corrTypeTwoGEN/tInvCorr");
   if(hdndpt3==0 || tdndpt3==0) {
     Error("[HistLoading]","could not get histogram");
     return;
   }

   // PYTHIA 8
   file4 = (TFile*) loadFile(file4,
	  "./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_PY8_Pt0to30_eta_0.0to2.4_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
   //"../corrections/rootOutput/GEN_TrkHistGEN_july28_py8v3_qcdPt0to20V3_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
   //"./rootOutput/GEN_TrkHistGEN_july28_proq20_qcdPt0to20V2_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
   //"./rootOutput/GEN_TrkHistGEN_july19_atlas_qcdPt0to15_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");

   hdndpt4 = (TH1D*) file4->Get("corrTypeTwoGEN/hInvCorrR");
   tdndpt4 = (TGraphErrors*) file4->Get("corrTypeTwoGEN/tInvCorr");
   if(hdndpt4==0 || tdndpt4==0) {
     Error("[HistLoading]","could not get histogram");
     return;
   }

   // X1 -> ProQ 20
   file5 = (TFile*) loadFile(file5,
      "./../rootOutput_postApp_2nd/dec222010_gen/GEN_TrkHistGEN_7TeV_dec14_qcdNSD_ProQ20_Pt0to20_eta_0.0to2.4_jet_0.0to2400.0_preTrackAna_varBin1_rebin4.root");
			     //"../corrections/rootOutput/GEN_TrkHistGEN_july28_proq20_qcdPt0to20V2_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
			     //"./rootOutput/GEN_TrkHistGEN_july28_py8v3_qcdPt0to20V3_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
                             //"./rootOutput/GEN_TrkHistGEN_july19_x1_qcdPt0to15_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");

   hdndpt5 = (TH1D*) file5->Get("corrTypeTwoGEN/hInvCorrR");
   tdndpt5 = (TGraphErrors*) file5->Get("corrTypeTwoGEN/tInvCorr");
   if(hdndpt5==0 || tdndpt5==0) {
     Error("[HistLoading]","could not get histogram");
     return;
   }

   // Atlas
   if(atlas){
     file6 = (TFile*) loadFile(file6,
			       "../corrections/rootOutput/GEN_TrkHistGEN_july28_atlas_qcdPt0to20_eta_0.0to2.4_jet_0.0to2000.0_preTrackAna_varBin1_rebin4.root");
     hdndpt6 = (TH1D*) file6->Get("corrTypeTwoGEN/hInvCorrR");
     tdndpt6 = (TGraphErrors*) file6->Get("corrTypeTwoGEN/tInvCorr");
     if(hdndpt6==0 || tdndpt6==0) {
       Error("[HistLoading]","could not get histogram");
       return;
     }
   }


   
   // Normalization 
   //float N_evt = 1.13643e+07;
   //hdndpt1->Scale(sigma_nsd);

   //--------------------------- CMS measurement ---------------------------
   cms_7000GeV = (TGraphErrors*) CMS_7TEV(1);

   
   //---------------------------- fits --------------------------------------
   TF1 *f2 = new TF1("fitTsallis","[0]*(1+(sqrt(0.1396**2+x**2)-0.1396)/([1]*[2]))**(-[2])",0.5,200);                                                                            
   f2->SetParameters(1.82045e+01,1.53540e-01,7.06942e+00); // fit the fit (used in paper)                                                                                        
   f2->SetLineColor(2), f2->SetLineWidth(2);

   // Basic canvas and dummy histogram
   TCanvas *call = new TCanvas("call","call",510,670);
   setPad(call);

   // ----- pad 1 
   pp1->cd();
   pp1->SetLogy();
   pp1->SetLogx();

   dum1 = GetDummyHist(pt_min,pt_max,ymin,ymax,"p_{T} [GeV/c]","Ed^{3}N/dp^{3} [GeV^{-2}c^{3}]",false);
   dum1->Draw("");
   dum1->GetXaxis()->SetNdivisions(908);
   dum1->GetYaxis()->SetNdivisions(407);

   int fillsty = 3001;

   th1Style2(tdndpt2,2,20,1.0,2,2,1,2,true);
   th1Style2(tdndpt3,4,20,1.0,4,2,2,2,false);
   //th1Style2(tdndpt4,6,20,1.0,6,2,9,2,false);
   th1Style2(tdndpt4,6,20,1.0,6,2,4,2,false);     
   //th1Style2(tdndpt5,19,20,1.0,19,2,3,3,false);
   th1Style2(tdndpt5,20,20,1.0,20,2,9,3,false); 
   if(atlas) th1Style2(tdndpt6,20,20,1.0,20,2,4,3,false);
   //th1Style1(hdndpt2,1,20,1.0,1,1.5,1,1); 

   tasydndpt1->SetMarkerSize(1.0); tasydndpt1->SetFillStyle(fillsty), tasydndpt1->SetFillColor(kGray);
   tasydndpt1->Draw("2");

   th1Style1(hdndpt1,1,20,1.0,1,1.5,1,1);  // draw the measurement on top of everything


   //TLegend *leg1 = new TLegend(0.37,0.47,0.74,0.85);
   TLegend *leg1 = new TLegend(0.22,0.09,0.59,0.47);
   leg1->SetMargin(0.3), leg1->SetBorderSize(0);
   leg1->SetFillColor(kWhite), leg1->SetFillStyle(0);
   leg1->SetTextSize(0.039), leg1->SetMargin(0.3);
   leg1->SetHeader("    #sqrt{s} = 7 TeV,   |#eta|<2.4");
   leg1->AddEntry(tasydndpt1,"CMS    #scale[0.7]{#int}Ldt = 2.96 pb^{-1}","plf");
   leg1->AddEntry(tdndpt2,"PYTHIA D6T","l");
   leg1->AddEntry(tdndpt3,"PYTHIA Perugia0","l");
   leg1->AddEntry(tdndpt5,"PYTHIA ProQ20","l");
   leg1->AddEntry(tdndpt4,"PYTHIA 8","l");
   if(atlas) leg1->AddEntry(tdndpt6,"PYTHIA Atlas","l");
   leg1->Draw();

   //putCMSPrel();
   //putIntLum();
   putB();

   // ----- pad 2 
   pp1_1->cd();
   pp1_1->SetLogx();
   
   dum1_1 = GetDummyHist(pt_min,pt_max,ymin_r,ymax_r,"p_{T} [GeV/c]","DATA / MC",false);
   setLowerPad(dum1_1);
   dum1_1->Draw("");

   TLine *line = new TLine(0,1,pt_max,1);
   line->SetLineStyle(2);
   line->SetLineWidth(2);
   line->Draw();

   hdndpt1_2_cln = (TH1D*) hdndpt1->Clone("hdndpt1_2_cln");
   hdndpt1_3_cln = (TH1D*) hdndpt1->Clone("hdndpt1_3_cln");
   hdndpt1_4_cln = (TH1D*) hdndpt1->Clone("hdndpt1_4_cln");
   hdndpt1_5_cln = (TH1D*) hdndpt1->Clone("hdndpt1_5_cln");

   hdndpt2_cln = (TH1D*) hdndpt2->Clone("hdndpt2_cln");
   hdndpt3_cln = (TH1D*) hdndpt3->Clone("hdndpt3_cln");
   hdndpt4_cln = (TH1D*) hdndpt4->Clone("hdndpt4_cln");
   hdndpt5_cln = (TH1D*) hdndpt5->Clone("hdndpt5_cln");

   hdndpt1_2_cln->Divide(hdndpt2_cln);
   hdndpt1_3_cln->Divide(hdndpt3_cln);
   hdndpt1_4_cln->Divide(hdndpt4_cln);
   hdndpt1_5_cln->Divide(hdndpt5_cln);


   if(atlas){
     hdndpt1_6_cln = (TH1D*) hdndpt1->Clone("hdndpt1_6_cln");
     hdndpt6_cln = (TH1D*) hdndpt6->Clone("hdndpt6_cln");
     hdndpt1_6_cln->Divide(hdndpt6_cln);
   }
   
   // Draw sys + stat combined error   
   createSysStatErrorHist(hdndpt1);
   tsyserr = (TGraphErrors*) TgraphIt(hsyserr);
   tsyserr->SetFillColor(kGray);
   tsyserr->SetFillStyle(fillsty);

   tsyserr->Draw("3");
   //hsyserr->Draw("pzsame");          

   //th1Style1(cms_7000GeV_div,13,30,1.0,13,1,1,1);
   th1Style1(hdndpt1_2_cln,2,20,1.0,2,2.0,1,3);
   th1Style1(hdndpt1_3_cln,4,20,1.0,4,2.0,2,3);
   //th1Style1(hdndpt1_4_cln,6,20,1.0,6,2.0,9,3);
   //th1Style1(hdndpt1_5_cln,19,20,1.0,19,2.0,3,3);
   th1Style1(hdndpt1_4_cln,6,20,1.0,6,2.0,4,3);
   th1Style1(hdndpt1_5_cln,20,20,1.0,20,2.0,9,3);
   if(atlas)  th1Style1(hdndpt1_6_cln,20,20,1.0,20,2.0,5,3);


   // print Xsection 
   PrintXsection(hdndpt1,1.);
   //PrintXsection(hdndpt1,1.);

   // save canvas 
   if(save){
     if(atlas) printCanvases(call, "spectra_inv_cms_vs_pythia_all_v3",0);
     else printCanvases(call, "spectra_inv_cms_vs_pythia_v3",0);
   }

}