Beispiel #1
0
//
// Main function
//
void drawROCandWPv4(){
  
  bazinga("Step #0");
  TCanvas *c1 = new TCanvas("c1","",10,10,600,600);
  //  c1->cd();

  TString tmvaFileName1 = tmvaFileNameBarrel[0];
  TString tmvaFileName2 = tmvaFileNameBarrel[1];
  TString tmvaFileName3 = tmvaFileNameBarrel[2];
  TString tmvaFileName4 = tmvaFileNameBarrel[3];
  bazinga("Step #1");
  const TString *cutFileNamesSet1 = cutFileNamesBarrelSet1;
  const TString *cutFileNamesSet2 = cutFileNamesBarrelSet2;
  const TString *cutFileNamesSet3 = cutFileNamesBarrelSet3;
  const TString *cutFileNamesSet4 = cutFileNamesBarrelSet4;
  if( !drawBarrel ){
    tmvaFileName1 = tmvaFileNameEndcap[0];
    tmvaFileName2 = tmvaFileNameEndcap[1];
    tmvaFileName3 = tmvaFileNameEndcap[2];
    tmvaFileName4 = tmvaFileNameEndcap[3];

    cutFileNamesSet1 = cutFileNamesEndcapSet1;
    cutFileNamesSet2 = cutFileNamesEndcapSet2;
    cutFileNamesSet3 = cutFileNamesEndcapSet3;
    cutFileNamesSet4 = cutFileNamesEndcapSet4;
  }
  bazinga("Step #2");
  // Open the file with TMVA output
  TFile *tmvaFile1 = new TFile(tmvaFileName1);
  TFile *tmvaFile2 = new TFile(tmvaFileName2);
  TFile *tmvaFile3 = new TFile(tmvaFileName3);
  TFile *tmvaFile4 = new TFile(tmvaFileName4);
  if( !tmvaFile1 || !tmvaFile2 || !tmvaFile3 || !tmvaFile4)
    assert(0);
  bazinga("Step #3");
  // 
  //  Draw the ROC curve
  //
  TH1F *hROC1 = (TH1F*)tmvaFile1->Get("Method_Cuts/Cuts/MVA_Cuts_rejBvsS");
  TH1F *hROC2 = (TH1F*)tmvaFile2->Get("Method_Cuts/Cuts/MVA_Cuts_rejBvsS");
  TH1F *hROC3 = (TH1F*)tmvaFile3->Get("Method_Cuts/Cuts/MVA_Cuts_rejBvsS");
  TH1F *hROC4 = (TH1F*)tmvaFile4->Get("Method_Cuts/Cuts/MVA_Cuts_rejBvsS");
  if( !hROC1 || !hROC2 || !hROC3|| !hROC3 )
    assert(0);

  //c1->cd();
  //hROC1->Draw();
  bazinga("Step #4");
  
  TH1F * hROC = new TH1F("hROC", "", 100, 0, 1);
  hROC->SetDirectory(0);

  for(int iBin = 1; iBin <=100; ++iBin){

    if (drawBarrel){
    // barrrel
      if(1<=iBin && iBin<=75)
	hROC->SetBinContent(iBin, hROC3->GetBinContent(iBin)) ;
      else if(76 <= iBin && iBin<=89)
	hROC->SetBinContent(iBin, hROC2->GetBinContent(iBin)) ;
      else if(90 <=iBin && iBin<=100)
	hROC->SetBinContent(iBin, hROC1->GetBinContent(iBin)) ;
    }
    else {
      // for endcap
      if(1<=iBin && iBin<=70)
	hROC->SetBinContent(iBin, hROC3->GetBinContent(iBin)) ;
      else if(71 <= iBin && iBin<=89)
	hROC->SetBinContent(iBin, hROC2->GetBinContent(iBin)) ;
      else if(90 <=iBin && iBin<=100)
	hROC->SetBinContent(iBin, hROC1->GetBinContent(iBin)) ;
    }
    
  }
  
  bazinga("Step #5");
  
  //Set histogram attributes and draw the ROC curve
  hROC->SetStats(0);
  hROC->SetLineWidth(2);
  hROC->SetTitle("");
  hROC->GetXaxis()->SetTitle("signal efficiency");
  hROC->GetYaxis()->SetTitle("background rejection");
  hROC->GetYaxis()->SetTitleOffset(1.4);
  if( drawBarrel ){
    hROC->GetXaxis()->SetRangeUser(0.6, 1.0);
    hROC->GetYaxis()->SetRangeUser(0.951, 1.0);
  }else{
    hROC->GetXaxis()->SetRangeUser(0.6, 1.0);
    hROC->GetYaxis()->SetRangeUser(0.8, 1.0);
  }

  c1->cd();
  // hROC->Draw("L");
  hROC1->SetLineColor(kRed);
  hROC2->SetLineColor(kOrange);
  hROC3->SetLineColor(kBlue);
  hROC4->SetLineColor(kGreen);
  hROC1->GetYaxis()->SetRangeUser(0.9, 1.0);
  hROC1->SetStats(0);
  hROC1->Draw("L");
  //hROC1->Draw("Lsame");
  //hROC2->Draw("Lsame");
  //hROC3->Draw("Lsame");
  //hROC4->Draw("Lsame");
  bazinga("Step #6");
  TString commentText = "barrel electrons";
  if( !drawBarrel )
    commentText = "endcap electrons";
  TLatex *comment = new TLatex(0.2, 0.2, commentText);
  comment->SetNDC(kTRUE);
  comment->Draw();

  c1->Update();
  bazinga("Step #7");
  // 
  // Overlay the cuts
  //

  // First find the TestTree for measuring efficiency and rejection
  printf("\n Take true electrons from %s   tree %s\n", 
	 fnameSignal.Data(), signalTreeName.Data());
  TTree *signalTree = getTreeFromFile( fnameSignal, signalTreeName);
  // Input background tree  
  printf("\n Take background electrons from %s   tree %s\n", 
	 fnameBackground.Data(), backgroundTreeName.Data());
  TTree *backgroundTree = getTreeFromFile( fnameBackground, backgroundTreeName);
  bazinga("Step #8");
  // Next, draw all working point sets
  if( nWorkingPointSets==4 ){

    TLegend *leg = new TLegend(0.15, 0.45, 0.5, 0.7);
    leg->SetFillStyle(0);
    leg->SetBorderSize(0);
    overlayWorkingPoints(c1, signalTree, backgroundTree, cutFileNamesSet1, 
			 markerColorSet1, markerStyleSet1, leg, legendSet1);
    // bazinga("Step #9");
    // overlayWorkingPoints(c1, signalTree, backgroundTree, cutFileNamesSet2, 
    // 			 markerColorSet2, markerStyleSet2, leg, legendSet2);
    // bazinga("Step #10");
    // overlayWorkingPoints(c1, signalTree, backgroundTree, cutFileNamesSet3,
    // 			 markerColorSet3, markerStyleSet3, leg, legendSet3);
    // bazinga("Step #11");
    // overlayWorkingPoints(c1, signalTree, backgroundTree, cutFileNamesSet4,  			   
    // 			 markerColorSet4, markerStyleSet4, leg, legendSet4);
    // bazinga("Step #12");
    leg->Draw("same");
    
  }
  
  
    // Save the figure into a file
    TString outname = "figures/plot_ROCandWP_barrel.png";
    bazinga("Step #13");
    if( !drawBarrel )
      outname = "figures/plot_ROCandWP_endcap.png";
    c1->Print(outname);
    
    return;
};
Beispiel #2
0
int main() {
  ic::Plot::SetHTTStyle();

  std::string dir="/vols/cms04/pjd12/invcmssws/CMSSW_7_1_5/src/HiggsAnalysis/CombinedLimit/exocombcards/";

  std::vector<Scan> scans;
  //  scans.push_back({"higgsCombinefullScan.MultiDimFit.mH125.root", "Observed", 1, nullptr});
  //  scans.push_back({"higgsCombineexpected.MultiDimFit.mH125.root", "Exp. for SM H", 32, nullptr});
//   scans.push_back({"higgsCombinenoBBBScan.MultiDimFit.mH125.root", "no bbb syst.", 38, nullptr});
  scans.push_back({dir+"higgsCombineCombExp.MultiDimFit.mH125.root", "Exp. for SM H", 1, nullptr});
  scans.push_back({dir+"higgsCombineCombObs.MultiDimFit.mH125.root", "Obs. for SM H", 1, nullptr});

  TCanvas c1("canvas","canvas");

  std::vector<TLine *> lines;


  TLegend *leg = new TLegend(0.65,0.75,0.9,0.9,"","brNDC");

  unsigned counter = 0;
  for (auto & sc : scans) {
    TFile f1(sc.file.c_str());
    TTree *t1 = dynamic_cast<TTree*>(f1.Get("limit"));
    double best1 = 0.0;
    TString res;
    sc.gr = new TGraph(ExtractGraph(t1, best1));
    if(counter==1){
      auto x1 = GetCrossings(*(sc.gr), 1.0);
      auto x2 = GetCrossings(*(sc.gr), 3.84);
      lines.push_back(new TLine(x1[0],0,x1[0],1.0));
      lines.back()->SetLineColor(2);
      lines.back()->SetLineWidth(2);
      lines.push_back(new TLine(x2[0],0,x2[0],3.84));
      lines.back()->SetLineColor(2);
      lines.back()->SetLineWidth(2);
    }
    sc.gr->SetLineColor(sc.color);
    sc.gr->SetLineWidth(3);
    sc.gr->Draw(counter ? "LSAME" : "AL");
    TString leg_text = "#splitline{"+sc.label+"}{"+res+"}";
    leg->AddEntry(sc.gr, leg_text, "L");
    counter++;
  }
  // c1.cd();
  // // g1.Print();
  // g1.SetLineColor(1);
  // g1.SetLineWidth(2);
  // // g1.SetMarkerColor(7);
  // g1.Draw("AC");
  scans[0].gr->SetMaximum(9);
  scans[0].gr->SetMinimum(0.);
  scans[0].gr->GetXaxis()->SetRangeUser(0., 0.9);
  scans[0].gr->GetXaxis()->SetTitle("BR_{inv}");
  scans[0].gr->GetXaxis()->SetTitleOffset(1.1);
  scans[0].gr->GetXaxis()->SetNdivisions(1005,true);
  scans[0].gr->GetXaxis()->SetLabelSize(0.05);
  scans[0].gr->GetYaxis()->SetLabelSize(0.05);
  scans[0].gr->GetXaxis()->SetLabelOffset(0.02);
  scans[0].gr->GetYaxis()->SetLabelOffset(0.02);
  scans[0].gr->GetYaxis()->SetTitle("-2 #Delta ln L");
  scans[0].gr->SetLineStyle(2);
  scans[0].gr->SetLineColor(1);
  leg->SetBorderSize(1);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);
  leg->SetLineColor(1);
  leg->SetLineStyle(1);
  leg->SetLineWidth(1);
  leg->SetFillColor(0);
  leg->SetFillStyle(1001);
  leg->Draw();
  lines.push_back(new TLine(0.,1,0.9,1.0));
  lines.back()->SetLineColor(2);
  lines.push_back(new TLine(0.,3.84,0.9,3.84));
  lines.back()->SetLineColor(2);
  //  for (auto l : lines) l->Draw();

  DrawCMSLogoTest(&c1,"CMS","preliminary",10);

  TLatex lat = TLatex();
  lat.SetNDC();
  lat.SetTextSize(0.04);                                                                                                                                    
  lat.SetTextFont(42);

  TLatex lat2 = TLatex();
  lat2.SetNDC();
  lat2.SetTextSize(0.03);
  lat2.SetTextFont(42);

  lat.DrawLatex(0.2,0.73,"Combination of all");
  lat.DrawLatex(0.2,0.68,"H#rightarrow inv. channels");


  c1.Update();
  c1.SaveAs("scan.pdf");
  return 0;
}
Beispiel #3
0
void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
  u2->SetName("u2");
  l2->SetName("l2");
  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
    Double_t x  = hh->GetXaxis()->GetBinCenter(i);
    Double_t y  = mean->Eval(x);
    Double_t e  = var->Eval(y);
    Double_t e1 = nVar * e;
    if (spd) e1 *= TMath::Log10(e);
    // Printf("%10e -> %10e +/- %10e", x, y, ee);
    g1->SetPoint(i-1, x, y);
    g1->SetPointError(i-1, 0, e1);
    u1->SetPoint(i-1, x, y+e1);
    l1->SetPoint(i-1, x, y-e1);
    // Printf("%3d: %f -> %f +/- %f", i, x, y, ee);

    Double_t e2 = nVar*0.05*x;
    g2->SetPoint(i-1, x, x);
    g2->SetPointError(i-1, 0, e2);
    u2->SetPoint(i-1, x, x+e2);
    l2->SetPoint(i-1, x, x-e2);
  }

  p = c->cd(1);
  c->Clear();
  c->cd();
  c->SetLogz();
  h->Draw("colz");
  g1->Draw("3 same");
  u1->Draw("l same");
  l1->Draw("l same");
  g2->Draw("3 same");
  u2->Draw("l same");
  l2->Draw("l same");

  Double_t ly = 0.9;
  Double_t dy = 0.06;
  TLatex* ltx = new TLatex(0.15, ly, Form("#LTy#GT = %f + %f x",
					   mean->GetParameter(0),
					   mean->GetParameter(1)));
  ltx->SetNDC();
  ltx->SetTextSize(dy);
  ltx->SetTextAlign(13);
  ltx->Draw();

  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#sigma_{y} = %f + %f x", 
				var->GetParameter(0),
				var->GetParameter(1)));
  
  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#delta = %f #sigma %s", 
				nVar, (spd ? "log_{10}(#sigma" : "")));
	    
					   
}
Beispiel #4
0
void compareMore(
    std::string datavar="h_ystar",
    std::string var3="id6",
    std::string output="test",
    std::string datafile="unified_angular_distributions/rebinnings/nozptcut/cts_CorrectedPlotsNoZPtCut_patJet.root",
    std::string mcfile1="unified_angular_distributions/rebinnings/nozptcut/weighted_exclusive1Jet_electron_genMore_DYToLL_M-50_1jEnh2_2jEnh35_3jEnh40_4jEnh50_7TeV-sherpa.root",
    std::string mcfile2="unified_angular_distributions/rebinnings/nozptcut/weighted_exclusive1Jet_electron_genMore_DYJetsToLL_TuneZ2_M-50_7TeV-madgraph-tauola.root",
    std::string mcfile3="unified_angular_distributions/rebinnings/nozptcut/Z_1jet_tota_cteq61._1___1___00ZPT00.root",
    std::string var1="", std::string var2="",
    float xmin=-9999.0, float xmax=-9999.0,
    std::string headertitle="Z(#rightarrow ee)+1 jet: no cut on p_{T}(Z)",
    std::string dataName="Data",
    std::string mcName1="Sherpa",
    std::string mcName2="Madgraph",
    std::string mcName3="MCFM",
    bool logScale=false)
{

    setTDRStyle();
    gStyle->SetOptStat(0);

    const int NHISTOS=4;
    TH1F* h[NHISTOS];
    char tempName[300];
    if(var1 ==  "" )var1=datavar;
    if(var2 ==  "" )var2=datavar;
    if(var3 ==  "" )var3=datavar;

    // first get the histogram files
    TFile *fdata  = TFile::Open(datafile.data());
    TFile *fmc1   = TFile::Open(mcfile1.data());
    TFile *fmc2   = TFile::Open(mcfile2.data());
    TFile *fmc3   = TFile::Open(mcfile3.data());

    h[0] = (TH1F*)(fdata->Get(datavar.data()));
    h[1]    = (TH1F*)(fmc1->Get(var1.data()));
    h[2]    = (TH1F*)(fmc2->Get(var2.data()));
    h[3]    = (TH1F*)(fmc3->Get(var3.data()));

    TH1D* hscale[NHISTOS];

    int COLOR[NHISTOS]= {1,4,2,kOrange-1};
    int MARKERSTYLE[NHISTOS]= {8,24,21,29};
    std::string xtitle;

    if(datavar=="h_ystar")
        xtitle = "0.5|Y_{Z}-Y_{jet}|";
    else if(datavar=="h_yB")
        xtitle = "0.5|Y_{Z}+Y_{jet}|";
    else if(datavar=="h_jetpt")
        xtitle = "p_{T}(jet) [GeV/c]";
    else if(datavar=="h_jety")
        xtitle = "Y(jet)";
    else if(datavar=="h_zpt")
        xtitle = "p_{T}(Z) [GeV/c]";
    else if(datavar=="h_zy")
        xtitle = "Y(Z)";

    for(int i=0; i < NHISTOS; i++) {

        hscale[i]   =(TH1D*) h[0]->Clone(Form("hscale%02i",i));
        hscale[i]   ->SetYTitle(Form("Ratio to %s",mcName3.data()));

//     hscale[i]   ->GetXaxis()->SetNdivisions(5);
        hscale[i]   ->GetXaxis()->SetDecimals();
        hscale[i]   ->GetYaxis()->SetDecimals();
        hscale[i]   ->SetXTitle(xtitle.data());

        hscale[i]->SetLineColor(COLOR[i]);
        hscale[i]->SetMarkerColor(COLOR[i]);
        hscale[i]->SetMarkerStyle(MARKERSTYLE[i]);

        hscale[i]->SetTitle("");
        hscale[i]->SetMaximum(2.05);
        hscale[i]->SetMinimum(0.0);
        hscale[i]->SetTitleOffset(1.2,"X");
        hscale[i]->SetTitleOffset(1.2,"Y");

        h[i]->SetTitle("");
        h[i]->GetXaxis()->SetDecimals();
        h[i]->GetYaxis()->SetDecimals();

        h[i]->SetLineColor(COLOR[i]);
        h[i]->SetMarkerColor(COLOR[i]);
        h[i]->SetMarkerSize(1);
        h[i]->SetMarkerStyle(MARKERSTYLE[i]);
        h[i]->SetTitleOffset(1.2,"Y");

    }

    // if normalizing to the same area, set the scale

    int binLo = -1;
    int binHi = -1;
    int nbins = h[0]->GetNbinsX();
    if(xmin>-9999.0 && xmax>-9999.0)
    {

        binLo = h[0]->FindBin(xmin);
        binHi = h[0]->FindBin(xmax)-1;

    }

    else
    {
        binLo = 1;
        binHi = nbins;
        xmin = h[0]->GetBinLowEdge(1);
        xmax = h[0]->GetBinLowEdge(nbins+1);
    }


    float scaleFactor[NHISTOS]= {1};

    for(int ih=0; ih < NHISTOS; ih++) {

        float integral = h[ih]->Integral(binLo,binHi);
//     scaleFactor[ih] = integral > 0? (float)h[0]->Integral(binLo,binHi)/integral: 1;
        scaleFactor[ih] = integral > 0? 1.0/integral: 1;
        h[ih]->Sumw2();
        h[ih]->Scale(scaleFactor[ih]);

    }

    for(int ih=0; ih < NHISTOS; ih++)
        cout << "histogram " << ih << " integral = " << h[ih]->Integral() << endl;


    // get the ratio

    for(int ih=0; ih < NHISTOS-1; ih++) {
        cout << "===================================================" << endl;
        cout << "For histogram " << ih << endl;
        for(int ib=1; ib<= nbins; ib++) {

            double nref    =h[NHISTOS-1]->GetBinContent(ib);
            double nreferr =h[NHISTOS-1]->GetBinError(ib);

            double ncomp   =h[ih]->GetBinContent(ib);
            double ncomperr=h[ih]->GetBinError(ib);

            double ratio = -9999;
            double err   = 1e-4;

            hscale[ih]->SetBinContent(ib,ratio);
            hscale[ih]->SetBinError(ib,err);

            if(ncomp<=0 || nref<=0)continue;

            if(ncomperr<=0 || nreferr<=0)
                continue;

            // now calculate the ratio 1
            ratio = ncomp/nref;
            err =
                (ratio)*sqrt(pow(nreferr/nref,2)+pow(ncomperr/ncomp,2));

            hscale[ih]->SetBinContent(ib,ratio);
            hscale[ih]->SetBinError(ib,err);

            cout << "Bin " << ib << " ratio = " << ratio << " +- " << err << endl;

            cout << "===================================================" << endl;
        } // end of loop over bins
    } // end of loop over histograms

    vector<float> maxArray;
    maxArray.clear();

    for(int ih=0; ih < NHISTOS; ih++) {

        h[ih]->GetXaxis()->SetRangeUser(xmin,xmax);
        hscale[ih]->GetXaxis()->SetRangeUser(xmin,xmax);
        float max_this  = h[ih]->GetBinError(h[ih]->GetMaximumBin()) + h[ih]->GetMaximum();
        maxArray.push_back(max_this);

    }


    float max = *max_element(maxArray.begin(),maxArray.end());
    cout << "Max = " << max << endl;

    for(int ih=0; ih < NHISTOS; ih++) {

        h[ih]->SetMaximum(1.3*max);
        if(!logScale)
            h[ih]->SetMinimum(-0.015);
        else
            h[ih]->SetMinimum(0.001);

    }

    cout << "here" << endl;
    TCanvas* c1 = new TCanvas("c1","",700,1000);
    c1->Divide(1,2,0.01,0);
    c1->cd(1);
    if(logScale)
        gPad->SetLogy(1);
    gPad->SetTopMargin(0.01);
    gPad->SetBottomMargin(0);
    gPad->SetRightMargin(0.04);


    cout << "here1" << endl;
    h[0]->SetYTitle("Arbitrary Unit");
    h[0]->Draw("e");
    for(int ih=0; ih < NHISTOS-1; ih++)
        h[ih]->Draw("esame");

    cout << "here2" << endl;

    h[NHISTOS-1]->Draw("hesame");

    cout << "here3" << endl;

    float x1NDC = 0.506307;
    float y1NDC = 0.555424;
    float x2NDC = 0.725251;
    float y2NDC = 0.867090;

    TLegend* leg = new TLegend(x1NDC,y1NDC,x2NDC,y2NDC);

    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->SetTextSize(0.05);
    leg->SetBorderSize(0);
    leg->SetHeader(headertitle.data());
    leg->AddEntry(h[0], dataName.data());
    leg->AddEntry(h[1], mcName1.data());
    leg->AddEntry(h[2], mcName2.data());
    leg->AddEntry(h[3], mcName3.data());
    leg->Draw("same");

    TLatex *lar = new TLatex(x1NDC, 0.91, "CMS   #sqrt{s} = 7 TeV, L_{int} = 4.9 fb^{-1}");
    lar->SetNDC(kTRUE);
    lar->SetTextSize(0.05);
    lar->Draw();


    c1->cd(2);
    gStyle->SetStatW       (0.3);
    gStyle->SetStatH       (0.3);
    gStyle->SetStatX       (0.879447);
    gStyle->SetStatY       (0.939033);
    gStyle->SetStatFontSize(0.05);
    gStyle->SetStatBorderSize(0);
    gPad->SetRightMargin(0.04);
    gPad->SetTopMargin(0);
    gPad->SetBottomMargin(0.2);
    gPad->SetTickx();
    gStyle->SetOptFit(1);

    cout << "here4" << endl;

    hscale[0]->Draw("e1");
    for(int ih=0; ih < NHISTOS-1; ih++) {
        hscale[ih]->Draw("e1same");
    }

    cout << "here5" << endl;
    TLine* l2 = new TLine(xmin,1.,xmax,1.);
    l2->SetLineColor(4);
    l2->SetLineStyle(3);
    l2->Draw("same");


    string dirName = "compareMore";
    gSystem->mkdir(dirName.data());

    std::string filename;
    std::string psname = dirName + "/" + var1;
    if(output !="test")
        psname = dirName+ "/zPt00" + output;
    else
        psname = dirName+ "/zPt00" + var1;
    filename = psname + ".eps";
    c1->Print(filename.data());
    filename = psname + ".gif";
    c1->Print(filename.data());
    filename = psname + ".pdf";
    c1->Print(filename.data());
    //   c1->Close();
}
Beispiel #5
0
void plotDistribution( TChain* data , TChain *mc , TCut sel , TCut vtxweight , char* var , int nbins , float xmin , float xmax , char* xtitle , char* plottitle = "" , bool printplot = false , bool residual = false , bool log = false ) {

    //--------------------------------------
    // define histograms and TGraphs
    //--------------------------------------

    TH1F* hdata      = new TH1F(Form("hdata_%i"     , iplot),Form("hdata_%i"    , iplot),nbins,xmin,xmax);
    TH1F* hmc        = new TH1F(Form("hmc_%i"       , iplot),Form("hmc_%i"      , iplot),nbins,xmin,xmax);
    TH1F* hmc_novtx  = new TH1F(Form("hmc_novtx_%i" , iplot),Form("hmc_novtx%i" , iplot),nbins,xmin,xmax);

    hdata->Sumw2();
    hmc->Sumw2();

    TGraphAsymmErrors* grdata = new TGraphAsymmErrors();
    TGraphAsymmErrors* grmc   = new TGraphAsymmErrors();

    TH1F* hdata_denom = new TH1F(Form("hdata_denom_%i",iplot),"",nbins,xmin,xmax);
    TH1F* hmc_denom   = new TH1F(Form("hmc_denom_%i"  ,iplot),"",nbins,xmin,xmax);

    //--------------------------------------
    // set up canvas and pads
    //--------------------------------------

    TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600);
    can->cd();
    if( log ) gPad->SetLogy();

    TPad *mainpad = new TPad("mainpad","mainpad",0.0,0.0,1.0,0.8);

    if( residual ) {
        mainpad->Draw();
        mainpad->cd();
        if( log ) mainpad->SetLogy();
    }

    //--------------------------------------
    // fill histos and TGraphs
    //--------------------------------------

    data->Draw(Form("min(%s,%f)>>hdata_%i"     , var,xmax-0.0001,iplot),sel);
    mc  ->Draw(Form("min(%s,%f)>>hmc_%i"       , var,xmax-0.0001,iplot),sel*vtxweight);
    mc  ->Draw(Form("min(%s,%f)>>hmc_novtx_%i" , var,xmax-0.0001,iplot),sel);

    for( int ibin = 1 ; ibin <= nbins ; ibin++ ) {
        hdata_denom->SetBinContent(ibin,hdata->Integral());
        hmc_denom->SetBinContent(ibin,hmc->Integral());
    }

    grdata->BayesDivide(hdata,hdata_denom);
    grmc->BayesDivide(hmc_novtx,hmc_denom);

    //--------------------------------------
    // get efficiencies and errors
    //--------------------------------------

    /*
    float ndata1     = (float) hdata->GetBinContent(1);
    float ndata      = (float) hdata->Integral();
    float effdata    = 1-ndata1 / ndata;

    // TGraphAsymmErrors* grdata_temp = new TGraphAsymmErrors();
    // TH1F* hdata_num_temp = new TH1F(Form("hdata_num_temp_%i",iplot),"",1,0,1);
    // TH1F* hdata_den_temp = new TH1F(Form("hdata_den_temp_%i",iplot),"",1,0,1);
    // hdata_num_temp->SetBinContent(1,ndata-ndata1);
    // hdata_den_temp->SetBinContent(1,ndata);
    // grdata_temp->BayesDivide(hdata_num_temp,hdata_den_temp);

    //float effdataerr = sqrt(ndata1) / ndata;
    float effdataerr = 0.5 * ( grdata->GetErrorYlow(0) + grdata->GetErrorYhigh(0) );
    //float effdataerr = 0.5 * ( grdata_temp->GetErrorYlow(0) + grdata_temp->GetErrorYhigh(0) );

    float nmc1       = (float) hmc->GetBinContent(1);
    float nmc        = (float) hmc->Integral();
    float effmc      = 1-nmc1 / nmc;
    //float effmcerr   = hmc->GetBinError(1) / nmc;
    float effmcerr   = 0.5 * ( grmc->GetErrorYlow(0) + grmc->GetErrorYhigh(0) );


    float datatot = hdata->Integral();
    float mctot   = hmc->Integral();

    cout << endl;
    cout << plottitle << endl;

    cout << "Data eff  " << Form("%.2f +/- %.3f",effdata,effdataerr) << endl;
    cout << "MC   eff  " << Form("%.2f +/- %.3f",effmc  ,effmcerr)   << endl;
    cout << "Data/MC   " << Form("%.2f +/- %.2f",ratio  ,ratioerr)   << endl;
    */

    float ndata    = hdata->Integral();
    float ndata1   = hdata->Integral(2,20);
    float ndata2   = hdata->Integral(3,20);
    float ndata3   = hdata->Integral(4,20);
    float ndata4   = hdata->Integral(5,20);
    float ndata5   = hdata->Integral(6,20);

    float nmc      = hmc->Integral();
    float nmc1     = hmc->Integral(2,20);
    float nmc2     = hmc->Integral(3,20);
    float nmc3     = hmc->Integral(4,20);
    float nmc4     = hmc->Integral(5,20);
    float nmc5     = hmc->Integral(6,20);

    float effdata1 = ndata1/ndata;
    float effdata2 = ndata2/ndata;
    float effdata3 = ndata3/ndata;
    float effdata4 = ndata4/ndata;
    float effdata5 = ndata5/ndata;

    float effmc1   = nmc1/nmc;
    float effmc2   = nmc2/nmc;
    float effmc3   = nmc3/nmc;
    float effmc4   = nmc4/nmc;
    float effmc5   = nmc5/nmc;

    float effdata1err = getBinomialError(ndata1,ndata);
    float effdata2err = getBinomialError(ndata2,ndata);
    float effdata3err = getBinomialError(ndata3,ndata);
    float effdata4err = getBinomialError(ndata4,ndata);
    float effdata5err = getBinomialError(ndata5,ndata);

    float effmc1err   = getBinomialError(nmc1,nmc);
    float effmc2err   = getBinomialError(nmc2,nmc);
    float effmc3err   = getBinomialError(nmc3,nmc);
    float effmc4err   = getBinomialError(nmc4,nmc);
    float effmc5err   = getBinomialError(nmc5,nmc);

    float ratio1      = effdata1/effmc1;
    float ratio2      = effdata2/effmc2;
    float ratio3      = effdata3/effmc3;
    float ratio4      = effdata4/effmc4;
    float ratio5      = effdata5/effmc5;

    float ratio1err   = ratio1 * sqrt(pow(effdata1err/effdata1,2)+pow(effmc1err/effmc1,2));
    float ratio2err   = ratio2 * sqrt(pow(effdata2err/effdata2,2)+pow(effmc2err/effmc2,2));
    float ratio3err   = ratio3 * sqrt(pow(effdata3err/effdata3,2)+pow(effmc3err/effmc3,2));
    float ratio4err   = ratio4 * sqrt(pow(effdata4err/effdata4,2)+pow(effmc4err/effmc4,2));
    float ratio5err   = ratio5 * sqrt(pow(effdata5err/effdata5,2)+pow(effmc5err/effmc5,2));

    cout << endl << endl << plottitle << endl;

    int left = 20;


    // char* delimstart = "|";
    // char* delim      = "|";
    // char* delimend   = "|";
    // char* pm         = "+/-";

    char* delimstart = "";
    char* delim      = "&";
    char* delimend   = "\\\\";
    char* pm         = "$\\pm$";

    cout << delimstart << setw(10) << "" << setw(4)
         << delim << setw(left) << "$>$ 1 GeV" << setw(4)
         << delim << setw(left) << "$>$ 2 GeV" << setw(4)
         << delim << setw(left) << "$>$ 3 GeV" << setw(4)
         << delim << setw(left) << "$>$ 4 GeV" << setw(4)
         << delim << setw(left) << "$>$ 5 GeV" << setw(4)
         << delimend << endl;

    cout << delimstart << setw(10) << "data" << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effdata1,pm,effdata1err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effdata2,pm,effdata2err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effdata3,pm,effdata3err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effdata4,pm,effdata4err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effdata5,pm,effdata5err) << setw(4)
         << delimend << endl;

    cout << delimstart << setw(10) << "mc" << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effmc1,pm,effmc1err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effmc2,pm,effmc2err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effmc3,pm,effmc3err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effmc4,pm,effmc4err) << setw(4)
         << delim << setw(left) << Form("%.3f %s %.4f",effmc5,pm,effmc5err) << setw(4)
         << delimend << endl;

    cout << delimstart << setw(10) << "data/mc" << setw(4)
         << delim << setw(left) << Form("%.2f %s %.2f",ratio1,pm,ratio1err) << setw(4)
         << delim << setw(left) << Form("%.2f %s %.2f",ratio2,pm,ratio2err) << setw(4)
         << delim << setw(left) << Form("%.2f %s %.2f",ratio3,pm,ratio3err) << setw(4)
         << delim << setw(left) << Form("%.2f %s %.2f",ratio4,pm,ratio4err) << setw(4)
         << delim << setw(left) << Form("%.2f %s %.2f",ratio5,pm,ratio5err) << setw(4)
         << delimend << endl;

    //--------------------------------------
    // draw stuff
    //--------------------------------------

    hdata->Scale(1.0/hdata->Integral());
    hmc->Scale(1.0/hmc->Integral());

    if( log ) hmc->GetYaxis()->SetRangeUser(0.0001,5);
    else      hmc->GetYaxis()->SetRangeUser(0.0,1);

    hmc->GetXaxis()->SetTitle(xtitle);
    hmc->SetLineColor(2);
    hmc->SetMarkerColor(2);
    hmc->DrawNormalized("hist");
    hmc->DrawNormalized("sameE1");
    hdata->SetLineColor(4);
    hdata->SetMarkerColor(4);
    hdata->Draw("sameE1");

    grdata->SetLineColor(6);
    grmc->SetLineColor(7);
    //grdata->Draw("sameP");
    //grmc->Draw("sameP");

    TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
    leg->AddEntry(hdata , "data" , "lp");
    leg->AddEntry(hmc   , "MC"   , "lp");
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->Draw();

    TLatex *t = new TLatex();
    t->SetNDC();

    if( TString(plottitle).Contains("el") ) t->DrawLatex(0.6,0.6,"electrons");
    if( TString(plottitle).Contains("mu") ) t->DrawLatex(0.6,0.6,"muons");

    if( TString(plottitle).Contains("0j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 0");
    if( TString(plottitle).Contains("1j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 1");
    if( TString(plottitle).Contains("2j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 2");
    if( TString(plottitle).Contains("3j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 3");
    if( TString(plottitle).Contains("4j") ) t->DrawLatex(0.6,0.5,"n_{jets} #geq 4");

    //--------------------------------------
    // draw residual plots
    //--------------------------------------

    if( residual ) {
        can->cd();

        TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0);
        respad->Draw();
        respad->cd();
        respad->SetGridy();

        TH1F* hratio = (TH1F*) hdata->Clone(Form("hratio_%i",iplot));
        hratio->Divide(hmc);

        hratio->SetMarkerColor(1);
        hratio->SetLineColor(1);
        hratio->Draw();
        hratio->GetYaxis()->SetRangeUser(0.5,1.5);
        hratio->GetYaxis()->SetNdivisions(5);
        hratio->GetYaxis()->SetLabelSize(0.2);
        hratio->GetXaxis()->SetLabelSize(0.0);

        TLine line;
        line.DrawLine(xmin,1.0,xmax,1.0);
    }

    //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel+"tkisonew>20");
    //data->Scan("run:lumi:event:probe->pt():probe->eta():tkisonew:met:mt:njets:nbl:nbm",sel);

    if( printplot ) can->Print(Form("plots/%s.pdf",plottitle));

    iplot++;

    // TCanvas *c2 = new TCanvas();
    // c2->cd();
    // grdata->Draw("AP");

}
void absoluteCS_CSnPb()
{
    TStyle * style = (TStyle*)gROOT->FindObject("graphStyle");

    if(!style)      
    {
        style = new TStyle("graphStyle","graphStyle");
    }

    TCanvas* c = new TCanvas("c1","",1200,1200);

    style->SetOptStat(0);
    style->SetOptTitle(0);    
    style->SetPalette(1,0);
    style->SetCanvasColor(10);      
    style->SetCanvasBorderMode(0);    
    style->SetFrameLineWidth(3);
    style->SetFrameFillColor(10);
    style->SetPadColor(10);
    style->SetHistLineWidth(3);
    style->SetHistLineColor(kBlue);
    style->SetMarkerSize(0.9);
    style->SetMarkerStyle(8);
    style->SetFuncWidth(3);
    style->SetFuncColor(kRed);
    style->SetLabelColor(kBlack,"xyz");
    style->SetTitleSize(0.06,"xyz");
    style->SetTitleFillColor(10);
    style->SetTitleTextColor(kBlack);
    style->SetEndErrorSize(0);

    gROOT->SetStyle("graphStyle");
    gROOT->ForceStyle();

    // read graphs
    string expFileName = "/data2/analysis/total.root";
    string litFileName = "/data2/analysis/literatureData.root";

    TFile* expFile = new TFile(expFileName.c_str(),"READ");
    TFile* litFile = new TFile(litFileName.c_str(),"READ");
    
    string expCGraphName = "CNat";
    string expSnGraphName = "SnNat";
    string expPbGraphName = "PbNat";

    string litCGraphName = "Natural C (n,tot)";
    string litSnGraphName = "Natural Sn (n,tot)";
    string litPbGraphName = "Natural Pb (n,tot)";
    
    TGraphAsymmErrors* expCGraph = (TGraphAsymmErrors*)expFile->Get(expCGraphName.c_str());
    TGraphAsymmErrors* expSnGraph = (TGraphAsymmErrors*)expFile->Get(expSnGraphName.c_str());
    TGraphAsymmErrors* expPbGraph = (TGraphAsymmErrors*)expFile->Get(expPbGraphName.c_str());

    TGraphAsymmErrors* litCGraph = (TGraphAsymmErrors*)litFile->Get(litCGraphName.c_str());
    TGraphAsymmErrors* litSnGraph = (TGraphAsymmErrors*)litFile->Get(litSnGraphName.c_str());
    TGraphAsymmErrors* litPbGraph = (TGraphAsymmErrors*)litFile->Get(litPbGraphName.c_str());

    // Set graph point and line characteristics
    expCGraph->SetLineColor(kRed);
    expCGraph->SetLineWidth(5);
    expCGraph->SetLineStyle(0);
    expCGraph->SetMarkerColor(kRed);

    expSnGraph->SetLineColor(kRed);
    expSnGraph->SetLineWidth(5);
    expSnGraph->SetLineStyle(0);
    expSnGraph->SetMarkerColor(kRed);

    expPbGraph->SetLineColor(kRed);
    expPbGraph->SetLineWidth(5);
    expPbGraph->SetLineStyle(0);
    expPbGraph->SetMarkerColor(kRed);

    litCGraph->SetLineColor(kBlack);
    litCGraph->SetLineWidth(3);
    litCGraph->SetLineStyle(2);
    litCGraph->SetMarkerColor(kBlack);

    litSnGraph->SetLineColor(kBlack);
    litSnGraph->SetLineWidth(3);
    litSnGraph->SetLineStyle(2);
    litSnGraph->SetMarkerColor(kBlack);

    litPbGraph->SetLineColor(kBlack);
    litPbGraph->SetLineWidth(3);
    litPbGraph->SetLineStyle(2);
    litPbGraph->SetMarkerColor(kBlack);

    // Pad dimensions and margins
    gPad->SetPad(0.005, 0.995, 0.995, 0.005);
    gPad->SetLeftMargin(0.15);
    gPad->SetRightMargin(0.01);
    gPad->SetTopMargin(0.03);
    gPad->SetBottomMargin(0.15);
    gPad->SetTicky(2);

    // X-axis parameters
    expCGraph->GetXaxis()->SetTitle("Energy (MeV)");
    expCGraph->GetXaxis()->SetTitleSize(0.05);
    expCGraph->GetXaxis()->SetTitleFont(2);
    expCGraph->GetXaxis()->SetTitleOffset(1.4);
    expCGraph->GetXaxis()->CenterTitle();

    expCGraph->GetXaxis()->SetLabelOffset(0.01);
    expCGraph->GetXaxis()->SetLabelSize(0.05);
    expCGraph->GetXaxis()->SetLabelFont(2);

    expCGraph->GetXaxis()->SetNdivisions(10);
    expCGraph->GetXaxis()->SetTickLength(0.03);

    // Y-axis parameters
    expCGraph->GetYaxis()->SetTitle("#sigma_{tot} (barns)");
    expCGraph->GetYaxis()->SetTitleSize(0.06);
    expCGraph->GetYaxis()->SetTitleFont(2);
    expCGraph->GetYaxis()->SetTitleOffset(0.8);
    expCGraph->GetYaxis()->CenterTitle();

    expCGraph->GetYaxis()->SetLabelOffset(0.01);
    expCGraph->GetYaxis()->SetLabelSize(0.05);

    expCGraph->GetYaxis()->SetLabelFont(2);
    expCGraph->GetYaxis()->SetNdivisions(10);
    expCGraph->GetYaxis()->SetTickLength(0.02);

    expCGraph->Draw("");
    expSnGraph->Draw("same");
    expPbGraph->Draw("same");
    litCGraph->Draw("same");
    litSnGraph->Draw("same");
    litPbGraph->Draw("same");
    expCGraph->Draw("same");
    expSnGraph->Draw("same");
    expPbGraph->Draw("same");

    gPad->SetLogx(1);
    
    expCGraph->GetYaxis()->SetRangeUser(0,9);

    TLatex latex;
    latex.SetNDC();
    latex.SetTextSize(0.035);
    latex.SetTextAlign(13); // align at top
    latex.DrawLatex(0.65,0.65,"Pb (elem.)");
    latex.DrawLatex(0.35,0.52,"Sn (elem.)");
    latex.DrawLatex(0.32,0.4,"C (elem.)");

    // Define legend format and contents
    TLegend *legend = new TLegend(0.7,0.8,0.9,0.9);
    legend->AddEntry(litCGraph,"lit data (analog)","l");
    legend->AddEntry(expCGraph,"new data (DSP)","l");
    legend->Draw();

    expFile->Close();
    litFile->Close();
}
void  eff_dz(){

 gROOT->SetStyle("Plain");
 gStyle -> SetErrorX(0);

 

   TFile *fMCdz= new TFile("output_data_iso025.root");


 TCanvas *c = new TCanvas("c","The Ntuple canvas",200,10,700,780);
  c->SetFillColor(10); 

    c->Divide(2,3); 
   
   
   gStyle->SetStatW(0.30);
   gStyle->SetStatH(0.20);
   gStyle->SetStatColor(42);
   gStyle->SetOptStat(""); //em
   gStyle->SetLabelSize(0.048,"xy");
   gStyle->SetLabelOffset(0.013,"x");
   gStyle->SetLabelOffset(0.013,"y");
   gStyle->SetPadBorderMode(0);
   gStyle->SetFillColor(0);
   gStyle->SetPadTickX(1);
   gStyle->SetPadTickY(1);

  TLatex *t = new TLatex();
   t->SetNDC();
   t->SetTextFont(62);
   t->SetTextColor(36);
   t->SetTextSize(0.08);
   t->SetTextAlign(12);

///////////////////////////////////////////



   c_1 -> cd();
   c->cd(1); 
     
 gPad->SetTopMargin(0.08);
 gPad->SetLeftMargin(0.163);
 gPad->SetBottomMargin(0.16);
 gPad->SetRightMargin(0.143);
   

fMCdz->cd();
fMCdz->ls();
//  tag_abseta_bin0
TGraphAsymmErrors  *histo1D = (TGraphAsymmErrors*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin0_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
  Double_t *yg = histo1D->GetY();
  Double_t *erryg = histo1D->GetEYhigh() ;
  for (int i = 0; i<4; i++) {
    printf("yg[%d] = %g\n", i,yg[i]);
    printf("erryg[%d] = %g\n", i,erryg[i]);
  }
cout << "--------------" << "\n";
//  tag_abseta_bin1
TGraphAsymmErrors  *histo1Db1 = (TGraphAsymmErrors*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin1_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
  Double_t *ygb1 = histo1Db1->GetY();
  Double_t *errygb1 = histo1Db1->GetEYhigh() ;
  for (int i = 0; i<4; i++) {
    printf("ygb1[%d] = %g\n", i,ygb1[i]);
    printf("errygb1[%d] = %g\n", i,errygb1[i]);
  }
cout << "--------------" << "\n";
//  tag_abseta_bin2
TGraphAsymmErrors  *histo1Db2 = (TGraphAsymmErrors*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin2_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
  Double_t *ygb2 = histo1Db2->GetY();
  Double_t *errygb2 = histo1Db2->GetEYhigh() ;
  for (int i = 0; i<4; i++) {
    printf("ygb2[%d] = %g\n", i,ygb2[i]);
    printf("errygb2[%d] = %g\n", i,errygb2[i]);
  }
cout << "--------------" << "\n";
//  tag_abseta_bin3
TGraphAsymmErrors  *histo1Db3 = (TGraphAsymmErrors*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin3_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
  Double_t *ygb3 = histo1Db3->GetY();
  Double_t *errygb3 = histo1Db3->GetEYhigh() ;
  for (int i = 0; i<4; i++) {
    printf("ygb3[%d] = %g\n", i,ygb3[i]);
    printf("errygb3[%d] = %g\n", i,errygb3[i]);
  }


double etabin[5] = {0, 0.9, 1.2, 2.1, 2.4};
TH2F *heta1eta2  = new TH2F("heta1eta2","eta1 vs eta2", 4, etabin, 4, etabin);

  for (int i(1); i <= 4 ; i++) {  // y
        for (int j(1); j <= 4; j++) {  // x
        if(i==1){ heta1eta2 -> SetBinContent(j,i,yg[j-1]);
                  heta1eta2 -> SetBinError(j,i,erryg[j-1]); }
        if(i==2){ heta1eta2 -> SetBinContent(j,i,ygb1[j-1]);
                  heta1eta2 -> SetBinError(j,i,errygb1[j-1]); }
        if(i==3){ heta1eta2 -> SetBinContent(j,i,ygb2[j-1]);
                  heta1eta2 -> SetBinError(j,i,errygb2[j-1]); }
        if(i==4){ heta1eta2 -> SetBinContent(j,i,ygb3[j-1]);
                  heta1eta2 -> SetBinError(j,i,errygb3[j-1]); }

}
}

heta1eta2 -> Draw("COLZ");
gStyle->SetPaintTextFormat("3.4f ");

heta1eta2->SetMarkerSize(1.8);
heta1eta2->Draw("TEXT E1 Same");


//////////////////////////////////////////////////////////

   c_2 -> cd();
   c->cd(2); 
     
 gPad->SetTopMargin(0.08);
 gPad->SetLeftMargin(0.163);
 gPad->SetBottomMargin(0.16);
 gPad->SetRightMargin(0.143);


fMCdz->cd();
//fMCdz->ls();
TH1F  *histo1Da = (TH1F*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin0_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
histo1Da ->Draw("ap");

//////////////////////////////////////////////////////////

   c_3 -> cd();
   c->cd(3); 
     
 gPad->SetTopMargin(0.08);
 gPad->SetLeftMargin(0.163);
 gPad->SetBottomMargin(0.16);
 gPad->SetRightMargin(0.143);
   

fMCdz->cd();

TH1F  *histo1Da = (TH1F*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin1_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
histo1Da ->Draw("ap");

//////////////////////////////////////////////////////////

   c_4 -> cd();
   c->cd(4); 
     
 gPad->SetTopMargin(0.08);
 gPad->SetLeftMargin(0.163);
 gPad->SetBottomMargin(0.16);
 gPad->SetRightMargin(0.143);
   

fMCdz->cd();
TH1F  *histo1Da = (TH1F*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin2_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
histo1Da ->Draw("ap");


//////////////////////////////////////////////////////////

   c_5 -> cd();
   c->cd(5); 
     
 gPad->SetTopMargin(0.08);
 gPad->SetLeftMargin(0.163);
 gPad->SetBottomMargin(0.16);
 gPad->SetRightMargin(0.143);
   

fMCdz->cd();
TH1F  *histo1Da = (TH1F*) fMCdz->Get("pathOr_pt_eta_abseta_PLOT_tag_abseta_bin3_&_Mu17Eff_pass_&_Tight2012_pass_&_tag_Tight2012_pass");
                                  
histo1Da ->Draw("ap");

/////////////////////////////////////////////////////////////
 

   c-> Print("eff_pathor_data.pdf"); 


   c->cd();
   c->Update();

}
int draw_closure_differential(int isPA=1, bool useZvtxWeight=false, bool useSF = false, bool isLog = false)
{
  gROOT->Macro("../Style.C");
  using namespace std;
  
  TString szPA;
  if (isPA==0) szPA="pp";
  else if (isPA==1) szPA="pA";
  else {cout << "select among isPA = 0, or 1"<< endl; return 0; }

  ////rap array in yCM (from forward to backward)
  const Int_t nRap = 8; 
  const Int_t nPt = 9; 
  const int nRapTmp = nRap +1; 
  const int nPtTmp = nPt +1; 
  
  Double_t rapArrNumFB[nRapTmp];
  Double_t rapArrNumFB_pp[nRapTmp] = {2.4, 1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4};// for pt dist.
  Double_t rapArrNumFB_pA[nRapTmp] = {1.93, 1.5, 0.9, 0., -0.9, -1.5, -1.93, -2.4, -2.87};// for pt dist.
  //Double_t rapArrNumBF[nRapTmp];
  //Double_t rapArrNumBF_pp[nRapTmp] = {-2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93, 2.4};// for rap dist.
  //Double_t rapArrNumBF_pA[nRapTmp] = {-2.87, -2.4, -1.93, -1.5, -0.9, 0., 0.9, 1.5, 1.93};// for rap dist.
  for (int iy=0; iy<nRapTmp; iy++){
    if (isPA==0) { rapArrNumFB[iy]=rapArrNumFB_pp[iy];}
    else { rapArrNumFB[iy]=rapArrNumFB_pA[iy];}
  } 
  
  ////pt array
  Double_t ptArrNum[10] = {2.0, 3.0, 4.0, 5.0, 6.5, 7.5, 8.5, 10., 14., 30.};
  
  //// array string
  string rapArr[nRap];
  for (Int_t iy=0; iy<nRap; iy++) {
    formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]);
    cout << iy <<"th rapArr = " << rapArr[iy] << endl;
  }
  string ptArr[nPt];
  for (Int_t ipt=0; ipt<nPt; ipt++) {
    formPtArr(ptArrNum[ipt], ptArrNum[ipt+1], &ptArr[ipt]);
    cout << ipt <<"th ptArr = " << ptArr[ipt] << endl;
  }
  
  // --- read-in file
  TFile * f2D = new TFile(Form("../FittingResult/totalHist_%s_8rap9pt_newcut_Zvtx%d_SF%d_noPtWeight.root",szPA.Data(),(int)useZvtxWeight,(int)useSF),"READ");
  // --- read-in 2D hist for "MC corrected yield" and "gen distributions"
  TH2D* h2D_MCCorrY_PR = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_MCCorrY_PR_%s",szPA.Data()));
  TH2D* h2D_MCCorrY_NP = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_MCCorrY_NP_%s",szPA.Data()));
  TH2D* h2D_Acc_Den_PR = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_Acc_Den_PR_%s",szPA.Data()));
  TH2D* h2D_Acc_Den_NP = (TH2D*)f2D->Get(Form("otherMCInfo/h2D_Acc_Den_NP_%s",szPA.Data()));
  
  const int nbinsX = h2D_MCCorrY_PR->GetNbinsX();
  const int nbinsY = h2D_MCCorrY_PR->GetNbinsY();
	cout << "nbinsX = " << nbinsX << ", nbinsY = " << nbinsY << endl;
  if (nbinsX != nRap) { cout << " *** Error!!! nbinsX != nRap"; return 0; };
  if (nbinsY != nPt) { cout << " *** Error!!! nbinsY != nPt"; return 0; };
  
  // ---  projection to 1D hist
  TH1D* h1D_MCCorrY_PR[nbinsX]; 
  TH1D* h1D_MCCorrY_NP[nbinsX]; 
  TH1D* h1D_Acc_Den_PR[nbinsX]; 
  TH1D* h1D_Acc_Den_NP[nbinsX]; 
  // iy=0 refers to forwards !!! (ordering here)
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    if (isPA==0){
      h1D_MCCorrY_PR[iy] = h2D_MCCorrY_PR->ProjectionY(Form("h1D_MCCorrY_PR_%d",iy),nbinsX-iy,nbinsX-iy);
      h1D_MCCorrY_NP[iy] = h2D_MCCorrY_NP->ProjectionY(Form("h1D_MCCorrY_NP_%d",iy),nbinsX-iy,nbinsX-iy);
      h1D_Acc_Den_PR[iy] = h2D_Acc_Den_PR->ProjectionY(Form("h1D_Acc_Den_PR_%d",iy),nbinsX-iy,nbinsX-iy);
      h1D_Acc_Den_NP[iy] = h2D_Acc_Den_NP->ProjectionY(Form("h1D_Acc_Den_NP_%d",iy),nbinsX-iy,nbinsX-iy);
    } else {
      h1D_MCCorrY_PR[iy] = h2D_MCCorrY_PR->ProjectionY(Form("h1D_MCCorrY_PR_%d",iy),iy+1,iy+1);
      h1D_MCCorrY_NP[iy] = h2D_MCCorrY_NP->ProjectionY(Form("h1D_MCCorrY_NP_%d",iy),iy+1,iy+1);
      h1D_Acc_Den_PR[iy] = h2D_Acc_Den_PR->ProjectionY(Form("h1D_Acc_Den_PR_%d",iy),iy+1,iy+1);
      h1D_Acc_Den_NP[iy] = h2D_Acc_Den_NP->ProjectionY(Form("h1D_Acc_Den_NP_%d",iy),iy+1,iy+1);
    }
  }

  //////////////////////////////////////////////////////////////////////////////////////
  //////////////////////////////////////////////////////////////////////////////////////
  
  //// set values as zero for unused bins
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    if (iy>=1 && iy<=6) {
      h1D_MCCorrY_PR[iy]->SetBinContent(1,0);
      h1D_MCCorrY_NP[iy]->SetBinContent(1,0);
      h1D_MCCorrY_PR[iy]->SetBinError(1,0);
      h1D_MCCorrY_NP[iy]->SetBinError(1,0);
      h1D_MCCorrY_PR[iy]->SetBinContent(2,0);
      h1D_MCCorrY_NP[iy]->SetBinContent(2,0);
      h1D_MCCorrY_PR[iy]->SetBinError(2,0);
      h1D_MCCorrY_NP[iy]->SetBinError(2,0);
      h1D_Acc_Den_PR[iy]->SetBinContent(1,0);
      h1D_Acc_Den_NP[iy]->SetBinContent(1,0);
      h1D_Acc_Den_PR[iy]->SetBinError(1,0);
      h1D_Acc_Den_NP[iy]->SetBinError(1,0);
      h1D_Acc_Den_PR[iy]->SetBinContent(2,0);
      h1D_Acc_Den_NP[iy]->SetBinContent(2,0);
      h1D_Acc_Den_PR[iy]->SetBinError(2,0);
      h1D_Acc_Den_NP[iy]->SetBinError(2,0);
    }
    if (iy>=2 && iy<=5) {
      h1D_MCCorrY_PR[iy]->SetBinContent(3,0);
      h1D_MCCorrY_NP[iy]->SetBinContent(3,0);
      h1D_MCCorrY_PR[iy]->SetBinError(3,0);
      h1D_MCCorrY_NP[iy]->SetBinError(3,0);
      h1D_Acc_Den_PR[iy]->SetBinContent(3,0);
      h1D_Acc_Den_NP[iy]->SetBinContent(3,0);
      h1D_Acc_Den_PR[iy]->SetBinError(3,0);
      h1D_Acc_Den_NP[iy]->SetBinError(3,0);
    }
    if (isPA ==0){ //for_pp 
      if (iy>=2 && iy<=5) { 
        h1D_MCCorrY_PR[iy]->SetBinContent(4,0);
        h1D_MCCorrY_NP[iy]->SetBinContent(4,0);
        h1D_MCCorrY_PR[iy]->SetBinError(4,0);
        h1D_MCCorrY_NP[iy]->SetBinError(4,0);
        h1D_Acc_Den_PR[iy]->SetBinContent(4,0);
        h1D_Acc_Den_NP[iy]->SetBinContent(4,0);
        h1D_Acc_Den_PR[iy]->SetBinError(4,0);
        h1D_Acc_Den_NP[iy]->SetBinError(4,0);
      }
    }
    else {
      if (iy>=2 && iy<=4) { // for_pA
        h1D_MCCorrY_PR[iy]->SetBinContent(4,0);
        h1D_MCCorrY_NP[iy]->SetBinContent(4,0);
        h1D_MCCorrY_PR[iy]->SetBinError(4,0);
        h1D_MCCorrY_NP[iy]->SetBinError(4,0);
        h1D_Acc_Den_PR[iy]->SetBinContent(4,0);
        h1D_Acc_Den_NP[iy]->SetBinContent(4,0);
        h1D_Acc_Den_PR[iy]->SetBinError(4,0);
        h1D_Acc_Den_NP[iy]->SetBinError(4,0);
      }
    }
  }
  
  ////// after zero-bin setting, normalize!
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    h1D_MCCorrY_PR[iy]->Scale(1./h1D_MCCorrY_PR[iy]->Integral());
    h1D_MCCorrY_NP[iy]->Scale(1./h1D_MCCorrY_NP[iy]->Integral());
    h1D_Acc_Den_PR[iy]->Scale(1./h1D_Acc_Den_PR[iy]->Integral());
    h1D_Acc_Den_NP[iy]->Scale(1./h1D_Acc_Den_NP[iy]->Integral());
    h1D_MCCorrY_PR[iy]->Scale(1,"width");
    h1D_MCCorrY_NP[iy]->Scale(1,"width");
    h1D_Acc_Den_PR[iy]->Scale(1,"width");
    h1D_Acc_Den_NP[iy]->Scale(1,"width");
  }
  
  // hRatio
  TH1D* hRatio_PR[nRap];
  TH1D* hRatio_NP[nRap];
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    hRatio_PR[iy]=(TH1D*)h1D_MCCorrY_PR[iy]->Clone(Form("hRatio_PR_%d",iy));
    hRatio_PR[iy]->Divide(h1D_Acc_Den_PR[iy]);
    hRatio_NP[iy]=(TH1D*)h1D_MCCorrY_NP[iy]->Clone(Form("hRatio_NP_%d",iy));
    hRatio_NP[iy]->Divide(h1D_Acc_Den_NP[iy]);
  }

  //////////////////////////////////////////////////////////////////
  //// --- Draw histograms
  
  TLegend *legUR = new TLegend(0.45, 0.75, 0.86, 0.92);
  SetLegendStyle(legUR);
  
  TLatex* latex = new TLatex();
  latex->SetNDC();
  latex->SetTextAlign(12);
  latex->SetTextSize(0.04);

  ///// prompt
  TCanvas* c_PR_01 = new TCanvas("c_PR_01","c_PR_01",1600,800);
  c_PR_01->Divide(4,2);
  
  TGraphAsymmErrors* g_MCCorrY_PR[nbinsX];
  TGraphAsymmErrors* g_Acc_Den_PR[nbinsX];
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    c_PR_01->cd(iy+1);
    if (isLog) gPad->SetLogy(1);
    else gPad->SetLogy(0);
    g_MCCorrY_PR[iy]=new TGraphAsymmErrors(h1D_MCCorrY_PR[iy]);
    g_Acc_Den_PR[iy]=new TGraphAsymmErrors(h1D_Acc_Den_PR[iy]);
    SetGraphStyle(g_MCCorrY_PR[iy],1,0);
    SetGraphStyle(g_Acc_Den_PR[iy],2,10);
    g_MCCorrY_PR[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    g_MCCorrY_PR[iy]->GetXaxis()->CenterTitle();
    g_MCCorrY_PR[iy]->GetXaxis()->SetLimits(0.,30.);
    g_MCCorrY_PR[iy]->GetYaxis()->SetTitle("");
    g_MCCorrY_PR[iy]->Draw("ap");
    g_Acc_Den_PR[iy]->Draw("p");
    if (iy==0) {
      legUR -> SetHeader(Form("%s Prompt J/#psi",szPA.Data()));
      legUR -> AddEntry(h1D_MCCorrY_PR[iy],"RECO/(Acc*Eff)","lp");
      legUR -> AddEntry(h1D_Acc_Den_PR[iy],"GEN","lp");
      legUR->Draw();
    }
    latex->DrawLatex(0.46,0.68,Form("%s",rapArr[iy].c_str()));
  }
  c_PR_01->SaveAs(Form("dir_closure/%s_PR_differential_isLog%d.pdf",szPA.Data(),(int)isLog));
  
  ///// non-prompt
  TCanvas* c_NP_01 = new TCanvas("c_NP_01","c_NP_01",1600,800);
  c_NP_01->Divide(4,2);
  
  TGraphAsymmErrors* g_MCCorrY_NP[nbinsX];
  TGraphAsymmErrors* g_Acc_Den_NP[nbinsX];
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    c_NP_01->cd(iy+1);
    if (isLog) gPad->SetLogy(1);
    else gPad->SetLogy(0);
    g_MCCorrY_NP[iy]=new TGraphAsymmErrors(h1D_MCCorrY_NP[iy]);
    g_Acc_Den_NP[iy]=new TGraphAsymmErrors(h1D_Acc_Den_NP[iy]);
    SetGraphStyle(g_MCCorrY_NP[iy],1,0);
    SetGraphStyle(g_Acc_Den_NP[iy],2,10);
    g_MCCorrY_NP[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    g_MCCorrY_NP[iy]->GetXaxis()->CenterTitle();
    g_MCCorrY_NP[iy]->GetXaxis()->SetLimits(0.,30.);
    g_MCCorrY_NP[iy]->GetYaxis()->SetTitle("");
    g_MCCorrY_NP[iy]->Draw("ap");
    g_Acc_Den_NP[iy]->Draw("p");
    if (iy==0) {
      legUR -> SetHeader(Form("%s Non-prompt J/#psi",szPA.Data()));
      legUR->Draw();
    }
    latex->DrawLatex(0.46,0.68,Form("%s",rapArr[iy].c_str()));
  }
  c_NP_01->SaveAs(Form("dir_closure/%s_NP_differential_isLog%d.pdf",szPA.Data(),(int)isLog));
  
  //////////////////////////////////////////////////////////////////
  //// ratio
  //////////////////////////////////////////////////////////////////
  
  ///// prompt
  TCanvas* c_PR_02 = new TCanvas("c_PR_02","c_PR_02",1600,800);
  c_PR_02->Divide(4,2);
  
  TGraphAsymmErrors* gRatio_PR[nbinsX];
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    c_PR_02->cd(iy+1);
    gPad->SetLogy(0);
    gRatio_PR[iy]=new TGraphAsymmErrors(hRatio_PR[iy]);
    SetGraphStyle(gRatio_PR[iy],1,0);
    gRatio_PR[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    gRatio_PR[iy]->GetYaxis()->SetTitle("corrected RECO / GEN");
    gRatio_PR[iy]->GetXaxis()->SetLimits(0.,30.);
    gRatio_PR[iy]->GetYaxis()->SetRangeUser(0.5,1.5);
    gRatio_PR[iy]->Draw("ap");
    latex->DrawLatex(0.56,0.88,Form("%s",rapArr[iy].c_str()));
    dashedLine(0.,1.,30.,1.,1,1);
  }
  c_PR_02->SaveAs(Form("dir_closure/%s_PR_differential_ratio.pdf",szPA.Data()));
  
  // --- non-prompt pp
  TCanvas* c_NP_02 = new TCanvas("c_NP_02","c_NP_02",1600,800);
  c_NP_02->Divide(4,2);
  
  TGraphAsymmErrors* gRatio_NP[nbinsX];
  for (Int_t iy = 0; iy < nbinsX; iy++) {
    c_NP_02->cd(iy+1);
    gPad->SetLogy(0);
    gRatio_NP[iy]=new TGraphAsymmErrors(hRatio_NP[iy]);
    SetGraphStyle(gRatio_NP[iy],1,0);
    gRatio_NP[iy]->GetXaxis()->SetTitle("p_{T} (GeV/c)");
    gRatio_NP[iy]->GetYaxis()->SetTitle("corrected RECO / GEN");
    gRatio_NP[iy]->GetXaxis()->SetLimits(0.,30.);
    gRatio_NP[iy]->GetYaxis()->SetRangeUser(0.5,1.5);
    gRatio_NP[iy]->Draw("ap");
    latex->DrawLatex(0.56,0.88,Form("%s",rapArr[iy].c_str()));
    dashedLine(0.,1.,30.,1.,1,1);
  }
  c_NP_02->SaveAs(Form("dir_closure/%s_NP_differential_ratio.pdf",szPA.Data()));
  
  return 0;

} // end of main func.
Beispiel #9
0
void DrawPlots(TString fn="rootplots/ttbar_partonLevel_histos_"+run+".root") {
  TFile *f = TFile::Open(fn);
  if (f==NULL) fatal("Cannot open file "+fn);
  
  TString pdf("Pdfs/top_plot_"+run+".pdf");
  c = new TCanvas();

  c->Print(pdf+"[");

  //divide canvas into quadrants
    c->Divide(2,2);

    TLatex tex; tex.SetNDC();
    tex.DrawLatex(0.35,0.49,"Leptonic pseudotop");
    c->cd(1); GetHisto(f,"pseudo_mass_matched")->Draw("e1");
    c->Update();

    c->cd(2); GetHisto(f,"pseudo_mass_unmatched")->Draw("e1");
    c->Update();

    c->cd(3); GetHisto(f,"pseudo_pt_matched")->Draw("e1 ");
    c->Update();

    c->cd(4); GetHisto(f,"pseudo_pt_unmatched") ->Draw("e1 ");
    c->Print(pdf);



    c->cd(1); GetHisto(f,"pseudo_eta_matched")->Draw("e1 ");
    c->Update();

    c->cd(2); GetHisto(f,"pseudo_eta_unmatched")->Draw("e1 ");

    c->Update();

    c->cd(3); GetHisto(f,"whadronic")->Draw("e1 y+ ");
    c->Update();

    c->cd(4); GetHisto(f,"wleptonic")->Draw("e1");
    c->Print(pdf);


    c->cd(1); GetHisto(f,"m_top")->Draw("e1");

    c->cd(2); GetHisto(f,"eta_top")->Draw("e1 c ");

    c->cd(3); GetHisto(f,"pt_top") ->Draw("e1 ");

    c->cd(4); GetHisto(f,"y_top")->Draw("e1 ");
    c->Print(pdf);



    c->cd(1); GetHisto(f,"eff_vs_topPt")->Draw("e1 ");

    c->cd(2); GetHisto(f,"neff_vs_topPt")->Draw("e1  ");

    c->cd(3); GetHisto(f,"eff_vs_topMass") ->Draw("e1 ");

    c->cd(4); GetHisto(f,"eff_vs_topeta") ->Draw("e1");
    c->Print(pdf);


    c->cd(1); GetHisto(f,"pseudo_btop_mass")->Draw("e1 ");

    c->cd(2); GetHisto(f,"pseudo_HW_top")->Draw("e1 ");

    c->cd(3); GetHisto(f,"pseudb")->Draw("e1");

    c->cd(4); GetHisto(f,"eff_vs_bmass")->Draw("e1");
    c->Print(pdf);

    c->Print(pdf+"]");


  }
Beispiel #10
0
/** 
 * Draw energy loss fits to a multi-page PDF. 
 *
 * @par Input: 
 * The input file is expected to contain a AliFMDCorrELossFit object
 * named @c elossfits in the top level directory.
 * 
 * @par Output: 
 * A multi-page PDF.  Note, that the PDF generated by ROOT in this way
 * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
 * and one should pass it through a filter to correct these problems.
 * 
 * @param fname   File name 
 * @param option  Drawing options 
 *
 * @ingroup pwglf_forward_scripts_corr
 */
void
DrawCorrVtxBias(const char* fname, const char* option="colz")
{
  //__________________________________________________________________
  // Load libraries and object 
  gROOT->Macro("$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");

  TFile* file = TFile::Open(fname, "READ");
  if (!file) { 
    Error("DrawCorrVtxBias", "Failed to open %s", fname);
    return;
  }
  TString pname(fname);
  pname.ReplaceAll(".root", ".pdf");

  const char* objName = 
    AliForwardCorrectionManager::Instance()
    .GetObjectName(AliForwardCorrectionManager::kVertexBias);
  AliFMDCorrVertexBias* corr = 
    static_cast<AliFMDCorrVertexBias*>(file->Get(objName));
  if (!corr) { 
    Error("DrawCorrVtxBias", "Object '%s' not found in %s", objName, fname);
    return;
  }

  //__________________________________________________________________
  // Create a canvas
  TCanvas* c = new TCanvas("c", "c", 800 / TMath::Sqrt(2), 800);
  c->SetFillColor(0);
  c->SetBorderSize(0);
  c->SetBorderMode(0);
  c->Print(Form("%s[", pname.Data()));
  
  gStyle->SetOptStat(0);
  gStyle->SetTitleColor(0);
  gStyle->SetTitleStyle(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleX(.1);
  gStyle->SetTitleY(1);
  gStyle->SetTitleW(.8);
  gStyle->SetTitleH(.09);
  gStyle->SetFrameFillColor(kWhite);
  gStyle->SetFrameBorderSize(1);
  gStyle->SetFrameBorderMode(1);
  gStyle->SetPalette(1);

  ClearCanvas(c);
  //__________________________________________________________________
  // Create a title page 
  TLatex* ll = new TLatex(.5,.8, fname);
  ll->SetTextAlign(22);
  ll->SetTextSize(0.03);
  ll->SetNDC();
  ll->Draw();

  TLatex* l = new TLatex(.5,.8, fname);
  l->SetNDC();
  l->SetTextSize(0.03);
  l->SetTextFont(132);
  l->SetTextAlign(12);
  l->DrawLatex(0.2, 0.70, "Vertex Bias Corrections");
  l->SetTextAlign(22);
  l->DrawLatex(0.5, 0.60,  "c_{v}(#eta,#phi)=#frac{1/N_{t}}{1/N_{v}}"
	       "#sum_{i}^{N_{tv}}N_{ch,i}(#eta,#phi) / "
	       "#sum_{i}^{N_{v}}N_{ch,i}(#eta,#phi)");
  l->SetTextAlign(12);
  l->DrawLatex(0.2, 0.50, "N_{t}: Number of events w/triggers");
  l->DrawLatex(0.2, 0.45, "N_{v}: Number of events w/vertex");
  l->DrawLatex(0.2, 0.40, "N_{tv}: Number of events w/trigger and vertex");
  l->DrawLatex(0.2, 0.35, "N_{ch,i}(#eta,#phi): Number of charged, "
	       "particles in (#eta,#phi) bin");
  l->DrawLatex(0.2, 0.30, "All quantities determined in MC");
  
  c->Print(pname.Data(), "Title:Title page");

  ClearCanvas(c);

  //__________________________________________________________________
  // Draw all corrections
  const TAxis& vtxAxis = corr->GetVertexAxis();
  Int_t        nVtx    = vtxAxis.GetNbins();
  UShort_t     nQ      = 2;
  UShort_t     d       = 0;
  for (UShort_t q = 0; q < nQ; q++) { 
    Char_t r = (q == 0 ? 'I' : 'O');

    ClearCanvas(c);
    c->Divide(2, (nVtx+1)/2);
    for (UShort_t v=1; v <= nVtx; v++) { 
      TVirtualPad* p = c->cd(v);
      
      
      TH2* h1 = corr->GetCorrection(r, v);
      if (!h1) { 
	Warning("DrawCorrVtxBias", "No correction for r=%c, v=%d", r, v);
	continue;
      }
      h1->Draw(option);
    }
    c->Print(pname.Data(), Form("Title:FMDX%c", r));
  }

  //__________________________________________________________________
  // Close output file 
  c->Print(Form("%s]", pname.Data()));
}
Beispiel #11
0
void replotSimpleMpT(){

   string type = "Embed";
   string ajLabel[3] = {"ALL","A_{J} > 0.24","A_{J} < 0.24"};
   int version = 0;
   int ajindex = 0;

   TH1::SetDefaultSumw2();
   //   int color[10] = {1,kGray,kBlue-3,38,kOrange-8,kRed-6,8,9,2};
   int color[10] = {1,1,kBlue-3,38,kOrange-8,kRed-6,8,9,2};

   string fname;

   if(type == "DATA"){
      fname = "data_cutOnly_05.root";
   }
   if(type == "Pythia"){
      fname = "pythia_cutOnly_05.root";
   }
   if(type == "Embed"){
      fname = "embed_cutOnly_05.root";
   }

   TFile* inf =  new TFile(fname.data());

   TH1D* h[10][20];
   TH1D* hx[10][20];
   TH1D* hy[10][20];
   TH1D* hwx[10][20];
   TH1D* hwy[10][20];

   bool upperBounded = false;

   int rebin = 4;
   int nHbins = 20;
   int nPtBins = 5;   
   double trackPtMin[20] = {0.5,0.5,1.5,4,8.,20};
   double trackPtMax[20] = {500,1.5,4,8.,20,500};

   TGraphErrors* g = new TGraphErrors(nPtBins);
   g->SetMarkerColor(1);
   g->SetMarkerStyle(20);
   g->SetMarkerSize(1.5);

   for(int j = 0; j < 5; j++){
      for(int i = 0; i < nPtBins; i++){

	 h[j][i] = (TH1D*)inf->Get(Form("h%d_%d",j,i));
	 h[j][i]->SetLineColor(color[i]);
	 h[j][i]->SetMarkerColor(color[i]);

	 hx[j][i] = (TH1D*)inf->Get(Form("hx%d_%d",j,i));
         hx[j][i]->SetLineColor(color[i]);
         hx[j][i]->SetMarkerColor(color[i]);

	 hy[j][i] = (TH1D*)inf->Get(Form("hy%d_%d",j,i));
         hy[j][i]->SetLineColor(color[i]);
         hy[j][i]->SetMarkerColor(color[i]);

	 hwx[j][i] = (TH1D*)inf->Get(Form("hwx%d_%d",j,i));
         hwx[j][i]->SetLineColor(color[i]);
         hwx[j][i]->SetMarkerColor(color[i]);

	 hwy[j][i] = (TH1D*)inf->Get(Form("hwy%d_%d",j,i));
         hwy[j][i]->SetLineColor(color[i]);
         hwy[j][i]->SetMarkerColor(color[i]);

	 hy[j][i]->SetTitle(";#slash{p}_{T}^{#perp} (GeV/c);Event Fraction");
	 hy[j][i]->GetXaxis()->CenterTitle();
         hy[j][i]->GetYaxis()->CenterTitle();
         hx[j][i]->SetTitle(";#slash{p}_{T}^{#parallel} (GeV/c);Event Fraction");

	 hx[j][i]->GetXaxis()->CenterTitle();
         hx[j][i]->GetYaxis()->CenterTitle();

	 hy[j][i]->Rebin(rebin);
         hy[j][i]->SetMarkerSize(0);
         hy[j][i]->SetLineWidth(2.);

	 hx[j][i]->Rebin(rebin);
         hx[j][i]->SetMarkerSize(0);
         hx[j][i]->SetLineWidth(2.);

	 if(hx[j][i]->Integral() > 0) hx[j][i]->Scale(1./hx[j][i]->Integral());
         if(hy[j][i]->Integral() > 0) hy[j][i]->Scale(1./hy[j][i]->Integral());
	 

	 //	 hx[j][i]->Fit("gaus");
         if(hx[j][i]->GetFunction("gaus"))hx[j][i]->GetFunction("gaus")->SetLineColor(color[i]);

      }
   }

   TLegend *leg=new TLegend(0.67,0.64,0.91,0.93);
   leg->SetFillColor(0);
   leg->SetBorderSize(0);
   leg->SetFillStyle(0);
   leg->SetTextFont(63);
   leg->SetTextSize(15);
   for(int i = 0; i < nPtBins; ++i){
      if(upperBounded){
         leg->AddEntry(hx[ajindex][i],Form("%0.1f<p_{T}^{Track}<%0.1f GeV/c",trackPtMin[i],trackPtMax[i]),"pl");
      }else if(i > 0){
         leg->AddEntry(hx[ajindex][i],Form("p_{T}^{Track}>%0.1f GeV/c",trackPtMin[i]),"pl");
      }
   }

   for(int i = 0; i < nPtBins; i++){
      g->SetPoint(i,hx[ajindex][i]->GetMean(),i);
      g->SetPointError(i,hx[ajindex][i]->GetMeanError(),0);
   }


   TCanvas* c3 = new TCanvas("c3","",600,600);
   c3->SetLogy();

   hx[ajindex][(int)(nPtBins-1)]->SetMaximum(520);
   hx[ajindex][(int)(nPtBins-1)]->Draw();
   for(int i = 0; i < nPtBins; ++i){
      hx[ajindex][i]->Draw("same");
      hx[ajindex][i]->Draw("same hist");
   }
   leg->Draw();

   TLatex *cms = new TLatex(0.2,0.88,"CMS");
   TLatex *snn = new TLatex(0.2,0.80,"PbPb #sqrt{s}_{_{NN}}=2.76 TeV");
   TLatex *lum = new TLatex(0.2,0.72,"#intL dt = 6.7 #mub^{-1}");
   TLatex *cent = new TLatex(0.2,0.64,"0-30%");
   if(ajindex > 0){
      TLatex *ajtxt = new TLatex(0.2,0.56,ajLabel[ajindex].data());
      ajtxt->SetNDC();
      ajtxt->SetTextFont(63);
      ajtxt->SetTextSize(22);
   }

   TLatex *pythia = new TLatex(0.2,0.88,"PYTHIA");
   TLatex *embedded = new TLatex(0.2,0.88,"Hydjet+PYTHIA");

   cms->SetNDC();
   cms->SetTextFont(63);
   cms->SetTextSize(22);
   snn->SetNDC();
   snn->SetTextFont(63);
   snn->SetTextSize(22);
   lum->SetNDC();
   lum->SetTextFont(63);
   lum->SetTextSize(22);
   cent->SetNDC();
   cent->SetTextFont(63);
   cent->SetTextSize(22);
   pythia->SetNDC();
   pythia->SetTextFont(63);
   pythia->SetTextSize(22);
   embedded->SetNDC();
   embedded->SetTextFont(63);
   embedded->SetTextSize(22);

   if(type == "DATA"){
      cms->Draw();
      snn->Draw();
      lum->Draw();
      cent->Draw();
   }
   if(type == "Pythia"){
      pythia->Draw();
   }
   if(type == "Embed"){
      embedded->Draw();
      cent->Draw();
   }
   if(ajindex > 0){
   ajtxt->Draw();
   }

   c3->Print(Form("MpTpllEvtByEvt_%d_%s_%d.gif",ajindex,type.data(),version));
   c3->Print(Form("MpTpllEvtByEvt_%d_%s_%d.eps",ajindex,type.data(),version));
   c3->Print(Form("MpTpllEvtByEvt_%d_%s_%d.C",ajindex,type.data(),version));

   TCanvas* c4 = new TCanvas("c4","",600,600);
   c4->SetLogy();
   hy[ajindex][nPtBins-1]->SetMaximum(520);
   hy[ajindex][nPtBins-1]->Draw();
   for(int i = 0; i < nPtBins; ++i){
      hy[ajindex][i]->Draw("same");
      hy[ajindex][i]->Draw("same hist");
   }
   leg->Draw();

   if(type == "DATA"){
      cms->Draw();
      snn->Draw();
      lum->Draw();
      cent->Draw();
   }
   if(type == "Pythia"){
      pythia->Draw();
   }
   if(type == "Embed"){
      embedded->Draw();
      cent->Draw();
   }
   if(ajindex > 0){
   ajtxt->Draw();
   }

   c4->Print(Form("MpTtrsEvtByEvt_%d_%s_%d.gif",ajindex,type.data(),version));
   c4->Print(Form("MpTtrsEvtByEvt_%d_%s_%d.eps",ajindex,type.data(),version));
   c4->Print(Form("MpTtrsEvtByEvt_%d_%s_%d.C",ajindex,type.data(),version));

}
void Control_all_cut_limit_auto()
{

const float intLumi = 3.0;
const int n_cut_index =11; // 10

  TString variable_name = "Ele_1st_pt" ;
  cout<<"variable_name: " << variable_name << endl;

  // define cuts
  
  int cut_value[n_cut_index];
  double lowest_cut=435 ;
  double scan_width = 20;// 21

  for(int i=0;i<n_cut_index ;i++){
        cut_value[i] = lowest_cut + scan_width*i;
        cout<<"cut_value[i]: "<< cut_value[i] << endl;
  }
  //

//int cut_value[n_cut_index] = 
//{115,136,157,178,199,220,241,262,283,304};

  TGraphAsymmErrors *grmedian_cls;
  TGraphAsymmErrors *grmedian_cls_new[n_cut_index];

  const int nMassEff = 11;  // # of mass point
  double mass[nMassEff] = {0};
  double medianD[nMassEff] = {0};


  grmedian_cls = new TGraphAsymmErrors(nMassEff, mass, medianD);


//  TString dir_path = "Datacards_txt_files/YuHsiang_DY_h_ele_1st_pT_cut_115/";
  TString dir_path[n_cut_index] ;
  TString leg_name[n_cut_index] ;

  int nXm = nMassEff; 

  for(int i=0;i<n_cut_index;i++){
//  for(int i=0;i<5;i++){
  dir_path[i] = Form("YuHsiang_DY_Ele_1st_pt_cut_%d/",cut_value[i] ) ;
//  dir_path[i] = Form("YuHsiang_DY_h_ele_1st_pT_cut_%d/",cut_value[i] ) ;
  dir_path[i] = "Datacards_text_and_ROOT_files/" + dir_path[i];
//  dir_path[i] = "Datacards_txt_files/" + dir_path[i];

//  if(cut_value[i]==515) {nXm = 10;}
//  if(cut_value[i]==615) {nXm = 10;}// lost M800
//  if(cut_value[i]==715) {nXm = 10;}// lost M800
//  if(cut_value[i]==815) {nXm = 8;}
//  if(cut_value[i]==915) {nXm = 8;}
//  if(cut_value[i]==1015) {nXm = 8;}
  if(cut_value[i]==515 || cut_value[i]==535 || cut_value[i]==555) {nXm = 10;}// lost M800
  if(cut_value[i]==575 || cut_value[i]==595 || cut_value[i]==615) {nXm = 10;}// lost M800
  if(cut_value[i]==635 ) {nXm = 10;}// lost M800
  if(cut_value[i]==835) {nXm = 8;}// lost M800, M1000, M1200


  cout<<endl;
  cout<<"dir_path[i]: "<< dir_path[i] <<" cut_value[i]: "<< cut_value[i]<<" nXm: "<< nXm <<endl;
  cout<<endl;


  grmedian_cls_new[i] =  plot_Asymptotic( dir_path[i] ,grmedian_cls, nXm );

//  leg_name[i] = Form("CL_{S} Expected Limit for cut pt>%d",cut_value[i] ) ;
  leg_name[i] = Form("cut pt>%d",cut_value[i] ) ;
  }





  TCanvas *c1 = new TCanvas("c1", "canvas with limits for Asymptotic CLs", 630, 600);


  TLegend *leg = new TLegend(.75, .35, 1., .85);
  leg->SetFillColor(0);
  leg->SetShadowColor(0);
  leg->SetTextFont(42);
  leg->SetTextSize(0.03);

  c1->SetGridx(1);
  c1->SetGridy(1);
    gPad->SetLogy();


  
  c1->cd();

//   double fr_left = 500.0, fr_down = 5E-2, fr_right = 4500.0, fr_up = 3E2;
//   double fr_left = 500.0, fr_down = 2E-1, fr_right = 1500.0, fr_up = 7E-1;
//   double fr_left = 1800.0, fr_down = 1.1E-1, fr_right = 2200.0, fr_up = 1.5E-1;
   double fr_left = 2800.0, fr_down = 1E-1, fr_right = 3200.0, fr_up = 1.1E-1;
  TH1F *hr = c1->DrawFrame(fr_left, fr_down, fr_right, fr_up, "");

  int colorN = 1;

// loop

  for(int i=0;i<n_cut_index;i++){

        if (i==0){colorN = kRed;}
        if (i==2){colorN = kOrange;}
        if (i==4){colorN = kCyan;}
        if (i==6){colorN = kBlue;}
        if (i==8){colorN = kGreen;}
	
  	grmedian_cls_new[i]->SetLineColor(colorN);
        grmedian_cls_new[i]->SetLineStyle(1);
  	grmedian_cls_new[i]->Draw();

//  	leg->AddEntry(grmedian_cls_new[i], "CL_{S} Expected Limit", "L");
        leg->AddEntry(grmedian_cls_new[i],leg_name[i] , "L");
  	leg->Draw();

	colorN = colorN+2;
  }
// end loop

  hr->SetXTitle("M_{Z'} [GeV]");
  hr->SetYTitle("95% #sigma_{Z'}xBR(Z'->ZH) [pb]");

    TLatex * latex = new TLatex();
    latex->SetNDC();
    latex->SetTextSize(0.04);
    latex->SetTextAlign(31);
    latex->SetTextAlign(11);

    latex->DrawLatex(0.25, 0.91, "CL_{S} Expected Limit, cut electron leading pt");
    latex->DrawLatex(0.18, 0.96, "CMS preliminary 2015");
    latex->DrawLatex(0.60, 0.96, Form("%.1f fb^{-1} at #sqrt{s} = 13 TeV", intLumi));


  TString save_name = "expected_limit_cut_";
  save_name = save_name + variable_name ;

  TString png_name = save_name + ".png";
  TString pdf_name = save_name + ".pdf";

  c1->SaveAs(png_name);
  c1->SaveAs(pdf_name);


//TString path_to_save = "/afs/cern.ch/user/y/yuchang/www/set_limit_optimize_leading_pt/" ;
TString path_to_save = "/afs/cern.ch/user/y/yuchang/www/optimize_cut_with_limit_use_eleIsPassLoose/leading_pt/" ;
pdf_name = path_to_save + pdf_name;

c1->SaveAs( pdf_name );


}// end codes
Beispiel #13
0
void plotSingleDssFFw(TString Tag="Mass"){

  TString mfile = "AWG82/ntuples/small/semFull_RunAll.root";
  TChain semil("ntp1");
  semil.Add(mfile);

  TString limits[2], xTitle, vari;
  if(Tag=="Mass"){
    limits[0] = "(70,1.9,5)"; 
    limits[1] = "(70,2.3,2.7)";
    xTitle = "Mass [GeV]";
    vari = "trueDmass";
  } else if(Tag=="Q2"){
    limits[0] = "(50,0,9)"; 
    limits[1] = "(50,0,9)";
    xTitle = "q^{2} [GeV^2]";
    vari = "trueQ2";
  } else if(Tag=="w"){
    limits[0] = "(50,1,1.6)"; 
    limits[1] = "(50,1,1.6)";
    xTitle = "w";
    vari = "(5.279*5.279+trueDmass*trueDmass-trueQ2)/(2*5.279*trueDmass)";
  } else if(Tag=="Plep"){
    limits[0] = "(50,0,3.5)"; 
    limits[1] = "(50,0,3.5)";
    xTitle = "p_{l,lab} [GeV]";
    vari = "truePLep";
  } else {
    cout<<"Tag has to be on of {Mass, Q2, w, Plep}"<<endl;
    return;
  }

  TH1F *histo[4][2];
  TString Dnames[] = {"D*_{0} l #nu","D'_{1} l #nu","D_{1} l #nu","D*_{2} l #nu"};
  TCut modeCut[] = {"(abs(MCD)==10421||abs(MCD)==10411)","(abs(MCD)==20423||abs(MCD)==20413)",
		    "(abs(MCD)==10423||abs(MCD)==10413)", "(abs(MCD)==425||abs(MCD)==415)"};
  TCut weird = "MCTaumode==-1&&wFF<100";
  TLatex *label = new TLatex();
  label->SetNDC(kTRUE);
  label->SetTextSize(0.08);
  TCanvas c("canvas","Comparison of D** FF weights",1000,600);
  c.Divide(2,2);
  gStyle->SetOptStat(0);
  int a=0;
  for(int i=0; i<4; i++){
    c.cd(i+1);
    TString totvari = vari; totvari += ">>h"; totvari += limits[i>1]; 
    TCut tot = modeCut[i]+weird; 
    semil.Draw(totvari,tot);
    TH1F *h = (TH1F*)gDirectory->Get("h");
    histo[i][0] = (TH1F*)h->Clone("noWeight"+i);
    tot *= "wFF";
    semil.Draw(totvari,tot);
    h = (TH1F*)gDirectory->Get("h");
    if(h) histo[i][1] = (TH1F*)h->Clone("Weight"+i);
    else{ 
      cout<<"No re-weighted histogram"<<endl;
      continue;
    }
    double ngen = histo[i][0]->Integral();
    double nsig = histo[i][1]->Integral();
    double maxi = histo[i][0]->GetMaximum();
    if(maxi<histo[i][1]->GetMaximum()) maxi = histo[i][1]->GetMaximum();

    histo[i][0]->SetMaximum(1.15*maxi);
    histo[i][0]->GetXaxis()->SetTitleOffset(.8);
    histo[i][0]->GetXaxis()->SetTitleSize(0.06);
    histo[i][0]->GetYaxis()->SetLabelSize(0.06);
    histo[i][0]->GetXaxis()->SetLabelSize(0.06);
    histo[i][0]->GetYaxis()->SetNdivisions(5+100*2);
    histo[i][0]->GetXaxis()->SetNdivisions(6+100*2);
    histo[i][0]->SetLineWidth(2);
    histo[i][0]->SetTitle("");
    histo[i][0]->SetXTitle(xTitle);
    histo[i][0]->Draw();
    histo[i][1]->SetLineWidth(2);
    histo[i][1]->SetLineColor(2);
    histo[i][1]->Draw("same");
    TString tag = Dnames[i]; 
    label->DrawLatex(.12,0.93,tag);
    TLegend *leg;
    if(0)
      leg = new TLegend(0.1,.73,0.43,0.9);
    else
      leg = new TLegend(0.59,.73,0.9,0.9);
    leg->SetTextSize(0.058);
    leg->SetFillColor(0);
    TString legtag = "ISGW2 ("; legtag+=round(ngen,0); legtag+=")";
    leg->AddEntry(histo[i][0],legtag);
    legtag = "LLSW ("; legtag+=round(nsig,0); legtag+=")";
    leg->AddEntry(histo[i][1],legtag);
    leg->Draw();
  }
  c.SaveAs("babar_code/eps/DssFFWeight_"+Tag+".eps");
}
Beispiel #14
0
void limit()
{
//=========Macro generated from canvas: limit/limit
//=========  (Thu Apr 27 14:38:33 2017) by ROOT version6.02/05
   TCanvas *limit = new TCanvas("limit", "limit",0,0,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   limit->SetHighLightColor(2);
   limit->Range(0,0,1,1);
   limit->SetFillColor(0);
   limit->SetBorderMode(0);
   limit->SetBorderSize(2);
   limit->SetLeftMargin(0.16);
   limit->SetRightMargin(0.04);
   limit->SetTopMargin(0.06);
   limit->SetBottomMargin(0.12);
   limit->SetFrameFillStyle(0);
   limit->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad
   TPad *pad = new TPad("pad", "pad",0,0,1,1);
   pad->Draw();
   pad->cd();
   pad->Range(-59.99999,-2.046818,1565,15.01);
   pad->SetFillColor(0);
   pad->SetBorderMode(0);
    pad->SetLogy();
   pad->SetBorderSize(2);
   pad->SetTickx(1);
   pad->SetTicky(1);
   pad->SetLeftMargin(0.16);
   pad->SetRightMargin(0.04);
   pad->SetTopMargin(0.06);
   pad->SetBottomMargin(0.12);
   pad->SetFrameFillStyle(0);
   pad->SetFrameBorderMode(0);
   pad->SetFrameFillStyle(0);
   pad->SetFrameBorderMode(0);
   
   TH1F *tmp01 = new TH1F("tmp01","Graph",100,200,1500);
   tmp01->SetMinimum(0.);
   tmp01->SetMaximum(13.98659);
   tmp01->SetStats(0);
   tmp01->SetLineStyle(0);
   tmp01->SetMarkerStyle(20);
   tmp01->GetXaxis()->SetTitle("m_{H} (GeV)");
   tmp01->GetXaxis()->SetLabelFont(42);
   tmp01->GetXaxis()->SetLabelOffset(0.01);
   tmp01->GetXaxis()->SetTitleSize(0.05);
   tmp01->GetXaxis()->SetTickLength(0.02);
   tmp01->GetXaxis()->SetTitleOffset(1.08);
   tmp01->GetXaxis()->SetTitleFont(42);
   tmp01->GetYaxis()->SetTitle("95% CL limit on #sigma/#sigma_{SM}");
   tmp01->GetYaxis()->SetLabelFont(42);
   tmp01->GetYaxis()->SetLabelOffset(0.007);
   tmp01->GetYaxis()->SetTitleSize(0.05);
   tmp01->GetYaxis()->SetTickLength(0.02);
   tmp01->GetYaxis()->SetTitleOffset(1.56);
   tmp01->GetYaxis()->SetTitleFont(42);
   tmp01->GetZaxis()->SetLabelFont(42);
   tmp01->GetZaxis()->SetLabelOffset(0.007);
   tmp01->GetZaxis()->SetTitleSize(0.05);
   tmp01->GetZaxis()->SetTickLength(0.02);
   tmp01->GetZaxis()->SetTitleFont(42);
   tmp01->Draw("AXIS");
   
   TH1F *tmp02 = new TH1F("tmp02","Graph",100,200,1500);
   tmp02->SetMinimum(0);
   tmp02->SetMaximum(13.98659);
   tmp02->SetStats(0);
   tmp02->SetLineStyle(0);
   tmp02->SetMarkerStyle(20);
   tmp02->GetXaxis()->SetTitle("m_{H} (GeV)");
   tmp02->GetXaxis()->SetLabelFont(42);
   tmp02->GetXaxis()->SetLabelOffset(0.01);
   tmp02->GetXaxis()->SetTitleSize(0.05);
   tmp02->GetXaxis()->SetTickLength(0.02);
   tmp02->GetXaxis()->SetTitleOffset(1.08);
   tmp02->GetXaxis()->SetTitleFont(42);
   tmp02->GetYaxis()->SetTitle("95% CL limit on #sigma/#sigma_{SM}");
   tmp02->GetYaxis()->SetLabelFont(42);
   tmp02->GetYaxis()->SetLabelOffset(0.007);
   tmp02->GetYaxis()->SetTitleSize(0.05);
   tmp02->GetYaxis()->SetTickLength(0.02);
   tmp02->GetYaxis()->SetTitleOffset(1.56);
   tmp02->GetYaxis()->SetTitleFont(42);
   tmp02->GetZaxis()->SetLabelFont(42);
   tmp02->GetZaxis()->SetLabelOffset(0.007);
   tmp02->GetZaxis()->SetTitleSize(0.05);
   tmp02->GetZaxis()->SetTickLength(0.02);
   tmp02->GetZaxis()->SetTitleFont(42);
   tmp02->Draw("AXIGSAME");
   
   Double_t Graph0_fx3001[27] = {
   200,
   250,
   300,
   350,
   400,
   450,
   500,
   550,
   600,
   650,
   700,
   750,
   800,
   850,
   900,
   950,
   1000,
   1050,
   1100,
   1150,
   1200,
   1250,
   1300,
   1350,
   1400,
   1450,
   1500};
   Double_t Graph0_fy3001[27] = {
   4.796875,
   2.148438,
   0.8398438,
   0.3857422,
   0.2001953,
   0.1088867,
   0.06591797,
   0.04736328,
   0.03564453,
   0.02783203,
   0.02294922,
   0.01806641,
   0.01513672,
   0.01220703,
   0.01123047,
   0.009277344,
   0.008300781,
   0.007324219,
   0.007324219,
   0.006347656,
   0.006347656,
   0.005371094,
   0.005371094,
   0.004394531,
   0.004394531,
   0.004394531,
   0.004394531};
   Double_t Graph0_felx3001[27] = {
   4.032346e-316,
   0,
   0,
   0,
   6.906313e-310,
   4.032343e-316,
   2.121996e-314,
   4.032582e-316,
   0,
   4.032588e-316,
   4.032343e-316,
   0,
   4.032584e-316,
   1.508018e-316,
   1.508219e-316,
   4.032589e-316,
   2.124327e-314,
   4.032593e-316,
   5.582942e-322,
   6.906313e-310,
   0,
   4.032344e-316,
   4.032583e-316,
   4.032588e-316,
   1.58101e-322,
   4.032293e-316,
   5.582942e-322};
   Double_t Graph0_fely3001[27] = {
   2.370331,
   1.057434,
   0.405159,
   0.1845837,
   0.09618759,
   0.05231667,
   0.03192902,
   0.02331161,
   0.01754379,
   0.01435089,
   0.01183319,
   0.009315491,
   0.008041382,
   0.006484985,
   0.005966187,
   0.004928589,
   0.00440979,
   0.004119873,
   0.004119873,
   0.003570557,
   0.003570557,
   0.00302124,
   0.00302124,
   0.002471924,
   0.002471924,
   0.002471924,
   0.002471924};
   Double_t Graph0_fehx3001[27] = {
   4.031643e-316,
   0,
   0,
   0,
   6.906313e-310,
   4.032106e-316,
   2.121996e-314,
   4.032349e-316,
   0,
   4.032354e-316,
   4.032106e-316,
   0,
   4.032351e-316,
   1.508018e-316,
   1.508219e-316,
   4.032356e-316,
   2.124327e-314,
   4.03236e-316,
   5.582942e-322,
   6.906313e-310,
   0,
   4.032107e-316,
   4.03235e-316,
   4.032354e-316,
   1.58101e-322,
   4.032222e-316,
   5.582942e-322};
   Double_t Graph0_fehy3001[27] = {
   5.693069,
   2.47175,
   0.8989364,
   0.4081147,
   0.2108151,
   0.1170805,
   0.07362081,
   0.05438244,
   0.04146756,
   0.03243252,
   0.02825768,
   0.02361592,
   0.01990321,
   0.01752287,
   0.01712826,
   0.0153559,
   0.01456667,
   0.01341494,
   0.01192601,
   0.0124739,
   0.01149977,
   0.01055484,
   0.01051202,
   0.008670811,
   0.008670811,
   0.008635777,
   0.008635777};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(27,Graph0_fx3001,Graph0_fy3001,Graph0_felx3001,Graph0_fehx3001,Graph0_fely3001,Graph0_fehy3001);
   grae->SetName("Graph0");
   grae->SetTitle("Graph");

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#ffff00");
   grae->SetFillColor(ci);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3001 = new TH1F("Graph_Graph3001","Graph",100,70,1630);
   Graph_Graph3001->SetMinimum(0);
   Graph_Graph3001->SetMaximum(11.53875);
   Graph_Graph3001->SetDirectory(0);
   Graph_Graph3001->SetStats(0);
   Graph_Graph3001->SetLineStyle(0);
   Graph_Graph3001->SetMarkerStyle(20);
   Graph_Graph3001->GetXaxis()->SetLabelFont(42);
   Graph_Graph3001->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph3001->GetXaxis()->SetTickLength(0.02);
   Graph_Graph3001->GetXaxis()->SetTitleOffset(1.08);
   Graph_Graph3001->GetXaxis()->SetTitleFont(42);
   Graph_Graph3001->GetYaxis()->SetLabelFont(42);
   Graph_Graph3001->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3001->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph3001->GetYaxis()->SetTickLength(0.02);
   Graph_Graph3001->GetYaxis()->SetTitleOffset(1.56);
   Graph_Graph3001->GetYaxis()->SetTitleFont(42);
   Graph_Graph3001->GetZaxis()->SetLabelFont(42);
   Graph_Graph3001->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3001->GetZaxis()->SetTitleSize(0.05);
   Graph_Graph3001->GetZaxis()->SetTickLength(0.02);
   Graph_Graph3001->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3001);
   
   grae->Draw("3");
   
   Double_t Graph1_fx3002[27] = {
   200,
   250,
   300,
   350,
   400,
   450,
   500,
   550,
   600,
   650,
   700,
   750,
   800,
   850,
   900,
   950,
   1000,
   1050,
   1100,
   1150,
   1200,
   1250,
   1300,
   1350,
   1400,
   1450,
   1500};
   Double_t Graph1_fy3002[27] = {
   4.796875,
   2.148438,
   0.8398438,
   0.3857422,
   0.2001953,
   0.1088867,
   0.06591797,
   0.04736328,
   0.03564453,
   0.02783203,
   0.02294922,
   0.01806641,
   0.01513672,
   0.01220703,
   0.01123047,
   0.009277344,
   0.008300781,
   0.007324219,
   0.007324219,
   0.006347656,
   0.006347656,
   0.005371094,
   0.005371094,
   0.004394531,
   0.004394531,
   0.004394531,
   0.004394531};
   Double_t Graph1_felx3002[27] = {
   4.028644e-316,
   2.608667e-321,
   4.022558e-316,
   0,
   2.420922e-322,
   4.028601e-316,
   0,
   2.11372e-314,
   0,
   4.940656e-323,
   8.744962e-322,
   0,
   0,
   4.940656e-323,
   0,
   6.906314e-310,
   5.33769e+160,
   0,
   4.021573e-316,
   6.906314e-310,
   0,
   1.188318e-312,
   4.027998e-316,
   0,
   1.58101e-322,
   4.027629e-316,
   1.630417e-322};
   Double_t Graph1_fely3002[27] = {
   1.490716,
   0.6650269,
   0.2516418,
   0.1146438,
   0.05974151,
   0.03228919,
   0.01945674,
   0.01420552,
   0.01069075,
   0.009417772,
   0.007765532,
   0.006113291,
   0.005277157,
   0.003647804,
   0.00335598,
   0.002772331,
   0.002480507,
   0.002317429,
   0.002832413,
   0.002231598,
   0.002231598,
   0.001888275,
   0.001888275,
   0.001544952,
   0.001544952,
   0.001544952,
   0.002162933};
   Double_t Graph1_fehx3002[27] = {
   1.179415e-312,
   2.608667e-321,
   4.022558e-316,
   0,
   2.420922e-322,
   4.028634e-316,
   0,
   2.113722e-314,
   0,
   4.940656e-323,
   8.744962e-322,
   0,
   0,
   4.940656e-323,
   0,
   6.906314e-310,
   2.139459e+161,
   0,
   4.021573e-316,
   6.906314e-310,
   0,
   1.188318e-312,
   4.027998e-316,
   0,
   1.58101e-322,
   4.027675e-316,
   1.630417e-322};
   Double_t Graph1_fehy3002[27] = {
   2.351828,
   1.053343,
   0.3849801,
   0.1768222,
   0.09017253,
   0.05078118,
   0.03126747,
   0.02303264,
   0.01790216,
   0.012869,
   0.0113431,
   0.009505779,
   0.008205643,
   0.007395977,
   0.0068043,
   0.006212621,
   0.006088058,
   0.005138258,
   0.004204029,
   0.005262822,
   0.003643492,
   0.004453157,
   0.003768056,
   0.004204029,
   0.004204029,
   0.003643492,
   0.003643492};
   grae = new TGraphAsymmErrors(27,Graph1_fx3002,Graph1_fy3002,Graph1_felx3002,Graph1_fehx3002,Graph1_fely3002,Graph1_fehy3002);
   grae->SetName("Graph1");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#00ff00");
   grae->SetFillColor(ci);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3002 = new TH1F("Graph_Graph3002","Graph",100,-8.010917e+160,2.406781e+161);
   Graph_Graph3002->SetMinimum(0);
   Graph_Graph3002->SetMaximum(7.86335);
   Graph_Graph3002->SetDirectory(0);
   Graph_Graph3002->SetStats(0);
   Graph_Graph3002->SetLineStyle(0);
   Graph_Graph3002->SetMarkerStyle(20);
   Graph_Graph3002->GetXaxis()->SetLabelFont(42);
   Graph_Graph3002->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph3002->GetXaxis()->SetTickLength(0.02);
   Graph_Graph3002->GetXaxis()->SetTitleOffset(1.08);
   Graph_Graph3002->GetXaxis()->SetTitleFont(42);
   Graph_Graph3002->GetYaxis()->SetLabelFont(42);
   Graph_Graph3002->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3002->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph3002->GetYaxis()->SetTickLength(0.02);
   Graph_Graph3002->GetYaxis()->SetTitleOffset(1.56);
   Graph_Graph3002->GetYaxis()->SetTitleFont(42);
   Graph_Graph3002->GetZaxis()->SetLabelFont(42);
   Graph_Graph3002->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3002->GetZaxis()->SetTitleSize(0.05);
   Graph_Graph3002->GetZaxis()->SetTickLength(0.02);
   Graph_Graph3002->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3002);
   
   grae->Draw("3");
   
   Double_t Graph2_fx1[27] = {
   200,
   250,
   300,
   350,
   400,
   450,
   500,
   550,
   600,
   650,
   700,
   750,
   800,
   850,
   900,
   950,
   1000,
   1050,
   1100,
   1150,
   1200,
   1250,
   1300,
   1350,
   1400,
   1450,
   1500};
   Double_t Graph2_fy1[27] = {
   4.796875,
   2.148438,
   0.8398438,
   0.3857422,
   0.2001953,
   0.1088867,
   0.06591797,
   0.04736328,
   0.03564453,
   0.02783203,
   0.02294922,
   0.01806641,
   0.01513672,
   0.01220703,
   0.01123047,
   0.009277344,
   0.008300781,
   0.007324219,
   0.007324219,
   0.006347656,
   0.006347656,
   0.005371094,
   0.005371094,
   0.004394531,
   0.004394531,
   0.004394531,
   0.004394531};
   TGraph *graph = new TGraph(27,Graph2_fx1,Graph2_fy1);
   graph->SetName("Graph2");
   graph->SetTitle("Graph");
   graph->SetFillColor(1);

   ci = TColor::GetColor("#ff0000");
   graph->SetLineColor(ci);
   graph->SetLineWidth(2);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","Graph",100,70,1630);
   Graph_Graph1->SetMinimum(0);
   Graph_Graph1->SetMaximum(5.276123);
   Graph_Graph1->SetDirectory(0);
   Graph_Graph1->SetStats(0);
   Graph_Graph1->SetLineStyle(0);
   Graph_Graph1->SetMarkerStyle(20);
   Graph_Graph1->GetXaxis()->SetLabelFont(42);
   Graph_Graph1->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetXaxis()->SetTickLength(0.02);
   Graph_Graph1->GetXaxis()->SetTitleOffset(1.08);
   Graph_Graph1->GetXaxis()->SetTitleFont(42);
   Graph_Graph1->GetYaxis()->SetLabelFont(42);
   Graph_Graph1->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetYaxis()->SetTickLength(0.02);
   Graph_Graph1->GetYaxis()->SetTitleOffset(1.56);
   Graph_Graph1->GetYaxis()->SetTitleFont(42);
   Graph_Graph1->GetZaxis()->SetLabelFont(42);
   Graph_Graph1->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1->GetZaxis()->SetTitleSize(0.05);
   Graph_Graph1->GetZaxis()->SetTickLength(0.02);
   Graph_Graph1->GetZaxis()->SetTitleFont(42);
   graph->SetHistogram(Graph_Graph1);
   
   graph->Draw("l");
   
   Double_t Graph3_fx2[27] = {
   200,
   250,
   300,
   350,
   400,
   450,
   500,
   550,
   600,
   650,
   700,
   750,
   800,
   850,
   900,
   950,
   1000,
   1050,
   1100,
   1150,
   1200,
   1250,
   1300,
   1350,
   1400,
   1450,
   1500};
   Double_t Graph3_fy2[27] = {
   4.79203,
   2.152691,
   0.8377939,
   0.3861777,
   0.1995838,
   0.1090425,
   0.0660598,
   0.04759021,
   0.03596779,
   0.02751563,
   0.02238263,
   0.01815241,
   0.01512282,
   0.01228406,
   0.01162986,
   0.009836298,
   0.008643669,
   0.007866618,
   0.007089044,
   0.006702567,
   0.005960677,
   0.005744891,
   0.005145786,
   0.004956617,
   0.004917011,
   0.004476165,
   0.004343825};
   graph = new TGraph(27,Graph3_fx2,Graph3_fy2);
   graph->SetName("Graph3");
   graph->SetTitle("Graph");
   graph->SetFillColor(1);
   graph->SetLineWidth(2);
   graph->SetMarkerStyle(20);
   
   TH1F *Graph_Graph2 = new TH1F("Graph_Graph2","Graph",100,70,1630);
   Graph_Graph2->SetMinimum(0);
   Graph_Graph2->SetMaximum(5.270799);
   Graph_Graph2->SetDirectory(0);
   Graph_Graph2->SetStats(0);
   Graph_Graph2->SetLineStyle(0);
   Graph_Graph2->SetMarkerStyle(20);
   Graph_Graph2->GetXaxis()->SetLabelFont(42);
   Graph_Graph2->GetXaxis()->SetTitleSize(0.05);
   Graph_Graph2->GetXaxis()->SetTickLength(0.02);
   Graph_Graph2->GetXaxis()->SetTitleOffset(1.08);
   Graph_Graph2->GetXaxis()->SetTitleFont(42);
   Graph_Graph2->GetYaxis()->SetLabelFont(42);
   Graph_Graph2->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph2->GetYaxis()->SetTitleSize(0.05);
   Graph_Graph2->GetYaxis()->SetTickLength(0.02);
   Graph_Graph2->GetYaxis()->SetTitleOffset(1.56);
   Graph_Graph2->GetYaxis()->SetTitleFont(42);
   Graph_Graph2->GetZaxis()->SetLabelFont(42);
   Graph_Graph2->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph2->GetZaxis()->SetTitleSize(0.05);
   Graph_Graph2->GetZaxis()->SetTickLength(0.02);
   Graph_Graph2->GetZaxis()->SetTitleFont(42);
   graph->SetHistogram(Graph_Graph2);
   
   graph->Draw("pl");
   
   TH1F *tmp0_copy3 = new TH1F("tmp0_copy3","Graph",100,200,1500);
   tmp0_copy3->SetMinimum(0);
   tmp0_copy3->SetMaximum(11.53875);
   tmp0_copy3->SetDirectory(0);
   tmp0_copy3->SetStats(0);
   tmp0_copy3->SetLineStyle(0);
   tmp0_copy3->SetMarkerStyle(20);
   tmp0_copy3->GetXaxis()->SetLabelFont(42);
   tmp0_copy3->GetXaxis()->SetTitleSize(0.05);
   tmp0_copy3->GetXaxis()->SetTickLength(0.02);
   tmp0_copy3->GetXaxis()->SetTitleOffset(1.08);
   tmp0_copy3->GetXaxis()->SetTitleFont(42);
   tmp0_copy3->GetYaxis()->SetLabelFont(42);
   tmp0_copy3->GetYaxis()->SetLabelOffset(0.007);
   tmp0_copy3->GetYaxis()->SetTitleSize(0.05);
   tmp0_copy3->GetYaxis()->SetTickLength(0.02);
   tmp0_copy3->GetYaxis()->SetTitleOffset(1.56);
   tmp0_copy3->GetYaxis()->SetTitleFont(42);
   tmp0_copy3->GetZaxis()->SetLabelFont(42);
   tmp0_copy3->GetZaxis()->SetLabelOffset(0.007);
   tmp0_copy3->GetZaxis()->SetTitleSize(0.05);
   tmp0_copy3->GetZaxis()->SetTickLength(0.02);
   tmp0_copy3->GetZaxis()->SetTitleFont(42);
   tmp0_copy3->Draw("sameaxis");
   
   TH1F *tmp0_copy4 = new TH1F("tmp0_copy4","Graph",100,200,1500);
   tmp0_copy4->SetMinimum(0);
   tmp0_copy4->SetMaximum(11.53875);
   tmp0_copy4->SetDirectory(0);
   tmp0_copy4->SetStats(0);
   tmp0_copy4->SetLineStyle(0);
   tmp0_copy4->SetMarkerStyle(20);
   tmp0_copy4->GetXaxis()->SetLabelFont(42);
   tmp0_copy4->GetXaxis()->SetTitleSize(0.05);
   tmp0_copy4->GetXaxis()->SetTickLength(0.02);
   tmp0_copy4->GetXaxis()->SetTitleOffset(1.08);
   tmp0_copy4->GetXaxis()->SetTitleFont(42);
   tmp0_copy4->GetYaxis()->SetLabelFont(42);
   tmp0_copy4->GetYaxis()->SetLabelOffset(0.007);
   tmp0_copy4->GetYaxis()->SetTitleSize(0.05);
   tmp0_copy4->GetYaxis()->SetTickLength(0.02);
   tmp0_copy4->GetYaxis()->SetTitleOffset(1.56);
   tmp0_copy4->GetYaxis()->SetTitleFont(42);
   tmp0_copy4->GetZaxis()->SetLabelFont(42);
   tmp0_copy4->GetZaxis()->SetLabelOffset(0.007);
   tmp0_copy4->GetZaxis()->SetTitleSize(0.05);
   tmp0_copy4->GetZaxis()->SetTickLength(0.02);
   tmp0_copy4->GetZaxis()->SetTitleFont(42);
   tmp0_copy4->Draw("sameaxig");
   
   TLegend *leg = new TLegend(0.495,0.825,0.945,0.925,NULL,"NBNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph3","Observed","LP");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","Expected","L");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph1","#pm1#sigma Expected","F");

   ci = TColor::GetColor("#00ff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","#pm2#sigma Expected","F");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   TPave *pave = new TPave(0.16,0.81,0.96,0.94,1,"brNDC");
   pave->SetFillColor(0);
   pave->Draw();
   
   leg = new TLegend(0.495,0.825,0.945,0.925,NULL,"NBNDC");
   leg->SetBorderSize(0);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   entry=leg->AddEntry("Graph3","Observed","LP");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","Expected","L");

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(2);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph1","#pm1#sigma Expected","F");

   ci = TColor::GetColor("#00ff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","#pm2#sigma Expected","F");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   TLatex *   tex = new TLatex(0.196,0.9113,"CMS");
tex->SetNDC();
   tex->SetTextAlign(13);
   tex->SetTextSize(0.048);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.196,0.8537,"Internal");
tex->SetNDC();
   tex->SetTextAlign(13);
   tex->SetTextFont(52);
   tex->SetTextSize(0.03648);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.96,0.952,"");
tex->SetNDC();
   tex->SetTextAlign(31);
   tex->SetTextFont(42);
   tex->SetTextSize(0.036);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.16,0.952,"");
tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.036);
   tex->SetLineWidth(2);
   tex->Draw();
   pad->Modified();
   limit->cd();
   limit->Modified();
   limit->cd();
   limit->SetSelected(limit);
}
void multiPlot () {

  gStyle->SetPadLeftMargin(0.12);
  
  gStyle->SetPadTopMargin(0.12);
  
  gStyle->SetPadBottomMargin(0.12);
  
  gStyle->SetPadRightMargin(0.12);

  
  
  vector<GraphInfo> expectedGraphs;


  /// largest values
  GraphInfo tauInfo (makePlots_limit_v4("limits_AN_v2_tau.dat", "xcheck_v1", "LJ Only", LIM8TEV), "TAU");
  tauInfo.theGraph->SetMarkerStyle(33);
  tauInfo.theGraph->SetMarkerSize(1.8);
  expectedGraphs.push_back(tauInfo );

  GraphInfo dilInfo (makePlots_limit_v4("limits_AN_v2_DIL.dat", "xcheck_v1", "LJ Only", LIM8TEV), "DIL");
  dilInfo.theGraph->SetMarkerStyle(21);
  //dilInfo.theGraph->SetMarkerSize(0.98);
  expectedGraphs.push_back(dilInfo );

  
  GraphInfo ljInfo(makePlots_limit_v4("limits_AN_v2_LJ.dat", "xcheck_v1", "LJ Only", LIM8TEV), "LJ");
  ljInfo.theGraph->SetMarkerStyle(23);
  //ljInfo.theGraph->SetMarkerSize(0.98);
  expectedGraphs.push_back( ljInfo );


  // smallest values
  GraphInfo comboInfo (makePlots_limit_v4("limits_AN_v2_LJ_DIL_tau.dat", "xcheck_v1", "LJ Only", LIM8TEV), "COMB");
  comboInfo.theGraph->SetMarkerStyle(20);
  //comboInfo.theGraph->SetMarkerSize(0.98);
  expectedGraphs.push_back(comboInfo);

  vector< pair<double,double> > minThenMax = getMinMaxOfGraphs (expectedGraphs);

  TLegend * allLeg = new TLegend (0.15, 0.65, 0.35, 0.88);
  allLeg->SetFillColor(0);
  

  TLatex *CMSInfoLatex = new TLatex(0.11, 0.91, "Median Exp Limits");
  CMSInfoLatex->SetNDC();
  CMSInfoLatex->SetTextFont(42);

  TString lumiinfo = " ";
  lumiinfo += "#sqrt{s} = 8 TeV, L = 19.5 fb^{-1}";

  double textSize = 0.04;
  double offset = 0.0;

  TLatex *LUMIInfoLatex = new TLatex(0.43-offset, 0.91, lumiinfo);
  LUMIInfoLatex->SetNDC();
  LUMIInfoLatex->SetTextFont(42);

  //Set to same size
  CMSInfoLatex->SetTextSize(textSize);
  LUMIInfoLatex->SetTextSize(textSize);

  double scaleRange = 1.01;

  TCanvas *allCan = new TCanvas ("allCan", "All Limit Results");
  allCan->cd();
  allCan->SetGridx(1);
  allCan->SetGridy(1);

  TLine* line = new TLine( minThenMax[0].first*(1.0/scaleRange), 1., minThenMax[0].second*scaleRange, 1. );
  line->SetLineColor(kRed);
  line->SetLineWidth(4);

  TH1D* h_dummy = new TH1D("h_dummy","",100, minThenMax[0].first*(1.0/scaleRange), minThenMax[0].second*scaleRange );
  
  h_dummy->SetTitle(";m_{H} (GeV);95% CL limit on #sigma/#sigma_{SM}");
  h_dummy->SetStats(0);
  h_dummy->GetYaxis()->SetRangeUser(0.,20.);
  h_dummy->SetMaximum(1.05*minThenMax[1].second);
  h_dummy->Draw();
  
  for (unsigned iGraph =0; iGraph < expectedGraphs.size(); iGraph++){
    TGraph * thisOne = expectedGraphs[iGraph].theGraph;
    string thisName = expectedGraphs[iGraph].legendName;
    

    thisOne->Draw("lpsame");
    allLeg->AddEntry(thisOne, thisName.c_str(), "p");

  }
  allLeg->Draw();

  CMSInfoLatex->Draw();
  LUMIInfoLatex->Draw();
  line->Draw();


  allCan->SaveAs("allChanMedian.pdf");
  allCan->SaveAs("allChanMedian.png");
  
  return;
}
Beispiel #16
0
void Plot_2D(string filename){
  
  //string filename = "data/scan_CH1-50_masked.root";
 
  // string varXname = "VMM # [1-8]";
  // string varYname = "CH # [1-64]";

  string varXname = "Pulsed CH # [1-64]";
  string varYname = "Recorded CH # [1-64]";
  string varZname = "# Recorded Pulses [/100 pulsed]";
  //string varZname = "#sigma(PDO) / #bar{PDO}";
  // int Nx = 8;
  // double Xmin = 0.5;
  // double Xmax = 8.5;
  int Nx = 64;
  double Xmin = 0.5;
  double Xmax = 64.5;
  // int Ny = 64;
  // double Ymin = 0.5;
  // double Ymax = 64.5;
  int Ny = 4097;
  double Ymin = -0.5;
  double Ymax = 4096.5;

  ///////////////////////////////////////////////////////
  setstyle(0);
  
  TChain* tree = new TChain("VMM_data","VMM_data");

  tree->AddFile(filename.c_str());

  MMFE8Base* base = new MMFE8Base(tree);

  int N = tree->GetEntries();

  TH2D* hist = new TH2D("hist","hist",
			Nx, Xmin, Xmax,
			Ny, Ymin, Ymax);

  TH2D* hist2 = new TH2D("hist2","hist2",
			 Nx, Xmin, Xmax,
			 Ny, Ymin, Ymax);

  TH2D* histN = new TH2D("histN","histN",
			 Nx, Xmin, Xmax,
			 Ny, Ymin, Ymax);

  for(int i = 0; i < N; i++){
    base->GetEntry(i);

    if(base->VMM != 0)
      continue;

    if(base->CHword == 24)
      continue;

    if(base->Delay != 30)
      continue;
    
    // hist->Fill(base->CHpulse,base->CHword,base->PDO);
    //histN->Fill(base->CHpulse,base->CHword);
    histN->Fill(base->CHpulse,base->BCID);

    // if(base->CHpulse != 5)
    //   continue;
    // base->CHpulse = base->CHword;

    hist->Fill(base->VMM,base->CHpulse,base->PDO);
    hist2->Fill(base->VMM,base->CHpulse,base->PDO*base->PDO);
    // if(histN->GetBinContent(base->VMM,base->CHpulse) <= 0)
    //   histN->SetBinContent(base->VMM,base->CHpulse,base->BCID);
    // else
    //   if(histN->GetBinContent(base->VMM,base->CHpulse) > base->BCID)
    // histN->SetBinContent(base->VMM,base->CHpulse,base->BCID);
    // histN->Fill(base->VMM,base->CHpulse);
  
  }

  for(int x = 0; x < Nx; x++){
    for(int y = 0; y < Ny; y++){
      double v = hist->GetBinContent(x+1,y+1);
      double v2 = hist2->GetBinContent(x+1,y+1);
      double N = histN->GetBinContent(x+1,y+1);
      double vbar = v/max(int(N),1);
      double v2bar = v2/max(int(N),1);
      //hist->SetBinContent(x+1,y+1,sqrt(v2bar-vbar*vbar)/vbar);
      hist->SetBinContent(x+1,y+1,vbar);
    }
  }

  TCanvas* can = new TCanvas("can","can",600,500);
  can->SetLeftMargin(0.15);
  can->SetRightMargin(0.22);
  can->SetBottomMargin(0.15);
  can->SetTopMargin(0.08);

  can->Draw();
  can->SetGridx();
  can->SetGridy();
  
  can->cd();

  hist = histN;

  hist->Draw("COLZ");

  hist->GetXaxis()->CenterTitle();
  hist->GetXaxis()->SetTitleFont(132);
  hist->GetXaxis()->SetTitleSize(0.06);
  hist->GetXaxis()->SetTitleOffset(1.06);
  hist->GetXaxis()->SetLabelFont(132);
  hist->GetXaxis()->SetLabelSize(0.05);
  hist->GetXaxis()->SetTitle(varXname.c_str());
  hist->GetYaxis()->CenterTitle();
  hist->GetYaxis()->SetTitleFont(132);
  hist->GetYaxis()->SetTitleSize(0.06);
  hist->GetYaxis()->SetTitleOffset(1.12);
  hist->GetYaxis()->SetLabelFont(132);
  hist->GetYaxis()->SetLabelSize(0.05);
  hist->GetYaxis()->SetTitle(varYname.c_str());
  hist->GetZaxis()->CenterTitle();
  hist->GetZaxis()->SetTitleFont(132);
  hist->GetZaxis()->SetTitleSize(0.06);
  hist->GetZaxis()->SetTitleOffset(1.3);
  hist->GetZaxis()->SetLabelFont(132);
  hist->GetZaxis()->SetLabelSize(0.05);
  hist->GetZaxis()->SetTitle(varZname.c_str());
  hist->GetZaxis()->SetRangeUser(0.9*hist->GetMinimum(),1.1*hist->GetMaximum());

  TLatex l;
  l.SetTextFont(132);
  l.SetNDC();
  l.SetTextSize(0.05);
  l.SetTextFont(132);
  l.DrawLatex(0.5,0.943,"MMFE8 Analysis");
  l.SetTextSize(0.04);
  l.SetTextFont(42);
  l.DrawLatex(0.15,0.943,"#bf{#it{ATLAS}} Internal");

  l.SetTextSize(0.06);
  l.SetTextFont(132);
  l.DrawLatex(0.80,0.04, "VMM #6");

 
}
void limAt125ByChan ( bool withObs = false ) {

  gStyle->SetPadLeftMargin(0.12);
  
  gStyle->SetPadTopMargin(0.12);
  
  gStyle->SetPadBottomMargin(0.12);
  
  gStyle->SetPadRightMargin(0.12);

  
  typedef  pair<TString, LimitPoint> NameLim;
  vector<NameLim> expectedPoints;

  

  /// largest values
  LimitPoint tauPoint = expWithErrorsAt125("obs_AN_v2_tau.dat", withObs);
  expectedPoints.push_back(NameLim("TAU", tauPoint)) ;

  LimitPoint dilPoint = expWithErrorsAt125("obs_AN_v2_DIL.dat", withObs);

  expectedPoints.push_back(NameLim("DIL", dilPoint));

  
  LimitPoint ljInfo = expWithErrorsAt125("obs_AN_v2_LJ.dat", withObs);
  
  expectedPoints.push_back(NameLim("LJETS", ljInfo));


  // smallest values
  LimitPoint comboPoint = expWithErrorsAt125("obs_AN_v2_LJ_DIL_tau.dat", withObs);
 
  expectedPoints.push_back(NameLim("COMBO", comboPoint));

  cout << "--------------- handling limits ------------ " << endl;

  const int bigNum = 100;
  unsigned numChan = expectedPoints.size();
  cout << "Number of channels = " << numChan << endl;

  double chanNum[bigNum], errLowChan[bigNum], errHighChan[bigNum], exp[bigNum], errLowExp[bigNum], errHighExp[bigNum], obs[bigNum];
  
  
  unsigned thisChan = 0;
  double maxUpperBound = 0.0;
  
  for ( vector<NameLim>::iterator iNameAndLim = expectedPoints.begin();
        iNameAndLim != expectedPoints.end();
        iNameAndLim ++ ) {    
    cout << "Analysis " << iNameAndLim->first
         << " Limit " << iNameAndLim->second.medianExpected
         << "Upper error is " << iNameAndLim->second.max1sig  
         << endl;

    chanNum[thisChan] = thisChan+1;
    errLowChan[thisChan] = 0;
    errHighChan[thisChan] = 0;

    exp[thisChan] = iNameAndLim->second.medianExpected;
    errLowExp[thisChan] =  exp[thisChan] - iNameAndLim->second.min1sig;
    errHighExp[thisChan] =  iNameAndLim->second.max1sig - exp[thisChan];
    if (withObs)
      obs[thisChan] = iNameAndLim->second.observed;

    
    if ( iNameAndLim->second.max1sig > maxUpperBound ){
      
      maxUpperBound = iNameAndLim->second.max1sig;
    }

    thisChan++;
    
  }

  double scaleRange = 1.05;
  TH2D* h_dummy = new TH2D("h_dummy","",100, 0, maxUpperBound*scaleRange, numChan, 0.5, numChan+0.5  );

  
  h_dummy->SetTitle(";95% CL limit on #sigma/#sigma_{SM} at M(H) = 125;");
  h_dummy->SetStats(0);
  //h_dummy->GetYaxis()->SetRangeUser(0.,numChan+1);

  // reset
  thisChan = 0; 
  for ( vector<NameLim>::iterator iNameAndLim = expectedPoints.begin();
        iNameAndLim != expectedPoints.end();
          iNameAndLim ++ ) {
    cout << "second loop bin is " << thisChan+1 << " and  analysis is "
         << iNameAndLim->first  << endl;
      
    h_dummy->GetYaxis()->SetBinLabel(thisChan+1, iNameAndLim->first);
    thisChan++;
  }
  

  TGraphAsymmErrors * limitsByChan = new TGraphAsymmErrors(numChan, exp, chanNum, errLowExp, errHighExp,  errLowChan, errHighChan);

  TGraph * limitsObs = 0 ;
  if (withObs) {
    limitsObs = new TGraph (numChan, obs, chanNum);
    limitsObs->SetMarkerStyle(25);
    limitsObs->SetMarkerSize(1.4);
    limitsObs->SetMarkerColor(kBlue);
  }
  
  TLatex *CMSInfoLatex = new TLatex(0.11, 0.91, "CMS Preliminary");
  CMSInfoLatex->SetNDC();
  CMSInfoLatex->SetTextFont(42);

  TString lumiinfo = " ";
  lumiinfo += "#sqrt{s} = 8 TeV, L = 19.5 fb^{-1}";

  double textSize = 0.04;
  double offset = 0.0;

  TLatex *LUMIInfoLatex = new TLatex(0.60-offset, 0.91, lumiinfo);
  LUMIInfoLatex->SetNDC();
  LUMIInfoLatex->SetTextFont(42);

  //Set to same size
  CMSInfoLatex->SetTextSize(textSize);
  LUMIInfoLatex->SetTextSize(textSize);

  TLine* line = new TLine( 1.0, 0.5, 1.0, numChan+0.5 );
  line->SetLineColor(kRed);
  line->SetLineWidth(4);

  TLegend * allLeg = new TLegend (0.65, 0.65, 0.85, 0.88);
  allLeg->SetFillColor(0);
  allLeg->AddEntry(limitsByChan, "Expected", "p");
  if(withObs)
    allLeg->AddEntry(limitsObs, "Observed", "p");

  TCanvas * myCan = new TCanvas ("LimByChan", "Limits by chan");
  myCan->cd();
  
  //h_dummy->SetMaximum(1.05*minThenMax[1].second);
  h_dummy->Draw();

  CMSInfoLatex->Draw();
  LUMIInfoLatex->Draw();
  line->Draw();
  allLeg->Draw();
    
  
  limitsByChan->Draw("p");
  if (withObs)
    limitsObs->Draw("psame");

  if (withObs)
    myCan->SaveAs("LimitsPerChanAt125WithObs.png");
  else 
    myCan->SaveAs("LimitsPerChanAt125.png");
  
}
void fitRatio_kyo01(bool isPrompt=true, bool isPbp=true, char* dirName="8rap9pt2gev"){
    gRandom->SetSeed(time(0));
		gROOT->Macro("./JpsiStyle.C");

		//latex box for beam, rapidity, pT info
		TLatex* latex = new TLatex();
		latex->SetNDC();
		latex->SetTextAlign(12);
		latex->SetTextSize(0.04);

		string rapArr[nRap];
		for (Int_t iy=0; iy<nRap; iy++) {
			formRapArr(rapArrNumFB[iy+1], rapArrNumFB[iy], &rapArr[iy]);
			cout << iy <<"th rapArr = " << rapArr[iy] << endl;
		}


//    TFile* fin = new TFile(Form("../pPbJPsiAnalysis/2015/004_closure/DataMcReco_8rap9pt/DataMcRecoPt_isPropmt%d.root",(int)isPrompt));//in KNU 
    TFile* fin = new TFile(Form("../004_closure/DataMcReco_%s/DataMcRecoPt_isPropmt%d.root",dirName,(int)isPrompt));//in KNU  //KYO
    string runstring;
    string runstringOverlay;
    if(isPbp) {runstring="Pbp"; runstringOverlay="pPb";}
    else {runstring="pPb"; runstringOverlay="Pbp"; }

    TGraphAsymmErrors* gRatio[nRap];
    TGraphAsymmErrors* gRatioOverlay[nRap];
    for(int iy=0;iy<nRap;iy++){
        gRatio[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstring.c_str(),iy));
        gRatioOverlay[iy]=(TGraphAsymmErrors*)fin->Get(Form("gRatio_%s_%d",runstringOverlay.c_str(),iy));
				gRatio[iy]->SetName(Form("gRatio_%d",iy));
				gRatioOverlay[iy]->SetName(Form("gRatioOverlay_%d",iy));
    }

    //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s.root",(int)isPrompt,runstring.c_str()),"recreate");
    //TFile* fout= new TFile(Form("ToyGaussian_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO
    TFile* fout= new TFile(Form("fitRatio_isPrompt%d_%s_kyo01.root",(int)isPrompt,runstring.c_str()),"recreate");//KYO

    ////////////////////////////////////////////////////////////
    // Output gaussian parameter histograms

    TH1D* hWeight[nRap];
    // TH1D* hWeightSigma[nRap];
    for(int iy=0;iy<nRap;iy++){
//				if (iy!=0) continue ; //KYO
        hWeight[iy]=new TH1D(Form("hWeight_%s_%d",runstring.c_str(),iy), Form("hWeight_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum);
    //    hWeightSigma[iy]=new TH1D(Form("hWeightSigma_%s_%d",runstring.c_str(),iy), Form("hWeightSigma_%s_%d",runstring.c_str(),iy), nPtFine, ptFineArrNum);
    }
#if 0
    int rapiditybin[nRap],nfpt[nRap];
    double mean[nRap][nPtFine],sigma[nRap][nPtFine];

    TTree* toyGaus[nRap];
    for(int iy=0;iy<nRap;iy++){
        toyGaus[iy]=new TTree(Form("toyGaus%d",iy),Form("rapidity bin %dth",iy));
        toyGaus[iy]->Branch("rapiditybin", &rapiditybin[iy]);
        toyGaus[iy]->Branch("nfpt", &nfpt[iy]);
        toyGaus[iy]->Branch("mean", mean[iy],"mean[nfpt]/D");
        toyGaus[iy]->Branch("sigma", sigma[iy],"sigma[nfpt]/D");
    }
#endif

    ////////////////////////////////////////////////////////////
    // Fitting

//    TF1* fhevi= new TF1("fhevi","[0]/(exp((-x+[1])/[2] +1)+[3])+[4]",0,30);
//    fhevi->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369);
//    TF1* fexp= new TF1("fexp","[0]/(1+exp([1]*x))+[2]/x",0.0,30.0);//Prompt
    TF1* func[nRap];
   
//    TCanvas* c1 = new TCanvas("c1", "", 1200,1500);
//    c1 -> Divide(3,3);
    TCanvas* c1 = new TCanvas("c1", "", 1600,800); //KYO
    c1 -> Divide(4,2); // KYO
    for(int iy=0;iy<nRap;iy++){
        c1->cd(iy+1);
        if(iy==0 || iy==nRap-1){
            func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5);
            func[iy]->SetParameters(-4.795, 1.653, 0.923, 3.018, 2.369);
            if(isPrompt==1 && isPbp==0 && iy==0) { 
                //      func[iy]->SetParameters(-51.7167, -0.694876, 0.491544,4.55470,12.1672);
#if 1
                func[iy]->FixParameter(0,-5.17167e+01 );
                func[iy]->FixParameter(1,-6.94876e-01 );
                //func[iy]->FixParameter(2,4.91544e-01 );
                func[iy]->FixParameter(2,9.91544e-01 );
                //func[iy]->FixParameter(3,4.55470e+00 );
                //func[iy]->FixParameter(3,3.55470e+00 );
                //func[iy]->FixParameter(4,1.11672e+01 );
#endif
            }
            else if(isPrompt==1 && isPbp==1 && iy==0) { 
                //func[iy]->FixParameter(0,-5.17167e+01 );
                func[iy]->FixParameter(1,2.06705e+00 );
                func[iy]->FixParameter(2,3.72512e-01 );
                func[iy]->FixParameter(3,3.11521e+00 );
                //func[iy]->FixParameter(4,1.11672e+01 );
            }
           
            else if (isPrompt==0 && isPbp==1 && iy==7) {
                func[iy]->FixParameter(0, -3.40711e+02);
                func[iy]->FixParameter(1, 3.20176e+00); 
                func[iy]->FixParameter(2, 1.09760e+00);
            }


        }  
        //else if(isPrompt==1 && isPbp==0 && iy==4){
        //  func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); 
        //  func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02);
        //} 
        else{
            func[iy] = new TF1(Form("func_%d",iy), fitHevi,0.0,30.0,5); 
            //func[iy]->SetParameters(-3.40711e+02,-2.02319e+00,1.42753e+00,2.98897e+00,1.14958e+02); //yeonju 0509
            func[iy]->SetParameters(-3.40711e+02,-5.20176e+00,1.79760e+00,2.98896e+00,1.14958e+02); //yeonju 0509
            //func[iy]->SetParameters(-3.40747e+02,3.32373e+00,6.51294e-01,2.98861e+00,1.14947e+02); //yeonju
            //yeonju
            if (isPrompt==0 && iy==2) {
                func[iy]->FixParameter(0, -3.40711e+02);
                func[iy]->FixParameter(1, -5.20176e+00); 
                func[iy]->FixParameter(2, 1.79760e+00);
                func[iy]->FixParameter(3, 2.98896);

            } else if (isPrompt==0 && iy==6) {
                func[iy]->FixParameter(0, -3.40711e+02);
                func[iy]->FixParameter(1, 3.20176e+00); 
                func[iy]->FixParameter(2, 1.79760e+00);

            }        
            //KYO
            if (isPrompt && iy==6) {
                func[iy]->FixParameter(0,-3.40743e+02);
                func[iy]->FixParameter(1,-2.56691e+01);
                func[iy]->FixParameter(2,5.14736e+00); 
            }
            else if (isPrompt && (iy==2 || iy==1)) {
                func[iy]->FixParameter(0,-3.40743e+02);
                func[iy]->FixParameter(1,-1.37032e-01);
                func[iy]->FixParameter(2,1.19902);
            }

            /*
               func[iy] = new TF1(Form("func_%d",iy), fitExp,0.0,30.0,3);
               if(isPrompt==0 && isPbp==1 && (iy==2 || iy==3 || iy==4 || iy==5) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01);
               if(isPrompt==0 && isPbp==0 && (iy==2 || iy==3 || iy==4) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01);
               if(isPrompt==1 && isPbp==0 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01);
               if(isPrompt==1 && isPbp==1 && (iy==3) ) func[iy]->SetParameters(-1.01556e+01,1.51712e-01,2.80282e+01);
               */
        }
        //KYO for TGraphAsymmErrors only
        if (!isPrompt && iy==0){
            func[iy]->SetParameters(-1.04829e+01,-5.38813e+00,2.10443e+00,1.74460e+00,6.89848e+02);
            func[iy]->FixParameter(0,-1.04829e+01);
            func[iy]->FixParameter(1,-5.38813e+00);
            func[iy]->FixParameter(2,2.10443e+00);
        }
        SetGraphStyle(gRatio[iy],2,0);
        SetGraphStyle(gRatioOverlay[iy],4,10);
        func[iy]->SetLineColor(kRed);
        gRatio[iy]->Fit(Form("func_%d",iy));
        gRatio[iy]->Draw("AP");
        gRatioOverlay[iy]->Draw("P");
        //func[iy]->Draw("same");
        if (iy==0){
            if (isPrompt) latex->DrawLatex(0.23,0.23,"Prompt J/#psi Pbp");
            else latex->DrawLatex(0.23, 0.23,"Non-prompt J/#psi Pbp");
        }
        latex->DrawLatex(0.56,0.80,Form("%s",rapArr[iy].c_str()));
        dashedLine(0.,1.,25.,1.,1,1);

        /*
				for(int ifpt=0;ifpt<nPtFine;ifpt++){
            int hBin = gRatio[iy]->FindBin(ptFineArrNum[ifpt+1]-0.1);
            double mean = func[iy]->Eval(ptFineArrNum[ifpt+1]);
            double sigma = gRatio[iy]->GetBinError(hBin) / mean;
            hWeight[iy]->SetBinContent(ifpt+1, mean);
            hWeight[iy]->SetBinError(ifpt+1, sigma);
            //cout <<"x : "<<ptFineArrNum[ifpt+1]-0.01<< ", gRatio bin : " <<hBin << ", Ratio error value : " <<  gRatio[iy]->GetBinError(hBin) << endl;
            //cout << iy+1 << "th rapidity, "<< ifpt<<"th fine ptbin, mean = "<< mean <<", sigma = "<<sigma<<endl;
        }
				*/
    }
    c1 -> Update();

    for(int iy=0;iy<nRap;iy++){
				cout << " **** " <<iy<< "th rap, values at min pT = " <<func[iy]->Eval(minPt[iy])<<endl;	
    }
    
		fout->cd();	
    for(int iy=0;iy<nRap;iy++){
        //hWeight[iy]->Write();
        gRatio[iy]->Write();
        func[iy]->Write();
    }
    c1->Write();
    fout->Close();

}//end of main func.
Beispiel #19
0
void qcd() {
   
  setTDRStyle();

  std::vector<double> bins;
  bins.push_back(275.);
  bins.push_back(325.);
  for ( int i = 0; i < 6; ++i ) { bins.push_back(375.+100.*i); }

  std::vector<double> widths;
  widths.push_back(25.);
  widths.push_back(25.);
  for ( int i = 0; i < 6; ++i ) { widths.push_back(50.); }

  std::vector<double> effs;
  effs.push_back(1.13);
  effs.push_back(0.83);
  effs.push_back(0.72);
  effs.resize(8,0.84);
//   effs.push_back(0.84);
//   effs.push_back(1.13);
//   effs.push_back(1.32);
//   effs.push_back(1.41);
//   effs.push_back(2.09);

  std::vector<double> errs;
  errs.push_back(0.34);
  errs.push_back(0.24);
  errs.push_back(0.19);
  errs.resize(8,0.14);
//   errs.push_back(0.14);
//   errs.push_back(0.24);
//   errs.push_back(0.35);
//   errs.push_back(0.50);
//   errs.push_back(0.80);

  std::vector<double> entries;
  entries.push_back(46272.);
  entries.push_back(43592.);
  entries.push_back(58746.);
  entries.push_back(78644.);
  entries.push_back(29516.);
  entries.push_back(11668.);
  entries.push_back(5416.);
  entries.push_back(5368.);

  std::vector<double> prescales;
  prescales.push_back(2000.);
  prescales.push_back(1000.);
  prescales.push_back(500.);
  prescales.push_back(125.);
  prescales.push_back(125.);
  prescales.push_back(125.);
  prescales.push_back(125.);
  prescales.push_back(125.);
  
  TCanvas* c = new TCanvas("tmp","tmp",900,600);
  
  TGraphAsymmErrors* gr1 = new TGraphAsymmErrors(8);
  gr1->SetName("Graph1");
  gr1->SetTitle("");
  gr1->SetFillColor(1);
  gr1->SetLineWidth(2);
  gr1->SetMarkerStyle(24);
  gr1->SetMarkerColor(1);
  gr1->SetMarkerSize(2.);

  TGraphAsymmErrors* gr2 = new TGraphAsymmErrors(8);
  gr2->SetName("Graph2");
  gr2->SetTitle("");
  gr2->SetFillColor(1);
  gr2->SetLineWidth(2);
  gr2->SetMarkerStyle(20);
  gr1->SetMarkerColor(1);
  gr2->SetMarkerSize(1.5);

  for ( int i = 0; i < bins.size(); ++i ) {
    double x = bins[i]+widths[i];
    double y = entries[i]*prescales[i];
    double ex = widths[i];
    double ey = sqrt(entries[i])*prescales[i];
    
    gr1->SetPoint(i+1,x,y);
    gr1->SetPointError(i+1,0.,0.,ey,ey);

    y = y / effs[i];
    ey = y * sqrt( (ey/y)*(ey/y) + (errs[i]/effs[i])*(errs[i]/effs[i]) );
    
    gr2->SetPoint(i+1,x,y);
    gr2->SetPointError(i+1,ex,ex,ey,ey);

    std::cout << " HT= " << bins[i] << " yield= " << y << " +/- " << ey << std::endl; 
 
  }
  
  TMultiGraph* mg = new TMultiGraph();
  mg->Add(gr1,"p");
  mg->Add(gr2,"p");
  mg->Draw("ap");
  mg->GetXaxis()->SetTitle("H_{T} (GeV)");
  mg->GetYaxis()->SetTitle("Bulk yields");
  mg->GetYaxis()->SetRangeUser(1.e5,1.e9);
  mg->GetXaxis()->SetRangeUser(275.,975.);

  TF1* fit = new TF1("fit","expo",275.,875.);
  gr2->Fit(fit,"R");
  fit->Draw("same");
  
  TLegend* leg = new TLegend( 0.45, 0.70, 0.85, 0.80 );
  leg->SetFillColor(0);
  leg->SetLineColor(0); 
  leg->SetShadowColor(0); 
  leg->SetTextSize(0.035);
  leg->AddEntry(gr1,"Raw counts weighted by prescales","p");
  leg->AddEntry(gr2,"Trigger efficiency corrected","p");
  leg->Draw("same");

  std::stringstream sss;
  sss << "CMS, 1.5 fb^{-1}, #sqrt{s} = 8 TeV";
  TLatex* tex = new TLatex(0.17,0.88,sss.str().c_str());
  tex->SetNDC();
  tex->SetTextSize(0.035);
  tex->Draw();

  c->SetLogy();

  return;
  
}
Beispiel #20
0
void fill_stack_eventcategories(TString variable_name, TString data_name, std::vector<TString> signal_names, std::vector<TString> names){
    TString canvas_name=variable_name+"_stack_canvas";
    CreateCanvas(canvas_name,"",900,600);
    TString stack_name=variable_name+"_stack";
    CreateStack(stack_name,"");

    int Nbkg=names.size();
    
    vector<int> colors;
    colors.push_back(4);
    colors.push_back(9);
    colors.push_back(5);
    colors.push_back(419);
    
    colors.push_back(7);
    if(colors.size()<Nbkg) {
        cout << "please specify colors" << endl;
        return;
    }
    
    TLegend *L = new TLegend(0.6,0.57,0.89,0.89);
	L->SetFillColor(10);
	L->SetLineColor(10);
	L->SetLineWidth(0);
    
    for(int ibkg=0; ibkg<Nbkg; ibkg++){
        TString histName=variable_name+names.at(ibkg);
        hName[histName]->SetFillColor(colors.at(ibkg));
        stackName[stack_name]->Add(hName[histName]);
        L->AddEntry(hName[histName], names.at(ibkg));
    }
    
    
	TString eventspad_name="eventspad_"+variable_name;
	TString ratiopad_name="ratiopad_"+variable_name;
	
	TPad *events_pad = new TPad(eventspad_name,"Events",0.0,0.3,1,1);
	TPad *ratio_pad = new TPad(ratiopad_name,"Ratio",0,0.,1,0.3);
	
	events_pad->SetTopMargin(0.1);
	events_pad->SetBottomMargin(0.05);
	ratio_pad->SetTopMargin(0.05);
	ratio_pad->SetBottomMargin(0.3);
	
	CName[canvas_name]->cd();
	events_pad->Draw();
	ratio_pad->Draw();
	
	events_pad->cd();
    gPad->SetLogy();
    
    hName[variable_name+data_name]->GetYaxis()->SetTitleOffset(0.65);
    hName[variable_name+data_name]->GetYaxis()->SetTitleSize(0.08);
    hName[variable_name+data_name]->GetYaxis()->SetLabelSize(0.05);
    hName[variable_name+data_name]->GetXaxis()->SetLabelSize(0);
    hName[variable_name+data_name]->GetXaxis()->SetTitleSize(0);
    
    hName[variable_name+data_name]->SetMarkerSize(0.5);
    hName[variable_name+data_name]->SetMarkerStyle(20);
    hName[variable_name+data_name]->DrawCopy("E1");
    stackName[stack_name]->DrawClone("histo same");
    hName[variable_name+data_name]->DrawCopy("E1 same");// draw data on top of MC and MC on top of data, so that data will always be visible

    
    TLatex txt;
    txt.SetNDC(kTRUE);
    txt.DrawLatex(0.2,0.85,"S_{T} > 300 GeV");
    txt.DrawLatex(0.4,0.75,"S_{T} > 500 GeV");
    txt.DrawLatex(0.65,0.42,"S_{T} > 1000 GeV");

    
    for(int isig=0; isig<signal_names.size();isig++){
        TString sigName=variable_name+signal_names.at(isig);
        hName[sigName]->SetLineWidth(3);
        hName[sigName]->SetLineStyle(kDashed);
        hName[sigName]->SetLineColor(1+isig);
        L->AddEntry(hName[sigName], signal_names.at(isig));
        hName[sigName]->DrawCopy("hist same");
    }
    L->DrawClone("same");
    ratio_pad->cd();
    TString dataMC=variable_name+"_RatioDataMC";

    hName[dataMC]->GetYaxis()->SetTitleOffset(0.45);
	hName[dataMC]->GetYaxis()->SetTitleSize(0.15);
	hName[dataMC]->GetYaxis()->SetTitleOffset(0.45);
	hName[dataMC]->GetYaxis()->SetLabelSize(0.08);
	
	
	hName[dataMC]->GetXaxis()->SetTitleSize(0.15);
	hName[dataMC]->GetXaxis()->SetLabelSize(0.12);
	hName[dataMC]->GetXaxis()->SetTitleSize(0.15);
    
    hName[dataMC]->DrawCopy("E1");
    
}
Beispiel #21
0
void svdComp(){

  const int norder_ = 2;
  double ratioMin = 0.95;
  double ratioMax = 1.05;
  double ratioMinVn8Vn6 = 0.99;
  double ratioMaxVn8Vn6 = 1.01;
  double ratioMinG1E = 0.5;
  double ratioMaxG1E = 3.2;

  double histMin = -0.2;
  double histMax = 1.2;

  double cumuMin = 0.00;
  double cumuMax = 0.13;
  double cumuRatMin = 0.95;
  double cumuRatMax = 1.03;
  double cumuRatMin86 = 0.997;
  double cumuRatMax86 = 1.003;
  double g1eMin = -1;
  double g1eMax = 0.5;

  //-- D'Agostini
  TFile * fDAgUnf;
  TH1D * hUnfoldStatDAg[NCENT];
  TH1D * hUnfoldSysDAg[NCENT];
  TH1D * hUnfoldStatAndSysDAg[NCENT];

  TFile * fDAgPhysics;
  TGraphErrors * grVn2RawDAg;
  TGraphErrors * grVn2RawDAgSys;
  TGraphErrors * grVn4RawDAg;
  TGraphErrors * grVn4RawDAgSys;
  TGraphErrors * grVn6RawDAg;
  TGraphErrors * grVn6RawDAgSys;
  TGraphErrors * grVn8RawDAg;
  TGraphErrors * grVn8RawDAgSys;
  TGraphErrors * grvn6vn4RatioDAg;
  TGraphErrors * grvn6vn4RatioDAgSys;
  TGraphErrors * grvn8vn4RatioDAg;
  TGraphErrors * grvn8vn4RatioDAgSys;
  TGraphErrors * grvn8vn6RatioDAg;
  TGraphErrors * grvn8vn6RatioDAgSys;
  TGraphErrors * grGamma1ExpDAg;
  TGraphErrors * grGamma1ExpDAgSys;

  //-- SVD
  TFile * fSVDPhysics;
  TH1D * hUnfoldSVD[NCENT];
  TGraphErrors * grVn2RawSVD;
  TGraphErrors * grVn4RawSVD;
  TGraphErrors * grVn6RawSVD;
  TGraphErrors * grVn8RawSVD;
  TGraphErrors * grvn6vn4RatioSVD;
  TGraphErrors * grvn8vn4RatioSVD;
  TGraphErrors * grvn8vn6RatioSVD;
  TGraphErrors * grGamma1ExpSVD;

  //-- Unfold ratios
  TCanvas * cUnfold;
  TCanvas * cUnfoldRatio_SVD_DAg;
  TH1D * hUnfoldRatio_SVD_DAg[NCENT];

  //-- Physics ratios
  double vn2SVD_DAg[NCENT];
  double vn4SVD_DAg[NCENT];
  double vn6SVD_DAg[NCENT];
  double vn8SVD_DAg[NCENT];
  double vn6vn4SVD_DAg[NCENT];
  double vn8vn4SVD_DAg[NCENT];
  double vn8vn6SVD_DAg[NCENT];
  double g1eSVD_DAg[NCENT];

  double vn2SVD_DAg_err[NCENT];
  double vn4SVD_DAg_err[NCENT];
  double vn6SVD_DAg_err[NCENT];
  double vn8SVD_DAg_err[NCENT];
  double vn6vn4SVD_DAg_err[NCENT];
  double vn8vn4SVD_DAg_err[NCENT];
  double vn8vn6SVD_DAg_err[NCENT];
  double g1eSVD_DAg_err[NCENT];

  TGraphErrors * grVn2RawRatio_SVD_DAg;
  TGraphErrors * grVn4RawRatio_SVD_DAg;
  TGraphErrors * grVn6RawRatio_SVD_DAg;
  TGraphErrors * grVn8RawRatio_SVD_DAg;
  TGraphErrors * grvn6vn4Ratio_SVD_DAg;
  TGraphErrors * grvn8vn4Ratio_SVD_DAg;
  TGraphErrors * grvn8vn6Ratio_SVD_DAg;
  TGraphErrors * grGamma1ExpRatio_SVD_DAg;

  TLatex latex;
  //
  // MAIN
  //
  setTDRStyle();
  latex.SetNDC();
  TExec *setex2 = new TExec("setex2","gStyle->SetErrorX(0.5)");
  //-- Get D'Agostini objects
  fDAgUnf = new TFile( Form("../../systematicStudies/SysUnfoldDistns_v%i.root", norder_) );
  for(int icent = 0; icent < NCENT; icent++){
    hUnfoldStatDAg[icent]       = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldStat_c%i", icent) );
    hUnfoldStatDAg[icent]->SetLineColor(1);
    hUnfoldStatDAg[icent]->SetMarkerColor(1);
    hUnfoldSysDAg[icent]        = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldSys_c%i", icent) );
    hUnfoldStatAndSysDAg[icent] = (TH1D*) fDAgUnf->Get( Form("hFinalUnfoldStatAndSys_c%i", icent) );
  }

  fDAgPhysics = new TFile( "../../systematicStudies/PhysicsResults.root" );
  grVn2RawDAg         = (TGraphErrors*) fDAgPhysics->Get( "grVn2Raw" );
  grVn2RawDAgSys      = (TGraphErrors*) fDAgPhysics->Get( "grVn2RawSys" );
  grVn4RawDAg         = (TGraphErrors*) fDAgPhysics->Get( "grVn4Raw" );
  grVn4RawDAgSys      = (TGraphErrors*) fDAgPhysics->Get( "grVn4RawSys" );
  grVn6RawDAg         = (TGraphErrors*) fDAgPhysics->Get( "grVn6Raw" );
  grVn6RawDAgSys      = (TGraphErrors*) fDAgPhysics->Get( "grVn6RawSys" );
  grVn8RawDAg         = (TGraphErrors*) fDAgPhysics->Get( "grVn8Raw" );
  grVn8RawDAgSys      = (TGraphErrors*) fDAgPhysics->Get( "grVn8RawSys" );
  grvn6vn4RatioDAg    = (TGraphErrors*) fDAgPhysics->Get( "grvn6vn4Ratio" );
  grvn6vn4RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn6vn4RatioSys" );
  grvn8vn4RatioDAg    = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn4Ratio" );
  grvn8vn4RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn4RatioSys" );
  grvn8vn6RatioDAg    = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn6Ratio" );
  grvn8vn6RatioDAgSys = (TGraphErrors*) fDAgPhysics->Get( "grvn8vn6RatioSys" );
  grGamma1ExpDAg      = (TGraphErrors*) fDAgPhysics->Get( "grGamma1Exp" );
  grGamma1ExpDAgSys   = (TGraphErrors*) fDAgPhysics->Get( "grGamma1ExpSys" );

  grVn2RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{2}", norder_) );
  grVn4RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{4}", norder_) );
  grVn6RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{6}", norder_) );
  grVn8RawDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}", norder_) );
  grvn6vn4RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{6}/v_{%i}{4}", norder_, norder_) );
  grvn8vn4RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}/v_{%i}{4}", norder_, norder_) );
  grvn8vn6RatioDAgSys->GetYaxis()->SetTitle( Form("v_{%i}{8}/v_{%i}{6}", norder_, norder_) );
  grGamma1ExpDAgSys->GetYaxis()->SetTitle("#gamma_{1}^{exp}");

  grVn2RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax);
  grVn4RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax);
  grVn6RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax);
  grVn8RawDAgSys->GetYaxis()->SetRangeUser(cumuMin, cumuMax);
  grvn6vn4RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin, cumuRatMax);
  grvn8vn4RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin, cumuRatMax);
  grvn8vn6RatioDAgSys->GetYaxis()->SetRangeUser(cumuRatMin86, cumuRatMax86);
  grGamma1ExpDAgSys->GetYaxis()->SetRangeUser(g1eMin, g1eMax);

  grVn2RawDAgSys->GetXaxis()->SetTitle("Centrality %");
  grVn4RawDAgSys->GetXaxis()->SetTitle("Centrality %");
  grVn6RawDAgSys->GetXaxis()->SetTitle("Centrality %");
  grVn8RawDAgSys->GetXaxis()->SetTitle("Centrality %");
  grvn6vn4RatioDAgSys->GetXaxis()->SetTitle("Centrality %");
  grvn8vn4RatioDAgSys->GetXaxis()->SetTitle("Centrality %");
  grvn8vn6RatioDAgSys->GetXaxis()->SetTitle("Centrality %");
  grGamma1ExpDAgSys->GetXaxis()->SetTitle("Centrality %");


  //-- Get SVD objects
  fSVDPhysics = new TFile( "../../systematicStudies/SVDPhysics.root" );

  for(int icent = 0; icent < NCENT; icent++){
    hUnfoldSVD[icent] = (TH1D*) fSVDPhysics->Get( Form("hrecokreg4_c%i", icent) );
    hUnfoldSVD[icent]->SetLineColor(2);
    hUnfoldSVD[icent]->SetMarkerColor(2);
    hUnfoldSVD[icent]->Scale( 1./hUnfoldSVD[icent]->Integral() );

    //-- Ratio to D'Agostini
    hUnfoldRatio_SVD_DAg[icent] = (TH1D*) hUnfoldSVD[icent]->Clone( Form("hUnfoldRatio_SVD_DAg_c%i", icent) );
    hUnfoldRatio_SVD_DAg[icent]->Divide( hUnfoldStatAndSysDAg[icent] );
    hUnfoldRatio_SVD_DAg[icent]->SetMinimum(histMin);
    hUnfoldRatio_SVD_DAg[icent]->SetMaximum(histMax);

  }

  grVn2RawSVD      = (TGraphErrors*) fSVDPhysics->Get( "grVn2" );
  grVn4RawSVD      = (TGraphErrors*) fSVDPhysics->Get( "grVn4" );
  grVn6RawSVD      = (TGraphErrors*) fSVDPhysics->Get( "grVn6" );
  grVn8RawSVD      = (TGraphErrors*) fSVDPhysics->Get( "grVn8" );
  grvn6vn4RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn6Vn4" );
  grvn8vn4RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn8Vn4" );
  grvn8vn6RatioSVD = (TGraphErrors*) fSVDPhysics->Get( "grVn8Vn6" );
  grGamma1ExpSVD   = (TGraphErrors*) fSVDPhysics->Get( "grG1E" );

  //-- Fill Ratio Arrays
  for(int icent = 0; icent < NCENT; icent++){

    //-- D'Agostini
    double vn2D    = grVn2RawDAg->GetY()[icent];
    double vn4D    = grVn4RawDAg->GetY()[icent];
    double vn6D    = grVn6RawDAg->GetY()[icent];
    double vn8D    = grVn8RawDAg->GetY()[icent];
    double vn6vn4D = grvn6vn4RatioDAg->GetY()[icent];
    double vn8vn4D = grvn8vn4RatioDAg->GetY()[icent];
    double vn8vn6D = grvn8vn6RatioDAg->GetY()[icent];
    double g1eD    = grGamma1ExpDAg->GetY()[icent];

    double vn2D_Ste    = grVn2RawDAg->GetErrorY(icent);
    double vn4D_Ste    = grVn4RawDAg->GetErrorY(icent);
    double vn6D_Ste    = grVn6RawDAg->GetErrorY(icent);
    double vn8D_Ste    = grVn8RawDAg->GetErrorY(icent);
    double vn6vn4D_Ste = grvn6vn4RatioDAg->GetErrorY(icent);
    double vn8vn4D_Ste = grvn8vn4RatioDAg->GetErrorY(icent);
    double vn8vn6D_Ste = grvn8vn6RatioDAg->GetErrorY(icent);
    double g1eD_Ste    = grGamma1ExpDAg->GetErrorY(icent);

    double vn2D_Sye    = grVn2RawDAgSys->GetErrorY(icent);
    double vn4D_Sye    = grVn4RawDAgSys->GetErrorY(icent);
    double vn6D_Sye    = grVn6RawDAgSys->GetErrorY(icent);
    double vn8D_Sye    = grVn8RawDAgSys->GetErrorY(icent);
    double vn6vn4D_Sye = grvn6vn4RatioDAgSys->GetErrorY(icent);
    double vn8vn4D_Sye = grvn8vn4RatioDAgSys->GetErrorY(icent);
    double vn8vn6D_Sye = grvn8vn6RatioDAgSys->GetErrorY(icent);
    double g1eD_Sye    = grGamma1ExpDAgSys->GetErrorY(icent);

    double vn2D_Tote    = sqrt( pow(vn2D_Ste, 2) + pow(vn2D_Sye, 2) );
    double vn4D_Tote    = sqrt( pow(vn4D_Ste, 2) + pow(vn4D_Sye, 2) );
    double vn6D_Tote    = sqrt( pow(vn6D_Ste, 2) + pow(vn6D_Sye, 2) );
    double vn8D_Tote    = sqrt( pow(vn8D_Ste, 2) + pow(vn8D_Sye, 2) );
    double vn6vn4D_Tote = sqrt( pow(vn6vn4D_Ste, 2) + pow(vn6vn4D_Sye, 2) );
    double vn8vn4D_Tote = sqrt( pow(vn8vn4D_Ste, 2) + pow(vn8vn4D_Sye, 2) );
    double vn8vn6D_Tote = sqrt( pow(vn8vn6D_Ste, 2) + pow(vn8vn6D_Sye, 2) );
    double g1eD_Tote    = sqrt( pow(g1eD_Ste, 2) + pow(g1eD_Sye, 2) );

    //-- SVD
    double vn2S    = grVn2RawSVD->GetY()[icent];
    double vn4S    = grVn4RawSVD->GetY()[icent];
    double vn6S    = grVn6RawSVD->GetY()[icent];
    double vn8S    = grVn8RawSVD->GetY()[icent];
    double vn6vn4S = grvn6vn4RatioSVD->GetY()[icent];
    double vn8vn4S = grvn8vn4RatioSVD->GetY()[icent];
    double vn8vn6S = grvn8vn6RatioSVD->GetY()[icent];
    double g1eS    = grGamma1ExpSVD->GetY()[icent];

    double vn2S_Ste    = grVn2RawSVD->GetErrorY(icent);
    double vn4S_Ste    = grVn4RawSVD->GetErrorY(icent);
    double vn6S_Ste    = grVn6RawSVD->GetErrorY(icent);
    double vn8S_Ste    = grVn8RawSVD->GetErrorY(icent);
    double vn6vn4S_Ste = grvn6vn4RatioSVD->GetErrorY(icent);
    double vn8vn4S_Ste = grvn8vn4RatioSVD->GetErrorY(icent);
    double vn8vn6S_Ste = grvn8vn6RatioSVD->GetErrorY(icent);
    double g1eS_Ste    = grGamma1ExpSVD->GetErrorY(icent);

    //-- Ratios
    double vn2SD;
    double vn4SD;
    double vn6SD;
    double vn8SD;
    double vn6vn4SD;
    double vn8vn4SD;
    double vn8vn6SD;
    double g1eSD;

    if(vn2D <= 0 || vn2S <= 0) vn2SD = -1;
    else                       vn2SD = vn2S / vn2D;
    if(vn4D <= 0 || vn4S <= 0) vn4SD = -1;
    else                       vn4SD = vn4S / vn4D;
    if(vn6D <= 0 || vn6S <= 0) vn6SD = -1;
    else                       vn6SD = vn6S / vn6D;
    if(vn8D <= 0 || vn8S <= 0) vn8SD = -1;
    else                       vn8SD = vn8S / vn8D;

    if(vn6vn4D <= 0 || vn6vn4S <= 0) vn6vn4SD = -1;
    else                             vn6vn4SD = vn6vn4S / vn6vn4D;
    if(vn8vn4D <= 0 || vn8vn4S <= 0) vn8vn4SD =-1;
    else                             vn8vn4SD =vn8vn4S/ vn8vn4D;
    if(vn8vn6D <= 0 || vn8vn6S <= 0) vn8vn6SD =-1;
    else                             vn8vn6SD =vn8vn6S/ vn8vn6D;
    if(g1eS < -100. || g1eD < -100.) g1eSD = -10000.;
    else                             g1eSD = g1eS / g1eD;

    double vn2SDe    = sqrt( pow(vn2S_Ste/vn2D, 2) + pow(vn2S*vn2D_Tote/vn2D/vn2D, 2) );
    double vn4SDe    = sqrt( pow(vn4S_Ste/vn4D, 2) + pow(vn4S*vn4D_Tote/vn4D/vn4D, 2) );
    double vn6SDe    = sqrt( pow(vn6S_Ste/vn6D, 2) + pow(vn6S*vn6D_Tote/vn6D/vn6D, 2) );
    double vn8SDe    = sqrt( pow(vn8S_Ste/vn8D, 2) + pow(vn8S*vn8D_Tote/vn8D/vn8D, 2) );
    double vn6vn4SDe = sqrt( pow(vn6vn4S_Ste/vn6vn4D, 2) + pow(vn6vn4S*vn6vn4D_Tote/vn6vn4D/vn6vn4D, 2) );
    double vn8vn4SDe = sqrt( pow(vn8vn4S_Ste/vn8vn4D, 2) + pow(vn8vn4S*vn8vn4D_Tote/vn8vn4D/vn8vn4D, 2) );
    double vn8vn6SDe = sqrt( pow(vn8vn6S_Ste/vn8vn6D, 2) + pow(vn8vn6S*vn8vn6D_Tote/vn8vn6D/vn8vn6D, 2) );
    double g1eSDe    = sqrt( pow(g1eS_Ste/g1eD, 2) + pow(g1eS*g1eD_Tote/g1eD/g1eD, 2) );

    vn2SVD_DAg[icent]    = vn2SD;
    vn4SVD_DAg[icent]    = vn4SD;
    vn6SVD_DAg[icent]    = vn6SD;
    vn8SVD_DAg[icent]    = vn8SD;
    vn6vn4SVD_DAg[icent] = vn6vn4SD;
    vn8vn4SVD_DAg[icent] = vn8vn4SD;
    vn8vn6SVD_DAg[icent] = vn8vn6SD;
    g1eSVD_DAg[icent]    = g1eSD;

    vn2SVD_DAg_err[icent]    = vn2SDe;
    vn4SVD_DAg_err[icent]    = vn4SDe;
    vn6SVD_DAg_err[icent]    = vn6SDe;
    vn8SVD_DAg_err[icent]    = vn8SDe;
    vn6vn4SVD_DAg_err[icent] = vn6vn4SDe;
    vn8vn4SVD_DAg_err[icent] = vn8vn4SDe;
    vn8vn6SVD_DAg_err[icent] = vn8vn6SDe;
    g1eSVD_DAg_err[icent]    = g1eSDe;

  }

  //-- TGraph time
  grVn2RawRatio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn2SVD_DAg,    CERR, vn2SVD_DAg_err);
  grVn4RawRatio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn4SVD_DAg,    CERR, vn4SVD_DAg_err);
  grVn6RawRatio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn6SVD_DAg,    CERR, vn6SVD_DAg_err);
  grVn8RawRatio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn8SVD_DAg,    CERR, vn8SVD_DAg_err);
  grvn6vn4Ratio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn6vn4SVD_DAg, CERR, vn6vn4SVD_DAg_err);
  grvn8vn4Ratio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn8vn4SVD_DAg, CERR, vn8vn4SVD_DAg_err);
  grvn8vn6Ratio_SVD_DAg    = new TGraphErrors(NCENT, centBinCenter, vn8vn6SVD_DAg, CERR, vn8vn6SVD_DAg_err);
  grGamma1ExpRatio_SVD_DAg = new TGraphErrors(NCENT, centBinCenter, g1eSVD_DAg,    CERR, g1eSVD_DAg_err);

  formatGraph(grVn2RawRatio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{2} Ratio: SVD/DAg", norder_),                    1, 20, "grVn2RawRatio_SVD_DAg");
  formatGraph(grVn4RawRatio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{4} Ratio: SVD/DAg", norder_),                    1, 20, "grVn4RawRatio_SVD_DAg");
  formatGraph(grVn6RawRatio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{6} Ratio: SVD/DAg", norder_),                    1, 20, "grVn6RawRatio_SVD_DAg");
  formatGraph(grVn8RawRatio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{8} Ratio: SVD/DAg", norder_),                    1, 20, "grVn8RawRatio_SVD_DAg");
  formatGraph(grvn6vn4Ratio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{6}/v_{%i}{4} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn6vn4Ratio_SVD_DAg");
  formatGraph(grvn8vn4Ratio_SVD_DAg,    "Centrality %", ratioMin,       ratioMax,       Form("v_{%i}{8}/v_{%i}{4} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn8vn4Ratio_SVD_DAg");
  formatGraph(grvn8vn6Ratio_SVD_DAg,    "Centrality %", ratioMinVn8Vn6, ratioMaxVn8Vn6, Form("v_{%i}{8}/v_{%i}{6} Ratio: SVD/DAg", norder_, norder_), 1, 20, "grvn8vn6Ratio_SVD_DAg");
  formatGraph(grGamma1ExpRatio_SVD_DAg, "Centrality %", ratioMinG1E,    ratioMaxG1E,    "#gamma_{1}^{exp} Ratio: SVD/DAg",                            1, 20, "grGamma1ExpRatio_SVD_DAg");

  grVn2RawSVD->SetLineColor(1);
  grVn4RawSVD->SetLineColor(1);
  grVn6RawSVD->SetLineColor(1);
  grVn8RawSVD->SetLineColor(1);
  grvn6vn4RatioSVD->SetLineColor(1);
  grvn8vn4RatioSVD->SetLineColor(1);
  grvn8vn6RatioSVD->SetLineColor(1);
  grGamma1ExpSVD->SetLineColor(1);

  grVn2RawSVD->SetMarkerColor(1);
  grVn4RawSVD->SetMarkerColor(1);
  grVn6RawSVD->SetMarkerColor(1);
  grVn8RawSVD->SetMarkerColor(1);
  grvn6vn4RatioSVD->SetMarkerColor(1);
  grvn8vn4RatioSVD->SetMarkerColor(1);
  grvn8vn6RatioSVD->SetMarkerColor(1);
  grGamma1ExpSVD->SetMarkerColor(1);

  //-- DRAW

  TLine * lOne = new TLine(0, 1.0, grVn2RawRatio_SVD_DAg->GetXaxis()->GetXmax(), 1.0);
  lOne->SetLineStyle(2);
  lOne->SetLineWidth(2);

  //-- cumus
  TLegend * legvn2 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675);
  legvn2->SetBorderSize(0);
  legvn2->SetFillStyle(0);
  legvn2->AddEntry(grVn2RawDAg, "D'Agostini", "lp");
  legvn2->AddEntry(grVn2RawSVD, "SVD",        "lp");

  TLegend * legvn4 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675);
  legvn4->SetBorderSize(0);
  legvn4->SetFillStyle(0);
  legvn4->AddEntry(grVn4RawDAg, "D'Agostini", "lp");
  legvn4->AddEntry(grVn4RawSVD, "SVD",        "lp");

  TLegend * legvn6 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675);
  legvn6->SetBorderSize(0);
  legvn6->SetFillStyle(0);
  legvn6->AddEntry(grVn6RawDAg, "D'Agostini", "lp");
  legvn6->AddEntry(grVn6RawSVD, "SVD",        "lp");

  TLegend * legvn8 = new TLegend(0.4939, 0.2013, 0.8977, 0.3675);
  legvn8->SetBorderSize(0);
  legvn8->SetFillStyle(0);
  legvn8->AddEntry(grVn8RawDAg, "D'Agostini", "lp");
  legvn8->AddEntry(grVn8RawSVD, "SVD",        "lp");


  TCanvas * cCumu = new TCanvas("cCumu", "cCumu", 2000, 1000);
  cCumu->Divide(4, 2);

  double mar = 0.2;
  double offs = 1.6;

  grVn2RawDAgSys->GetYaxis()->SetTitleOffset(offs);
  grVn4RawDAgSys->GetYaxis()->SetTitleOffset(offs);
  grVn6RawDAgSys->GetYaxis()->SetTitleOffset(offs);
  grVn8RawDAgSys->GetYaxis()->SetTitleOffset(offs);
  grVn2RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);
  grVn4RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);
  grVn6RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);
  grVn8RawRatio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);

  cCumu->cd(1)->SetLeftMargin(mar);
  grVn2RawDAgSys->Draw("apE2");
  grVn2RawDAg->Draw("psame");
  grVn2RawSVD->Draw("psame");
  legvn2->Draw("same");

  cCumu->cd(2)->SetLeftMargin(mar);
  grVn4RawDAgSys->Draw("apE2");
  grVn4RawDAg->Draw("psame");
  grVn4RawSVD->Draw("psame");
  legvn4->Draw("same");

  cCumu->cd(3)->SetLeftMargin(mar);
  grVn6RawDAgSys->Draw("apE2");
  grVn6RawDAg->Draw("psame");
  grVn6RawSVD->Draw("psame");
  legvn6->Draw("same");

  cCumu->cd(4)->SetLeftMargin(mar);
  grVn8RawDAgSys->Draw("apE2");
  grVn8RawDAg->Draw("psame");
  grVn8RawSVD->Draw("psame");
  legvn8->Draw("same");

  cCumu->cd(5)->SetLeftMargin(mar);
  grVn2RawRatio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumu->cd(6)->SetLeftMargin(mar);
  grVn4RawRatio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumu->cd(7)->SetLeftMargin(mar);
  grVn6RawRatio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumu->cd(8)->SetLeftMargin(mar);
  grVn8RawRatio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumu->SaveAs("cumu.pdf");

  //-- cumu Ratios
  TLegend * legvn6vn4 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560);
  legvn6vn4->SetBorderSize(0);
  legvn6vn4->SetFillStyle(0);
  legvn6vn4->AddEntry(grvn6vn4RatioDAg, "D'Agostini", "lp");
  legvn6vn4->AddEntry(grvn6vn4RatioSVD, "SVD",        "lp");
 
  TLegend * legvn8vn4 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560);
  legvn8vn4->SetBorderSize(0);
  legvn8vn4->SetFillStyle(0);
  legvn8vn4->AddEntry(grvn8vn4RatioDAg, "D'Agostini", "lp");
  legvn8vn4->AddEntry(grvn8vn4RatioSVD, "SVD",        "lp");

  TLegend * legvn8vn6 = new TLegend(0.2146, 0.1898, 0.6194, 0.3560);
  legvn8vn6->SetBorderSize(0);
  legvn8vn6->SetFillStyle(0);
  legvn8vn6->AddEntry(grvn8vn6RatioDAg, "D'Agostini", "lp");
  legvn8vn6->AddEntry(grvn8vn6RatioSVD, "SVD",        "lp");

  TCanvas * cCumuRatio = new TCanvas("cCumuRatio", "cCumuRatio", 1500, 1000);
  cCumuRatio->Divide(3, 2);

  grvn6vn4RatioDAgSys->GetYaxis()->SetTitleOffset(offs);
  grvn8vn4RatioDAgSys->GetYaxis()->SetTitleOffset(offs);
  grvn8vn6RatioDAgSys->GetYaxis()->SetTitleOffset(offs+0.1);
  grvn6vn4Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);
  grvn8vn4Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs);
  grvn8vn6Ratio_SVD_DAg->GetYaxis()->SetTitleOffset(offs+0.1);

  cCumuRatio->cd(1)->SetLeftMargin(mar);
  grvn6vn4RatioDAgSys->Draw("apE2");
  grvn6vn4RatioDAg->Draw("psame");
  grvn6vn4RatioSVD->Draw("psame");
  legvn6vn4->Draw("same");

  cCumuRatio->cd(2)->SetLeftMargin(mar);
  grvn8vn4RatioDAgSys->Draw("apE2");
  grvn8vn4RatioDAg->Draw("psame");
  grvn8vn4RatioSVD->Draw("psame");
  legvn8vn4->Draw("same");

  cCumuRatio->cd(3)->SetLeftMargin(mar);
  grvn8vn6RatioDAgSys->Draw("apE2");
  grvn8vn6RatioDAg->Draw("psame");
  grvn8vn6RatioSVD->Draw("psame");
  legvn8vn6->Draw("same");

  cCumuRatio->cd(4)->SetLeftMargin(mar);
  grvn6vn4Ratio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumuRatio->cd(5)->SetLeftMargin(mar);
  grvn8vn4Ratio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumuRatio->cd(6)->SetLeftMargin(mar);
  grvn8vn6Ratio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cCumuRatio->SaveAs("cumuRatio.pdf");

  //-- Gamma1Exp
  TLegend * legg1e = new TLegend(0.1846, 0.1898, 0.5894, 0.3560);
  legg1e->SetBorderSize(0);
  legg1e->SetFillStyle(0);
  legg1e->AddEntry(grGamma1ExpDAg, "D'Agostini", "lp");
  legg1e->AddEntry(grGamma1ExpSVD, "SVD",        "lp");

  TCanvas * cG1E = new TCanvas("cG1E", "cG1E", 1000, 500);
  cG1E->Divide(2, 1);

  cG1E->cd(1);
  grGamma1ExpDAgSys->Draw("apE2");
  grGamma1ExpDAg->Draw("psame");
  grGamma1ExpSVD->Draw("psame");
  legg1e->Draw("same");

  cG1E->cd(2);
  grGamma1ExpRatio_SVD_DAg->Draw("ap");
  lOne->Draw("same");

  cG1E->SaveAs("G1E.pdf");

  //-- Unfold Distns

  TLegend * legUnf = new TLegend(0.6, 0.6, 0.9, 0.8);
  legInit(legUnf);
  legUnf->AddEntry(hUnfoldStatDAg[0], "D'Agostini", "lp");
  legUnf->AddEntry(hUnfoldSVD[0],     "SVD",        "lp");

  cUnfold = new TCanvas("cUnfold", "cUnfold", 2000, 1500);
  cUnfold->Divide(4,3);
  for(int icent = 0; icent < NCENT; icent++){
    cUnfold->cd(icent+1);
    cUnfold->cd(icent+1)->SetLogy();
    hUnfoldSysDAg[icent]->Draw("e2");
    setex2->Draw();
    if(icent == 0) legUnf->Draw("same");
  }
  for(int icent= 0; icent < NCENT; icent++){
    cUnfold->cd(icent+1);
    hUnfoldStatDAg[icent]->Draw("same");
    hUnfoldSVD[icent]->Draw("same");
    latex.DrawLatex(0.67, 0.88, Form( "Cent %i-%i%s", cent_min[icent], cent_max[icent], "%") );
  }
  cUnfold->SaveAs("UnfoldCompare.pdf");

  //-- Unfold Ratio SVD/DAg
  cUnfoldRatio_SVD_DAg = new TCanvas("cUnfoldRatio_SVD_DAg", "cUnfoldRatio_SVD_DAg", 2000, 1500);
  cUnfoldRatio_SVD_DAg->Divide(4,3);
  for(int icent= 0; icent < NCENT; icent++){
    cUnfoldRatio_SVD_DAg->cd(icent+1);
    hUnfoldRatio_SVD_DAg[icent]->Draw();
    latex.DrawLatex(0.67, 0.88, Form( "Cent %i-%i%s", cent_min[icent], cent_max[icent], "%") );
  }
  cUnfoldRatio_SVD_DAg->SaveAs("UnfoldRatioCompare.pdf");

}
void PostFitCombine(TString Plots = "fit_s", TString InpDir = "FitResults_DataCardFixbtagSysVisPhSp_hSF-PreApp-v0_Tree_LepJets_NewJEC-OldKinFit_v8-0-6_Spring16-80X_36814pb-1_2btag", TString FitDir = "OBSERVED"){

  TString PlotsFileName;
  if(FitDir == "OBSERVED") PlotsFileName = "obs";
  if(FitDir == "EXPECTED") PlotsFileName = "exp";
 
  TString inputfile = "CombineResults/" + InpDir + "/" + FitDir + "/fitDiagnostics" + PlotsFileName + "MLF.root";
  
 
  setTDRStyle();

  gROOT->SetStyle("Plain");
  gStyle->SetOptFit(1000);
  gStyle->SetOptStat("emruo");
  gStyle->SetOptStat(kFALSE);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  
  int col_ttbb = TColor::GetColor("#660000");
  int col_ttb  = TColor::GetColor("#ffcc00");
  int col_ttcc = TColor::GetColor("#cc6600");
  int col_ttc  = TColor::GetColor("#cc6600");
  int col_ttLF = TColor::GetColor("#ff0000");
  int col_tt   = TColor::GetColor("#FF7F7F");

  int col_ttbarBkg  = TColor::GetColor("#ff6565");
  int col_SingleTop = TColor::GetColor("#ff00ff");
  int col_WJets     = TColor::GetColor("#33cc33");
  int col_ZJets     = TColor::GetColor("#3366ff");
  int col_QCD       = TColor::GetColor("#ffff00");
  int col_ttbarV    = TColor::GetColor("#e75c8d");
  int col_ttbarH    = TColor::GetColor("#e5c4f4");
  int col_VV        = TColor::GetColor("#ffffff");
 
  TFile *hfile = NULL;
  hfile = TFile::Open(inputfile);
  cout << "file loaded: " << inputfile << endl;

  std::vector<TString> hNamefile;
  std::vector<int> hColor;
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattbb"); // 0
  hColor.push_back(TColor::GetColor("#660000"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattbj"); // 1 
  hColor.push_back(TColor::GetColor("#ffcc00"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattcc"); // 2
  hColor.push_back(TColor::GetColor("#cc6600"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattLF"); // 3
  hColor.push_back(TColor::GetColor("#ff0000"));
  hNamefile.push_back("ttbar_PowhegPythiaBkgtt");
  hColor.push_back(TColor::GetColor("#FF7F7F"));
  hNamefile.push_back("ttHbb_PowhegPythia");
  hColor.push_back(TColor::GetColor("#e5c4f4"));
  hNamefile.push_back("ttV_Madgraph");
  hColor.push_back(TColor::GetColor("#e75c8d"));
  hNamefile.push_back("WJets_aMCatNLO");
  hColor.push_back(TColor::GetColor("#33cc33"));
  hNamefile.push_back("QCD");
  hColor.push_back(TColor::GetColor("#ffff00"));
  hNamefile.push_back("SingleTop");
  hColor.push_back(TColor::GetColor("#ff00ff"));
  hNamefile.push_back("VV");
  hColor.push_back(TColor::GetColor("#ffffff"));
  hNamefile.push_back("ZJets_aMCatNLO");
  hColor.push_back(TColor::GetColor("#3366ff"));
  hNamefile.push_back("total");
  hColor.push_back(1);
  hNamefile.push_back("total_signal");
  hColor.push_back(1);
  hNamefile.push_back("total_background");
  hColor.push_back(1);



  //TString dirname[2]     = {"Name1","Name2"};     //{mu,e}
  TString dirname[2]     = {"ch1","ch2"};     //{mu,e}
  TString titlechname[2] = {"#mu+Jets","e+Jets"}; 
  TString chname[2]      = {"mujets","ejets"};    

  std::vector<TH1D*> hInput[2];
  TH1D    *hData[2], *hData_reg[2][20];
  THStack *AllMC[2], *AllMC_reg[2][20];
  
  THStack *AllMC_CSV1[2], *AllMC_CSV2[2];

  // THStack Initialization
  for(int ich=0;ich<2;ich++){
    AllMC[ich] = new THStack("PostFit_"+chname[ich], "CSV Distribution Post-Fit ("+titlechname[ich]+")");  
    for(int ireg=0;ireg<20;ireg++){
      TString RegNum;
      RegNum.Form("%i",ireg); 
      AllMC_reg[ich][ireg] = new THStack("PostFit_"+chname[ich]+RegNum, "CSV Distribution Post-Fit ("+titlechname[ich]+") for "+RegNum);        
    } // for(ireg)
  } // for(ich)
 
  cout << "Loading histograms... " << endl;

  // MC Profiles
  for(int ich=0;ich<2;ich++){

    for(int ih=0;ih<hNamefile.size();ih++){      
      cout << "shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih) << endl;
      TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c" + hNamefile.at(ih));
      htemp->SetFillColor(hColor.at(ih));
      htemp->SetLineColor(1);
      hInput[ich].push_back(htemp);
      cout << hNamefile.at(ih) << " = " << htemp->Integral()  << endl;
      if(ih==0) AllMC[ich]->SetHistogram((TH1D*)htemp->Clone("FirstStack"));
      if (!hNamefile.at(ih).Contains("total")) AllMC[ich] -> Add(htemp);
      // Data
      // Clone Histo Structure only once
      if(ih==0){
	hData[ich] = (TH1D *) htemp->Clone("data_"+dirname[ich]);
	hData[ich]->Reset();
      }
    } // for(ih)

    // Data TGraph
    TGraphAsymmErrors *DataFull = (TGraphAsymmErrors *) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/data")->Clone("data_"+dirname[ich]);
    for(int ibin=1;ibin<=hData[ich]->GetNbinsX();ibin++){ 
      double igb, EvtBinData, EvtErrBinData;
      DataFull->GetPoint((ibin-1),igb,EvtBinData); 
      hData[ich]->SetBinContent(ibin,EvtBinData);
      EvtErrBinData = DataFull->GetErrorY((ibin-1));
      hData[ich]->SetBinError(ibin,EvtErrBinData);
    }
    
    // Histograms for each region
    for(int ih=0;ih<hNamefile.size();ih++){

      TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c_reg" + hNamefile.at(ih));
      
      for(int ireg=0;ireg<20;ireg++){
	TH1D *htempreg = new TH1D ("","",20,0,20);       
    	for(int ibin=1;ibin<=20;ibin++){
	  //if ( (ibin+20*ireg) == 181) cout << hNamefile.at(ih) << " " << ibin+20*ireg << " : " << htemp->GetBinContent(ibin+20*ireg) << " ; " << htemp->GetBinError(ibin+20*ireg) << endl;
    	  htempreg->SetBinContent(ibin,htemp->GetBinContent(ibin+20*ireg));	  
    	  htempreg->SetBinError(ibin,htemp->GetBinError(ibin+20*ireg));	  
	  htempreg->SetFillColor(hColor.at(ih));
    	} // for(ibin)
	if(ih==0) AllMC_reg[ich][ireg]->SetHistogram((TH1D*)htempreg->Clone("FirstStack"));
	if (!hNamefile.at(ih).Contains("total")) AllMC_reg[ich][ireg] -> Add(htempreg);
      } // for(ireg)
    } // for(ih)

    // Data
    for(int ireg=0;ireg<20;ireg++){
      TString RegNum;
      RegNum.Form("%i",ireg);
      hData_reg[ich][ireg] = new TH1D ("hData_"+chname[ich]+RegNum,"Data Histogram "+titlechname[ich]+" for "+RegNum,20,0,20);       

      // Data
      for(int ibin=1;ibin<=20;ibin++){ 
	double igb, EvtBinData, EvtErrBinData;
	DataFull->GetPoint(((ibin-1)+(20*ireg)),igb,EvtBinData); 
	hData_reg[ich][ireg]->SetBinContent(ibin,EvtBinData);	  
	EvtErrBinData = DataFull->GetErrorY((ibin-1));
	hData_reg[ich][ireg]->SetBinError(ibin,EvtErrBinData);

	hData_reg[ich][ireg]->SetMarkerStyle(20);
	hData_reg[ich][ireg]->SetMarkerSize(0.5);
      } // for(ibin)
    } // for(ireg)


    // Recover basic CSV plots
    // -- MC
    TH1D *GlobalCSVJet[12][2]; // 12 components
    AllMC_CSV1[ich] = new THStack("CSV1_"+chname[ich], "CSV-AddJet1 Distribution Post-Fit ("+titlechname[ich]+")");
    AllMC_CSV2[ich] = new THStack("CSV2_"+chname[ich], "CSV-AddJet2 Distribution Post-Fit ("+titlechname[ich]+")");

    for(int ih=0;ih<12;ih++){
      GlobalCSVJet[ih][0] = new TH1D("GlobalCSVJet1_" + hNamefile.at(ih), "CSV distribution for AddJet-1", 20, 0.0, 1.0);
      GlobalCSVJet[ih][1] = new TH1D("GlobalCSVJet2_" + hNamefile.at(ih), "CSV distribution for AddJet-2", 20, 0.0, 1.0);
      RecoverCSVHisto (hInput[ich].at(ih), GlobalCSVJet[ih][0], GlobalCSVJet[ih][1]);
      GlobalCSVJet[ih][0]->SetFillColor(hColor.at(ih));
      GlobalCSVJet[ih][1]->SetFillColor(hColor.at(ih));
      
      if(ih==0) AllMC_CSV1[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][0]->Clone("FirstStack"));
      if(ih==0) AllMC_CSV2[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][1]->Clone("FirstStack"));
      AllMC_CSV1[ich] -> Add(GlobalCSVJet[ih][0]);
      AllMC_CSV2[ich] -> Add(GlobalCSVJet[ih][1]);
    }

    // -- Data
    TH1D *GlobalCSVJet_Data[2]; // 12 components
    GlobalCSVJet_Data[0] = new TH1D("GlobalCSVJet1_Data", "CSV distribution for AddJet-1", 20, 0.0, 1.0);
    GlobalCSVJet_Data[1] = new TH1D("GlobalCSVJet2_Data", "CSV distribution for AddJet-2", 20, 0.0, 1.0);
    RecoverCSVHisto (hData[ich], GlobalCSVJet_Data[0], GlobalCSVJet_Data[1]);
    
    // -----------
    // Plotting
    // -----------

    TH1D *hstyle = new TH1D ("","",
			     hData[ich]->GetNbinsX(),
			     hData[ich]->GetBinLowEdge (1),
			     hData[ich]->GetBinLowEdge (hData[ich]->GetNbinsX()+1));
    
    hstyle -> SetMaximum(1.1*hInput[ich].at(12)->GetMaximum());
    hstyle -> GetYaxis()->SetTitleFont(42);
    hstyle -> GetYaxis()->SetTitleOffset(0.7);
    hstyle -> GetYaxis()->SetTitleSize(0.05);
    hstyle -> GetYaxis()->SetLabelFont(42);
    hstyle -> GetYaxis()->SetLabelSize(0.045);
    hstyle -> GetYaxis()->SetNdivisions(607);
    hstyle -> GetYaxis()->SetTitle("Events / unit"); 
    
    
    hData[ich] -> SetMarkerStyle(20); 
    hData[ich] -> SetMarkerSize(0.4); 
    hData[ich] -> SetLineWidth(1); 
    hData[ich] -> SetTitle(""); 
    
    
    TCanvas *cPlots;//histos
    cPlots = new TCanvas("cPlots"+dirname[ich] ,"Plots");
    cPlots->Divide(1,2);
    TPad    *pad[4], *glpad[2];
    // Global Pad
    glpad[0] = (TPad*)cPlots->GetPad(1);
    glpad[0]->Divide(1,2);
    glpad[1] = (TPad*)cPlots->GetPad(2);
    glpad[1]->Divide(1,2);

    //Plot Pad
    pad[0] = (TPad*)glpad[0]->GetPad(1);
    pad[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    pad[0]->SetTopMargin(0.1);
    pad[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    pad[1] = (TPad*)glpad[0]->GetPad(2);
    pad[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    pad[1]->SetGridx();
    pad[1]->SetGridy();
    pad[1]->SetTopMargin(0.05);
    pad[1]->SetBottomMargin(0.4);
    pad[1]->SetRightMargin(0.04);

    //Plot Pad
    pad[2] = (TPad*)glpad[1]->GetPad(1);
    pad[2]->SetPad(0.01, 0.23, 0.99, 0.99);
    pad[2]->SetTopMargin(0.1);
    pad[2]->SetRightMargin(0.04);
    
    //Ratio Pad
    pad[3] = (TPad*)glpad[1]->GetPad(2);
    pad[3]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    pad[3]->SetGridx();
    pad[3]->SetGridy();
    pad[3]->SetTopMargin(0.05);
    pad[3]->SetBottomMargin(0.4);
    pad[3]->SetRightMargin(0.04);
    
    pad[0]->cd();

    hstyle->Draw();
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    
    TH1D *RatioFull = HistoRatio (hData[ich] , (TH1D*) AllMC[ich]->GetStack()->Last());
    TGraphErrors *gRatioFull = new TGraphErrors(RatioFull);
    gRatioFull->SetFillStyle(1001);
    gRatioFull->SetFillColor(chatch);
    gRatioFull->SetName("gRatioFull");


    TLegend *leg;
    float legPos[4] = {0.70,  // x_o
		       0.40,  // y_o
		       0.94,  // x_f
		       0.87}; // y_f
 
    leg = new TLegend(legPos[0],legPos[1],legPos[2],legPos[3]);
    leg->SetFillColor(0);
    leg->SetLineColor(0);
    leg->SetLineWidth(0.0);
    leg->SetTextFont(62);
    leg->SetTextSize(0.03);
    leg->SetNColumns(2);
  
    leg->AddEntry(hData[ich],         "Data","PL");
    leg->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    leg->AddEntry(hInput[ich].at(10), "VV","F");
    leg->AddEntry(hInput[ich].at(9),  "Single t","F");
    leg->AddEntry(hInput[ich].at(8),  "QCD","F");
    leg->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    leg->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    leg->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    leg->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    leg->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    leg->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    leg->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    leg->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    leg->AddEntry(gRatioFull,         "Stat. Unc.","F");

    leg->Draw("SAME");
    
    TLatex *titlePr;      
    titlePr  = new TLatex(-20.,50.,"35.9 fb^{-1} (13TeV)");
    titlePr->SetNDC();
    titlePr->SetTextAlign(12);
    titlePr->SetX(0.78);
    titlePr->SetY(0.935);
    titlePr->SetTextFont(42);
    titlePr->SetTextSize(0.05);
    titlePr->SetTextSizePixels(24);
    titlePr->Draw("SAME");
    
    TLatex *title;
    //title  = new TLatex(-20.,50.,"CMS(2016) #sqrt{s} = 13TeV, L = 35.9 fb^{-1}");
    title  = new TLatex(-20.,50.,"CMS");
    title->SetNDC();
    title->SetTextAlign(12);
    title->SetX(0.13);
    title->SetY(0.84);
    title->SetTextFont(61);
    title->SetTextSize(0.06);
    title->SetTextSizePixels(24);
    title->Draw("SAME");
  
    TLatex *chtitle;
    chtitle  = new TLatex(-20.,50.,titlechname[ich]+"");
    chtitle->SetNDC();
    chtitle->SetTextAlign(12);
    chtitle->SetX(0.14);
    chtitle->SetY(0.74);
    chtitle->SetTextFont(42);
    chtitle->SetTextSize(0.05);
    chtitle->SetTextSizePixels(24);
    chtitle->Draw("SAME");

    pad[2]->cd();
    pad[2]->cd()->SetLogy();
    
    TH1D *hstyleLog = (TH1D *)hstyle->Clone();
    hstyleLog -> SetMaximum(10.0*hInput[ich].at(12)->GetMaximum());
    hstyleLog -> SetMinimum(0.8);
    hstyleLog -> Draw();
    
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");

    pad[1]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    pad[3]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    TString dirfigname_pdf = "CombineResults/Figures_" + InpDir + Plots + FitDir + "/";
    // make a dir if it does not exist!!
    gSystem->mkdir(dirfigname_pdf, kTRUE);

    cPlots->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_NormLog.pdf");

    // -----------------------------------------------------------------------------
    // Only Log Plots
    // -----------------------------------------------------------------------------

    TCanvas *cPlotsLog;//histos                                                                                                                                                                   
    cPlotsLog = new TCanvas("cPlotsLog"+dirname[ich] ,"Plots");
    cPlotsLog->Divide(1,2);
    TPad    *padLog[2];

    //Plot Pad
    padLog[0] = (TPad*)cPlotsLog->GetPad(1);
    padLog[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    padLog[0]->SetTopMargin(0.1);
    padLog[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    padLog[1] = (TPad*)cPlotsLog->GetPad(2);;
    padLog[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padLog[1]->SetGridx();
    padLog[1]->SetGridy();
    padLog[1]->SetTopMargin(0.05);
    padLog[1]->SetBottomMargin(0.4);
    padLog[1]->SetRightMargin(0.04);

    padLog[0]->cd();
    padLog[0]->cd()->SetLogy();
    
    hstyleLog -> Draw();
    
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");

    TLegend *legLog;
    legLog = new TLegend(0.70,0.60,0.94,0.87);
    legLog->SetFillColor(0);
    legLog->SetLineColor(0);
    legLog->SetLineWidth(0.0);
    legLog->SetTextFont(62);
    legLog->SetTextSize(0.03);
    legLog->SetNColumns(2);
  
    legLog->AddEntry(hData[ich],         "Data","PL");
    legLog->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    legLog->AddEntry(hInput[ich].at(10), "VV","F");
    legLog->AddEntry(hInput[ich].at(9),  "Single t","F");
    legLog->AddEntry(hInput[ich].at(8),  "QCD","F");
    legLog->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    legLog->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    legLog->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    legLog->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    legLog->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    legLog->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    legLog->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    legLog->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    legLog->AddEntry(gRatioFull,         "Stat. Unc.","F");
    legLog->Draw("SAME");

    padLog[1]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    cPlotsLog->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_OnlyLog.pdf");
    
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // Plots by Regions
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    int ireg = 0;
    for(int ican=0;ican<5;ican++){

      TString CanNum;
      CanNum.Form("%i",ican); 
      TCanvas *cPlots_reg;//histos
      cPlots_reg = new TCanvas("cPlots_reg" + CanNum + dirname[ich] ,"Plots By regions");
      cPlots_reg->Divide(2,2);
      
      for(int icr=1;icr<=4;icr++){

        //cPlots_reg->cd(icr);

	TPad *glpad_reg = (TPad*)cPlots_reg->cd(icr);
	glpad_reg->Divide(2,1);
	TPad *pad_reg[2];
	//Plot Pad
	pad_reg[0] = (TPad*)glpad_reg->GetPad(1);
	pad_reg[0]->SetPad(0.01, 0.23, 0.99, 0.99);
	pad_reg[0]->SetTopMargin(0.1);
	pad_reg[0]->SetRightMargin(0.04);	
	//Ratio Pad
	pad_reg[1] = (TPad*)glpad_reg->GetPad(2);
	pad_reg[1]->SetPad(0.01, 0.02, 0.99, 0.3);
	gStyle->SetGridWidth(1);
	gStyle->SetGridColor(14);
	pad_reg[1]->SetGridx();
	pad_reg[1]->SetGridy();
	pad_reg[1]->SetTopMargin(0.05);
	pad_reg[1]->SetBottomMargin(0.4);
	pad_reg[1]->SetRightMargin(0.04);

	pad_reg[0]->cd();
	pad_reg[0]->SetLogy();
	TH1D *hstyle_reg = (TH1D*)AllMC_reg[ich][ireg]->GetHistogram(); 
	hstyle_reg -> Reset();
	hstyle_reg -> SetMaximum(10.0*hData_reg[ich][ireg]->GetMaximum());
	hstyle_reg -> SetMinimum(0.7);
	hstyle_reg -> GetYaxis()->SetTitleOffset(0.9);
	hstyle_reg -> GetYaxis()->SetTitleSize(0.05);
	hstyle_reg -> GetYaxis()->SetLabelSize(0.05);
	hstyle_reg -> GetYaxis()->SetTitle("Events"); 

	pad_reg[0]->cd();
	hstyle_reg->Draw();
	AllMC_reg[ich][ireg] -> Draw("HISTSAME"); 
	hData_reg[ich][ireg] -> Draw("E1SAME"); 
	titlePr->Draw("SAME");
	title->Draw("SAME");
	chtitle->Draw("SAME");	

	TH1D *RatioFull_reg = HistoRatio (hData_reg[ich][ireg] , (TH1D*) AllMC_reg[ich][ireg]->GetStack()->Last());
	TGraphErrors *gRatioFull_reg = new TGraphErrors(RatioFull_reg);
	gRatioFull_reg->SetFillStyle(1001);
	gRatioFull_reg->SetFillColor(chatch);
	gRatioFull_reg->SetName("gRatioFull");
	
	pad_reg[1]->cd();
	RatioFull_reg->GetYaxis()->SetTitleOffset(0.25);	
	RatioFull_reg->Draw("HIST");
	gRatioFull_reg->Draw("e2");
	RatioFull_reg->Draw("HISTSAME");
	
	ireg++;
      } // for(ireg) 

      cPlots_reg->SaveAs(dirfigname_pdf + "RegionHisto_" + CanNum + "_" + dirname[ich] + "_NormLog.pdf");
    } // for(ican) 


    TCanvas *cPlotsI;
    cPlotsI = new TCanvas("cPlotsI"+dirname[ich] ,"Plots");
    cPlotsI->Divide(1,2);

    TPad    *padI[4];
    //Plot Pad
    padI[0] = (TPad*)cPlotsI->GetPad(1);
    padI[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    padI[0]->SetTopMargin(0.1);
    padI[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    padI[1] = (TPad*)cPlotsI->GetPad(2);
    padI[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padI[1]->SetGridx();
    padI[1]->SetGridy();
    padI[1]->SetTopMargin(0.05);
    padI[1]->SetBottomMargin(0.4);
    padI[1]->SetRightMargin(0.04);

    TCanvas *cPlotsII;
    cPlotsII = new TCanvas("cPlotsII"+dirname[ich] ,"Plots");
    cPlotsII->Divide(1,2);
    //Plot Pad
    padI[2] = (TPad*)cPlotsII->GetPad(1);
    padI[2]->SetPad(0.01, 0.23, 0.99, 0.99);
    padI[2]->SetTopMargin(0.1);
    padI[2]->SetRightMargin(0.04);
    
    //Ratio Pad
    padI[3] = (TPad*)cPlotsII->GetPad(2);
    padI[3]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padI[3]->SetGridx();
    padI[3]->SetGridy();
    padI[3]->SetTopMargin(0.05);
    padI[3]->SetBottomMargin(0.4);
    padI[3]->SetRightMargin(0.04);
    


    TH1D *hstyleI = new TH1D ("hstyleI","",
			      GlobalCSVJet_Data[1]->GetNbinsX(),
			      GlobalCSVJet_Data[1]->GetBinLowEdge (1),
			      GlobalCSVJet_Data[1]->GetBinLowEdge (GlobalCSVJet_Data[1]->GetNbinsX()+1));
    
    hstyleI -> SetMaximum(1.1*GlobalCSVJet_Data[1]->GetMaximum());
    hstyleI -> GetYaxis()->SetTitleOffset(0.8);
    hstyleI -> GetYaxis()->SetTitleSize(0.05);
    hstyleI -> GetYaxis()->SetLabelSize(0.05);
    hstyleI -> GetYaxis()->SetTitle("Events"); 
    
    GlobalCSVJet_Data[0] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[0] -> SetMarkerSize(0.4); 
    GlobalCSVJet_Data[0] -> SetLineWidth(1); 
    GlobalCSVJet_Data[0] -> SetTitle(""); 


    padI[0]->cd();
    padI[0]->cd()->SetLogy();
    
    hstyleI -> SetMaximum(100.0*GlobalCSVJet_Data[0]->GetMaximum());
    hstyleI -> SetMinimum(0.7);
    hstyleI -> Draw();

    AllMC_CSV1[ich] -> Draw("HISTSAME");

    GlobalCSVJet_Data[0] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[0] -> SetMarkerSize(0.6); 
    GlobalCSVJet_Data[0] -> SetLineWidth(1); 
    GlobalCSVJet_Data[0] -> SetTitle(""); 
    GlobalCSVJet_Data[0] -> Draw("SAME");

    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");	

    TLegend *legI;
    legI = new TLegend(0.70,0.64,0.93,0.87);
    legI->SetFillColor(0);
    legI->SetLineColor(0);
    legI->SetLineWidth(0.0);
    legI->SetTextFont(62);
    legI->SetTextSize(0.03);
    legI->SetNColumns(2);
  
    legI->AddEntry(hData[ich],         "Data","PL");
    legI->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    legI->AddEntry(hInput[ich].at(10), "VV","F");
    legI->AddEntry(hInput[ich].at(9),  "Single t","F");
    legI->AddEntry(hInput[ich].at(8),  "QCD","F");
    legI->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    legI->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    legI->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    legI->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    legI->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    legI->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    legI->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    legI->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    legI->AddEntry(gRatioFull,         "Stat. Unc.","F");

    legI->Draw("SAME");

    TH1D *RatioFullJet1 = HistoRatio (GlobalCSVJet_Data[0] , (TH1D*) AllMC_CSV1[ich]->GetStack()->Last());
    TGraphErrors *gRatioFullJet1 = new TGraphErrors(RatioFullJet1);
    gRatioFullJet1->SetFillStyle(1001);
    gRatioFullJet1->SetFillColor(chatch);
    gRatioFullJet1->SetName("gRatioFullJet2");

    padI[1]->cd();
    RatioFullJet1 ->GetYaxis()->SetTitleOffset(0.25);
    RatioFullJet1 ->GetXaxis()->SetTitle("CSVv2");
    RatioFullJet1 ->Draw("HIST");
    gRatioFullJet1->Draw("e2");
    RatioFullJet1 ->Draw("HISTSAME");

    padI[2]->cd();
    padI[2]->cd()->SetLogy();
    // No Log
    TH1D *hstyleII = (TH1D *)hstyleI -> Clone("StyleII"); 
    hstyleII -> SetMaximum(100.0*GlobalCSVJet_Data[1]->GetMaximum());
    hstyleII -> SetMinimum(0.7);

    hstyleII -> Draw();
    AllMC_CSV2[ich] -> Draw("HISTSAME");

    GlobalCSVJet_Data[1] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[1] -> SetMarkerSize(0.5); 
    GlobalCSVJet_Data[1] -> SetLineWidth(1); 
    GlobalCSVJet_Data[1] -> SetTitle(""); 
    GlobalCSVJet_Data[1] -> Draw("SAME");

    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");	

    legI->Draw("SAME");

    TH1D *RatioFullJet2 = HistoRatio (GlobalCSVJet_Data[1] , (TH1D*) AllMC_CSV2[ich]->GetStack()->Last());
    TGraphErrors *gRatioFullJet2 = new TGraphErrors(RatioFullJet2);
    gRatioFullJet2->SetFillStyle(1001);
    gRatioFullJet2->SetFillColor(chatch);
    gRatioFullJet2->SetName("gRatioFullJet2");

    padI[3]->cd();
    RatioFullJet2 ->GetYaxis()->SetTitleOffset(0.25);
    RatioFullJet2 ->GetXaxis()->SetTitle("CSVv2");
    RatioFullJet2 ->Draw("HIST");
    gRatioFullJet2->Draw("e2");
    RatioFullJet2 ->Draw("HISTSAME");


    cPlotsI ->SaveAs(dirfigname_pdf + "CSVHistosJet1_" + dirname[ich] + "_Log.pdf");
    cPlotsII->SaveAs(dirfigname_pdf + "CSVHistosJet2_" + dirname[ich] + "_Log.pdf");

    // ttbb Shape

    


  }// for(ich)
  

}
Beispiel #23
0
void printHisto( TCanvas *can , TChain *data , TChain *mc , TCut num , TCut denom , char* var , int nbins , float xmin , float xmax , char* xtitle , char* ytitle) {

    can->cd();

    TPad *plotpad = new TPad("plotpad","plotpad",0.0,0.0,1.0,0.8);
    plotpad->Draw();
    plotpad->cd();

    float ptbin[] = {30., 40., 60. , 80. , 100. , 120. , 150. , 200 , 300 };
    int   nptbin  = 8;

    //TH1F* hpass   = new TH1F(Form("hpass_%i",iplot),Form("hpass_%i",iplot),nptbin,ptbin);
    //TH1F* hall    = new TH1F(Form("hall_%i" ,iplot),Form("hall_%i" ,iplot),nptbin,ptbin);

    // TH1F* hpass_data = new TH1F(Form("hpass_data_%i",iplot),Form("hpass_data_%i",iplot),nbins,xmin,xmax);
    // TH1F* hall_data  = new TH1F(Form("hall_data_%i" ,iplot),Form("hall_data_%i" ,iplot),nbins,xmin,xmax);
    // TH1F* hpass_mc   = new TH1F(Form("hpass_mc_%i"  ,iplot),Form("hpass_mc_%i"  ,iplot),nbins,xmin,xmax);
    // TH1F* hall_mc    = new TH1F(Form("hall_mc_%i"   ,iplot),Form("hall_mc_%i"   ,iplot),nbins,xmin,xmax);

    TH1F* hpass_data   = new TH1F(Form("hpass_data_%i"  ,iplot),Form("hpass_data_%i"  ,iplot),nptbin,ptbin);
    TH1F* hall_data    = new TH1F(Form("hall_data_%i"   ,iplot),Form("hall_data_%i"   ,iplot),nptbin,ptbin);
    TH1F* hratio_data  = new TH1F(Form("hratio_data_%i" ,iplot),Form("hratio_data_%i" ,iplot),nptbin,ptbin);
    TH1F* hpass_mc     = new TH1F(Form("hpass_mc_%i"    ,iplot),Form("hpass_mc_%i"    ,iplot),nptbin,ptbin);
    TH1F* hall_mc      = new TH1F(Form("hall_mc_%i"     ,iplot),Form("hall_mc_%i"     ,iplot),nptbin,ptbin);
    TH1F* hratio_mc    = new TH1F(Form("hratio_mc_%i"   ,iplot),Form("hratio_mc_%i"   ,iplot),nptbin,ptbin);
    TH1F* hsf          = new TH1F(Form("hsf_%i"         ,iplot),Form("hsf_%i"         ,iplot),nptbin,ptbin);

    hpass_data->Sumw2();
    hall_data->Sumw2();
    hratio_data->Sumw2();
    hpass_mc->Sumw2();
    hall_mc->Sumw2();
    hratio_mc->Sumw2();
    hsf->Sumw2();

    //TCanvas *can = new TCanvas(Form("can_%i",iplot),Form("can_%i",iplot),600,600);
    //can->cd();

    data->Draw(Form("min(%s,%f)>>hpass_data_%i"  , var,xmax-0.0001,iplot),denom+num);
    data->Draw(Form("min(%s,%f)>>hall_data_%i"   , var,xmax-0.0001,iplot),denom);
    mc->Draw  (Form("min(%s,%f)>>hpass_mc_%i"    , var,xmax-0.0001,iplot),denom+num);
    mc->Draw  (Form("min(%s,%f)>>hall_mc_%i"     , var,xmax-0.0001,iplot),denom);

    TGraphAsymmErrors *grdata = new TGraphAsymmErrors();
    grdata->BayesDivide(hpass_data,hall_data);

    TGraphAsymmErrors *grmc = new TGraphAsymmErrors();
    grmc->BayesDivide(hpass_mc,hall_mc);

    // cout << "data all  " << hall_data->GetBinContent(8) << endl;
    // cout << "data pass " << hpass_data->GetBinContent(8) << endl;
    // cout << "data eff  " << hpass_data->GetBinContent(8) / hall_data->GetBinContent(8) << endl;

    // Double_t x;
    // Double_t y;
    // grdata->GetPoint(7,x,y);
    // cout << "data eff2 " << y << endl;

    gPad->SetGridx();
    gPad->SetGridy();

    grdata->SetMarkerColor(2);
    grdata->SetLineColor(2);
    grmc->SetMarkerColor(4);
    grmc->SetLineColor(4);
    grmc->SetMarkerStyle(25);

    grdata->GetXaxis()->SetRangeUser(30,300);
    grdata->GetYaxis()->SetRangeUser(0.8,1.0);
    grdata->GetXaxis()->SetTitle(xtitle);
    grdata->GetYaxis()->SetTitle(ytitle);
    grdata->Draw("AP");
    grmc->Draw("sameP");

    TLegend *leg = new TLegend(0.5,0.2,0.7,0.4);
    leg->AddEntry(grdata ,"data","lp");
    leg->AddEntry(grmc   ,"mc"  ,"lp");
    leg->SetBorderSize(1);
    leg->SetFillColor(0);
    //leg->Draw();

    TLatex *t = new TLatex();
    t->SetNDC();

    if( TString(denom.GetTitle()).Contains("njets==0") ) t->DrawLatex(0.2,0.2,"n_{jets}=0");
    if( TString(denom.GetTitle()).Contains("njets==1") ) t->DrawLatex(0.2,0.2,"n_{jets}=1");
    if( TString(denom.GetTitle()).Contains("njets==2") ) t->DrawLatex(0.2,0.2,"n_{jets}=2");
    if( TString(denom.GetTitle()).Contains("njets==3") ) t->DrawLatex(0.2,0.2,"n_{jets}=3");
    if( TString(denom.GetTitle()).Contains("njets>=4") ) t->DrawLatex(0.2,0.2,"n_{jets}#geq4");

    can->cd();

    TPad *respad = new TPad("respad","respad",0.0,0.8,1.0,1.0);
    respad->Draw();
    respad->cd();
    respad->SetGridy();

    // TGraphAsymmErrors* gr_ratio = (TGraphAsymmErrors*) grdata->Clone("gr_ratio");
    // gr_ratio->Divide(grmc);
    // gr_ratio->Draw();

    hratio_data->Divide(hpass_data,hall_data,1,1,"B");
    hratio_mc  ->Divide(hpass_mc  ,hall_mc,1,1,"B");
    hsf        ->Divide(hratio_data,hratio_mc,1,1);

    hsf->GetYaxis()->SetRangeUser(0.9,1.1);
    hsf->GetYaxis()->SetNdivisions(3);
    hsf->GetYaxis()->SetLabelSize(0.2);
    hsf->GetXaxis()->SetLabelSize(0.0);

    hsf->Draw("E1");

    iplot ++;
}
Beispiel #24
0
/** 
 * 
 * 
 * @param o 
 * @param useWeights 
 * @param correct
 *
 * @ingroup pwglf_forward_scripts_tests
 */
void
TestPoisson(Double_t o=.3, bool useWeights=false, bool correct=true)
{
  const char* load = "$ALICE_PHYSICS/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C";
  if (!gROOT->GetClass("AliAODForwardMult")) {
    gROOT->Macro(load);
    gROOT->GetInterpreter()->UnloadFile(gSystem->ExpandPathName(load));
  }
  
  // --- Parameters of this script -----------------------------------
  Int_t      nBin =  5;  // Our detector matrix size 
  Int_t      nMax = TMath::Max(Int_t(nBin * nBin * o + .5)+nBin/2,nBin);  
  Int_t      nEv  = 10000; // Number of events
  Double_t   mp   = o;   // The 'hit' probability 


  TH2D* base = new TH2D("base", "Basic histogram", 
			nBin,-.5, nBin-.5, nBin, -.5, nBin-.5);
  base->SetXTitle("#eta");
  base->SetYTitle("#varphi");
  base->SetDirectory(0);
  base->SetOption("colz");

  Int_t tN1=nMax;    Double_t tMin1; Double_t tMax1;
  Int_t tN2=nMax*10; Double_t tMin2; Double_t tMax2=nMax;
  MakeIntegerAxis(tN1, tMin1, tMax1);
  MakeIntegerAxis(tN2, tMin2, tMax2);
  TH2D* corr = new TH2D("comp", "Comparison", 
			tN1, tMin1, tMax1, tN2, tMin2, tMax2);
  corr->SetXTitle("Input");
  corr->SetYTitle("Poisson");
  corr->SetDirectory(0);
  corr->SetOption("colz");
  corr->SetStats(0);
  TLine* lcorr = new TLine(0, 0, tMax2, tMax2);

  Int_t mm = TMath::Max(Int_t(nBin * o + .5),nBin/2);
  tN2=mm*10; tMax2 = mm;
  MakeIntegerAxis(tN2, tMin2, tMax2);
  Info("", "Making mean w/nbins=%d,range=[%f,%f]", tN2, tMin2, tMax2);
  TH2D* mean = new TH2D("mean", "Mean comparison", 
			tN2, tMin2, tMax2, tN2, tMin2, tMax2);
  mean->SetXTitle("Input");
  mean->SetYTitle("Poisson");
  mean->SetDirectory(0);
  mean->SetOption("colz");
  mean->SetStats(0);
  TLine* lmean = new TLine(tMin2, tMin2, tMax2, tMax2);

  TH1D* dist = new TH1D("dist", "Distribution of hits", tN1, tMin1, tMax1);
  dist->SetXTitle("s");
  dist->SetYTitle("P(s)");
  dist->SetFillColor(kRed+1);
  dist->SetFillStyle(3001);
  dist->SetDirectory(0);

  TH1D* diff = new TH1D("diff", "P-T", 100, -25, 25);
  diff->SetXTitle("Difference");
  diff->SetFillColor(kRed+1);
  diff->SetFillStyle(3001);
  diff->SetYTitle("Prob");

  AliPoissonCalculator* c = new AliPoissonCalculator("ignored");
  c->Init(nBin ,nBin);

  for (Int_t i = 0; i < nEv; i++) { 
    c->Reset(base);
    base->Reset();

    for (Int_t iEta = 0; iEta < nBin; iEta++) { 
      for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { 
	// Throw a die 
	Int_t m = gRandom->Poisson(mp);
	dist->Fill(m);

	// Fill into our base histogram 
	base->Fill(iEta, iPhi, m);

	// Fill into poisson calculator 
	c->Fill(iEta, iPhi, m > 0, (useWeights ? m : 1));
      }
    }
    // Calculate the result 
    TH2D* res = c->Result(correct);
    
    // Now loop and compare 
    Double_t mBase = 0;
    Double_t mPois = 0;
    for (Int_t iEta = 0; iEta < nBin; iEta++) { 
      for (Int_t iPhi = 0; iPhi < nBin; iPhi++) { 
	Double_t p = res->GetBinContent(iEta, iPhi);
	Double_t t = base->GetBinContent(iEta, iPhi);

	mBase += t;
	mPois += p;
	corr->Fill(t, p);
	diff->Fill(p-t);
      }
    }
    Int_t nn = nBin * nBin;
    mean->Fill(mBase / nn, mPois / nn);
  }

  TCanvas* cc = new TCanvas("c", "c", 900, 900);
  cc->SetFillColor(0);
  cc->SetFillStyle(0);
  cc->SetBorderMode(0);
  cc->SetRightMargin(0.02);
  cc->SetTopMargin(0.02);
  cc->Divide(2,2);
  
  TVirtualPad* pp = cc->cd(1);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetLogz();
  pp->SetGridx();
  pp->SetGridy();
  corr->Draw();
  lcorr->Draw();

  pp = cc->cd(2);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.02);
  pp->SetTopMargin(0.02);
#if 0
  c->GetMean()->Draw();
#elif 1 
  pp->SetLogy();
  diff->Draw();
#elif 1
  c->GetOccupancy()->Draw();
#else
  pp->SetLogy();
  dist->SetStats(0);
  dist->Scale(1. / dist->Integral());
  dist->Draw();
  TH1D* m1 = c->GetMean();
  m1->Scale(1. / m1->Integral());
  m1->Draw("same");
  Double_t eI;
  Double_t ii = 100 * dist->Integral(2, 0);
  TLatex* ll = new TLatex(.97, .85, 
			  Form("Input #bar{m}: %5.3f", mp));
  ll->SetNDC();
  ll->SetTextFont(132);
  ll->SetTextAlign(31);
  ll->Draw();
  ll->DrawLatex(.97, .75, Form("Result #bar{m}: %5.3f", dist->GetMean()));
  ll->DrawLatex(.97, .65, Form("Occupancy: #int_{1}^{#infty}P(s)ds = %6.2f%%",
			       ii));
			 
#endif

  pp = cc->cd(3);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetGridx();
  pp->SetGridy();
  c->GetCorrection()->Draw();

  pp = cc->cd(4);
  pp->SetFillColor(0);
  pp->SetFillStyle(0);
  pp->SetBorderMode(0);
  pp->SetRightMargin(0.15);
  pp->SetTopMargin(0.02);
  pp->SetLogz();
  pp->SetGridx();
  pp->SetGridy();
  mean->Draw();
  lmean->Draw();

  cc->cd();
}
Beispiel #25
0
    void DrawCMSLogoTest(TPad* pad, TString cmsText, TString extraText, int iPosX,
		   float relPosX, float relPosY, float relExtraDY) {
    TVirtualPad *pad_backup = gPad;
    pad->cd();
    float cmsTextFont = 61;  // default is helvetic-bold

    bool writeExtraText = extraText.Length() > 0;
    float extraTextFont = 52;  // default is helvetica-italics

    // text sizes and text offsets with respect to the top frame
    // in unit of the top margin size
    TString lumiText;
    float lumiTextOffset = 0.2;
    float cmsTextSize = 0.8;
    float lumiTextSize = 0.6;
    // float cmsTextOffset    = 0.1;  // only used in outOfFrame version

    // ratio of "CMS" and extra text size
    float extraOverCmsTextSize = 0.76;

    //!!MAKE CHOICE CONFIGURABLE
    TString lumi_13TeV = "20.1 fb^{-1}";
    TString lumi_8TeV = "18.9-19.7 fb^{-1}";
    TString lumi_7TeV = "0-4.9 fb^{-1}";

    lumiText +=lumi_8TeV;
    lumiText +=" (8 TeV) + ";
    lumiText +=lumi_7TeV;
    lumiText +=" (7 TeV)";



    bool outOfFrame = false;
    if (iPosX / 10 == 0) {
      outOfFrame = true;
    }
    int alignY_ = 3;
    int alignX_ = 2;
    if (iPosX / 10 == 0) alignX_ = 1;
    if (iPosX == 0) alignX_ = 1;
    if (iPosX == 0) alignY_ = 1;
    if (iPosX / 10 == 1) alignX_ = 1;
    if (iPosX / 10 == 2) alignX_ = 2;
    if (iPosX / 10 == 3) alignX_ = 3;
    if (iPosX == 0) relPosX = 0.14;
    int align_ = 10 * alignX_ + alignY_;

    float l = pad->GetLeftMargin();
    float t = pad->GetTopMargin();
    float r = pad->GetRightMargin();
    float b = pad->GetBottomMargin();

    TLatex latex;
    latex.SetNDC();
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);

    float extraTextSize = extraOverCmsTextSize * cmsTextSize;
    float pad_ratio = (static_cast<float>(pad->GetWh()) * pad->GetAbsHNDC()) /
      (static_cast<float>(pad->GetWw()) * pad->GetAbsWNDC());
    if (pad_ratio < 1.) pad_ratio = 1.;

    latex.SetTextFont(42);
    latex.SetTextAlign(31); 
    latex.SetTextSize(lumiTextSize*t*pad_ratio);    
    latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText);

    if (outOfFrame) {
      latex.SetTextFont(cmsTextFont);
      latex.SetTextAlign(11);
      latex.SetTextSize(cmsTextSize * t * pad_ratio);
      latex.DrawLatex(l, 1 - t + lumiTextOffset * t, cmsText);
    }


    float posX_ = 0;
    if (iPosX % 10 <= 1) {
      posX_ = l + relPosX * (1 - l - r);
    } else if (iPosX % 10 == 2) {
      posX_ = l + 0.5 * (1 - l - r);
    } else if (iPosX % 10 == 3) {
      posX_ = 1 - r - relPosX * (1 - l - r);
    }
    float posY_ = 1 - t - relPosY * (1 - t - b);
    if (!outOfFrame) {
      latex.SetTextFont(cmsTextFont);
      latex.SetTextSize(cmsTextSize * t * pad_ratio);
      latex.SetTextAlign(align_);
      latex.DrawLatex(posX_, posY_, cmsText);
      if (writeExtraText) {
	latex.SetTextFont(extraTextFont);
	latex.SetTextAlign(align_);
	latex.SetTextSize(extraTextSize * t * pad_ratio);
	latex.DrawLatex(posX_, posY_ - relExtraDY * cmsTextSize * t, extraText);
      }
    } else if (writeExtraText) {
      if (iPosX == 0) {
	posX_ = l + relPosX * (1 - l - r);
	posY_ = 1 - t + lumiTextOffset * t;
      }
      latex.SetTextFont(extraTextFont);
      latex.SetTextSize(extraTextSize * t * pad_ratio);
      latex.SetTextAlign(align_);
      latex.DrawLatex(posX_, posY_, extraText);
    }
    pad_backup->cd();
  }
void compareplots_noRatio(){
  vector<TFile*> files; 
  files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/ttbarMergedFxFx8TeVCTEQ6M-extracted.root"));
  files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_30/ttbarMergedFxFxMS30GeVMECut10GeV8TeVCTEQ6M-extracted.root"));   
  files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbarMergedMS100GeV8TeVCTEQ6M-extracted.root"));   
  files.push_back(new TFile("/storage/9/schweiger/analyseFxFx/pythia8/100kEvents/mergingscale_100/ttbarMergedMS100GeVMCCut50GeV8TeVCTEQ6M-extracted.root"));   
  


  
  vector<TString> names;
  names.push_back("ttbar +0/1 Jet, #mu_{Q}=10 GeV #mu_{ME} = 10 GeV");
  names.push_back("ttbar +0/1 Jet, #mu_{Q}=30 GeV #mu_{ME} = 10 GeV");
  names.push_back("ttbar +0/1 Jet, #mu_{Q}=100 GeV #mu_{ME} = 10 GeV");
  names.push_back("ttbar +0/1 Jet, #mu_{Q}=100 GeV #mu_{ME} = 50 GeV");
  
  
  vector<TString> titles;
  titles.push_back("Gen-Jet p_{T}  with pos weights (GeV)");
  titles.push_back("Gen-Jet p_{T} with neg weights (GeV)");
  titles.push_back("Gen-Jet p_{T} (GeV)");
  titles.push_back("Gen_Jet #phi with pos. weights");
  titles.push_back("Gen_Jet #phi with neg. weights");
  titles.push_back("Gen_Jet #phi");
  titles.push_back("Gen Jet #theta with pos weights");
  titles.push_back("Gen Jet #theta with neg weights");
  titles.push_back("Gen Jet #theta");
  titles.push_back("Gen Jet Energy with pos weights (GeV) ");
  titles.push_back("Gen Jet Energy with neg weights (GeV)");
  titles.push_back("Gen Jet Energy (GeV)");
  titles.push_back("p_{T} of hardest Gen-Jet with pos weights (GeV)");
  titles.push_back("p_{T} of hardest Gen-Jet with neg weights (GeV)");
  titles.push_back("p_{T} of hardest Gen-Jet (GeV)");
  titles.push_back("p_{T} of 2nd hardest Gen-Jet with pos weights (GeV)");
  titles.push_back("p_{T} of 2nd hardest Gen-Jet with neg weights (GeV)");
  titles.push_back("p_{T} of 2nd hardest Gen-Jet (GeV)");
  titles.push_back("#eta of hardest Gen-Jets with pos weights");
  titles.push_back("#eta of hardest Gen-Jets with neg weights");
  titles.push_back("#eta of hardest Gen-Jets");
  titles.push_back("Number of Gen-Jets with pos. weights");
  titles.push_back("Number of Gen-Jets with neg. weights");
  titles.push_back("Number of Gen-Jets");

  TFile *vergleich = new TFile("vergleich_ttbar_0Jet.root","RECREATE");

// Show no statistics box
gStyle->SetOptStat(0);

TH1::SetDefaultSumw2();

// Main program part
  TIter nextkey(files.at(0)->GetListOfKeys());
  TKey *key;
  bool first=true;
  TCanvas* c = new TCanvas();
  c->Print("plots.pdf[");

  // Save also as pictures
  int pictureNumber = 0;

  int run = 0;
  while (key = (TKey*)nextkey()) {
    pictureNumber++;
    TString pictureName = TString::Format("%d.png",pictureNumber);


    vector<TH1F*> histos;
    histos.push_back((TH1F*)key->ReadObj());
    for(size_t i=1;i<files.size();i++){
      histos.push_back((TH1F*)files.at(i)->Get(histos.at(0)->GetName()));
    }
		       
    for(size_t i=0;i<histos.size();i++){
      if(i == 0){
	histos.at(i)->SetLineColor(kBlack);
      }
      if(i == 1){
	histos.at(i)->SetLineColor(kRed);
      }
      if(i == 2){
	histos.at(i)->SetLineColor(kBlue);
      }
      if(i == 3){
	histos.at(i)->SetLineColor(kGreen+2);
      }
      if(i == 4){
	histos.at(i)->SetLineColor(kMagenta-7);
      }
      if(i == 5){
	histos.at(i)->SetLineColor(kOrange+7);
      }
    }
   
    for(size_t i=0;i<histos.size();i++){
      histos.at(i)->Sumw2();
      histos.at(i)->Scale(1./histos.at(i)->Integral(),"width");
    }

// Set axis title
histos.at(0)->GetYaxis()->SetTitle("Normalized units"); 
std::string const histogramName = histos.at(1)->GetName();
histos.at(0)->GetXaxis()->SetLabelSize(0.05);
histos.at(0)->GetXaxis()->SetLabelOffset(0.006);
histos.at(0)->GetYaxis()->SetLabelSize(0.05);
histos.at(0)->GetYaxis()->SetLabelOffset(0.006);
histos.at(0)->GetXaxis()->SetTitleSize(0.06);
histos.at(0)->GetXaxis()->SetTitleOffset(1.1);
histos.at(0)->GetYaxis()->SetTitleSize(0.06);
histos.at(0)->GetYaxis()->SetTitleOffset(1.15);
	

 histos.at(0)->GetXaxis()->SetTitle(titles.at(run));
 run = run+1;
 if(run == (3*8)){
   run = 0;
 }

// If only two histograms per plot make a ratio plot
if(histos.size() == 2)
{

//create main pad  
                                                                                                                                                          
           TPad *mainPad = new TPad("","",0.0,0.0,1.0,1.0);
           mainPad->SetNumber(1);
           mainPad->SetBottomMargin(0.15);
           mainPad->SetRightMargin(0.04);
	   mainPad->SetLeftMargin(0.13);
           mainPad->Draw();
	   gStyle->SetOptTitle(0);
           //create ratio pad                                                                                                                                                           
           /*TPad *ratioPad = new TPad("","",0.0,0.0,1.0,0.3);
           ratioPad->SetTopMargin(0.0);
           ratioPad->SetBottomMargin(0.4);
           ratioPad->SetLeftMargin(0.13);                                                                                                                                             
           ratioPad->SetRightMargin(0.04);
           gStyle->SetOptTitle(0);
           ratioPad->SetFillColor(0);
           ratioPad->SetNumber(2);
           ratioPad->SetGridy();                                                                                                                                                      
           ratioPad->Draw();*/

// Draw both histograms first
c->cd(1);

histos.at(0)->Draw("histo E");
histos.at(1)->Draw("histo same E");

// Show legend and statistical tests in first pad
    for(size_t i=0;i<histos.size()-1;i=i+2){

      double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1));
      ksresult=floor(ksresult*1000+0.5)/1000;
      double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW");
      chi2result=floor(chi2result*1000+0.5)/1000;

      stringstream ss;
      //ss << "     KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result << " Private Work"; 
      ss << "            Private Work";
      const char * ch = & ss.str().c_str();;
      TLatex * ks = new TLatex(0.1, 0.9-0.03*i, ch );
      ks->SetTextColor(histos.at(i)->GetLineColor());
      ks->SetNDC();
      ks->Draw("");      

    }

    TLegend* l = new TLegend(0.40,0.9,0.69,0.99);
    // Options for legend
    l->SetBorderSize(0);
    l->SetLineStyle(0);
    l->SetTextSize(0.049);
    l->SetFillStyle(0);
    for(size_t i=0;i<names.size();i++){
      l->AddEntry(histos.at(i),names.at(i),"L");
    }
    l->Draw("same");

/*
// Clone histograms and draw ratio plot
c->cd(2);
 TH1F* ratioHisto = (TH1F*)histos.at(0)->Clone();
ratioHisto->Divide(histos.at(1));
ratioHisto->SetLineColor(kBlue);
ratioHisto->SetStats(false);
ratioHisto->GetYaxis()->SetTitle("Ratio #frac{noFxFx}{FxFx}");
// Same Size like in histogram
ratioHisto->SetLabelSize(histos.at(0)->GetLabelSize() * 0.7 / 0.3);
ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("Y") * 0.3 / 0.7), "Y");
ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("Y") * 0.7 / 0.3), "Y");
ratioHisto->SetTitleOffset((histos.at(0)->GetTitleOffset("X")), "X");
ratioHisto->SetTitleSize((histos.at(0)->GetTitleSize("X") * 0.7 / 0.3), "X");
// Use nicer range
ratioHisto->GetYaxis()->SetRangeUser(0, 2.2);
ratioHisto->GetYaxis()->SetNdivisions(503);
ratioHisto->GetYaxis()->SetLabelSize(0.06 * 0.7 / 0.3);
ratioHisto->Draw();*/
}
else
{
        TPad *mainPad = new TPad("","",0.0,0.0,1.0,1.0);
        mainPad->SetNumber(1);
        mainPad->SetBottomMargin(0.15);
        mainPad->SetRightMargin(0.04);
        mainPad->SetLeftMargin(0.13);
        mainPad->Draw();
        gStyle->SetOptTitle(0);
        //mainPad->SetLogx(1);
	c->cd(1);

    histos.at(0)->Draw("histo E");
    for(size_t i=0;i<histos.size();i++){
      histos.at(i)->Draw("histo same E");
    }


    for(size_t i=0;i<histos.size()-1;i=i+2){
      /*
      double ksresult = histos.at(i)->KolmogorovTest(histos.at(i+1));
      ksresult=floor(ksresult*1000+0.5)/1000;
      double chi2result =histos.at(i)->Chi2Test(histos.at(i+1),"WW");
      chi2result=floor(chi2result*1000+0.5)/1000;

      stringstream ss;
      ss << "KS: " <<std::setprecision(3) << ksresult << " chi2: " <<std::setprecision(3) << chi2result; 
      const char * ch = & ss.str().c_str();;
      TText * ks = new TText(0.1, 0.9-0.03*i, ch );
      ks->SetTextColor(histos.at(i)->GetLineColor());
      ks->SetNDC();
      ks->Draw("");      
      */
    }

    TLegend* l = new TLegend(0.65,0.5,0.9,0.7);
    l->SetBorderSize(0);
    l->SetLineStyle(0);
    //    l->SetTextSize(0.039);
    l->SetFillStyle(0);
    for(size_t i=0;i<names.size();i++){
      l->AddEntry(histos.at(i),names.at(i),"L");
    }
    l->Draw("same");
}

    c->Print("plots.pdf");
    c->SaveAs(pictureName);
    vergleich->WriteTObject(c);

}
  c->Print("plots.pdf]");


}
Beispiel #27
0
void limit_scan()
{

  gROOT->Reset();
  gROOT->SetStyle("Plain");

  /*  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadRightMargin(0.05);
  gStyle->SetPadBottomMargin(0.15);  
  gStyle->SetPadTopMargin(0.05);   
  gStyle->SetTitleXSize(0.04);
  gStyle->SetTitleXOffset(1.05);
  gStyle->SetTitleYSize(0.04);
  gStyle->SetTitleYOffset(1.05);   
  */
  //expected including MC stat. uncertainty
  double observed_xsec[200];
  double mass[200];
  double kM[200];
  double kM_pb[200];

  int counter_array=0;

  for(int k=0; k<200; k++)
    {
      observed_xsec[k]=0.;
      mass[k]=0.;
      kM_pb[k]=0.;
      kM[k]=0.;      
    }

  string line;
  ifstream observed_in ("expected_limit_mass_kM.txt");
  //ifstream observed_in ("observed_limit_mass_kM.txt");
  //ifstream observed_in ("observed_limit_mass_kM_add_cuts.txt");
  if (observed_in.is_open())
  {
    while(!observed_in.eof())
    {

	  observed_in >> mass[counter_array];
	  observed_in >> kM[counter_array];      
	  observed_in >> observed_xsec[counter_array];      
     
	  std::cout << "\n" << mass[counter_array] << endl;
	  std::cout << kM[counter_array] << endl;      
	  std::cout << observed_xsec[counter_array] << endl;      

      counter_array++;
      std::cout << counter_array << endl;

      if(mass[counter_array-1]==4000)break;

    }
    observed_in.close();
  }

  std::cout << counter_array << endl;

  double lambda_fix[4];
  lambda_fix[0]=0.07;  
  lambda_fix[1]=0.05;
  lambda_fix[2]=0.01;
  lambda_fix[3]=0.007;  

  //remove after testing

  double xsec_max[200];

  int counter_points_plot[4];

  double lambdaP_solution[4][200];

  for(int k=0; k<200; k++)
    {
      xsec_max[k]=0.;
    }

  for(int j=0;j<4;j++)
    {
      counter_points_plot[j]=0.;
      for(int f=0;f<counter_array;f++)
	{
	  lambdaP_solution[j][f]=0.;
	}
    }
  
  for(int j=0;j<4;j++)
    {
      for(int f=0;f<counter_array;f++)
	{
	  
	  //kM[f]=kM_pb[f]*1000.;
	  xsec_max[f]=kM[f]*2./3.*pow(lambda_fix[j],2);

	  //check the solvability condition
	  if(xsec_max[f]<observed_xsec[f])break;
	  
	  //get the solution and keep counting ...
	  lambdaP_solution[j][f]=sqrt((2*pow(lambda_fix[j],2))/((2*pow(lambda_fix[j],2)*kM[f]/observed_xsec[f])-3));
	  
	  /*
	    if(j==0)
	    {
	      std::cout << f << endl;
	      std::cout << mass[f] << endl;
	      std::cout << observed_xsec[f] << " " << xsec_max[f] << endl;	    
	      std::cout << lambdaP_solution[j][f] << endl;
	      std::cout << endl;
	    }
	  */

	  /*
	    std::cout << mass[f] << endl;
	    std::cout << kM[f] << endl;
	    std::cout << observed_xsec[f] << endl;      
	    std::cout << lambdaP_solution[j][f] << endl;
	    std::cout << endl;
	  */

	  counter_points_plot[j]++;	
	}
      
      if(counter_points_plot[j]<counter_array)
	{
	  lambdaP_solution[j][counter_points_plot[j]]=10.;
	  counter_points_plot[j]++;
	}
    }

  /*
  for(int fg=0;fg<counter_points_plot[0];fg++)
    {
	    std::cout << mass[fg] << endl;
	    std::cout << observed_xsec[fg] << endl;      
	    std::cout << lambdaP_solution[3][fg] << endl;
	    std::cout << endl;      
    }
  */

  TCanvas *c_lambdaP=new TCanvas("c_lambdaP","",800,800);
  c_lambdaP->SetGridx();
  c_lambdaP->SetGridy();  

  //lambdaP=0.07
  double lambdaP_solution_0[200];
  for(int f=0;f<counter_points_plot[0];f++)
    {
      lambdaP_solution_0[f]=lambdaP_solution[0][f];
    }

  TGraph *graph_lambdaP_0 = new TGraph(counter_points_plot[0],mass,lambdaP_solution_0);  

 
  c_lambdaP->cd();
  gPad->SetLogy();

  graph_lambdaP_0->SetLineWidth(3);
  graph_lambdaP_0->SetLineStyle(10);  
  graph_lambdaP_0->SetLineColor(kRed);  
  graph_lambdaP_0->SetMarkerStyle(22);
  graph_lambdaP_0->SetMarkerSize(1.2); 
  graph_lambdaP_0->SetMarkerColor(kRed);  
  graph_lambdaP_0->GetYaxis()->SetRangeUser(0.0005,0.2);
  graph_lambdaP_0->GetXaxis()->SetRangeUser(200.,5000.);

  graph_lambdaP_0->GetXaxis()->SetTitleFont(42);
  graph_lambdaP_0->GetYaxis()->SetTitleFont(42);
  graph_lambdaP_0->GetXaxis()->SetLabelFont(42);
  graph_lambdaP_0->GetYaxis()->SetLabelFont(42);  

  graph_lambdaP_0->GetYaxis()->SetTitle("#lambda'_{311}");
  graph_lambdaP_0->GetXaxis()->SetTitle("M_{#tilde{#nu}_{#tau}} (GeV)");  
  graph_lambdaP_0->GetXaxis()->SetLabelSize(0.03);

  //lambdaP=0.05
  double lambdaP_solution_1[200];
  for(int f=0;f<counter_points_plot[1];f++)
    {
      lambdaP_solution_1[f]=lambdaP_solution[1][f];
    }

  TGraph *graph_lambdaP_1 = new TGraph(counter_points_plot[1],mass,lambdaP_solution_1);  

  graph_lambdaP_1->SetLineWidth(3);
  graph_lambdaP_1->SetLineStyle(7); 
  graph_lambdaP_1->SetLineColor(kBlue);  
  graph_lambdaP_1->SetMarkerStyle(22);
  graph_lambdaP_1->SetMarkerSize(1.2); 
  graph_lambdaP_1->SetMarkerColor(kBlue);   
  graph_lambdaP_1->GetYaxis()->SetRangeUser(0.001,0.4);  
  graph_lambdaP_1->GetXaxis()->SetRangeUser(200.,5000.);

  //lambdaP=0.01
  double lambdaP_solution_2[200];
  for(int f=0;f<counter_points_plot[2];f++)
    {
      lambdaP_solution_2[f]=lambdaP_solution[2][f];
    }

  TGraph *graph_lambdaP_2 = new TGraph(counter_points_plot[2],mass,lambdaP_solution_2);  

  graph_lambdaP_2->SetLineWidth(3);
  graph_lambdaP_2->SetLineStyle(9); 
  graph_lambdaP_2->SetLineColor(418);  
  graph_lambdaP_2->SetMarkerStyle(22);
  graph_lambdaP_2->SetMarkerSize(1.2);
  graph_lambdaP_2->SetMarkerColor(kGreen);    
  graph_lambdaP_2->GetYaxis()->SetRangeUser(0.001,0.4); 
  graph_lambdaP_2->GetXaxis()->SetRangeUser(200.,5000.);

  //lambdaP=0.007
  double lambdaP_solution_3[200];
  for(int f=0;f<counter_points_plot[3];f++)
    {
      lambdaP_solution_3[f]=lambdaP_solution[3][f];
    }

  TGraph *graph_lambdaP_3 = new TGraph(counter_points_plot[3],mass,lambdaP_solution_3);  

  graph_lambdaP_3->SetLineWidth(3);
  graph_lambdaP_3->SetLineStyle(1); 
  graph_lambdaP_3->SetLineColor(kBlack);  
  graph_lambdaP_3->SetMarkerStyle(22);
  graph_lambdaP_3->SetMarkerSize(1.2);
  graph_lambdaP_3->SetMarkerColor(kBlack);    
  graph_lambdaP_3->GetYaxis()->SetRangeUser(0.001,0.4); 
  graph_lambdaP_3->GetXaxis()->SetRangeUser(200.,5000.);

  //Let's draw it

  graph_lambdaP_0->Draw("Al");  
  graph_lambdaP_1->Draw("l,same");
  graph_lambdaP_2->Draw("l,same");
  graph_lambdaP_3->Draw("l,same");  

  TLegend *leg_example = new TLegend(0.45,0.15,0.95,0.40);
  leg_example->SetFillColor(0);
  leg_example->SetTextFont(42);
  
  leg_example->AddEntry(graph_lambdaP_0, "95% CL limit #lambda_{132}=#lambda_{231}=0.07","l");
  leg_example->AddEntry(graph_lambdaP_1, "95% CL limit #lambda_{132}=#lambda_{231}=0.05","l"); 
  leg_example->AddEntry(graph_lambdaP_2, "95% CL limit #lambda_{132}=#lambda_{231} =0.01","l"); 
  leg_example->AddEntry(graph_lambdaP_3, "95% CL limit #lambda_{132}=#lambda_{231}=0.007","l"); 

  leg_example->Draw("same");  


    TLatex* CMS_text = new TLatex(0.14,0.85,"CMS");
    CMS_text->SetNDC();
    CMS_text->SetTextSize(0.04);
    CMS_text->SetTextAngle(0);
    CMS_text->Draw("same");
    
    TLatex* CMS_text_2 = new TLatex(0.14,0.81,"Preliminary");
    //TLatex* CMS_text_2 = new TLatex(0.20,0.83,"own work in");
    CMS_text_2->SetNDC();
    CMS_text_2->SetTextFont(52);
    CMS_text_2->SetTextSize(0.04);
    CMS_text_2->SetTextAngle(0);
    CMS_text_2->Draw("same");    
    
    /*
    TLatex* CMS_text_3 = new TLatex(0.20,0.78,"progress");
    CMS_text_3->SetNDC();
    CMS_text_3->SetTextFont(52);
    CMS_text_3->SetTextSize(0.05);
    CMS_text_3->SetTextAngle(0);
    CMS_text_3->Draw("same");        
    */

    TLatex* lumiText = new TLatex(0.93,0.92,"2.5 fb^{-1} (13 TeV)");
    lumiText->SetNDC();
    lumiText->SetTextFont(42);
    lumiText->SetTextSize(0.03);
    lumiText->SetTextAlign(32);
    lumiText->Draw("same");     

    /*
    TLatex* expectedText = new TLatex(0.62,0.43,"expected limits");
    expectedText->SetNDC();
    expectedText->SetTextFont(42);
    expectedText->SetTextSize(0.04);
    expectedText->SetTextAngle(0);
    expectedText->Draw("same");       
    */
}
Beispiel #28
0
void 
CMS_lumi( TPad* pad, int iPeriod, int iPosX )
{            
  bool outOfFrame    = false;
  if( iPosX/10==0 ) 
    {
      outOfFrame = true;
    }
  int alignY_=3;
  int alignX_=2;
  if( iPosX/10==0 ) alignX_=1;
  if( iPosX==0    ) alignX_=1;
  if( iPosX==0    ) alignY_=1;
  if( iPosX/10==1 ) alignX_=1;
  if( iPosX/10==2 ) alignX_=2;
  if( iPosX/10==3 ) alignX_=3;
  //if( iPosX == 0  ) relPosX = 0.12;
  int align_ = 10*alignX_ + alignY_;

  float H = pad->GetWh();
  float W = pad->GetWw();
  float l = pad->GetLeftMargin();
  float t = pad->GetTopMargin();
  float r = pad->GetRightMargin();
  float b = pad->GetBottomMargin();
  //  float e = 0.025;

  pad->cd();

  TString lumiText;
  if( iPeriod==1 )
    {
      lumiText += "E_{#mu} = 150 GeV";
    }
  else if ( iPeriod==2 )
    {
      lumiText += "";
    }

   
  std::cout << lumiText << endl;

  TLatex latex;
  latex.SetNDC();
  latex.SetTextAngle(0);
  latex.SetTextColor(kBlack);    

  float extraTextSize = extraOverCmsTextSize*cmsTextSize;

  latex.SetTextFont(42);
  latex.SetTextAlign(31); 
  latex.SetTextSize(lumiTextSize*t);    
  latex.DrawLatex(1-r,1-t+lumiTextOffset*t,lumiText);

  if( outOfFrame )
    {
      latex.SetTextFont(cmsTextFont);
      latex.SetTextAlign(11); 
      latex.SetTextSize(cmsTextSize*t);    
      latex.DrawLatex(l,1-t+lumiTextOffset*t,cmsText);
    }
  
  pad->cd();

  float posX_=0;
  if( iPosX%10<=1 )
    {
      posX_ =   l + relPosX*(1-l-r);
    }
  else if( iPosX%10==2 )
    {
      posX_ =  l + 0.5*(1-l-r);
    }
  else if( iPosX%10==3 )
    {
      posX_ =  1-r - relPosX*(1-l-r);
    }
  float posY_ = 1-t - relPosY*(1-t-b);
  if( !outOfFrame )
    {
      if( drawLogo )
	{
	  posX_ =   l + 0.045*(1-l-r)*W/H;
	  posY_ = 1-t - 0.045*(1-t-b);
	  float xl_0 = posX_;
	  float yl_0 = posY_ - 0.15;
	  float xl_1 = posX_ + 0.15*H/W;
	  float yl_1 = posY_;
	  TASImage* CMS_logo = new TASImage("CMS-BW-label.png");
	  TPad* pad_logo = new TPad("logo","logo", xl_0, yl_0, xl_1, yl_1 );
	  pad_logo->Draw();
	  pad_logo->cd();
	  CMS_logo->Draw("X");
	  pad_logo->Modified();
	  pad->cd();
	}
      else
	{
	  latex.SetTextFont(cmsTextFont);
	  latex.SetTextSize(cmsTextSize*t);
	  latex.SetTextAlign(align_);
	  latex.DrawLatex(posX_, posY_, cmsText);
	  if( writeExtraText ) 
	    {
	      latex.SetTextFont(extraTextFont);
	      latex.SetTextAlign(align_);
	      latex.SetTextSize(extraTextSize*t);
	      latex.DrawLatex(posX_, posY_- relExtraDY*cmsTextSize*t, extraText);
	    }
	}
    }
  else if( writeExtraText )
    {
      if( iPosX==0) 
	{
	  posX_ =   l +  relPosX*(1-l-r);
	  posY_ =   1-t+lumiTextOffset*t;
	}
      latex.SetTextFont(extraTextFont);
      latex.SetTextSize(extraTextSize*t);
      latex.SetTextAlign(align_);
      latex.DrawLatex(posX_, posY_, extraText);      
    }
  return;
}
//void pi0_mfitpeak(char *FileName, char *HistName, Int_t etapi0flag) 
void pi0_mfitpeak(TH1F *mh1, Int_t etapi0flag, float xmin, float xmax, int npol,float res[],int posFlag, const char *dirName, const char *histName, float text_x, float text_y, const char *texName) 
  
{
  TGaxis::SetMaxDigits(3);


  // TVirtualFitter::SetDefaultFitter("Minuit");
  


  // This script attempts to fit any pi0 peak so that the freaking fit function would converge
  // currently background is fitted to a pol4 function and the peak by a gaussian;
  // results are not very nice
  // usage  .x pi0_mfitpeak.C++ ("pi0calib.root","minv_spb")
  // or eg.  .x pi0_mfitpeak.C ("../pi0anal/pi0ana_punorm.root","minv_spb",0)

  gROOT->Reset();
  //  gStyle->SetOptFit();
  //  gStyle->SetOptFit(0);
  //  gStyle->SetOptStat(0);
  //  gStyle->SetOptTitle(0);
Bool_t NOTE=1;
  if(NOTE) gStyle->SetCanvasBorderMode(0);

  gStyle->SetPadTopMargin(0.08);
  gStyle->SetPadBottomMargin(0.12);
  gStyle->SetPadLeftMargin(0.15);
  gStyle->SetPadRightMargin(0.08);

  mh1->GetXaxis()->SetRangeUser(xmin,xmax);
  
  Int_t highx=500;
  TCanvas *c2 = new TCanvas("c2","",200,10,highx,500);


    // cout<<FileName<<" "<<HistName<<endl;

  //     TFile f(FileName);
  //   TH1F *mh1 = (TH1F*) f.Get(HistName);
      mh1->SetMarkerStyle(20);
      mh1->SetMarkerSize(1.);
      mh1->SetStats(0); // 1/0 to set the stat box

   mh1->GetXaxis()->SetTitle("Invariant Mass of Photon Pairs (GeV/c^{2})");


   float binwidth = mh1->GetBinWidth(1);
   
   char *ytitle = new char[100];

   sprintf(ytitle,"Photon Pairs / %4.3f GeV/c^{2}",binwidth);
   

   mh1->GetYaxis()->SetTitle(ytitle);


   mh1->GetXaxis()->SetTitleSize(0.055);
   mh1->GetYaxis()->SetTitleSize(0.055);
   mh1->GetXaxis()->SetLabelSize(0.045);
   mh1->GetYaxis()->SetLabelSize(0.045);
   mh1->GetXaxis()->SetTitleOffset(0.90);
   mh1->GetXaxis()->CenterTitle();
   mh1->GetYaxis()->SetTitleOffset(1.32);
   

   // First work with the histogram and find the peak and fit ranges
   TAxis *xaxis = mh1->GetXaxis();
   Float_t binsiz= xaxis->GetBinCenter(3) - xaxis->GetBinCenter(2);
   Int_t nbins = xaxis->GetNbins(); 
   Float_t nevtperbin0[10000];
   Float_t errorbin0[10000];
   Float_t nevttot;
   Float_t maxbin=0; Int_t nmaxbin=0, nminbord=0, nmaxbord=nbins;
   
   for (Int_t nn=1; nn <= nbins; nn++)
     {
       nevtperbin0[nn] = mh1->GetBinContent(nn); 
       if(nevtperbin0[nn] > maxbin) { maxbin=nevtperbin0[nn]; nmaxbin=nn; }
       errorbin0[nn] = mh1->GetBinError(nn); 
       nevttot+=nevtperbin0[nn];
       if(nevtperbin0[nn] > 0 && nminbord == 0) nminbord=nn; 
       if(nevtperbin0[nn] == 0 && (nn > nminbord +10) && nmaxbord==0 && nminbord > 0) nmaxbord=nn; 
     }
   cout<<"Minbordl "<<nminbord<<" with events: "<<nevtperbin0[nminbord]<<endl;
   cout<<"Maxbordl "<<nmaxbord<<" with events: "<<nevtperbin0[nmaxbord]<<endl;
   nminbord+=0;
   nmaxbord-=0;
   Int_t nmin0=nminbord;
   while(nevtperbin0[nminbord] < nevtperbin0[nmaxbin]*0.025) nminbord++;
   while(nevtperbin0[nmaxbord] < nevtperbin0[nmaxbin]*0.025) nmaxbord--;
   // the above was just to get the info and low/high bins

   // Set the fit range ! This is for total fit !	 
   Float_t fitl=xmin;
     float fith=xmax;
   //     Float_t fitl=0.07, fith=0.2;// this works better for pileup
   //         Float_t fitl=0.08, fith=0.18;// this works even better for pileup
     //  if(etapi0flag == 1)
     // {
     //  fitl=0.35; fith=0.75;
     //}
     

     //   if(fitl < xaxis->GetBinCenter(nmin0)) fitl = xaxis->GetBinCenter(nmin0);
   //if(fith > xaxis->GetBinCenter(nmaxbord)) fith = xaxis->GetBinCenter(nmaxbord);
 
   


   cout<<" fit range "<<fitl<<" -- "<<fith<<endl;

   cout <<"Bin size "<<binsiz<<endl;
   cout<<"Total events "<<nevttot<<endl;
   cout<<"MaxBin "<<nmaxbin<<" with events: "<<nevtperbin0[nmaxbin]<<endl;
   cout<<"Minbord "<<nminbord<<" with events: "<<nevtperbin0[nminbord]<<endl;
   cout<<"Maxbord "<<nmaxbord<<" with events: "<<nevtperbin0[nmaxbord]<<endl;
      mh1->DrawCopy("sep");

      Float_t lowgauss=0.135-4.*0.010;
      Float_t highgauss=0.135+4.*0.010;
      if(etapi0flag == 1)
	{
	  lowgauss=0.55-5.*0.025;
              highgauss=0.55+5.*0.025;
	}
      Int_t nlowgauss=Int_t((lowgauss-xaxis->GetBinCenter(1))/Float_t(binsiz)+0.5);
      Int_t nhighgauss=Int_t((highgauss-xaxis->GetBinCenter(1))/Float_t(binsiz)+0.5);
      cout <<xaxis->GetBinCenter(nlowgauss)<<" "<<xaxis->GetBinCenter(nhighgauss)<<endl;
   // now make the "background" histogram and fit it with p4
      Float_t lowvalgauss=nevtperbin0[nlowgauss];
      Float_t increm=(nevtperbin0[nhighgauss]-nevtperbin0[nlowgauss])/Float_t(nhighgauss-nlowgauss);
      TH1F *hbkg = (TH1F*)mh1->Clone();
      hbkg->SetName("bkg_clone");
      for (Int_t nn=nlowgauss; nn<=nhighgauss; nn++)
	{
	  hbkg->SetBinContent(nn,Float_t(lowvalgauss+(nn-nlowgauss)*increm));
	  hbkg->SetBinError(nn,sqrt(lowvalgauss+(nn-nlowgauss)*increm));
	}
      hbkg->DrawCopy("samesep");
      //      break;
      // Now define the "gaussian" histogram
      TH1F *hgauss = (TH1F*)mh1->Clone();
      hgauss->SetName("gauss_clone");
      hgauss->Sumw2();
      hgauss->Add(mh1,hbkg,1,-1); // if errors are independent Add needs to be used !
       for (Int_t nn=1; nn <= nbins; nn++)
	 {
	   if(hgauss->GetBinContent(nn) < 0.) hgauss->SetBinContent(nn,0.001*nevtperbin0[nmaxbin]);
	   hgauss->SetBinError(nn,sqrt(hgauss->GetBinContent(nn)));
	 }

   // Declare function with wich to fit
       TF1 *g1 = new TF1("g1","gaus",lowgauss,highgauss);
   hgauss->Fit(g1,"R0");
   hgauss->DrawCopy("sep");
   g1->Draw("same");
   //  break;

   char *polff = new char[20];

   sprintf(polff,"pol%d",npol);
   
   TF1 *p4bkg; 
   if(etapi0flag != 1)
     p4bkg   = new TF1("pm2",polff, xaxis->GetBinCenter(nminbord),xaxis->GetBinCenter(nmaxbord));
   else
     p4bkg   = new TF1("pm2",polff, 0.35,0.75);
   
   

   hbkg->Fit(p4bkg,"R0");
   hbkg->DrawCopy("sep");
   p4bkg->SetLineStyle(kDashed);
   p4bkg->Draw("same");
   // break;
   
   
   Double_t par[20],parf[20],errparf[20];
   g1->GetParameters(&par[0]);
   p4bkg->GetParameters(&par[3]);

   char *totff = new char[20];
   
   sprintf(totff,"gaus(0)+pol%d(3)",npol);
   
   
   TF1 *total = new TF1("total",totff,fitl,fith);
   TF1 *p4bkgfin   = new TF1("pm2",polff,fitl,fith);
   total->SetParameters(par);

   if(etapi0flag==0){
     total->SetParLimits(1,0.10,0.15);
     total->SetParLimits(2,0.135*0.06,0.135*0.3);
     
   }else{
     total->SetParLimits(1,0.35,0.65);
   }
   
   
   //  total->FixParameter(1,1.21340e-01); 
   // total->FixParameter(2,2.69780e-02);
   
   
   

   

   mh1->Fit(total,"R0");
   
   cout<<" yield.. "<< total->GetParameter(0) <<"+/- " << total->GetParError(0)<<endl;
   

     total->GetParameters(parf);


     for( Int_t nn=0; nn < 3+npol+1; nn++) errparf[nn]=total->GetParError(nn);
     g1->SetParameters(&parf[0]);
     p4bkgfin->SetParameters(&parf[3]);
     cout <<" Piz Mass = "<<parf[1]*1000.<<" +- "<<errparf[1]*1000.<<
       " Sigma ="<<parf[2]*1000.<<" +- "<<errparf[2]*1000.<<endl;
      cout << " Sigma Rel. = "<< parf[2]/parf[1]<<" +- "
	   << errparf[2]/parf[1] <<endl;

    Float_t int_min=parf[1]-3.*parf[2];
    Float_t int_max=parf[1]+3.*parf[2];
    Float_t sig_peak=g1->Integral(int_min,int_max)/binsiz;
    Float_t bkgd_peak=p4bkgfin->Integral(int_min,int_max)/binsiz;
    cout<<" In +-3. sigma window: Signal="<<sig_peak<<" Bkgd="<<bkgd_peak<<endl;
    Float_t SB=sig_peak/bkgd_peak; Float_t SBerr=SB*(sqrt(1./sig_peak+1./bkgd_peak));
    cout<<" Signal/Bkgd "<<SB<<" +- "<<SBerr<<endl;   

    int_min=parf[1]-2.*parf[2];
    int_max=parf[1]+2.*parf[2];
    sig_peak=g1->Integral(int_min,int_max)/binsiz;
    bkgd_peak=p4bkgfin->Integral(int_min,int_max)/binsiz;
    cout<<" In +-2.sigma window: Signal="<<sig_peak<<" Bkgd="<<bkgd_peak<<endl;
    SB=sig_peak/bkgd_peak; SBerr=SB*(sqrt(1./sig_peak+1./bkgd_peak));
    cout<<" Signal/Bkgd "<<SB<<" +- "<<SBerr<<endl;   
 			

    float S = sig_peak; 
    float B = bkgd_peak; 
    
    int_min=parf[1]-20.*parf[2];
    int_max=parf[1]+20.*parf[2];
    float S_all = g1->Integral(int_min,int_max)/binsiz;
    
    

    float test_sall =  parf[0] * parf[2] * sqrt(acos(-1)) / binsiz; 
    
    cout<<"signal all: "<< S_all << " "<< test_sall <<endl; 
    
    float Serr_all = errparf[0]/ parf[0] * S_all; 
    


    res[0] = S_all; 
    res[1] = Serr_all; 

    res[2] = parf[1]; 
    res[3] = errparf[1];
    
    res[4] = parf[2]; 
    res[5] = errparf[2];

    res[6] = SB; 
    res[7] = SBerr; 
    


    total->SetLineWidth(3);
    
   total->SetLineColor(kBlue);

   p4bkgfin->SetLineWidth(3);
   
   p4bkgfin->SetLineColor(kRed);
   mh1->DrawCopy("sep");

   //   total->SetRange(0.07,0.185);
   //    p4bkgfin->SetRange(0.07,0.185);
   total->Draw("same");
   p4bkgfin->SetLineStyle(kDashed);
   p4bkgfin->Draw("same");   

   TLatex l;
   
   //   l.SetTextSize(0.06);
   l.SetTextSize(0.05);
   
   
   l.SetTextColor(1);
   l.SetNDC();
   
  
   float sigma = parf[2]/ parf[1]*100; 
   float sigmaerr = errparf[2]/ parf[1]*100; 
   char *sigma_name = new char[50]; 
   if(sigmaerr>0.005)
     sprintf(sigma_name,"#sigma = %3.2f #pm %3.2f %% ",sigma,sigmaerr);
   else sprintf(sigma_name,"#sigma = %3.2f %% ",sigma);
   
   if(posFlag==1){
     l.DrawLatex(0.54,0.75,sigma_name);
   }else if( posFlag==2){
     l.DrawLatex(0.54,0.3,sigma_name);

   }
      
      //  sprintf(sigma_name,"S/B = %3.2f #pm %3.2f ",SB,SBerr);
      //
      sprintf(sigma_name,"S = %2.1f #pm %2.1f",S_all,Serr_all);
	      //
      
      // l.DrawLatex(0.5,0.5,sigma_name);
      
      sprintf(sigma_name,"M = %3.1f #pm %3.1f MeV",parf[1]*1000.,errparf[1]*1000);
      if(posFlag==1){
      l.DrawLatex(0.54,0.82,sigma_name);
      }else if( posFlag==2){
	l.DrawLatex(0.54,0.37,sigma_name);

      }
      ///l.DrawLatex(0.169,470.,"d)");


      c2->Modified();
   c2->Update();
   //   c2->SaveAs("nice_pi0.gif");

   
   
   if( text_x >0 && text_y >0){
    TLatex *   tex = new TLatex(text_x, text_y, texName);
    tex->SetNDC();
    tex->SetTextSize(0.06);
    tex->SetLineWidth(2);
    tex->Draw();
  }
  

   char *filename = new char[1000];

   
   sprintf(filename,"%s/%s.gif",dirName,histName);
   c2->Print(filename);
   sprintf(filename,"%s/%s.C",dirName,histName);
   c2->Print(filename);
   
   // .x pi0_mfitpeak.C ("pi0ana_508030.root","minv_spb",0)
   // .x pi0_mfitpeak.C ("pi0ana_npu.root","minv_bkg",0)  
   // .x pi0_mfitpeak.C ("pi0ana_punormv2.root","minv_spb",0)
}
Beispiel #30
0
void fitBvar(TString collsyst="PbPb", TString inputfile ="", TString npfile="ROOTfiles/NPFitPbPb.root", float centMin=0, float centMax=100, TString outputfile="outHisto")
{
  collisionsystem = collsyst;
  infname = outputfile;
  centmin = centMin;
  centmax = centMax;
  if(collsyst != "PbPb") isPbPb = false;

  gStyle->SetTextSize(0.05);
  gStyle->SetTextFont(42);
  gStyle->SetPadRightMargin(0.02);
  gStyle->SetPadLeftMargin(0.18);
  gStyle->SetPadTopMargin(0.09);
  gStyle->SetPadBottomMargin(0.145);
  gStyle->SetTitleX(.0f);

  TF1* fit (float ptmin, float ptmax, int s, int b, int widVar); // widVar=0,1

  TCanvas* c = new TCanvas("c","",600,600);

  TF1* bmass = new TF1("bmass","[0]",7,50);
  bmass->SetTitle(";B^{+} p_{T} (GeV/c);fraction of default yield");
  bmass->SetMinimum(0.9);
  bmass->SetMaximum(1.1);
  if(isPbPb)
    {
    bmass->SetMinimum(0.9);
    bmass->SetMaximum(1.1);
    }
  bmass->SetParameter(0,1);
  bmass->SetLineWidth(1);
  bmass->SetLineColor(kRed);
  bmass->SetLineStyle(2);
  bmass->GetXaxis()->SetTitleOffset(1.3);
  bmass->GetYaxis()->SetTitleOffset(1.8);
  bmass->GetXaxis()->SetLabelOffset(0.007);
  bmass->GetYaxis()->SetLabelOffset(0.007);
  bmass->GetXaxis()->SetTitleSize(0.045);
  bmass->GetYaxis()->SetTitleSize(0.045);
  bmass->GetXaxis()->SetTitleFont(42);
  bmass->GetYaxis()->SetTitleFont(42);
  bmass->GetXaxis()->SetLabelFont(42);
  bmass->GetYaxis()->SetLabelFont(42);
  bmass->GetXaxis()->SetLabelSize(0.04);
  bmass->GetYaxis()->SetLabelSize(0.04);
  bmass->Draw();

  TLatex* Title = new TLatex(0.1,0.94, Form("Fit Variation for %s",collisionsystem.Data()));
  Title->SetNDC();
  Title->SetTextAlign(12);
  Title->SetTextSize(0.04);
  Title->SetTextFont(42);
  Title->Draw("Same");

  TLegend* leg = new TLegend(0.2,0.67,0.4,0.87,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);

    getNPFnPar(npfile, NPpar);
    std::cout<<"NP parameter 0: "<<NPpar[0]<<std::endl;
    std::cout<<"NP parameter 1: "<<NPpar[1]<<std::endl;

    TString inputf;
    if(nBins == 1) inputf = Form("%s_integrated.root",inputfile.Data());
    else inputf = Form("%s.root",inputfile.Data());

    TFile* data = new TFile(inputf.Data());  
    TH1D* h_def = (TH1D*)data->Get("hPt"); 
    TH1D* hwidvar;
    int cnt =0;

    for(int s=0;s<nsig;s++)
    {
	bkgmax[0]=sigmax[s]+2;

	for(int b=0;b<nbkg;b++)
	{

	  if(s==0 || b==0)
	  {
	      TH1D* hvar = new TH1D(Form("h_%s",bkgname[b].Data()),"",nBins,ptBins);
	      if(s==0 && b==0) hwidvar = new TH1D("h_widvar","",nBins,ptBins);

	      for(int i=0;i<nBins;i++)
		{

		  double def_y = h_def->GetBinContent(i+1);
		  double def_err = h_def->GetBinError(i+1);
		 
		  TF1* f = fit(ptBins[i],ptBins[i+1],s,b,0);
		  cout<<"YIELD / YIELDERR:  "<< yield <<" "<< yieldErr << endl;
		  cout << "DEF YIELD:  "<< def_y*(ptBins[i+1]-ptBins[i]) <<endl;
		  double y = yield/(ptBins[i+1]-ptBins[i]);
		  double err = yieldErr/(ptBins[i+1]-ptBins[i]);

		  double y_fr = y/def_y;
		  cout << "YIELD FRACTION: " << y_fr << endl;
		  double err_fr = sqrt(pow(err/def_y,2)+pow(def_err*y/(def_y*def_y),2));

		  hvar->SetBinContent(i+1,y_fr);
		  hvar->SetBinError(i+1,err_fr);
		  hvar->SetMarkerStyle(8);
		  hvar->SetMarkerColor(4+cnt);
		  cnt++;

		  if(s==0 && b==0)
		  {    		     
		      f = fit(ptBins[i],ptBins[i+1],0,0,1);
		      cout<<"YIELD / YIELDERR:  "<< yield <<" "<< yieldErr << endl;
		      cout << "DEF YIELD:  "<< def_y*(ptBins[i+1]-ptBins[i]) <<endl;
		      y = yield/(ptBins[i+1]-ptBins[i]);
		      err = yieldErr/(ptBins[i+1]-ptBins[i]);

		      y_fr = y/def_y;
		      cout << "YIELD FRACTION: " << y_fr << endl;
		      err_fr = sqrt(pow(err/def_y,2)+pow(def_err*y/(def_y*def_y),2));

		      hwidvar->SetBinContent(i+1,y_fr);
		      hwidvar->SetBinError(i+1,err_fr);
		      hwidvar->SetMarkerStyle(8);
		      hwidvar->SetMarkerColor(3);
		  }

		}

		c->cd();
		hvar->Draw("Same");
		if(s==0 && b==0) hwidvar->Draw("Same");

		leg->AddEntry(hvar,Form("%s and %s",signame[s].Data(),bkgname[b].Data()),"pl");
		if(s==0 && b==0) leg->AddEntry(hwidvar, "Width Variation", "pl");
	    }
	}
    }

  c->cd();
  leg->Draw("Same");

  if(nBins == 1) c->SaveAs(Form("SystPDF/total_var_%s.pdf",collisionsystem.Data()));  
  else c->SaveAs(Form("SystPDF/var_%s.pdf",collisionsystem.Data()));  
}