Exemplo n.º 1
0
void make1DLimit(TString combine_dir,TString type= "WH",bool blind=true){
  //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiWH_0_175/";
  //WH
  wh_limits.push_back(wh_125);
  wh_limits.push_back(wh_150);
  wh_limits.push_back(wh_175);
  wh_limits.push_back(wh_200);
  //HH
  hh_limits.push_back(hh_125);
  hh_limits.push_back(hh_150);
  hh_limits.push_back(hh_175);
  hh_limits.push_back(hh_200);

  TGraph obser( (200-125)/25 );
  TGraph graph( (200-125)/25 );
  TGraphAsymmErrors error( (200-125)/25 );
  TGraphAsymmErrors error2S( (200-125)/25 );

  TGraph obser_r( (200-125)/25 );
  TGraph graph_r( (200-125)/25 );
  TGraphAsymmErrors error_r( (200-125)/25 );
  TGraphAsymmErrors error_r2S( (200-125)/25 );
  
  TGraphErrors* theo = 0;
  if(type=="WH") theo = getTheoXSec("xsecs/CharginoNeutralino.txt");
  else theo = getTheoXSec("xsecs/Higgsino_ElectroHiggs.txt");
  //else theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt");

  for(int m=125;m<=200;m+=25) {
    int i=(m-125)/25;
    TFile limit_file(Form("%s/higgsCombineChi%s_0_%d.Asymptotic.mH120.root",combine_dir.Data(),type.Data(),m) );
    TTree *limit_tree = (TTree*)limit_file.Get("limit");
    TTreeFormula limit_form("get_limit","limit",limit_tree);
    
    float down_2s = -1;
    float down = -1;
    float exp = -1;
    float up = -1;
    float up_2s = -1;
    float obs = -1;

    if( type == "WH" )
      {
	down_2s = wh_limits.at(i)[0];
	down = wh_limits.at(i)[1];
	exp = wh_limits.at(i)[2];
	up = wh_limits.at(i)[3];
	up_2s = wh_limits.at(i)[4];
	obs = wh_limits.at(i)[5];
      }
    else if ( type == "HH")
      {
	down_2s = hh_limits.at(i)[0];
	down = hh_limits.at(i)[1];
	exp = hh_limits.at(i)[2];
	up = hh_limits.at(i)[3];
	up_2s = hh_limits.at(i)[4];
	obs = hh_limits.at(i)[5];
      }
    else
      {
	std::cerr << "UNRECOGNIZED OPTION!!! QUITTING" << std::endl;
      }
    
    if(i==0) m+=5; //first point is actually at m=130
    graph.SetPoint(i,float(m), exp);
    error.SetPoint(i,float(m), exp);
    error2S.SetPoint(i, float(m), exp);
    error.SetPointError(i, 0, 0, exp-down, up-exp);
    error2S.SetPointError(i, 0 , 0 , exp-down_2s, up_2s-exp);
  
    graph_r.SetPoint(i,float(m),exp/theo->Eval(m));
    error_r.SetPoint(i,float(m),exp/theo->Eval(m));
    error_r2S.SetPoint(i,float(m),exp/theo->Eval(m));
    error_r.SetPointError(i,0,0,(exp-down)/theo->Eval(m),(up-exp)/theo->Eval(m));
    error_r2S.SetPointError(i, 0, 0, (exp-down_2s)/theo->Eval(m), (up_2s-exp)/theo->Eval(m) );
    
  
    obser.SetPoint(i,float(m),obs);
    obser_r.SetPoint(i,float(m),obs/theo->Eval(m));
    if(i==0) m-=5;
  }


    TCanvas cv;
    cv.SetLogy();
    cv.SetGrid(1,1);
    theo->SetMaximum(1e2);
    theo->SetMinimum(1e-2);
    theo->GetYaxis()->SetLabelSize(0.05);
    theo->GetYaxis()->SetTitleSize(0.06);
    theo->GetYaxis()->SetTitleOffset(0.8);
    theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    theo->GetXaxis()->SetTitle("m_{chargino} (GeV)");
    if(type=="HH") theo->GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    theo->SetFillColor(kBlue);
    theo->SetLineStyle(kDotted);
    theo->SetLineWidth(2);
    
    error.SetMaximum(1e2);
    error.SetMinimum(1e-2);
    error.GetYaxis()->SetLabelSize(0.04);
    error.GetYaxis()->SetTitleSize(0.06);
    error.GetYaxis()->SetTitleOffset(0.8);
    error.GetXaxis()->SetLabelSize(0.04);
    error.GetXaxis()->SetTitleSize(0.05);
    error.GetXaxis()->SetTitleOffset(0.9);
    error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    error.GetXaxis()->SetTitle("m_{chargino} (GeV)");
    if(type=="HH") error.GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    error.SetFillColor(kGreen);
    error2S.SetFillColor(kYellow);
    error2S.SetTitle("");
    error.SetTitle("");
    error.Draw("A3");
    error2S.Draw("3SAME");
    error.Draw("3");
    
    theo->SetTitle("");
    theo->Draw("3C");

    graph.SetLineStyle(kDashed);
    graph.SetLineWidth(2.0);
    graph.SetTitle("");
    graph.Draw("C");

    obser.SetLineStyle(1);
    obser.SetLineWidth(2.0);
    obser.SetTitle("");
    if(!blind) obser.Draw("C");

    TLegend leg(0.65,0.65,0.89,0.89);
    leg.SetFillColor(0);
    leg.SetBorderSize(0);
    leg.AddEntry(&graph,"expected","l");
    leg.AddEntry(&error,"expected #pm1#sigma","F");
    leg.AddEntry(&error2S,"expected #pm2#sigma","F");
    leg.AddEntry(theo,"theoretical","f");
    if(!blind)     leg.AddEntry(&obser,"observed","l");

    leg.Draw("SAME");

    TLatex latex;
    latex.SetNDC();
    latex.SetTextAngle(0);
    latex.SetTextColor(kBlack);    
    float extraTextSize = extraOverCmsTextSize*cmsSize;
    latex.SetTextFont(lumifont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);    
    latex.DrawLatex(lumix, lumiy,lumiText);
    
    latex.SetTextFont(cmsTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);
    latex.DrawLatex(cmsx, cmsy, CMSText);
    
    latex.SetTextFont(extraTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(extraTextSize);
    latex.DrawLatex(extrax, extray, extraText);

    TString infix=(blind ? "" : "_OBS");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.png");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.pdf");
    cv.SaveAs(combine_dir+"/expected_exclusion_"+type+"_1D"+infix+"_v2.C");

    error_r.SetMaximum(1e2);
    error_r.SetMinimum(1e-2);

    error_r.SetTitle("");
    error_r.GetYaxis()->SetLabelSize(0.04);
    error_r.GetYaxis()->SetTitleSize(0.06);
    error_r.GetYaxis()->SetTitleOffset(0.8);
    error_r.GetXaxis()->SetLabelSize(0.04);
    error_r.GetXaxis()->SetTitleSize(0.05);
    error_r.GetXaxis()->SetTitleOffset(0.9);
    error_r.GetYaxis()->SetTitle("#sigma_{95%}/#sigma_{NLO}");
    if(type=="HH") error_r.GetXaxis()->SetTitle("m_{neutralino} (GeV)");
    else error_r.GetXaxis()->SetTitle("m_{chargino} (GeV)");
    error_r.SetFillColor(kGreen);
    error_r2S.SetFillColor(kYellow);
    error_r2S.SetTitle("");
    error_r.Draw("A3");
    error_r2S.Draw("3SAME");
    error_r.Draw("3SAME");

    graph_r.SetLineStyle(kDashed);
    graph_r.SetLineWidth(2);
    graph_r.SetTitle("");
    graph_r.Draw("C");

    TLine l(125,1,205,1);
    l.SetLineWidth(3);
    l.SetLineColor(kBlue);
    //l.Draw("SAME");

    obser_r.SetLineWidth(2);
    if(!blind) obser_r.Draw("C");
    leg.Draw("SAME");

    //lbl.SetY(0.20);
    //leg.SetY1NDC(0.28);
    //leg.SetY2NDC(0.43);

    //prelim.Draw();
    //lbl.Draw();
    latex.SetTextFont(lumifont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);    
    latex.DrawLatex(lumix, lumiy,lumiText);
    
    latex.SetTextFont(cmsTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(cmsSize);
    latex.DrawLatex(cmsx, cmsy, CMSText);
    
    latex.SetTextFont(extraTextFont);
    latex.SetTextAlign(31); 
    latex.SetTextSize(extraTextSize);
    latex.DrawLatex(extrax, extray, extraText);
    
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.png");
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.pdf");
    cv.SaveAs(combine_dir+"/expected_exclusion_ratio_"+type+"_1D"+infix+"_v2.C");
}
void minuitFit()
{

  TH1F::SetDefaultSumw2(); 
  TH1D::SetDefaultSumw2(); 

  cout << "Must Use Same Binning as previous Analysis!" << endl;

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  haveName = kFALSE;
  char fname[100];
  TFile* file;
  Bool_t makePDF = checkMakePDF();
  Bool_t makeROOT = checkMakeRoot();
  if(makeROOT){
    sprintf(fname,"/Users/zach/Research/pythia/200GeVTemplate/FFOutput/%s_FIT.root",FileNameR);
    file = new TFile(fname,"RECREATE");
    if (file->IsOpen()==kFALSE)
    {
      std::cout << "!!! Outfile Not Opened !!!" << std::endl;
      makeROOT = kFALSE;
    }
  }


  char name[1000];
  sprintf(name,"/Users/zach/Research/pythia/200GeVTemplate/currentTemplate.root");
  TFile *fT = new TFile(name,"READ");
  sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root");
  TFile *fD = new TFile(name,"READ");
  if (fT->IsOpen()==kFALSE || fD->IsOpen()==kFALSE)
  { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl
    << "Looking for currentB.root, currentC.root, and currentData.root" << std::endl;
    exit(1); }

  // Set constants and projection bins (from header file anaConst, analysis constants)

  Float_t lowpt[numPtBins],highpt[numPtBins];
  for(Int_t c=0; c< numPtBins; c++){
    lowpt[c] = anaConst::lpt[c];
    highpt[c] = anaConst::hpt[c];
  }
  Float_t hptCut=anaConst::hptCut;

  // Make Canvases
  TCanvas* deltaPhi  = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* deltaPhi2  = new TCanvas("deltaPhi2","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000);
  TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000);
  TCanvas* fitResultC = new TCanvas("fitResultC","RB Extraction Combined Trigs",150,0,1150,1000);
  TCanvas* fitResultP = new TCanvas("fitResultP","RB Previous Analysis",150,0,1150,1000);
  TCanvas* scaleCheck = new TCanvas("scaleCheck","Check scale diff",150,0,1150,1000);
  TCanvas* prettyPlot = new TCanvas("prettyPlot","PrettyPlot",150,0,1150,1000);
  deltaPhi  ->Divide(3,3);
  deltaPhi2 ->Divide(3,3);
  fitResult0->Divide(3,4);
  fitResult2->Divide(3,4);
  fitResultC->Divide(3,4);
  fitResultP->Divide(2,2);
  scaleCheck->Divide(1,2);

  // Get and Draw histos
  TPaveText* lbl[numPtBins];
  TPaveText* stat[4][numPtBins];
  char statLabel[100];
  char textLabel[100];
  Int_t plotbin;
  Double_t norm0,norm2,normB,normC;

  // Get ptbin independent hists
  histoNorms = (TH2F*)fD->Get("histoNorms");
   // Get Previous Analysis
  TFile *file3 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_25_35.root");
  Hdphi[0]  = (TH1D*)file3->Get("fit_25_35");
  HpphiD[0] = (TH1D*)file3->Get("De_25_35");
  HpphiB[0] = (TH1D*)file3->Get("Be_25_35");
  TFile *file4 = new TFile("/Users/zach/Research/previousNPEhFigures/Chi2_55_65.root");
  Hdphi[1]  = (TH1D*)file4->Get("fit_55_65");
  HpphiD[1] = (TH1D*)file4->Get("De_55_65");
  HpphiB[1] = (TH1D*)file4->Get("Be_55_65");

  for(Int_t ptbin=0; ptbin<numPtBins; ptbin++)
  {
    bPtNorms[ptbin]   = (TH1F*)fT->Get(Form("beEventTally_%i",ptbin));
    cPtNorms[ptbin]   = (TH1F*)fT->Get(Form("ceEventTally_%i",ptbin));

    norm0 = histoNorms->GetBinContent(histoNorms->GetBin(1,ptbin+1));
    norm2 = histoNorms->GetBinContent(histoNorms->GetBin(3,ptbin+1));
    normB = bPtNorms[ptbin]->GetBinContent(1);
    normC = cPtNorms[ptbin]->GetBinContent(1);

    cout << ptbin << "; 0: " << norm0 << " 2: " << norm2 << endl;

    if( norm0 == 0)
    {
      cout << ptbin << " For this bin, some norm0 = 0" << endl;
      continue;
    }
    if( norm2 == 0 )
    {
      cout << ptbin << " For this bin, some norm2 = 0" << endl;
      continue;
    }
    if( normB == 0 )
    {
      cout << ptbin << " For this bin, some normB = 0" << endl;
      continue;
    }
    if( normC == 0)
    {
      cout << ptbin << " For this bin, some normC = 0" << endl;
      continue;
    }
    plotbin = ptbin;
    // Init necessary plotting tools
    lbl[ptbin] = new TPaveText(.15,.15,.35,.23,Form("NB NDC%i",ptbin));
    sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]);
    lbl[ptbin]->AddText(textLabel);
    lbl[ptbin]->SetFillColor(kWhite);

    projB[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawbe_%i",ptbin));
    projC[ptbin] = (TH1D*)fT->Get(Form("hdPhiRawce_%i",ptbin));
    projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin));
    projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin));
 
    pileupCorrect[ptbin][0] = (TH1D*)fD->Get(Form("pileupCorrection_%i_0",ptbin));
    pileupCorrect[ptbin][1] = (TH1D*)fD->Get(Form("pileupCorrection_%i_2",ptbin));
    pileupCorrect[ptbin][0]->Sumw2();
    pileupCorrect[ptbin][1]->Sumw2();

    // Do any rebinning
    Int_t RB = 1;
    projB[ptbin]->Rebin(RB);
    projC[ptbin]->Rebin(RB);
    projData0[ptbin]->Rebin(RB);
    projData2[ptbin]->Rebin(RB);

    // Clone to make plots without effecting fits
    plotD0[ptbin] = (TH1D*) projData0[ptbin]->Clone();
    plotD2[ptbin] = (TH1D*) projData2[ptbin]->Clone();
    plotB[ptbin]  = (TH1D*) projB[ptbin]->Clone();
    plotC[ptbin]  = (TH1D*) projC[ptbin]->Clone();

    // Set features that are the same in plots
    projData0[ptbin]->SetLineColor(kBlue);
    projData2[ptbin]->SetLineColor(kGreen+3);
    projB[ptbin]->SetLineColor(kRed);
    projC[ptbin]->SetLineColor(kBlack);
    projC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);
    plotD0[ptbin]->SetLineColor(kBlue);
    plotD2[ptbin]->SetLineColor(kGreen+3);
    plotD0[ptbin]->SetMarkerStyle(20);
    plotD0[ptbin]->SetMarkerColor(kBlue);
    plotD0[ptbin]->SetMarkerSize(0.4);
    plotB[ptbin]->SetLineColor(kRed);
    plotC[ptbin]->SetLineColor(kBlack);
    plotC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);

    combData[ptbin] = (TH1D*) projData0[ptbin]->Clone();
    combData[ptbin] -> Add(projData2[ptbin]);
    combData[ptbin]->SetLineColor(kBlue);
    combData[ptbin]->SetMarkerStyle(20);
    combData[ptbin]->SetMarkerColor(kBlue);
    combData[ptbin]->SetMarkerSize(0.4);
    combData[ptbin]->SetTitle("");

    // Normalize
    projB[ptbin]     -> Scale(1./normB);
    projC[ptbin]     -> Scale(1./normC);
    projData0[ptbin] -> Scale(1./norm0);
    projData2[ptbin] -> Scale(1./norm2);
    plotD0[ptbin]    -> Scale(1./norm0);
    plotD2[ptbin]    -> Scale(1./norm2);
    plotB[ptbin]     -> Scale(1./normB);
    plotC[ptbin]     -> Scale(1./normC);
    combData[ptbin]  -> Scale(1./(norm0+norm2));

    // Subtract Pileup correction (data only)
    projData0[ptbin]->Sumw2();projData2[ptbin]->Sumw2();
    //projData0[ptbin]->Add(pileupCorrect[ptbin][0],-1);
    //projData2[ptbin]->Add(pileupCorrect[ptbin][1],-1);

    // Draw Templates on own plots
    if(ptbin+1 <= 9) deltaPhi->cd(plotbin+1);
    if(ptbin+1 > 9) deltaPhi2->cd(ptbin-8);
    plotC[ptbin]->GetYaxis()->SetRangeUser(-.1,0.8);
    plotC[ptbin]  -> Draw("hist");
    plotB[ptbin]  -> Draw("same hist");
    plotD0[ptbin] -> Draw("same");
    plotD2[ptbin] -> Draw("same");
    lbl[ptbin]    -> Draw("same");

    TLegend* leg = new TLegend(0.65,0.6,0.85,0.85);
    leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe");
    leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe");
    leg->AddEntry(projData0[ptbin],"HT0","lpe");
    leg->AddEntry(projData2[ptbin],"HT2","lpe");
    leg->Draw();

    deltaPhi->cd(1);
    Hdphi[0]->Draw("same");
    deltaPhi->cd(4);
    Hdphi[1]->Draw("same");

      if(ptbin == 1)
      {
        prettyPlot->cd();
        plotC[ptbin]->GetYaxis()->SetRangeUser(0,0.35);
        plotC[ptbin]->SetMarkerStyle(20);
        plotC[ptbin]->SetMarkerSize(0.6);
        plotB[ptbin]->SetMarkerStyle(21);
        plotB[ptbin]->SetMarkerSize(0.6);
        plotB[ptbin]->SetMarkerColor(kRed);
        plotD0[ptbin]->SetMarkerStyle(22);
        plotD0[ptbin]->SetMarkerSize(0.9);
        plotC[ptbin]->GetXaxis()->SetTitle("#Delta#phi_{NPE-h} (rad)");
        plotC[ptbin]->GetYaxis()->SetTitle("#frac{1}{N_{NPE}} #frac{dN}{d(#Delta#phi)}");
        plotC[ptbin]->DrawClone("P");
        plotB[ptbin]->DrawClone("same P");
        plotD0[ptbin]->DrawClone("same P");
        TLegend* legPret = new TLegend(0.65,0.6,0.85,0.85);
        legPret->AddEntry(plotB[ptbin],"B #rightarrow NPE-h, Monte Carlo","LPE");
        legPret->AddEntry(plotC[ptbin],"D #rightarrow NPE-h, Monte Carlo","LPE");
        legPret->AddEntry(plotD0[ptbin],"NPE-h 2012 STAR Data","LPE");
        lbl[ptbin]->Draw("same");
        legPret->Draw("same");
      }

    /*// Draw Scale Check
      scaleCheck->cd(1);
      TH1F* HT0 = (TH1F*) plotD0[0]->Clone();
      HT0->Divide(HT0,Hdphi[0],1,1);
      HT0->Draw();
      scaleCheck->cd(2);
      TH1F* HT2 = (TH1F*) plotD2[3]->Clone();
      HT2->Divide(HT2,Hdphi[1],1,1);
      HT0->GetXaxis()->SetRangeUser(-3.5,3.5);
      HT2->GetXaxis()->SetRangeUser(-3.5,3.5);
      HT2->Draw();
      lbl[ptbin]->Draw("same");
      TLegend* legSC = new TLegend(0.65,0.6,0.85,0.85);
      legSC->AddEntry(HT0,"HT0/prevdata","lpe");
      legSC->AddEntry(HT2,"HT2/prevdata","lpe");
      legSC->Draw();*/

    /////////////////////
    // Do the actual fits
    /////////////////////

    currentPtBin = ptbin;
    cout << "!!!!!!! HT0 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    TMinuit* gMinuit = new TMinuit(1);
    gMinuit->SetFCN(chi2_0);
    currentPtBin = ptbin;
    doFit(gMinuit,p01[ptbin],p00[ptbin],e01[ptbin],e00[ptbin]);

    // assign to plotting variables
    if(highpt[ptbin] < 6)
    {
      pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
      dx[plotCount0] = 0.;
      ptOFF1[plotCount0] = pT[ptbin];
      Rb0[plotCount0] = p01[ptbin];///(p01[ptbin]+p00[ptbin]);
      eb0[plotCount0] = e01[ptbin];
      plotCount0++;
    }

    // Plot results
    fitResult0->cd(ptbin+1);
    TH1D* dClone = (TH1D*) projData0[ptbin]->Clone();
    TH1D* cClone = (TH1D*) projC[ptbin]->Clone();
    TH1D* bClone = (TH1D*) projB[ptbin]->Clone();
    stat[0][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
    sprintf(statLabel,"Chi2/NDF: %.2f/%.0f",curChi2,curNDF);
    stat[0][ptbin]->InsertText(statLabel);
    stat[0][ptbin]->SetFillColor(kWhite);
    cClone->Scale((1.-p01[ptbin])*p00[ptbin]); bClone->Scale(p00[ptbin]*p01[ptbin]); // scale by contribution param
    cClone->Add(bClone);
    //cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
    dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
    dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
    dClone->Draw();
    cClone->Draw("same");
    stat[0][ptbin]->Draw("same");
    lbl[ptbin]->Draw("same");


    cout << "!!!!!!! HT2 ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    gMinuit->SetFCN(chi2_2);
    doFit(gMinuit,p21[ptbin],p20[ptbin],e21[ptbin],e20[ptbin]);

    // assign to plotting variables
    if(highpt[ptbin] > 3.6)
    {
      pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
      ptOFF2[plotCount2] = pT[ptbin];
      Rb2[plotCount2] = p21[ptbin];///(p21[ptbin]+p20[ptbin]);
      eb2[plotCount2] = e21[ptbin];
      plotCount2++;
    }

    // Plot results
    fitResult2->cd(ptbin+1);
    dClone = (TH1D*) projData2[ptbin]->Clone();
    cClone = (TH1D*) projC[ptbin]->Clone();
    bClone = (TH1D*) projB[ptbin]->Clone();
    stat[2][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
    sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
    stat[2][ptbin]->InsertText(statLabel);
    stat[2][ptbin]->SetFillColor(kWhite);
    cClone->Scale((1.-p21[ptbin])*p20[ptbin]); bClone->Scale(p20[ptbin]*p21[ptbin]); // scale by contribution param
    cClone->Add(bClone);
    // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
    dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
    dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
    dClone->Draw();
    cClone->Draw("same");
    stat[2][ptbin]->Draw("same");
    lbl[ptbin]->Draw("same");

    cout << "!!!!!!! HTC ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
    gMinuit->SetFCN(chi2_C);
    doFit(gMinuit,pC1[ptbin],pC0[ptbin],eC1[ptbin],eC0[ptbin]);
    // assign to plotting variables
    pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
    RbC[plotCount] = pC1[ptbin];///(p21[ptbin]+p20[ptbin]);
    ebC[plotCount] = eC1[ptbin];
    plotCount++;
  }

  cout << "!!!!!!! Previous Data: 0"<<" !!!!!!!"<< endl;

  //////////
  // 2.5-3.5 GeV Bin
  //////////

  gMinuit->SetFCN(chi2_P0);
  doFit(gMinuit,RbP[0],SF[0],EbP[0],eSF[0]);

  // assign plotting variables
  pTP[0] = 3.;

  // Plot results
  fitResultP->cd(1);
  /*TH1D* dClone = (TH1D*) Hdphi[0]->Clone();
    TH1D* cClone = (TH1D*) projC[0]->Clone();
    TH1D* bClone = (TH1D*) projB[0]->Clone();*/
  TH1D* dClone = (TH1D*) projData0[0]->Clone();
  TH1D* cClone = (TH1D*) HpphiD[0]->Clone();
  TH1D* bClone = (TH1D*) HpphiB[0]->Clone();
  stat[3][0] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][0]->InsertText(statLabel);
  stat[3][0]->SetFillColor(kWhite);
  cClone->Scale((1.-RbP[0])*SF[0]); bClone->Scale(RbP[0]*SF[0]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][0]->Draw("same");

  ////////
  // 5.5-6.5 GeV Bin
  ////////

  gMinuit->SetFCN(chi2_P1);
  doFit(gMinuit,RbP[1],SF[1],EbP[1],eSF[1]);

  // assign plotting variables
  pTP[1] = 6.;

  // Plot results
  fitResultP->cd(2);
  /*dClone = (TH1D*) Hdphi[1]->Clone();
    cClone = (TH1D*) projC[3]->Clone();
    bClone = (TH1D*) projB[3]->Clone();*/
  dClone = (TH1D*) projData2[3]->Clone();
  cClone = (TH1D*) HpphiD[1]->Clone();
  bClone = (TH1D*) HpphiB[1]->Clone();
  stat[3][1] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][1]->InsertText(statLabel);
  stat[3][1]->SetFillColor(kWhite);
  cClone->Scale((1.-RbP[1])*SF[1]); bClone->Scale(RbP[1]*SF[1]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][1]->Draw("same");

  ////////
  // Old Data, Old Template
  ///////
  gMinuit->SetFCN(chi2_PP);
  doFit(gMinuit,RbPP[0],SFPP[0],EbPP[0],eSFPP[0]);

  // assign plotting variables
  pTPP[0] = 3.;

  // Plot results
  fitResultP->cd(3);
  dClone = (TH1D*) Hdphi[0]->Clone();
  cClone = (TH1D*) HpphiD[0]->Clone();
  bClone = (TH1D*) HpphiB[0]->Clone();
  stat[3][2] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][2]->InsertText(statLabel);
  stat[3][2]->SetFillColor(kWhite);
  cClone->Scale((1.-RbPP[0])*SFPP[0]); bClone->Scale(RbPP[0]*SFPP[0]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][2]->Draw("same");

  // Bin at 6 GeV
  gMinuit->SetFCN(chi2_PP1);
  doFit(gMinuit,RbPP[1],SFPP[1],EbPP[1],eSFPP[1]);

  // assign plotting variables
  pTPP[1] = 6.;

  // Plot results
  fitResultP->cd(4);
  dClone = (TH1D*) Hdphi[1]->Clone();
  cClone = (TH1D*) HpphiD[1]->Clone();
  bClone = (TH1D*) HpphiB[1]->Clone();
  stat[3][3] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%iP",0));
  sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
  stat[3][3]->InsertText(statLabel);
  stat[3][3]->SetFillColor(kWhite);
  cClone->Scale((1.-RbPP[1])*SFPP[1]); bClone->Scale(RbPP[1]*SFPP[1]); // scale by contribution param
  cClone->Add(bClone);
  // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
  dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
  dClone->GetYaxis()->SetRangeUser(-0.1,0.6);
  cClone->SetLineColor(kRed);
  dClone->Draw();
  cClone->Draw("same");
  stat[3][3]->Draw("same");


  // Get FONLL Calc
  Int_t l=0;
  char line[1000];
  Float_t xF[100],yF[100],minF[100],maxF[100];
  ifstream fp("/Users/zach/Research/pythia/200GeVTemplate/FONLL.txt",ios::in);
  while (!fp.eof()){
    fp.getline(line,1000);
    sscanf(line,"%f %f %f %f",&xF[l],&yF[l],&minF[l],&maxF[l]);
    //  printf("L: %f %f\n",xF[l],yF[l]);
    l++;
  }
  fp.close();

  // Get Previous Analysis 
  Int_t p=0;
  Float_t xP[100],yP[100],dyP[100];
  ifstream fp1("/Users/zach/Research/pythia/200GeVTemplate/run5_6.txt",ios::in);
  while (!fp1.eof()){
    fp1.getline(line,1000);
    sscanf(line,"%f %f %f",&xP[p],&yP[p],&dyP[p]);
    // printf("L: %f %f\n",xF[l],yF[l]);
    p++;
  }
  fp1.close();

  //cout << "at bottom contrib plot" << endl;
  TCanvas* c1 = new TCanvas("c1","Bottom Contribution",150,0,1150,1000);
  TGraphErrors *gr0     = new TGraphErrors(plotCount0-1,ptOFF1,Rb0,dx,eb0);
  TGraphErrors *gr2     = new TGraphErrors(plotCount2-1,ptOFF2,Rb2,dx,eb2);
  TGraphErrors *grC     = new TGraphErrors(plotCount-1,pT,RbC,dx,ebC);
  TGraphErrors *grF     = new TGraphErrors(l-1,xF,yF);
  TGraphErrors *grFmax  = new TGraphErrors(l-1,xF,maxF);
  TGraphErrors *grFmin  = new TGraphErrors(l-1,xF,minF);
  TGraphErrors *grP     = new TGraphErrors(p-1,xP,yP,0,dyP);
  TGraphErrors *grPr    = new TGraphErrors(2,pTP,RbP,0,EbP);
  TGraphErrors *grPPr   = new TGraphErrors(2,pTPP,RbPP,0,EbPP);


  c1->cd(1);

  grP->SetTitle("");
  grP->GetXaxis()->SetTitle("NPE p_{T} (GeV/c)");
  grP->GetYaxis()->SetTitle("r_{B}");
  gr0->SetMarkerStyle(20);
  gr0->SetMarkerSize(1);
  gr0->SetLineColor(kBlue);
  gr0->SetMarkerColor(kBlue);
  gr2->SetMarkerStyle(22);
  gr2->SetMarkerSize(1);
  gr2->SetLineColor(kRed);
  gr2->SetMarkerColor(kRed);
  grC->SetMarkerStyle(21);
  grC->SetMarkerSize(1);
  grC->SetLineColor(kRed);
  grC->SetMarkerColor(kRed);
  grP->GetXaxis()->SetLimits(0,10);
  grP->GetYaxis()->SetRangeUser(0,1);
  grF->SetLineStyle(1);
  grFmax->SetLineStyle(2);
  grFmin->SetLineStyle(2);
  grP->SetMarkerStyle(33);
  grP->SetMarkerColor(kBlack);
  grPr->SetMarkerStyle(29);
  grPr->SetMarkerColor(9);
  grPr->SetLineColor(9);
  grPPr->SetMarkerStyle(29);
  grPPr->SetMarkerColor(49);
  grPPr->SetLineColor(49);


  grP->Draw("AP");
  //grC->Draw("same P");
  gr2->Draw("same P");
  grF->Draw("same");
  grFmax->Draw("same");
  grFmin->Draw("same");
  gr0->Draw("same P");
 // grPr->Draw("same P");
  //grPPr->Draw("same P");

  TLegend* leg2 = new TLegend(0.15,0.68,0.48,0.85);
  leg2->AddEntry(gr0,"STAR Run 12 - Low p_{T} Analysis","pe");
  leg2->AddEntry(gr2,"STAR Run 12 - High p_{T} Analysis","pe");
  //leg2->AddEntry(grC,"Combined Trigs","pe");
  leg2->AddEntry(grP,"STAR Run 6 Analysis (Stat. Uncertainty)","pe");
//  leg2->AddEntry(grPr,"Run 12 Data, Run 5/6 Templates)","pe");
  //leg2->AddEntry(grPPr,"Run 5/6 Refit (prev Template)","pe");
  leg2->AddEntry(grF,"FONLL Calculation","l");
  leg2->Draw("same");

  // Write to Root File if open
  if(makeROOT){
    file3->Close();
    file4->Close();
    file->cd();
    grP->Write("PreviousData");
    //grC->Write("same P");
    gr2->Write("HT2");
    grF->Write("FONLL");
    grFmax->Write("FONLLmax");
    grFmin->Write("FONLLmin");
    gr0->Write("HT0");
    // grPr->Write("PrevTempMyData");
    //grPPr->Write("PrevTempPreData");
  }

  // Make PDF with output canvases
  if(makePDF)
  {
    //Set front page
    TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900);
    fp->cd();
    TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99);
    bLabel->SetFillColor(38);
    bLabel->Draw();
    TLatex tl;
    tl.SetNDC();
    tl.SetTextColor(kWhite);
    tl.SetTextSize(0.033);
    char tlName[100];
    char tlName2[100];

    TString titlename = FileName;
    int found = titlename.Last('/');
    if(found >= 0){
      titlename.Replace(0, found+1, "");
    } 
    sprintf(tlName, "RUN 12 NPE-h   #Delta#phi Correlations");
    tl.SetTextSize(0.05);
    tl.SetTextColor(kWhite);
    tl.DrawLatex(0.05, 0.92,tlName);

    TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12);
    bFoot->SetFillColor(38);
    bFoot->Draw();
    tl.SetTextColor(kWhite);
    tl.SetTextSize(0.05);
    tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString());
    tl.SetTextColor(kBlack);
    tl.SetTextSize(0.03);
    tl.DrawLatex(0.1, 0.14, titlename);
    sprintf(tlName,"TEST");
    tl.DrawLatex(0.1, 0.8,tlName);

    // Place canvases in order
    TCanvas* temp = new TCanvas();
    sprintf(name, "FFOutput/%s.pdf[", FileName);
    temp->Print(name);
    sprintf(name, "FFOutput/%s.pdf", FileName);

    temp = deltaPhi; 
    temp->Print(name);
    temp = fitResult0;
    temp->Print(name);
    temp = fitResult2;
    temp->Print(name);
    // temp = fitResultC;
    // temp->Print(name);
    temp = c1;
    temp->Print(name);

    sprintf(name, "FFOutput/%s.pdf]", FileName);
    temp->Print(name);
  }
  if(makeROOT)
  {
    file->Write();
    file->Close();
  }
}
Exemplo n.º 3
0
void MakePlots(TString filename, TString energy="8TeV", TString lumi=""){
  TString outDir=filename; outDir.ReplaceAll("fitres","img");
  outDir="tmp/";
  //std::map<TString, TH2F *> deltaNLL_map;
  
  /*------------------------------ Plotto */
  TCanvas *c = new TCanvas("c","c");
  
  TFile f_in(filename, "read");
  if(f_in.IsZombie()){
    std::cerr << "File opening error: " << filename << std::endl;
    return;
  }
  
  TList *KeyList = f_in.GetListOfKeys();
  std::cout << KeyList->GetEntries() << std::endl;
  for(int i =0; i <  KeyList->GetEntries(); i++){
    c->Clear();
    TKey *key = (TKey *)KeyList->At(i);
    if(TString(key->GetClassName())!="RooDataSet") continue;
    RooDataSet *dataset = (RooDataSet *) key->ReadObj();
    
    TString constTermName = dataset->GetName();
    TString alphaName=constTermName; alphaName.ReplaceAll("constTerm","alpha");

    TTree *tree = dataset2tree(dataset);
    TGraphErrors bestFit_ = bestFit(tree, alphaName, constTermName);
    TH2F *hist = prof2d(tree, alphaName, constTermName, "nll", "(12,-0.0005,0.0115,29,-0.0025,0.1425)",true);

//     //    deltaNLL_map.insert(std::pair <TString, TH2F *>(keyName,hist));
    hist->SaveAs(outDir+"/deltaNLL-"+constTermName+".root");
    hist->Draw("colz");
    bestFit_.Draw("P same");
    bestFit_.SetMarkerSize(2);

    Int_t iBinX, iBinY;
    Double_t x,y;
    hist->GetBinWithContent2(0,iBinX,iBinY);
    x= hist->GetXaxis()->GetBinCenter(iBinX);
    y= hist->GetYaxis()->GetBinCenter(iBinY);
    TGraph nllBestFit(1,&x,&y);

    nllBestFit.SetMarkerStyle(3);
    nllBestFit.SetMarkerColor(kRed);
    TList* contour68 = contourFromTH2(hist, 0.68);

    hist->Draw("colz");
    hist->GetZaxis()->SetRangeUser(0,50);
    bestFit_.Draw("P same");
    nllBestFit.Draw("P same");
    //contour68->Draw("same");
    c->SaveAs(outDir+"/deltaNLL-"+constTermName+".png");
    hist->SaveAs("tmp/hist-"+constTermName+".root");
    nllBestFit.SaveAs("tmp/nllBestFit.root");
    contour68->SaveAs("tmp/contour68.root");
    delete hist;
    hist = prof2d(tree, alphaName, constTermName, "nll", "(12,-0.0005,0.0115,29,-0.0025,0.1425)");
    RooHistPdf *histPdf = nllToL(hist);
    delete hist;
    RooDataSet *gen_dataset=histPdf->generate(*histPdf->getVariables(),1000000,kTRUE,kFALSE);
    TTree *genTree = dataset2tree(gen_dataset);
    genTree->SaveAs("tmp/genTree-"+constTermName+".root");
    delete gen_dataset;
    delete histPdf;
    
    TGraphErrors toyGraph = g(genTree, constTermName);
    TGraphErrors bestFitGraph = g(tree,alphaName, constTermName);
    TGraphErrors bestFitScanGraph = g(y, x);
    delete genTree;
    delete tree;
    toyGraph.SetFillColor(kGreen);
    toyGraph.SetLineColor(kBlue);
    toyGraph.SetLineStyle(2);
    bestFitGraph.SetLineColor(kBlack);
    bestFitScanGraph.SetLineColor(kRed);
    bestFitScanGraph.SetLineWidth(2);


    
    TMultiGraph g_multi("multigraph","");
    g_multi.Add(&toyGraph,"L3");
    g_multi.Add(&toyGraph,"L");
    g_multi.Add(&bestFitGraph, "L");
    g_multi.Add(&bestFitScanGraph, "L");
   
    g_multi.Draw("A");

    c->Clear();
    g_multi.Draw("A");
    c->SaveAs(outDir+"/smearing_vs_energy-"+constTermName+".png");

    //    TPaveText *pv = new TPaveText(0.7,0.7,1, 0.8);    
//     TLegend *legend = new TLegend(0.7,0.8,0.95,0.92);
//     legend->SetFillStyle(3001);
//     legend->SetFillColor(1);
//     legend->SetTextFont(22); // 132
//     legend->SetTextSize(0.04); // l'ho preso mettendo i punti con l'editor e poi ho ricavato il valore con il metodo GetTextSize()
//   //  legend->SetFillColor(0); // colore di riempimento bianco
//     legend->SetMargin(0.4);  // percentuale della larghezza del simbolo
    //    SetLegendStyle(legend);
	
    //Plot(c, data,mc,mcSmeared,legend, region, filename, energy, lumi);
  }
  
  f_in.Close();
  
  return;
}
Exemplo n.º 4
0
void make1DLimitHH(TString combine_dir,bool blind=true){
  //TString combine_dir = "test_runSusyHgg/signalInj_sms_ChiHH_0_175/";

  TGraph obser( (275-125)/25 );
  TGraph graph( (275-125)/25 );
  TGraphAsymmErrors error( (275-125)/25 );

    for(int m=125;m<501;m+=25) {
      int i=(m-125)/25;
      TFile limit_file(Form("%s/higgsCombineChiHH_0_%d.Asymptotic.mH120.root",combine_dir.Data(),m) );
      TTree *limit_tree = (TTree*)limit_file.Get("limit");
      TTreeFormula limit_form("get_limit","limit",limit_tree);

      limit_tree->GetEntry(1);
      float down = limit_form.EvalInstance();
      limit_tree->GetEntry(2);
      float exp = limit_form.EvalInstance();
      limit_tree->GetEntry(3);
      float up = limit_form.EvalInstance();
      limit_tree->GetEntry(5);
      float obs = limit_form.EvalInstance();

      graph.SetPoint(i,float(m),exp);
      error.SetPoint(i,float(m),exp);
      error.SetPointError(i,0,0,exp-down,up-exp);

      obser.SetPoint(i,float(m),obs);
    }

    TGraphErrors* theo = getTheoXSec("/home/amott/HggApp/SusyHgg/xsecs/Higgsino.txt");

    TCanvas cv;
    cv.SetLogy();

    theo->SetMaximum(1e2);
    theo->SetMinimum(1e-2);
    theo->GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    theo->GetXaxis()->SetTitle("m_{chargino}");
    theo->SetFillColor(kBlue);
    theo->SetLineStyle(kDotted);
    theo->SetLineWidth(2.0);
    
    error.SetMaximum(1e2);
    error.SetMinimum(1e-2);
    error.GetYaxis()->SetTitle("95% CL #sigma upper limit (pb)");
    error.GetXaxis()->SetTitle("m_{chargino}");
    error.SetFillColor(kGreen);
    error.Draw("A3");

    theo->Draw("3C");

    graph.SetLineStyle(kDashed);
    graph.SetLineWidth(2);
    graph.Draw("C");

    obser.SetLineStyle(1);
    obser.SetLineWidth(2);
    if(!blind) obser.Draw("C");

    TLegend leg(0.7,0.7,0.85,0.85);
    leg.SetFillColor(0);
    leg.SetBorderSize(0);
    leg.AddEntry(&graph,"expected","l");
    leg.AddEntry(&error,"expected #pm1#sigma","F");
    leg.AddEntry(theo,"theoretical","f");
    if(!blind)     leg.AddEntry(&obser,"observed","l");

    leg.Draw("SAME");

    TLatex prelim(0.65,0.96,"CMS Preliminary");
    prelim.SetNDC();
    prelim.SetTextSize(0.045);
    prelim.Draw();

    TLatex lbl(0.5,0.86,"#sqrt{s} = 8 TeV  #int L dt = 19.78 fb^{-1}");
    lbl.SetNDC();
    lbl.SetTextSize(0.045);
    lbl.Draw();

    cv.SaveAs(combine_dir+"expected_exclusion_HH_1D.png");


}
Exemplo n.º 5
0
void limit_reb()
{
//=========Macro generated from canvas: limits/limit
//=========  (Thu Sep 22 12:17:10 2016) by ROOT version6.02/08
   TCanvas *limits = new TCanvas("limits", "limit",550,195,702,600);
   limits->Range(0.6111515,-38.33737,4.042061,-34.96366);
   limits->SetFillColor(0);
   limits->SetBorderMode(0);
   limits->SetBorderSize(2);
   limits->SetLogx();
   limits->SetLogy();
   limits->SetFrameBorderMode(0);
   limits->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3001[18] = {
   20,
   30,
   40,
   50,
   60,
   70,
   80,
   90,
   100,
   200,
   300,
   400,
   500,
   700,
   1000,
   2000,
   3000,
   5000};
   Double_t Graph0_fy3001[18] = {
   6.235417e-36,
   6.656746e-37,
   2.262722e-37,
   1.202159e-37,
   8.13632e-38,
   6.332249e-38,
   5.372319e-38,
   4.833697e-38,
   4.489232e-38,
   4.332769e-38,
   5.252924e-38,
   6.342704e-38,
   7.477645e-38,
   9.802517e-38,
   1.341753e-37,
   2.543024e-37,
   3.764757e-37,
   6.161271e-37};
   Double_t Graph0_felx3001[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph0_fely3001[18] = {
   3.098445e-36,
   3.311771e-37,
   1.125534e-37,
   5.97395e-38,
   4.033772e-38,
   3.144153e-38,
   2.672203e-38,
   2.40628e-38,
   2.232825e-38,
   2.156849e-38,
   2.620711e-38,
   3.168511e-38,
   3.736759e-38,
   4.903225e-38,
   6.71478e-38,
   1.272391e-37,
   1.884008e-37,
   3.081215e-37};
   Double_t Graph0_fehx3001[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph0_fehy3001[18] = {
   6.738838e-36,
   7.334375e-37,
   2.460543e-37,
   1.290625e-37,
   8.677873e-38,
   6.732755e-38,
   5.736414e-38,
   5.168521e-38,
   4.806038e-38,
   4.698138e-38,
   5.711198e-38,
   6.923562e-38,
   8.160256e-38,
   1.072586e-37,
   1.472118e-37,
   2.791597e-37,
   4.134292e-37,
   6.739957e-37};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(18,Graph0_fx3001,Graph0_fy3001,Graph0_felx3001,Graph0_fehx3001,Graph0_fely3001,Graph0_fehy3001);
   grae->SetName("Graph0");
   grae->SetTitle("");
   grae->SetFillColor(5);
   grae->SetLineColor(5);
   grae->SetMarkerColor(5);
   grae->SetMarkerSize(0);
   
   TH1F *Graph_Graph3001 = new TH1F("Graph_Graph3001","",100,9,5000);
   Graph_Graph3001->SetMinimum(1e-38);
   Graph_Graph3001->SetMaximum(5e-36);
   Graph_Graph3001->SetDirectory(0);
   Graph_Graph3001->SetStats(0);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   Graph_Graph3001->SetLineColor(ci);
   Graph_Graph3001->GetXaxis()->SetTitle("M_{ #chi}  [GeV]");
   Graph_Graph3001->GetXaxis()->SetLabelFont(42);
   Graph_Graph3001->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph3001->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph3001->GetXaxis()->SetTitleFont(42);
   Graph_Graph3001->GetYaxis()->SetTitle("SD WIMP Inelastic cross section   [cm^{2}]");
   Graph_Graph3001->GetYaxis()->SetLabelFont(42);
   Graph_Graph3001->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph3001->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph3001->GetYaxis()->SetTitleOffset(1.3);
   Graph_Graph3001->GetYaxis()->SetTitleFont(42);
   Graph_Graph3001->GetZaxis()->SetLabelFont(42);
   Graph_Graph3001->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph3001->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph3001->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3001);
   
   grae->Draw("ae3");
   
   Double_t Graph1_fx3002[18] = {
   20,
   30,
   40,
   50,
   60,
   70,
   80,
   90,
   100,
   200,
   300,
   400,
   500,
   700,
   1000,
   2000,
   3000,
   5000};
   Double_t Graph1_fy3002[18] = {
   6.235417e-36,
   6.656746e-37,
   2.262722e-37,
   1.202159e-37,
   8.13632e-38,
   6.332249e-38,
   5.372319e-38,
   4.833697e-38,
   4.489232e-38,
   4.332769e-38,
   5.252924e-38,
   6.342704e-38,
   7.477645e-38,
   9.802517e-38,
   1.341753e-37,
   2.543024e-37,
   3.764757e-37,
   6.161271e-37};
   Double_t Graph1_felx3002[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fely3002[18] = {
   1.919487e-36,
   2.054087e-37,
   6.969767e-38,
   3.708937e-38,
   2.497175e-38,
   1.945069e-38,
   1.652413e-38,
   1.49063e-38,
   1.382935e-38,
   1.342629e-38,
   1.630138e-38,
   1.96447e-38,
   2.311742e-38,
   3.024679e-38,
   4.142171e-38,
   7.849003e-38,
   1.161671e-37,
   1.90178e-37};
   Double_t Graph1_fehx3002[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fehy3002[18] = {
   2.91616e-36,
   3.144374e-37,
   1.060046e-37,
   5.600252e-38,
   3.780837e-38,
   2.930568e-38,
   2.503852e-38,
   2.248217e-38,
   2.089524e-38,
   2.035206e-38,
   2.469941e-38,
   2.98816e-38,
   3.527862e-38,
   4.641931e-38,
   6.36456e-38,
   1.207218e-37,
   1.788054e-37,
   2.918083e-37};
   grae = new TGraphAsymmErrors(18,Graph1_fx3002,Graph1_fy3002,Graph1_felx3002,Graph1_fehx3002,Graph1_fely3002,Graph1_fehy3002);
   grae->SetName("Graph1");
   grae->SetTitle("Graph");
   grae->SetFillColor(3);
   grae->SetLineColor(3);
   grae->SetMarkerColor(3);
   grae->SetMarkerSize(0);
   
   TH1F *Graph_Graph3002 = new TH1F("Graph_Graph3002","Graph",100,18,5498);
   Graph_Graph3002->SetMinimum(2.691127e-38);
   Graph_Graph3002->SetMaximum(1.006374e-35);
   Graph_Graph3002->SetDirectory(0);
   Graph_Graph3002->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph3002->SetLineColor(ci);
   Graph_Graph3002->GetXaxis()->SetLabelFont(42);
   Graph_Graph3002->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph3002->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph3002->GetXaxis()->SetTitleFont(42);
   Graph_Graph3002->GetYaxis()->SetLabelFont(42);
   Graph_Graph3002->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph3002->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph3002->GetYaxis()->SetTitleFont(42);
   Graph_Graph3002->GetZaxis()->SetLabelFont(42);
   Graph_Graph3002->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph3002->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph3002->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3002);
   
   grae->Draw("e3");
   
   Double_t Graph2_fx1001[16] = {
   20,
   29.8071,
   39.90202,
   53.41583,
   62.16429,
   69.85718,
   83.21777,
   90,
   105.0887,
   200,
   300,
   388.2045,
   590.8438,
   746.1269,
   1000,
   4244.204};
   Double_t Graph2_fy1001[16] = {
   8e-36,
   7.162923e-37,
   2.027528e-37,
   9.91722e-38,
   7.461589e-38,
   6.3506e-38,
   5.354015e-38,
   5e-38,
   4.600252e-38,
   5e-38,
   6e-38,
   7.252295e-38,
   9.823615e-38,
   1.210266e-37,
   1.5e-37,
   4.354065e-37};
   Double_t Graph2_fex1001[16] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph2_fey1001[16] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   TGraphErrors *gre = new TGraphErrors(16,Graph2_fx1001,Graph2_fy1001,Graph2_fex1001,Graph2_fey1001);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");
   gre->SetLineColor(2);
   gre->SetLineWidth(3);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1001 = new TH1F("Graph_Graph1001","Graph",100,18,4666.624);
   Graph_Graph1001->SetMinimum(4.140227e-38);
   Graph_Graph1001->SetMaximum(8.7954e-36);
   Graph_Graph1001->SetDirectory(0);
   Graph_Graph1001->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1001->SetLineColor(ci);
   Graph_Graph1001->GetXaxis()->SetLabelFont(42);
   Graph_Graph1001->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetXaxis()->SetTitleFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelFont(42);
   Graph_Graph1001->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetYaxis()->SetTitleFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelFont(42);
   Graph_Graph1001->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1001->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1001);
   
   gre->Draw("pc");
   
   Double_t Graph3_fx1002[18] = {
   20,
   30,
   40,
   50,
   60,
   70,
   80,
   90,
   100,
   200,
   300,
   400,
   500,
   700,
   1000,
   2000,
   3000,
   5000};
   Double_t Graph3_fy1002[18] = {
   6.235417e-36,
   6.656746e-37,
   2.262722e-37,
   1.202159e-37,
   8.13632e-38,
   6.332249e-38,
   5.372319e-38,
   4.833697e-38,
   4.489232e-38,
   4.332769e-38,
   5.252924e-38,
   6.342704e-38,
   7.477645e-38,
   9.802517e-38,
   1.341753e-37,
   2.543024e-37,
   3.764757e-37,
   6.161271e-37};
   Double_t Graph3_fex1002[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fey1002[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(18,Graph3_fx1002,Graph3_fy1002,Graph3_fex1002,Graph3_fey1002);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");
   gre->SetLineStyle(7);
   gre->SetLineWidth(3);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1002 = new TH1F("Graph_Graph1002","Graph",100,9,5000);
   Graph_Graph1002->SetMinimum(1e-38);
   Graph_Graph1002->SetMaximum(5e-36);
   Graph_Graph1002->SetDirectory(0);
   Graph_Graph1002->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1002->SetLineColor(ci);
   Graph_Graph1002->GetXaxis()->SetLabelFont(42);
   Graph_Graph1002->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetXaxis()->SetTitleFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelFont(42);
   Graph_Graph1002->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetYaxis()->SetTitleFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelFont(42);
   Graph_Graph1002->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1002->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1002);
   
   gre->Draw("pc");
   
   Double_t Graph4_fx1003[18] = {
   20,
   30,
   40,
   50,
   60,
   70,
   80,
   90,
   100,
   200,
   300,
   400,
   500,
   700,
   1000,
   2000,
   3000,
   5000};
   Double_t Graph4_fy1003[18] = {
   6.799454e-36,
   6.289303e-37,
   1.870549e-37,
   9.204725e-38,
   5.949289e-38,
   4.510389e-38,
   3.771558e-38,
   3.355162e-38,
   3.097464e-38,
   2.942263e-38,
   3.569344e-38,
   4.311977e-38,
   5.08662e-38,
   6.667747e-38,
   9.131451e-38,
   1.729417e-37,
   2.564344e-37,
   4.191275e-37};
   Double_t Graph4_fex1003[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1003[18] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(18,Graph4_fx1003,Graph4_fy1003,Graph4_fex1003,Graph4_fey1003);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetLineWidth(3);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1003 = new TH1F("Graph_Graph1003","Graph",100,18,5498);
   Graph_Graph1003->SetMinimum(2.648037e-38);
   Graph_Graph1003->SetMaximum(7.476458e-36);
   Graph_Graph1003->SetDirectory(0);
   Graph_Graph1003->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_Graph1003->SetLineColor(ci);
   Graph_Graph1003->GetXaxis()->SetLabelFont(42);
   Graph_Graph1003->GetXaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetXaxis()->SetTitleFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelFont(42);
   Graph_Graph1003->GetYaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetYaxis()->SetTitleFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelFont(42);
   Graph_Graph1003->GetZaxis()->SetLabelSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleSize(0.035);
   Graph_Graph1003->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1003);
   
   gre->Draw("pc");
   
   TLegend *leg = new TLegend(0.307047,0.6660839,0.6073826,0.8653846,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.033);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph4","XENON100 Observed 90% CLs limit","lpf");
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph3","XENON100 Expected 90% CLs limit","lpf");
   entry->SetFillStyle(1001);
   entry->SetLineColor(1);
   entry->SetLineStyle(7);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","XMASS 90% CL limit","lpf");
   entry->SetFillStyle(1001);
   entry->SetLineColor(2);
   entry->SetLineStyle(1);
   entry->SetLineWidth(3);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph1","1 #sigma","f");
   entry->SetFillColor(3);
   entry->SetFillStyle(1001);
   entry->SetLineColor(3);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","2 #sigma","f");
   entry->SetFillColor(5);
   entry->SetFillStyle(1001);
   entry->SetLineColor(5);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   TH1F *Graph_copy = new TH1F("Graph_copy","",100,9,5000);
   Graph_copy->SetMinimum(1e-38);
   Graph_copy->SetMaximum(5e-36);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);

   ci = TColor::GetColor("#000099");
   Graph_copy->SetLineColor(ci);
   Graph_copy->GetXaxis()->SetTitle("M  [GeV]");
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelSize(0.035);
   Graph_copy->GetXaxis()->SetTitleSize(0.035);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("#sigma");
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelSize(0.035);
   Graph_copy->GetYaxis()->SetTitleSize(0.035);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelSize(0.035);
   Graph_copy->GetZaxis()->SetTitleSize(0.035);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   limits->Modified();
   limits->cd();
   limits->SetSelected(limits);
}
Exemplo n.º 6
0
void histos_avg(){
	gStyle->SetOptFit(1);
	gStyle->SetOptStat(1110);

	std::string material[3] = {"lxe","lxe_tpb","lyso"};
	std::string interaction[3] = {"","_noCher","_noScint"};

	std::string filepath = "/home/jmbenlloch/next/petalo/work/histo/phys/5ps/jitter/";

	double sigmasNPE[3][2][2][5][10]; // [mat][inter][smear][pde][npe]
	double errorsNPE[3][2][2][5][10]; // [mat][inter][smear][pde][npe]
	double sigmasDT[3][2][2][5][8]; // [mat][inter]]smear][pde][dt]
	double errorsDT[3][2][2][5][8]; // [mat][inter][smear][pde][dt]
	int npes[10] = {1,2,3,4,5,6,7,8,9,10};
//	int pdes[5] = {10,30,50,70,100};
	char pdeChar[5];

	TCanvas *c1 = new TCanvas("c1","multipads",900,700);

	for(int mat=0; mat<2;mat++){
		if (mat==0){
			int pdes[5] = {10,15,20,100};
		}else{
			int pdes[5] = {30,50,70,100};
		}

		for(int inter=1; inter<2;inter++){
			for(int smear=0; smear<1;smear++){
				for(int pde=0; pde<4;pde++){
					sprintf(pdeChar, "%.2lf", pdes[pde]/100.0);
					if(pdes[pde]==100){
						sprintf(pdeChar, "0%.2lf", pdes[pde]/100.0);
					}
					std::string fileName = filepath + material[mat] + interaction[inter] + std::string("_QE_") + std::string(pdeChar) + std::string("_SPTR_80_ASIC_30_DT300_histos.root"); std::string(Form("%d", 1));
					std::cout << fileName << std::endl;
					TFile *fIn = new TFile(fileName.c_str(), "read");

					std::string baseName = "AVG.";
					std::string smearName = "";
					if(smear==1){
						smearName = "Smear";
					}

					//NPE
					for(int npe=0;npe<10;npe++){
						std::string histName = baseName + smearName + std::string("DTOF2") + std::string("N") + std::string(Form("%d", npes[npe]));
						std::cout << histName << std::endl;

						TH1F *h1 = (TH1F*) fIn->Get(histName.c_str());
						TF1* gauF1 = new TF1("gauF1","gaus",-200,200);
						h1->Fit("gauF1","","e",-200,200);
						h1->Draw();

						std::string path = "/home/jmbenlloch/next/petalo/work/histo/phys/5ps/jitter_avg/npe/";
						std::string histo = path + material[mat] + interaction[inter] + std::string("_QE_") + std::string(pdeChar) + std::string("_") + histName + std::string(".png");
						std::cout << histo << std::endl;

						c1->Print(histo.c_str());

						// FWHM
						sigmasNPE[mat][inter][smear][pde][npe] = 2.35 * h1->GetFunction("gauF1")->GetParameter(2);
						errorsNPE[mat][inter][smear][pde][npe] = 2.35 * h1->GetFunction("gauF1")->GetParError(2);
					}

					fIn->Close();
				}
			}
		}
	}
	c1->Close();

	double npesD[10] = {1,2,3,4,5,6,7,8,9,10};
	//EColor colors[5] = {kRed,kBlue,kGreen+3,kCyan};
	EColor colors[5] = {kRed,kBlack,kGreen+3,kBlue};

	for(int mat=0; mat<2;mat++){
		if (mat==0){
			int pdes[5] = {10,15,20,100};
		}else{
			int pdes[5] = {30,50,70,100};
		}

		for(int inter=1; inter<2;inter++){
			for(int smear=0; smear<1;smear++){
				std::string smearName = "";
				if(smear==1){
					smearName = "_smear";
				}
				//NPE
				//TCanvas *c2 = new TCanvas("c2","multipads",900,700);
				TCanvas *c2 = tcanvset("c");

				//TLegend *leg = new TLegend(0.7, 0.7, 0.9, 0.9);
				TLegend *leg = tlegset();
				leg->SetFillColor(0);

				for(int pde=0; pde<4;pde++){
					TGraphErrors *gLxe = new TGraphErrors(10, npesD, sigmasNPE[mat][inter][smear][pde], 0, errorsNPE[mat][inter][smear][pde]);
					gLxe->SetLineColor(colors[pde]);
					gLxe->SetLineWidth(2);
					gLxe->SetLineStyle(4-pde);
					grerrplot(*gLxe);

					leg->AddEntry(gLxe,Form("PDE %d%%", pdes[pde]), "lp");
					std::cout << "pde: " << pde << std::endl;

					if(pde==0){
						gLxe->SetTitle("");
						gLxe->GetXaxis()->SetTitle("Number of photoelectrons");
						gLxe->GetXaxis()->SetLimits(0,10);
						gLxe->GetYaxis()->SetTitle("CRT (ps)");
						gLxe->SetMinimum(0.);
						gLxe->SetMaximum(250.);
						gLxe->Draw();

					}else{
						gLxe->Draw("same");
					}
					if(pde==3){
						leg->Draw("same");
					}
				}
				std::string path = "/home/jmbenlloch/next/petalo/PESOA/PETALOS/root/paper/plots/";
				std::string histo = path + material[mat] + interaction[inter] + std::string("_avg_npe") + smearName + std::string(".png");

				c2->Print(histo.c_str());
				c2->Close();

			}
		}
	}
}
Exemplo n.º 7
0
void minuitFit()
{
  
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);

  Bool_t makePDF = checkMakePDF();
  
  char name[1000];
  sprintf(name,"/Users/zach/Research/pythia/ptHatTemplate/outputs/currentB.root");
  TFile *fB = new TFile(name,"READ");
  sprintf(name,"/Users/zach/Research/pythia/ptHatTemplate/outputs/currentC.root");
  TFile *fC = new TFile(name,"READ");
  sprintf(name,"/Users/zach/Research/rootFiles/run12NPEhPhi/currentData.root");
  TFile *fD = new TFile(name,"READ");
  if (fB->IsOpen()==kFALSE || fC->IsOpen()==kFALSE)
    { std::cout << "!!!!!! Either B,C, or Data File not found !!!!!!" << std::endl
		<< "Looking for currentB.root, currentC.root, and currentData.root" << std::endl;
      exit(1); }
  
  // Set constants and projection bins (from header file anaConst, analysis constants)
  
  Float_t lowpt[numPtBins],highpt[numPtBins];
  for(Int_t c=0; c< numPtBins; c++){
    lowpt[c] = anaConst::lpt[c];
    highpt[c] = anaConst::hpt[c];
  }
  Float_t hptCut=anaConst::hptCut;
  Double_t p00[numPtBins],p01[numPtBins],p20[numPtBins],p21[numPtBins];
  Double_t e00[numPtBins],e01[numPtBins],e20[numPtBins],e21[numPtBins];
  Double_t pC0[numPtBins],pC1[numPtBins],eC0[numPtBins],eC1[numPtBins];
  Double_t Rb0[numPtBins],Rb2[numPtBins],RbC[numPtBins],pT[numPtBins];
  Double_t eb0[numPtBins],eb2[numPtBins],ebC[numPtBins],dx[numPtBins];
  Double_t ptOFF1[numPtBins],ptOFF2[numPtBins];
  Int_t plotCount0 = 0, plotCount2 = 0, plotCount = 0;
  
  // Make Canvases
  TCanvas* deltaPhi  = new TCanvas("deltaPhi","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* deltaPhi2  = new TCanvas("deltaPhi2","Pythia Delta Phi",150,0,1150,1000);
  TCanvas* fitResult0 = new TCanvas("fitResult0","RB Extraction HT0",150,0,1150,1000);
  TCanvas* fitResult2 = new TCanvas("fitResult2","RB Extraction HT2",150,0,1150,1000);
  TCanvas* fitResultC = new TCanvas("fitResultC","RB Extraction Combined Trigs",150,0,1150,1000);
  deltaPhi  ->Divide(3,3);
  deltaPhi2 ->Divide(3,3);
  fitResult0->Divide(3,4);
  fitResult2->Divide(3,4);
  fitResultC->Divide(3,4);

  // Get and Draw histos
  TPaveText* lbl[numPtBins];
  TPaveText* stat[3][numPtBins];
  char statLabel[100];
  char textLabel[100];
  Int_t plotbin;
  Float_t norm0,norm2,normB,normC;

  // Get ptbin independent hists
  histoNorms = (TH1F*)fD->Get("histoNorms");
  bPtNorms   = (TH1F*)fB->Get("ptNorm");
  cPtNorms   = (TH1F*)fC->Get("ptNorm");
  
  for(Int_t ptbin=0; ptbin<numPtBins; ptbin++)
    {
      norm0 = histoNorms->GetBinContent(histoNorms->GetBin(1,ptbin+1));
      norm2 = histoNorms->GetBinContent(histoNorms->GetBin(3,ptbin+1));
      normB = bPtNorms->GetBinContent(bPtNorms->GetBin(ptbin+1));
      normC = cPtNorms->GetBinContent(cPtNorms->GetBin(ptbin+1));

      if(norm0 == 0)
	{
	  cout << ptbin << " For this bin, some norm0 = 0" << endl;
	  continue;
	}
      if( norm2 == 0 )
	{
	  cout << ptbin << " For this bin, some norm2 = 0" << endl;
	  continue;
	}
      if( normB == 0 )
	{
	  cout << ptbin << " For this bin, some normB = 0" << endl;
	  continue;
	}
      if(normC == 0)
	{
	  cout << ptbin << " For this bin, some normC = 0" << endl;
	  continue;
	}
      plotbin = ptbin;
      // Init necessary plotting tools
      lbl[ptbin] = new TPaveText(.15,.15,.35,.23,Form("NB NDC%i",ptbin));
      sprintf(textLabel,"%.1f < P_{T,e} < %.1f",lowpt[ptbin],highpt[ptbin]);
      lbl[ptbin]->AddText(textLabel);
      lbl[ptbin]->SetFillColor(kWhite);

      projB[ptbin] = (TH1D*)fB->Get(Form("delPhi_%i",ptbin));
      projC[ptbin] = (TH1D*)fC->Get(Form("delPhi_%i",ptbin));
      projData0[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_0_%i",ptbin));
      projData2[ptbin]= (TH1D*)fD->Get(Form("NPEhDelPhi_2_%i",ptbin));
      // Do any rebinning
      Int_t RB = 1;
      projB[ptbin]->Rebin(RB);
      projC[ptbin]->Rebin(RB);
      projData0[ptbin]->Rebin(RB);
      projData2[ptbin]->Rebin(RB);

      // Clone to make plots without effecting fits
      plotD0[ptbin] = (TH1D*) projData0[ptbin]->Clone();
      plotD2[ptbin] = (TH1D*) projData2[ptbin]->Clone();
      plotB[ptbin]  = (TH1D*) projB[ptbin]->Clone();
      plotC[ptbin]  = (TH1D*) projC[ptbin]->Clone();

      // Set features that are the same in plots
      projData0[ptbin]->SetLineColor(kBlue);
      projData2[ptbin]->SetLineColor(kGreen+3);
      projB[ptbin]->SetLineColor(kRed);
      projC[ptbin]->SetLineColor(kBlack);
      projC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);
      plotD0[ptbin]->SetLineColor(kBlue);
      plotD2[ptbin]->SetLineColor(kGreen+3);
      plotD0[ptbin]->SetMarkerStyle(20);
      plotD0[ptbin]->SetMarkerColor(kBlue);
      plotD0[ptbin]->SetMarkerSize(0.4);
      plotB[ptbin]->SetLineColor(kRed);
      plotC[ptbin]->SetLineColor(kBlack);
      plotC[ptbin]->GetXaxis()->SetRangeUser(-3.5,3.5);

      combData[ptbin] = (TH1D*) projData0[ptbin]->Clone();
      combData[ptbin] -> Add(projData2[ptbin]);
      combData[ptbin]->SetLineColor(kBlue);
      combData[ptbin]->SetMarkerStyle(20);
      combData[ptbin]->SetMarkerColor(kBlue);
      combData[ptbin]->SetMarkerSize(0.4);
      combData[ptbin]->SetTitle("");
      
      // Normalize
      projB[ptbin]     -> Scale(1/normB);
      projC[ptbin]     -> Scale(1/normC);
      projData0[ptbin] -> Scale(1/norm0);
      projData2[ptbin] -> Scale(1/norm2);
      plotD0[ptbin]    -> Scale(1/norm0);
      plotD2[ptbin]    -> Scale(1/norm2);
      plotB[ptbin]     -> Scale(1/(normB));
      plotC[ptbin]     -> Scale(1/(normC));
      combData[ptbin]  -> Scale(1/(norm0+norm2));
    /*projB[ptbin]     -> Scale(projData0[ptbin]->GetBinContent(70)/projB[ptbin]->GetBinContent(70));
      projC[ptbin]     -> Scale(projData0[ptbin]->GetBinContent(70)/projC[ptbin]->GetBinContent(70));
      plotB[ptbin]     -> Scale(projData0[ptbin]->GetBinContent(70)/plotB[ptbin]->GetBinContent(70));
      plotC[ptbin]     -> Scale(projData0[ptbin]->GetBinContent(70)/plotC[ptbin]->GetBinContent(70));
      */
      
      // Draw Templates on own plots
      if(ptbin+1 <= 9) deltaPhi->cd(plotbin+1);
      if(ptbin+1 > 9) deltaPhi2->cd(ptbin-8);
      plotC[ptbin]->GetYaxis()->SetRangeUser(-.1,0.5);
      plotC[ptbin]  -> Draw("hist");
      plotB[ptbin]  -> Draw("same hist");
      plotD0[ptbin] -> Draw("same");
      plotD2[ptbin] -> Draw("same");
      lbl[ptbin]    -> Draw("same");

      TLegend* leg = new TLegend(0.65,0.6,0.85,0.85);
      leg->AddEntry(projB[ptbin],"b#bar{b}->NPE","lpe");
      leg->AddEntry(projC[ptbin],"c#bar{c}->NPE","lpe");
      leg->AddEntry(projData0[ptbin],"HT0","lpe");
      leg->AddEntry(projData2[ptbin],"HT2","lpe");
      leg->Draw();

      /////////////////////
      // Do the actual fits
      /////////////////////

      cout << "!!!!!!! HT0 ptbin: " << highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
      currentPtBin = ptbin;
      double arglist[10];int ierflg=0;
      TMinuit *gMinuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params
      gMinuit->SetMaxIterations(50000);
      gMinuit->SetFCN(chi2_0);
      arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma
      gMinuit->mnexcm("SET ERR",arglist,1,ierflg);

      //starting values
      double vstart[2]={0.3,1}; //frac
      double step[2]={0.01,0.01}; //starting step
      gMinuit->mnparm(0,"BtoNPE frac",vstart[0],step[0],0.000,2,ierflg);
      gMinuit->mnparm(1,"Scale Factor",vstart[1],step[1],0.000,2,ierflg);
      //simple scan to get better start values
      gMinuit->mnexcm("SCAN",arglist,0,ierflg); 
      cout<<"done with first scan!"<<endl;

      //minimization
      arglist[0]=5000; //maxcalls
      arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before
      gMinuit->mnexcm("MINIMIZE",arglist,2,ierflg);

      cout<< "done with fit! Error Flag: " << ierflg << endl;

       //fit results
      double dum1,dum2;
      TString *str0 = new TString("BtoNPE frac");
      TString *str1 = new TString("Scale Factor");
      gMinuit->mnpout(0,*str0,p01[ptbin],e01[ptbin],dum1,dum2,ierflg);
      gMinuit->mnpout(1,*str1,p00[ptbin],e00[ptbin],dum1,dum2,ierflg);

      cout << endl << endl << "HT0 PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl
	   << "rB: " << p01[ptbin] << " rC: " << p00[ptbin] << endl
	   << "erB: " << e01[ptbin] << " erC: " << e00[ptbin] << endl << endl;
      
      //Print results
      double amin,edm,errdef;
      int nvpar,nparx,icstat;
      gMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
      gMinuit->mnprin(4,amin);
      
      // assign to plotting variables
      if(highpt[ptbin] < 6)
	{
	  pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
	  dx[plotCount0] = 0.;
	  ptOFF1[plotCount0] = pT[ptbin];
	  Rb0[plotCount0] = p01[ptbin];///(p01[ptbin]+p00[ptbin]);
	  eb0[plotCount0] = e01[ptbin];
	  plotCount0++;
	}
    
      // Plot results
      fitResult0->cd(ptbin+1);
      TH1D* dClone = (TH1D*) projData0[ptbin]->Clone();
      TH1D* cClone = (TH1D*) projC[ptbin]->Clone();
      TH1D* bClone = (TH1D*) projB[ptbin]->Clone();
      stat[0][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
      sprintf(statLabel,"Chi2/NDF: %.2f/%.0f",curChi2,curNDF);
      stat[0][ptbin]->InsertText(statLabel);
      stat[0][ptbin]->SetFillColor(kWhite);
      cClone->Scale((1.-p01[ptbin])*p00[ptbin]); bClone->Scale(p00[ptbin]*p01[ptbin]); // scale by contribution param
      cClone->Add(bClone);
      //cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
      dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
      dClone->GetYaxis()->SetRangeUser(-0.1,0.4);
      dClone->Draw();
      cClone->Draw("same");
      stat[0][ptbin]->Draw("same");
      lbl[ptbin]->Draw("same");
            

      cout << "!!!!!!! HT2 ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
      fitResult2->cd(ptbin+1);
      currentPtBin = ptbin;
      TMinuit *g2Minuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params
      g2Minuit->SetMaxIterations(50000);
      g2Minuit->SetFCN(chi2_2);
      arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma
      g2Minuit->mnexcm("SET ERR",arglist,1,ierflg);

      //starting values
      double vstart2[2]={0.3,1}; //frac
      double step2[2]={0.01,0.01}; //starting step
      g2Minuit->mnparm(0,"BtoNPE frac",vstart2[0],step2[0],0.000,2,ierflg);
      g2Minuit->mnparm(1,"Scale Factor",vstart2[1],step2[1],0.000,2,ierflg);
      //simple scan to get better start values
      g2Minuit->mnexcm("SCAN",arglist,0,ierflg); 
      cout<<"done with first scan!"<<endl;

      //minimization
      arglist[0]=5000; //maxcalls
      arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before
      g2Minuit->mnexcm("MINIMIZE",arglist,2,ierflg);

      cout<< "done with fit! Error Flag: " << ierflg << endl;

       //fit results
      TString *str2 = new TString("BtoNPE frac");
      TString *str3 = new TString("Scale Factor");
      g2Minuit->mnpout(0,*str2,p21[ptbin],e21[ptbin],dum1,dum2,ierflg);
      g2Minuit->mnpout(1,*str3,p20[ptbin],e20[ptbin],dum1,dum2,ierflg);

      cout << endl << endl << "HT2 PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl
	   << "rB: " << p21[ptbin] << " rC: " << p20[ptbin] << endl
	   << "erB: " << e21[ptbin] << " erC: " << e20[ptbin] << endl << endl;
      
      //Print results
      g2Minuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
      g2Minuit->mnprin(4,amin);
      
      // assign to plotting variables
      if(highpt[ptbin] > 3.6)
	{
	  pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
	  ptOFF2[plotCount2] = pT[ptbin];
	  Rb2[plotCount2] = p21[ptbin];///(p21[ptbin]+p20[ptbin]);
	  eb2[plotCount2] = e21[ptbin];
	  plotCount2++;
	}

      // Plot results
      fitResult2->cd(ptbin+1);
      dClone = (TH1D*) projData2[ptbin]->Clone();
      cClone = (TH1D*) projC[ptbin]->Clone();
      bClone = (TH1D*) projB[ptbin]->Clone();
      stat[2][ptbin] = new TPaveText(.4,.75,.85,.85,Form("NB NDC%i",ptbin));
      sprintf(statLabel,"Chi2/NDF: %.2f/%.2f",curChi2,curNDF);
      stat[2][ptbin]->InsertText(statLabel);
      stat[2][ptbin]->SetFillColor(kWhite);
      cClone->Scale((1.-p21[ptbin])*p20[ptbin]); bClone->Scale(p20[ptbin]*p21[ptbin]); // scale by contribution param
      cClone->Add(bClone);
      // cClone->Scale(dClone->GetMaximum()/cClone->GetMaximum());
      dClone->GetXaxis()->SetRangeUser(anaConst::lowPhi,anaConst::highPhi);
      dClone->GetYaxis()->SetRangeUser(-0.1,0.4);
      dClone->Draw();
      cClone->Draw("same");
      stat[2][ptbin]->Draw("same");
      lbl[ptbin]->Draw("same");

      cout << "!!!!!!! HT0&2 ptbin: " <<  highpt[ptbin] << "-" << lowpt[ptbin] <<" !!!!!!!"<< endl;
      fitResultC->cd(ptbin+1);
      currentPtBin = ptbin;
      TMinuit *gCMinuit=new TMinuit(2); //initialize TMinuit with a maximum of 3 params
      gCMinuit->SetMaxIterations(50000);
      gCMinuit->SetFCN(chi2_C);
      arglist[0]=1; //error definition: chi^2 change by 1 to get 1 sigma
      gCMinuit->mnexcm("SET ERR",arglist,1,ierflg);

      //starting values
      double vstartC[2]={0.3,1}; //frac
      double stepC[2]={0.01,0.01}; //starting step
      gCMinuit->mnparm(0,"BtoNPE frac",vstartC[0],stepC[0],0.000,2,ierflg);
      gCMinuit->mnparm(1,"Scale Factor",vstartC[1],stepC[1],0.000,2,ierflg);
      //simple scan to get better start values
      gCMinuit->mnexcm("SCAN",arglist,0,ierflg); 
      cout<<"done with first scan!"<<endl;

      //minimization
      arglist[0]=5000; //maxcalls
      arglist[1]=0.5; // tolerance = 0.001*[this value]*[error def] //5.0 before
      gCMinuit->mnexcm("MINIMIZE",arglist,2,ierflg);

      cout<< "done with fit! Error Flag: " << ierflg << endl;

       //fit results
      TString *str4 = new TString("BtoNPE frac");
      TString *str5 = new TString("Scale Factor");
      gCMinuit->mnpout(0,*str4,pC1[ptbin],eC1[ptbin],dum1,dum2,ierflg);
      gCMinuit->mnpout(1,*str5,pC0[ptbin],eC0[ptbin],dum1,dum2,ierflg);

      cout << endl << endl << "HTC PT Bin: " << lowpt[ptbin] << "-" << highpt[ptbin] << endl
	   << "rB: " << pC1[ptbin] << " rC: " << pC0[ptbin] << endl
	   << "erB: " << eC1[ptbin] << " erC: " << eC0[ptbin] << endl << endl;

      //Print results
      gCMinuit->mnstat(amin,edm,errdef,nvpar,nparx,icstat);
      gCMinuit->mnprin(4,amin);
      
      // assign to plotting variables
      pT[ptbin] = (lowpt[ptbin]+highpt[ptbin])/2.;
      RbC[plotCount] = pC1[ptbin];///(p21[ptbin]+p20[ptbin]);
      ebC[plotCount] = eC1[ptbin];
      plotCount++;
    }

  // Get FONLL Calc
  Int_t l=0;
  char line[1000];
  Float_t xF[100],yF[100],minF[100],maxF[100];
  ifstream fp("/Users/zach/Research/pythia/ptHatTemplate/FONLL.txt",ios::in);
  while (!fp.eof()){
    fp.getline(line,1000);
    sscanf(line,"%f %f %f %f",&xF[l],&yF[l],&minF[l],&maxF[l]);
    //  printf("L: %f %f\n",xF[l],yF[l]);
    l++;
  }
  fp.close();

  // Get Previous Analysis 
  Int_t p=0;
  Float_t xP[100],yP[100],dyP[100];
  ifstream fp1("/Users/zach/Research/pythia/ptHatTemplate/run5_6.txt",ios::in);
  while (!fp1.eof()){
    fp1.getline(line,1000);
    sscanf(line,"%f %f %f",&xP[p],&yP[p],&dyP[p]);
    // printf("L: %f %f\n",xF[l],yF[l]);
    p++;
  }
  fp1.close();

  //cout << "at bottom contrib plot" << endl;
  TCanvas* c1 = new TCanvas("c1","Bottom Contribution",150,0,1150,1000);
  TGraphErrors *gr0     = new TGraphErrors(plotCount0-1,ptOFF1,Rb0,dx,eb0);
  TGraphErrors *gr2     = new TGraphErrors(plotCount2-1,ptOFF2,Rb2,dx,eb2);
  TGraphErrors *grC     = new TGraphErrors(plotCount-1,pT,RbC,dx,ebC);
  TGraphErrors *grF     = new TGraphErrors(l-1,xF,yF);
  TGraphErrors *grFmax  = new TGraphErrors(l-1,xF,maxF);
  TGraphErrors *grFmin  = new TGraphErrors(l-1,xF,minF);
  TGraphErrors *grP     = new TGraphErrors(p-1,xP,yP,0,dyP);

  c1->cd(1);

  gr0->SetTitle("Bottom Contribution");
  gr0->GetXaxis()->SetTitle("p_{T,e}");
  gr0->GetYaxis()->SetTitle("#frac{r_{B}}{(r_{B}+r_{C})}");
  gr0->SetMarkerStyle(20);
  gr0->SetMarkerSize(1);
  gr0->SetLineColor(kBlue);
  gr0->SetMarkerColor(kBlue);
  gr2->SetMarkerStyle(22);
  gr2->SetMarkerSize(1);
  gr2->SetLineColor(kRed);
  gr2->SetMarkerColor(kRed);
  grC->SetMarkerStyle(21);
  grC->SetMarkerSize(1);
  grC->SetLineColor(kRed);
  grC->SetMarkerColor(kRed);
  gr0->GetXaxis()->SetLimits(1,14);
  gr0->GetYaxis()->SetRangeUser(0,1);
  grF->SetLineStyle(1);
  grFmax->SetLineStyle(2);
  grFmin->SetLineStyle(2);
  grP->SetMarkerStyle(33);
  grP->SetMarkerColor(kBlack);
  
  
  gr0->Draw("AP");
  // grC->Draw("same P");
  gr2->Draw("same P");
  grF->Draw("same");
  grFmax->Draw("same");
  grFmin->Draw("same");
  grP->Draw("same P");

  TLegend* leg2 = new TLegend(0.15,0.68,0.4,0.85);
  leg2->AddEntry(gr0,"High Tower 0 Trigs","pe");
  leg2->AddEntry(gr2,"High Tower 2 Trigs","pe");
  // leg2->AddEntry(grC,"Combined Trigs","pe");
  leg2->AddEntry(grF,"FONLL (Uncertainty: Scale Only)","l");
  leg2->AddEntry(grP,"Run 5/6 Analysis (Stat Uncertainty)","pe");
  leg2->Draw("same");
  
   // Make PDF with output canvases
  if(makePDF)
    {
      //Set front page
      TCanvas* fp = new TCanvas("fp","Front Page",100,0,1000,900);
      fp->cd();
      TBox *bLabel = new TBox(0.01, 0.88, 0.99, 0.99);
      bLabel->SetFillColor(38);
      bLabel->Draw();
      TLatex tl;
      tl.SetNDC();
      tl.SetTextColor(kWhite);
      tl.SetTextSize(0.033);
      char tlName[100];
      char tlName2[100];
      
      TString titlename = FileName;
      int found = titlename.Last('/');
      if(found >= 0){
	titlename.Replace(0, found+1, "");
      } 
      sprintf(tlName, "RUN 12 NPE-h   #Delta#phi Correlations");
      tl.SetTextSize(0.05);
      tl.SetTextColor(kWhite);
      tl.DrawLatex(0.05, 0.92,tlName);
      
      TBox *bFoot = new TBox(0.01, 0.01, 0.99, 0.12);
      bFoot->SetFillColor(38);
      bFoot->Draw();
      tl.SetTextColor(kWhite);
      tl.SetTextSize(0.05);
      tl.DrawLatex(0.05, 0.05, (new TDatime())->AsString());
      tl.SetTextColor(kBlack);
      tl.SetTextSize(0.03);
      tl.DrawLatex(0.1, 0.14, titlename);
      sprintf(tlName,"TEST");
      tl.DrawLatex(0.1, 0.8,tlName);
      
      // Place canvases in order
      TCanvas* temp = new TCanvas();
      sprintf(name, "FFOutput/%s.pdf[", FileName);
      temp->Print(name);
      sprintf(name, "FFOutput/%s.pdf", FileName);

      temp = deltaPhi; 
      temp->Print(name);
      temp = fitResult0;
      temp->Print(name);
      temp = fitResult2;
      temp->Print(name);
      temp = fitResultC;
      temp->Print(name);
      temp = c1;
      temp->Print(name);
      
      sprintf(name, "FFOutput/%s.pdf]", FileName);
      temp->Print(name);
    }
}
void fit_fy_vs_y_from_all_angles(TString tgt_pos){

  // histo parameters
  gStyle->SetTitleYOffset(1.2);
  gStyle->SetTitleXOffset(1.0);
  gStyle->SetLabelSize(0.06,"x");
  gStyle->SetLabelSize(0.06,"y");
  gStyle->SetTitleSize(0.06,"x");
  gStyle->SetTitleSize(0.06,"y");
  gStyle->SetTitleX(0.4);
  gStyle->SetTitleW(0.6);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleFillColor(0);
  gStyle->SetTitleFontSize(0.09);
  gStyle->SetStripDecimals(0);

 
  // Fit and stat parameters
  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  gStyle->SetStatFont(132);
  gStyle->SetStatY(0.99);
  gStyle->SetStatX(0.99);
  gStyle->SetStatW(0.20);
  gStyle->SetStatH(0.20);

  //Pad parameters
  gStyle->SetPadColor(0); 
  gStyle->SetPadBorderMode(0);
  gStyle->SetFrameBorderMode(0);
  gStyle->SetPadBorderSize(0);
  gStyle->SetPadTopMargin(0.18);
  gStyle->SetPadBottomMargin(0.16);
  gStyle->SetPadRightMargin(0.05);
  gStyle->SetPadLeftMargin(0.15);
  
  //set target flag
  if(tgt_pos.Contains("us")) 
    upstream = true;
  else
    upstream = false;

  // Open a file to output the fy values
  fp = fopen(Form("%s_al_fy_for_all_angles.txt",tgt_pos.Data()), "w+");
  // fprintf(fp, This is testing for fprintf...\n");
  // fputs("This is testing for fputs...\n", fp);
  
  //Delete all the objects stored in the current directory memmory
  gDirectory->Delete("*");
  
  std::vector<std::string> files;
  Double_t angles[6] = {18,22,26,32,40,50};

  // vectors to store the fy and y from individual angles and their errors
  TVectorD *fyv = new TVectorD();
  TVectorD *yv= new TVectorD();
  TVectorD *yev= new TVectorD();
  TVectorD *fyev= new TVectorD();
  
  // vectors to store the fy_data/fy_model ratio and its error
  TVectorD *ratio = new TVectorD();
  TVectorD *eratio = new TVectorD();

  // vectors to store all the data together
  TVectorD *tfyv = new TVectorD();
  TVectorD *tyv= new TVectorD();
  TVectorD *tyev= new TVectorD();
  TVectorD *tfyev= new TVectorD();
  

 // Open canvas to draw the comparision between Fy vs Y using sig_exp and sig_exp corrected for sig_di// s
  TCanvas * c = new TCanvas("c", "",0,0,1000,1000);  
  c->Draw();
  c->Divide(1,2);
  
  Int_t pp = 0;

  // select files for a target with the given angle and get fy and y
  for(int i=0;i<6;i++){

    std::cout<<"reading angle = "<<angles[i]<<std::endl;
    files =  get_files(angles[i], tgt_pos);
    if(nodata){
      //skip. Do nothing
      nodata = false;
    }
    else{

      // get the fy and y from data with their errors
      get_fy_y(files, fyv, yv, yev, fyev);
      for(int k =0;k<fyv->GetNoElements();k++){


	// Fill the full arrays
	(*tfyv).ResizeTo(pp+1);
	(*tfyev).ResizeTo(pp+1);
	(*tyv).ResizeTo(pp+1);
	(*tyev).ResizeTo(pp+1);

	(*tfyv).operator()(pp) = (*fyv)[k];
	(*tfyev).operator()(pp) = (*fyev)[k];
	(*tyv).operator()(pp) = (*yv)[k];
	(*tyev).operator()(pp) = (*yev)[k];

	// Fill the full ratio arrays
	(*ratio).ResizeTo(pp+1);
	(*eratio).ResizeTo(pp+1);

	(*ratio).operator()(pp)=((*fyv)[k]/al_fy_from_pass0((*yv)[k]));
	//std::cout<<ratio(k)<<std::endl;
	(*eratio).operator()(pp)=((*fyev)[k]/al_fy_from_pass0((*yv)[k]));
	std::cout<<" @ y = "<<(*yv)[k]<<" (ratio, eratio) = "<<"("<<(*ratio)[pp]<<","<<(*eratio)[pp]<<")"<<std::endl;


	pp++;

      }
    }
  }  
  


  TLegend * leg= new TLegend(0.2,0.6,0.4,0.8);

  myfunc();

  TGraphErrors *gp = new TGraphErrors(*tyv,*tfyv,*tyev,*tfyev);
  c->cd(1);
  gPad->SetGridy();
  gPad->SetGridx();
  gp->Draw("AEP");
  gp->SetMarkerStyle(4);
  gp->SetMarkerColor(kBlue);
  gp->SetLineStyle(1);
  gp->SetLineColor(kBlue);
  gp->Fit("myfunc","EBMR");
  TF1 *tfit = gp->GetFunction("myfunc");
  tfit->SetLineColor(kRed);


  gp->GetYaxis()->SetRangeUser(0,4);
  gp->GetXaxis()->SetRangeUser(-1.0,0.2);
  gp->GetXaxis()->SetTitle("y(GeV/c)");
  gp->GetYaxis()->SetTitle("F(y)(GeV/c)^{-1}");
  gp->SetTitle("");
  leg->AddEntry(gp,"data","p");
  leg->AddEntry(tfit,"F(y) from pass1","l");

  
  // From model:
  myfunc();
  TF1 *ft = new TF1("ft"," al_fy_from_pass0(x)",-1.0,0.1); 
  ft->SetLineColor(kBlack);
  ft->SetLineStyle(1);
 
  // draw the model
  ft->Draw("same");
  leg->AddEntry(ft,"F(y) model","l");
  leg->Draw();

  // Draw in log scale
  c->cd(2);
  gPad->SetGridy();
  gPad->SetGridx();
  gp->Draw("AEP");
  ft->Draw("same");
  gPad->Modified();
  gPad->Update();
  gPad->SetLogy();
  gp->GetYaxis()->SetRangeUser(1e-6,10);
  gp->GetXaxis()->SetRangeUser(-1.0,0.2);
  gp->SetTitle(Form("%s Al, Y scaling with DIS subtraction;y(GeV/c);F(y,q)(GeV/c)^{-1}",tgt_pos.Data()));
  leg->Draw();

 
  TCanvas * c1 = new TCanvas("c1", "",0,0,700,500);  
  c1->Draw();
  gPad->SetGridy();
  gPad->SetGridx();
  // Fill the ratio graphs
  TGraphErrors * grr = new TGraphErrors(*tyv,*ratio,*tyev,*eratio); 
  grr->SetMarkerStyle(2);
  grr->SetMarkerColor(2);
  grr->SetLineStyle(1);
  grr->SetLineColor(2);
  grr->Draw("AEP");
  //grr->GetYaxis()->SetRangeUser(-100);
  grr->GetXaxis()->SetRangeUser(-1.0,0.2);
  grr->GetXaxis()->SetTitle("y(GeV/c)");
  grr->GetYaxis()->SetTitle("data_{F(y)}/model_{F(y)}");


 //close the text file
  fclose(fp);

  // // // c->Print(Form("xsec_rad_exp_mod_ratio_x_geq_%2.1f_and_x_leq_%2.1f_%s_dummy_%s_%s.png",xlow,xup,tgt_pos.Data(),angle.Data(),fit.Data()));
 
}
Exemplo n.º 9
0
void Significance_auto(){

 //  prepare the weights for 4 background samples

const int N_background_points = 4;
double background_cross_section[N_background_points] = { 139.4 , 42.75 , 5.497 , 2.21 };
//double background_number_of_events[N_background_points] = { 2377497 , 955972 , 1048047 , 987977 };
double background_number_of_events[N_background_points] =   { 2327916 , 955972 , 1038512 , 974623 };
double background_weights[N_background_points];

for(int i=0;i<N_background_points;i++) 
{ background_weights[i] = background_cross_section[i] / background_number_of_events[i];  
}


 // prepare all thing used in below

  const int N_mass_points = 13;
  int Zprime_mass[N_mass_points]={600,800,1000,1200,1400,1600,1800,2000,2500,3000,3500,4000,4500};
  TString path = "/Users/index0192/13_TeV_Task/Zprime_Electron_channel/plot_SubLedaing_ele_pt_optimize/";

  TCanvas *c1[N_mass_points];
  TString c1_name;

  TString leg_name1 = "Significance";
  TString leg_name2 = "Signal efficiency";
  TString leg_name3 = "Background efficiency";


  //



  // now calulate the significance

  // loop in k, which mass point you want to know its Significance

  for(int k=0 ; k<N_mass_points ; k++){
if( k!= 2 && k!= 7 && k!= 9)continue;
if( k!= 7 )continue;
//continue;

	// c1 name	
  	cout<< "Zprime_mass[k]: " << Zprime_mass[k] << endl;
	c1_name  = Form("Significance_and_efficiency_for_Zprme_M_%d", Zprime_mass[k] );
        c1[k] = new TCanvas(c1_name,"Significance in different cut value",200,10,700,500);

	// open the signal ROOT file
  	TString signal_shape_file = Form("signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);
  	signal_shape_file = path + signal_shape_file ;
  	TFile *f_signal = new TFile (signal_shape_file);

	// open the signal histogram
//  	TString histo_name= "h_ele_pT" ;
        TString histo_name= "h_abs_dEta_ZH" ;
  	TH1D *h_2nd_ele_pT;
  	h_2nd_ele_pT = (TH1D*) f_signal -> Get(histo_name);

        // try to determine the highest cut value
  	int max_non_zero_bin = -1;
  	for( int m=1 ; m<= h_2nd_ele_pT->GetNbinsX() ;m++ ){
       		double bin_content = h_2nd_ele_pT->GetBinContent(m);
       		if( bin_content != 0 ){ max_non_zero_bin = m; }
  	}
	cout<<"max_non_zero_bin: "<< max_non_zero_bin <<endl;

        int min_non_zero_bin = -1;
        for( int m=1 ; m<= h_2nd_ele_pT->GetNbinsX() ;m++ ){
                double bin_content = h_2nd_ele_pT->GetBinContent(m);
                if( bin_content != 0 ){ min_non_zero_bin = m; break; }
        }
        cout<<"min_non_zero_bin: "<< min_non_zero_bin <<endl;

        double bin_width = h_2nd_ele_pT ->GetBinWidth(1);

//	double scan_width = 5; // how many unit you scan your cut points, default I use 5 GeV
        double scan_width = 0.05;
//	scan_width = 100;


	// decide the highest bin that can be divided by the scan-width	
 	int multipier = (max_non_zero_bin - min_non_zero_bin) * bin_width / scan_width;
        cout<<"multipier: "<< multipier <<endl;
  	double highest_cut =  multipier * scan_width;
  	cout<< "highest_cut: " <<  highest_cut <<endl;

        // input the lowest cut value
//  	int lowest_cut = 35;
//        int lowest_cut = 10;
//        int lowest_cut = 115;
        double lowest_cut = 0;

	// save the cut point value for every 5 Gev BTW highest and lowest value 
  	int n_cut_points = (highest_cut - lowest_cut)/scan_width + 1;
  	const int N_cut_points = n_cut_points;
  	cout<< "N_cut_points: " << N_cut_points << endl<<endl;
  	double cut_points[N_cut_points];
 
  	for(int i=0;i<N_cut_points;i++){
  		cut_points[i] = lowest_cut + scan_width*i;
     	}

  	// TGraph for Significance  
  	const int Nbins = N_cut_points ;
  	double vx[Nbins] ;

  	double vy_significance[Nbins] ;
        double vy_significance_errx[Nbins] ;
        double vy_significance_erry[Nbins] ;

  	double vy_sig_eff[Nbins] ;
        double vy_sig_eff_errx[Nbins] ;
        double vy_sig_eff_erry[Nbins] ;

  	double vy_background_eff[Nbins] ;
        double vy_background_eff_errx[Nbins] ;
        double vy_background_eff_erry[Nbins] ;

	for(int i=0;i<Nbins;i++){
		vy_significance_errx[i]=0;    vy_significance_erry[Nbins]=0; 
		vy_sig_eff_errx[i]=0;         vy_sig_eff_erry[i]=0;
		vy_background_eff_errx[i]=0;  vy_background_eff_erry[i]=0;
	}


  	// draw the Tgraph for significance, signal eff. and background eff.
  	TString c1_title = Form("M_{Z'}=%d GeV", Zprime_mass[k] );
  	TLegend *leg=new TLegend(0.4,0.7,0.9,0.9);


  //

  // use Eiko's eff. fn
  bool Eiko_efficiency_function=false;
  Eiko_efficiency_function= true;
  if(Eiko_efficiency_function){


		// signal eff

		        TH1F *h_2nd_ele_pT_ = (TH1F*) h_2nd_ele_pT ->Clone("");
                        h_2nd_ele_pT_->Sumw2();

                        float eff[Nbins], eff_err[Nbins];


		// background eff

		        TH1F *h_background_2nd_ele_pT_combine = (TH1F*) h_2nd_ele_pT_ ->Clone("");
        		h_background_2nd_ele_pT_combine->Reset();
			h_background_2nd_ele_pT_combine->Sumw2();

                        // prepare background sample name
                        TString background_shape_file[N_background_points];
                        for(int l=0 ; l<N_background_points ; l++ ){
                                if(l==0 ){ background_shape_file[l] = Form("background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==1 ){ background_shape_file[l] = Form("background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==2 ){ background_shape_file[l] = Form("background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[k]);}
                                if(l==3 ){ background_shape_file[l] = Form("background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[k]);}
                        }// loop l background shape file
     
        		// loop background sample, open histogram, weight it, and add together 
        		for(int i=0; i<N_background_points;i++){

                		// open
                		background_shape_file[i] = path + background_shape_file[i];
                		TFile *f_background = new TFile ( background_shape_file[i] );
                		TH1D *h_background_2nd_ele_pT;
                		h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

                		// weight
                                h_background_2nd_ele_pT->Sumw2();
          		      	h_background_2nd_ele_pT->Scale( background_weights[i] );

                		// add
                		h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);

        		}// loop i background shape file

			// h_background_2nd_ele_pT_combine is ready for background


			//float background_eff[Nbins], background_eff_err[Nbins];

                        TH1F *h_background_2nd_ele_pT_combine_scale1 = (TH1F*) h_background_2nd_ele_pT_combine ->Clone("new");
                        double lumi = 1000;
//                        double lumi = 1;
                        h_background_2nd_ele_pT_combine_scale1->Scale( lumi );

                        float background_eff[Nbins], background_eff_err[Nbins];



                // significance

			cout<<endl;
                        cout<<"significance"<<endl;

                        TH1F *h_background_2nd_ele_pT_combine_scale2 = (TH1F*) h_background_2nd_ele_pT_combine ->Clone("new");
		        lumi = 1000;
			h_background_2nd_ele_pT_combine_scale2->Scale( lumi );

//                        float sig[Nbins], sig_err[Nbins];


//                        float eff[Nbins], eff_err[Nbins];
//                        float background_eff[Nbins], background_eff_err[Nbins];
                        float sig[Nbins], sig_err[Nbins];

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

                                vx[i] = cut_points[i];

//                              efficiency(eff[i],eff_err[i], h_2nd_ele_pT_, ( i * scan_width ) + lowest_cut + 1 );
//                              double bin_width = h_2nd_ele_pT_ ->GetBinWidth(1);

                                int FirstBinForCut = min_non_zero_bin;
                                int LastBinForCut = (cut_points[i] - lowest_cut)/bin_width + min_non_zero_bin  ;
                                cout<< "LastBinForCut: "<< LastBinForCut <<endl;
                                int mode = 0;
                                int FirstBinForTotal = min_non_zero_bin;
                                int LastBinForTotal = -1;


                                efficiency(eff[i],eff_err[i], h_2nd_ele_pT_, FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal );
                                vy_sig_eff[i] = eff[i];
                                vy_sig_eff_erry[i] = eff_err[i];


                                efficiency(background_eff[i] ,background_eff_err[i],h_background_2nd_ele_pT_combine_scale1 , FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal );
                                vy_background_eff[i] = background_eff[i]; 
                                vy_background_eff_erry[i] = background_eff_err[i];


                                significance( sig[i] , sig_err[i] , h_2nd_ele_pT_  , h_background_2nd_ele_pT_combine_scale2  ,FirstBinForCut , LastBinForCut, mode , FirstBinForTotal , LastBinForTotal  );
                                vy_significance[i] = sig[i];
                                vy_significance_erry[i] = sig_err[i];




                              cout<<"i:  "<< i  <<endl;
                              cout<<"cut point vx[i]:  "<< vx[i]  <<endl;

                              cout<<"vy_sig_eff[i]:  "<<vy_sig_eff[i]   <<endl;
                              cout<<"vy_sig_eff_erry[i]:  "<<vy_sig_eff_erry[i]   <<endl;

 //                             cout<<"vy_background_eff[i]:  "<<vy_background_eff[i]   <<endl;
 //                             cout<<"vy_background_eff_erry[i]:  "<<vy_background_eff_erry[i]   <<endl;

 //                             cout<<"vy_significance[i]:  "<<vy_significance[i]   <<endl;
 //                             cout<<"vy_significance_erry[i]:  "<<vy_significance_erry[i]   <<endl;



                        }// end loop





                }// end if


  // find the highest significance
  int hightest_bin =-9;
  double highest_sig=-99; 

  for(int i=0;i<Nbins; i++)
  {
  double temp = vy_significance[i] + vy_significance_erry[i]; 
  if(temp > highest_sig){highest_sig = temp; hightest_bin = i;}

  }
  cout<<endl;
  cout<< "Zprime_mass[k]: " << Zprime_mass[k] << endl;
  cout<<"hightest_bin : "<< hightest_bin << endl;  
  cout<<"highest_sig : "<<highest_sig << endl;
  cout<<"vx[hightest_bin] : "<< vx[hightest_bin] <<endl;
  cout<<"sig: "<< vy_significance[hightest_bin] <<" +/- "<< vy_significance_erry[hightest_bin] << endl;
  cout<<endl;

  // draw the TGraphError

  c1[k]->cd();

  TGraphErrors *gr 		  = new TGraphErrors(Nbins , vx , vy_significance, vy_significance_errx, vy_significance_erry );
  TGraphErrors *gr_eff 		  = new TGraphErrors(Nbins , vx , vy_sig_eff, vy_sig_eff_errx, vy_sig_eff_erry );
  TGraphErrors *gr_background_eff = new TGraphErrors(Nbins , vx , vy_background_eff, vy_background_eff_errx, vy_background_eff_erry );


  // draw setting
  gr->GetYaxis()->SetRangeUser(0, 1.1);
  gr->SetTitle(c1_title);
//  gr->GetXaxis()->SetTitle("Minimum p_{T} threshold of leading electron [ GeV]");
  gr->GetXaxis()->SetTitle("| delta eta |");

  gr->SetLineColor(2);
  gr_eff->SetLineColor(kBlue);
  gr_background_eff->SetLineColor(kGreen+2);

  gr->SetLineStyle(1);
  gr_eff->SetLineStyle(1);
  gr_background_eff->SetLineStyle(1);

  gr->SetLineWidth(3);
  gr_eff->SetLineWidth(3);
  gr_background_eff->SetLineWidth(3);

  gr->SetMarkerColor(2);
  gr_eff->SetMarkerColor(kBlue);
  gr_background_eff->SetMarkerColor(kGreen+2);

  gr->SetMarkerStyle(4);
  gr_eff->SetMarkerStyle(5);
  gr_background_eff->SetMarkerStyle(8);

  gr->SetMarkerSize(1);
  gr_eff->SetMarkerSize(1);
  gr_background_eff->SetMarkerSize(1);

  gr->Draw("ALP");
  gr_eff->Draw("same lp");
  gr_background_eff->Draw("same lp");

  leg->AddEntry( gr , leg_name1 ,"pl");
  leg->AddEntry( gr_eff , leg_name2 ,"pl");
  leg->AddEntry( gr_background_eff , leg_name3 ,"pl");
  leg->Draw();

  TString path_name = "/Users/index0192/13_TeV_Task/Zprime_Electron_channel/plot_SubLedaing_ele_pt_optimize/" ;
  c1_name = path_name + c1_name + ".png";
  c1[k]->SaveAs(c1_name);





//  delete h_2nd_ele_pT;
  delete f_signal;
  }// loop k Zprime mass points













  // show the 2nd ele pT distribution of different mass points
  // that is another loop

bool the_2nd_ele_pT_varies_mass = false; 
// the_2nd_ele_pT_varies_mass = true;
if( the_2nd_ele_pT_varies_mass ){

  // define used object
  TString c2_name = "2nd_ele_pT_distribuion_of_signal_varies_mass";
  TString c3_name = "2nd_ele_pT_distribuion_of_background_varies_mass";

  TCanvas *c2 = new TCanvas(c2_name,"2nd_ele_pT_distribuion_signal",200,10,700,500);
  TCanvas *c3 = new TCanvas(c3_name,"2nd_ele_pT_distribuion_background",200,10,700,500);
//  TCanvas *c4 = new TCanvas("2nd_ele_pT_distribuion_background_zoom_in","2nd_ele_pT_distribuion_background_zoom_in",200,10,700,500);
  int  colorN = 1;
  TLegend *leg2 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg3 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg4 = new TLegend(0.585,0.3,0.9,0.9);
  TLegend *leg5[N_mass_points];// for input
//  int rebin_times = 16;
//  int rebin_times = 1;
  int rebin_times = 4;

  TCanvas *c5[N_mass_points];

  for(int k=0;k<13;k++){
if( k!= 2 && k!= 7 && k!= 9)continue;
//if( k!= 2 )continue;
//  for(int k=2;k<3;k++){
//continue;

        leg5[k] = new TLegend(0.50,0.8,0.9,0.9);// for input
        TString c5_name = Form("input_signal_and_background_in_Zprime_M-%d",Zprime_mass[k]);
	c5[k] = new TCanvas(c5_name,"input signal and background",200,10,700,500);
	
// First for signal distribution

	// prepare background sample name
        TString signal_shape_file = Form("signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);
//        TString signal_shape_file = Form("no_zprime_cut_signal_shape_in_Zprime_M-%d.root",Zprime_mass[k]);

	// open the signal histogram
        signal_shape_file = path + signal_shape_file ;
        TFile *f_signal = new TFile (signal_shape_file);

//        TString histo_name= "h_ele_pT" ;
//        TString histo_name= "h_Zprime_mass" ;
        TString histo_name= "h_abs_dEta_ZH" ;
//        TString histo_name= "h_abs_dPhi_ZH" ;
//        TString histo_name= "h_abs_dR_ZH" ;


        TH1D *h_2nd_ele_pT;
        h_2nd_ele_pT = (TH1D*) f_signal -> Get(histo_name);

        TH1D *h_2nd_ele_pT_clone = (TH1D*) h_2nd_ele_pT ->Clone("");// for later be template for background

// Second for background distribution

	// prepare background sample name
        TString background_shape_file[N_background_points];
        for(int l=0 ; l<N_background_points ; l++ ){
        	if(l==0 ){ background_shape_file[l] = Form("background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==1 ){ background_shape_file[l] = Form("background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==2 ){ background_shape_file[l] = Form("background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[k]);}
                if(l==3 ){ background_shape_file[l] = Form("background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[k]);}
	}// loop l background shape file 

	TH1D *h_background_2nd_ele_pT_combine = (TH1D*) h_2nd_ele_pT_clone ->Clone("");
	h_background_2nd_ele_pT_combine->Reset();

	// loop background sample, open histogram, weight it, and add together 
        for(int i=0; i<N_background_points;i++){

		// open
                background_shape_file[i] = path + background_shape_file[i];
                TFile *f_background = new TFile ( background_shape_file[i] );
                TH1D *h_background_2nd_ele_pT;
                h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

		// weight
		h_background_2nd_ele_pT->Scale( background_weights[i] );

		// add
		h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);

        }// loop i background shape file


// Now
// h_2nd_ele_pT is ready for signal
// h_background_2nd_ele_pT_combine is ready for background






	// input signal and background shape
        // c5[k] is the comparison of signal and background input shape

       	// input signal

        TH1D *input_signal = (TH1D*) h_2nd_ele_pT ->Clone("");

        input_signal->Scale( 1/input_signal->Integral() );
        input_signal->SetTitle("2nd electron pT distribution");
        input_signal->SetStats(0);
        input_signal->Rebin(rebin_times);


        // input background

        TH1D *input_background = (TH1D*) h_background_2nd_ele_pT_combine ->Clone("");

        input_background->Scale( 1/input_background->Integral() );
        input_background->Rebin(rebin_times);

	// decide max-x and max-y
	double MaxX=0,MaxY=0; 

	int signal_max_bin=-9;
	double signal_max_content=-99;
        for( int m=1 ; m<= input_signal->GetNbinsX() ;m++ ){
                double bin_content = input_signal->GetBinContent(m);
		// seek the biggest non-zero bin  
                if( bin_content != 0 ){ signal_max_bin = m; }
		if( bin_content >= signal_max_content ){ signal_max_content = bin_content ; }
        }       

        int background_max_bin=-9;
        double background_max_content=-99;
        for( int m=1 ; m<= input_background->GetNbinsX() ;m++ ){
                double bin_content = input_background->GetBinContent(m);
                if( bin_content != 0 ){ background_max_bin = m; }
                if( bin_content >= background_max_content ){ background_max_content = bin_content ; }
        }
	
	if( signal_max_bin >= background_max_bin ){ MaxX = signal_max_bin; }
	else{ MaxX = background_max_bin;}
	MaxX = MaxX * rebin_times * 1.1  ;
        input_signal->GetXaxis()->SetRangeUser(0, MaxX );

        if( signal_max_content >= background_max_content ){ MaxY = signal_max_content; }
        else{ MaxY = background_max_content;}
        MaxY = MaxY * 1.1  ;
        input_signal->GetYaxis()->SetRangeUser(0, MaxY );

	// other setting
//	input_signal->GetXaxis()->SetTitle("Sub-leading electron p_{T} [ GeV]");
//        input_signal->GetXaxis()->SetTitle("Leading electron p_{T} [ GeV]");
        input_signal->GetXaxis()->SetTitle("| delta eta|");
//        input_signal->GetXaxis()->SetTitle("| delta Phi|");
//        input_signal->GetXaxis()->SetTitle("delta R");
        input_signal->GetYaxis()->SetTitle("Arbitrary Unit");
        input_signal ->SetFillColor(2);
	input_signal->SetFillStyle(1001);
 	input_signal ->SetLineColor(2);
        input_background->SetLineColor(4);
	input_background->SetLineWidth(3); 
 	input_signal->SetTitle("");
	input_background->SetTitle("");

	// draw
        c5[k]->cd();
        input_signal -> Draw();
        input_background -> Draw("same");

        TString leg_input_name =  Form("Signal, M_{Z'}=%d GeV",Zprime_mass[k]);
        leg5[k]->AddEntry( input_signal ,leg_input_name ,"lf");
        leg_input_name = "DY+jets";
        leg5[k]->AddEntry( input_background ,leg_input_name ,"lf");
        leg5[k]->Draw();

	//save
        TString input_save_name =  Form("input_in_Zprime_mass_%d.png",Zprime_mass[k]);
        input_save_name = path + input_save_name ;
        c5[k]->SaveAs(input_save_name);






	// signal shape varies with mass
        // c2 is signal distribution varies with mass
        TH1D *h_signal_varies_mass = (TH1D*) h_2nd_ele_pT ->Clone("");

        h_signal_varies_mass->Scale( 1/h_signal_varies_mass->Integral() );
//        h_signal_varies_mass->SetTitle("2nd electron pT distribution");
        h_signal_varies_mass->SetTitle("");
        h_signal_varies_mass->SetStats(0);

        if( k==0){colorN = kRed;}
        else if( k==3){colorN = kOrange;}
        else if( k==6){colorN = kYellow;}
        else if( k==9){colorN = kCyan;}

        h_signal_varies_mass->SetLineColor(colorN);
        h_signal_varies_mass->GetXaxis()->SetTitle("| delta eta |");
        h_signal_varies_mass->Rebin(rebin_times);

        c2->cd();
        if(k==0){h_signal_varies_mass -> Draw(); h_signal_varies_mass->GetXaxis()->SetRangeUser(0, 1250);}
        else {h_signal_varies_mass -> Draw("same");}

        TString leg_singal_name =  Form("signal in Z' mass= %d",Zprime_mass[k]);
        leg2->AddEntry( h_signal_varies_mass ,leg_singal_name ,"L");
        leg2->Draw();






	// background shape varies with mass
        // c3 is background distribution varies with mass 
        TH1D *h_background_varies_mass = (TH1D*) h_background_2nd_ele_pT_combine ->Clone("");

        h_background_varies_mass->Scale( 1/h_background_varies_mass->Integral() );
        h_background_varies_mass->SetTitle("2nd electron pT distribution");
        h_background_varies_mass->SetTitle("");
        h_background_varies_mass->SetStats(0);

        h_background_varies_mass->SetLineColor(colorN);
        colorN = colorN + 1;// afer used in signal and background color+1

        h_background_varies_mass->Rebin(rebin_times);
        h_background_varies_mass->GetXaxis()->SetTitle("| delta eta |");

        c3->cd();
        if(k==0){
                h_background_varies_mass->GetXaxis()->SetRangeUser(0, 1250);   
                h_background_varies_mass->GetYaxis()->SetRangeUser(0, 1); 
                h_background_varies_mass -> Draw(); 
                }
        else {h_background_varies_mass->GetYaxis()->SetRangeUser(0, 0.3); h_background_varies_mass -> Draw("same");}

        TString leg_background_name =  Form("background in Z' mass= %d",Zprime_mass[k]);
        leg3->AddEntry( h_background_varies_mass ,leg_background_name ,"L");
        leg3->Draw();





  }// loop k Zprime mass point


c2_name = path + c2_name + ".png";
c3_name = path + c3_name + ".png";

c2->cd();
c2->SaveAs(c2_name);

c3->cd();
c3->SaveAs(c3_name);



}// end if




  // combine the 4 background shape to get the Zprime mass distribution 

bool Zprime_mass_combined_background = false;
//Zprime_mass_combined_background = true;
if(Zprime_mass_combined_background)
  {     // Zprime_mass[0] is M = 600 

	// prepare the background sample name
        TString background_shape_file[N_background_points];
        for(int l=0 ; l<N_background_points ; l++ ){
                if(l==0 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT100to200_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==1 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT200to400_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==2 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT400to600_in_Zprime_M-%d.root",Zprime_mass[0]);}
                if(l==3 ){ background_shape_file[l] = Form("no_zprime_cut_background_shape_DYJets_HT600toInf_in_Zprime_M-%d.root",Zprime_mass[0]);}
        }// loop l background shape file 

	// prepare a template histogram and reset it 
        TString template_name = path + background_shape_file[0] ;
        TFile *f_template = new TFile ( template_name );
        TString histo_name= "h_Zprime_mass" ;
        TH1D *h_template;
        h_template = (TH1D*) f_template -> Get(histo_name);

        TH1D *h_background_2nd_ele_pT_combine = (TH1D*) h_template ->Clone("");
        h_background_2nd_ele_pT_combine->Reset();

	// loop background sample, open, weight, and add
        for(int i=0; i<N_background_points;i++){

		// open
                background_shape_file[i] = path + background_shape_file[i];
                TFile *f_background = new TFile ( background_shape_file[i] );
                TH1D *h_background_2nd_ele_pT;
                h_background_2nd_ele_pT = (TH1D*) f_background -> Get(histo_name);

		// weight
		h_background_2nd_ele_pT->Scale(background_weights[i]  );

		// add
                h_background_2nd_ele_pT_combine ->Add(h_background_2nd_ele_pT);
        }// loop i background shape file

        TCanvas *c6 = new TCanvas("background_Zprime_mass","",200,10,700,500);
	c6->cd();
	h_background_2nd_ele_pT_combine->Rebin(8);
	h_background_2nd_ele_pT_combine->Draw();

  }// end if


}
Exemplo n.º 10
0
void gyieldsp()
{
//=========Macro generated from canvas: c1/c1
//=========  (Fri Jul 31 19:31:43 2015) by ROOT version6.05/01
   TCanvas *c1 = new TCanvas("c1", "c1",0,23,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   c1->Range(0,0,1,1);
   c1->SetFillColor(0);
   c1->SetBorderMode(0);
   c1->SetBorderSize(2);
   c1->SetTickx(1);
   c1->SetTicky(1);
   c1->SetLeftMargin(0.16);
   c1->SetRightMargin(0.04);
   c1->SetTopMargin(0.08);
   c1->SetBottomMargin(0.12);
   c1->SetFrameFillStyle(0);
   c1->SetFrameBorderMode(0);
  
// ------------>Primitives in pad: pad1
   TPad *pad1 = new TPad("pad1", "pad1",0,0.26,1,1);
   pad1->Draw();
   pad1->cd();
   pad1->Range(-3.5,-6.621622,2.75,158.9189);
   pad1->SetFillColor(0);
   pad1->SetBorderMode(0);
   pad1->SetBorderSize(2);
   pad1->SetTickx(1);
   pad1->SetTicky(1);
   pad1->SetLeftMargin(0.16);
   pad1->SetRightMargin(0.04);
   pad1->SetTopMargin(0.1142857);
   pad1->SetBottomMargin(0.04);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   pad1->SetFrameFillStyle(0);
   pad1->SetFrameBorderMode(0);
   
   Double_t Graph0_fx3021[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy3021[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph0_felx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fely3021[10] = {
   7.299733,
   7.206486,
   6.824632,
   6.594841,
   6.406375,
   6.079494,
   5.746822,
   5.225105,
   4.165823,
   2.787035};
   Double_t Graph0_fehx3021[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fehy3021[10] = {
   5.988963,
   6.218694,
   6.307709,
   6.368316,
   5.847823,
   5.655323,
   5.083818,
   4.561256,
   3.722445,
   2.542957};
   TGraphAsymmErrors *grae = new TGraphAsymmErrors(10,Graph0_fx3021,Graph0_fy3021,Graph0_felx3021,Graph0_fehx3021,Graph0_fely3021,Graph0_fehy3021);
   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);

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   
   TH1F *Graph_Graph3021 = new TH1F("Graph_Graph3021","Graph",100,-2.5,2.5);
   Graph_Graph3021->SetMinimum(0);
   Graph_Graph3021->SetMaximum(140);
   Graph_Graph3021->SetDirectory(0);
   Graph_Graph3021->SetStats(0);
   Graph_Graph3021->SetLineStyle(0);
   Graph_Graph3021->SetMarkerStyle(20);
   Graph_Graph3021->GetXaxis()->SetNdivisions(505);
   Graph_Graph3021->GetXaxis()->SetLabelFont(42);
   Graph_Graph3021->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetXaxis()->SetLabelSize(0);
   Graph_Graph3021->GetXaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3021->GetXaxis()->SetTitleFont(42);
   Graph_Graph3021->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_Graph3021->GetYaxis()->SetLabelFont(42);
   Graph_Graph3021->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetYaxis()->SetLabelSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleSize(0.07142857);
   Graph_Graph3021->GetYaxis()->SetTitleOffset(1.05);
   Graph_Graph3021->GetYaxis()->SetTitleFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelFont(42);
   Graph_Graph3021->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3021->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3021->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3021->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3021);
   
   grae->Draw("a2");
   
   Double_t Graph1_fx3022[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy3022[10] = {
   103.56,
   105.744,
   103.4081,
   100.0093,
   97.03688,
   94.36609,
   90.5471,
   82.43278,
   65.82142,
   43.43165};
   Double_t Graph1_felx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fely3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph1_fehx3022[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fehy3022[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph1_fx3022,Graph1_fy3022,Graph1_felx3022,Graph1_fehx3022,Graph1_fely3022,Graph1_fehy3022);
   grae->SetName("Graph1");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   grae->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   grae->SetLineColor(ci);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->SetMarkerSize(0);
   grae->Draw("z");
   
   Double_t Graph2_fx3023[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy3023[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph2_felx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fely3023[10] = {
   8.336985,
   8.261181,
   7.634488,
   6.438496,
   6.661149,
   6.164321,
   6.1019,
   4.954787,
   4.773841,
   2.599375};
   Double_t Graph2_fehx3023[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fehy3023[10] = {
   8.262572,
   7.14746,
   6.62492,
   6.725295,
   5.946212,
   5.838684,
   5.077774,
   5.257491,
   3.443198,
   2.602454};
   grae = new TGraphAsymmErrors(10,Graph2_fx3023,Graph2_fy3023,Graph2_felx3023,Graph2_fehx3023,Graph2_fely3023,Graph2_fehy3023);
   grae->SetName("Graph2");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   
   TH1F *Graph_Graph3023 = new TH1F("Graph_Graph3023","Graph",100,-2.88,2.88);
   Graph_Graph3023->SetMinimum(33.22782);
   Graph_Graph3023->SetMaximum(108.7062);
   Graph_Graph3023->SetDirectory(0);
   Graph_Graph3023->SetStats(0);
   Graph_Graph3023->SetLineStyle(0);
   Graph_Graph3023->SetMarkerStyle(20);
   Graph_Graph3023->GetXaxis()->SetLabelFont(42);
   Graph_Graph3023->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph3023->GetXaxis()->SetTitleFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelFont(42);
   Graph_Graph3023->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph3023->GetYaxis()->SetTitleFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelFont(42);
   Graph_Graph3023->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph3023->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph3023->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph3023->GetZaxis()->SetTitleFont(42);
   grae->SetHistogram(Graph_Graph3023);
   
   grae->Draw("2");
   
   Double_t Graph3_fx3024[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy3024[10] = {
   91.59545,
   95.26883,
   95.65156,
   95.47892,
   95.94693,
   96.02597,
   93.3635,
   84.56484,
   65.95871,
   42.11706};
   Double_t Graph3_felx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fely3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph3_fehx3024[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fehy3024[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   grae = new TGraphAsymmErrors(10,Graph3_fx3024,Graph3_fy3024,Graph3_felx3024,Graph3_fehx3024,Graph3_fely3024,Graph3_fehy3024);
   grae->SetName("Graph3");
   grae->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   grae->SetFillColor(ci);
   grae->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   grae->SetLineColor(ci);
   grae->SetLineStyle(7);
   grae->SetLineWidth(4);
   grae->SetMarkerStyle(20);
   grae->Draw("z");
   
   Double_t Graph4_fx1011[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1011[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t Graph4_fex1011[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1011[10] = {
   6.667786,
   4.792637,
   3.765295,
   3.224798,
   3.479167,
   3.377478,
   3.07273,
   3.40604,
   2.800731,
   2.87761};
   TGraphErrors *gre = new TGraphErrors(10,Graph4_fx1011,Graph4_fy1011,Graph4_fex1011,Graph4_fey1011);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t gyieldsp_exp_statonly_1_fx1012[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t gyieldsp_exp_statonly_1_fy1012[10] = {
   108.0732,
   102.2597,
   100.2246,
   101.796,
   105.3416,
   99.73788,
   98.62062,
   85.94448,
   62.90271,
   44.47931};
   Double_t gyieldsp_exp_statonly_1_fex1012[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t gyieldsp_exp_statonly_1_fey1012[10] = {
   2.814265,
   2.293805,
   2.181326,
   2.056934,
   2.054972,
   2.059018,
   2.050204,
   2.01317,
   1.754638,
   1.667829};
   gre = new TGraphErrors(10,gyieldsp_exp_statonly_1_fx1012,gyieldsp_exp_statonly_1_fy1012,gyieldsp_exp_statonly_1_fex1012,gyieldsp_exp_statonly_1_fey1012);
   gre->SetName("gyieldsp_exp_statonly_1");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(1.2);
   
   TH1F *Graph_gyieldsp_exp_statonly_11012 = new TH1F("Graph_gyieldsp_exp_statonly_11012","Graph",100,-2.64,2.64);
   Graph_gyieldsp_exp_statonly_11012->SetMinimum(36.00388);
   Graph_gyieldsp_exp_statonly_11012->SetMaximum(117.6951);
   Graph_gyieldsp_exp_statonly_11012->SetDirectory(0);
   Graph_gyieldsp_exp_statonly_11012->SetStats(0);
   Graph_gyieldsp_exp_statonly_11012->SetLineStyle(0);
   Graph_gyieldsp_exp_statonly_11012->SetMarkerStyle(20);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleOffset(1.1);
   Graph_gyieldsp_exp_statonly_11012->GetXaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleOffset(1.5);
   Graph_gyieldsp_exp_statonly_11012->GetYaxis()->SetTitleFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelFont(42);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelOffset(0.007);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetLabelSize(0.05);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleSize(0.06);
   Graph_gyieldsp_exp_statonly_11012->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_gyieldsp_exp_statonly_11012);
   
   gre->Draw("pz");
   
   TLegend *leg = new TLegend(0.6,0.1,0.9,0.3142857,NULL,"brNDC");
   leg->SetBorderSize(0);
   leg->SetTextSize(0.05714286);
   leg->SetLineColor(1);
   leg->SetLineStyle(1);
   leg->SetLineWidth(1);
   leg->SetFillColor(0);
   leg->SetFillStyle(1001);
   TLegendEntry *entry=leg->AddEntry("Graph4","Data","p");
   entry->SetLineColor(1);
   entry->SetLineStyle(1);
   entry->SetLineWidth(1);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(20);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph0","CT10","lf");

   ci = TColor::GetColor("#ffff00");
   entry->SetFillColor(ci);
   entry->SetFillStyle(1001);

   ci = TColor::GetColor("#ff0000");
   entry->SetLineColor(ci);
   entry->SetLineStyle(1);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   entry=leg->AddEntry("Graph2","CT10+EPS09","lf");

   ci = TColor::GetColor("#009900");
   entry->SetFillColor(ci);
   entry->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   entry->SetLineColor(ci);
   entry->SetLineStyle(7);
   entry->SetLineWidth(4);
   entry->SetMarkerColor(1);
   entry->SetMarkerStyle(21);
   entry->SetMarkerSize(1);
   entry->SetTextFont(42);
   leg->Draw();
   
   TPaveText *pt = new TPaveText(-2.35,125,-0.35,140,"br");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   TText *AText = pt->AddText("Luminosity uncertainty: 3.5%");
   pt->Draw();
   
   pt = new TPaveText(0.27,0.2,0.5,0.3428571,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(13);
   pt->SetTextFont(42);
   pt->SetTextSize(0.05714286);
   AText = pt->AddText("W^{+} #rightarrow #font[12]{l}^{+} + #nu");
   AText = pt->AddText("p_{T}^{#font[12]{l}} > 25 GeV/c");
   pt->Draw();
      tex = new TLatex(0.96,0.9177143," #sqrt{s_{NN}} = 5.02 TeV");
tex->SetNDC();
   tex->SetTextAlign(31);
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.16,0.9177143,"pPb 34.6 nb^{-1}");
tex->SetNDC();
   tex->SetTextFont(42);
   tex->SetTextSize(0.05714286);
   tex->SetLineWidth(2);
   tex->Draw();
      tex = new TLatex(0.924,0.8476571,"CMS");
tex->SetNDC();
   tex->SetTextAlign(33);
   tex->SetTextFont(61);
   tex->SetTextSize(0.06857143);
   tex->SetLineWidth(2);
   tex->Draw();
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0);
   Graph_copy->SetMaximum(140);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0);
   Graph_copy->GetXaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("d#sigma (W^{+}#rightarrow#font[12]{l}^{+}#nu) / d#eta_{lab} [nb]");
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleSize(0.07142857);
   Graph_copy->GetYaxis()->SetTitleOffset(1.05);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad1->Modified();
   c1->cd();
  
// ------------>Primitives in pad: pad2
   TPad *pad2 = new TPad("pad2", "pad2",0,0,1,0.288);
   pad2->Draw();
   pad2->cd();
   pad2->Range(-3.5,0.35,2.75,1.35);
   pad2->SetFillColor(0);
   pad2->SetFillStyle(4000);
   pad2->SetBorderMode(0);
   pad2->SetBorderSize(2);
   pad2->SetTickx(1);
   pad2->SetTicky(1);
   pad2->SetLeftMargin(0.16);
   pad2->SetRightMargin(0.04);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.4);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   pad2->SetFrameFillStyle(4000);
   pad2->SetFrameBorderMode(0);
   
   TH1F *Graph = new TH1F("Graph","Graph",100,-2.5,2.5);
   Graph->SetMinimum(0.75);
   Graph->SetMaximum(1.35);
   Graph->SetDirectory(0);
   Graph->SetStats(0);
   Graph->SetLineStyle(0);
   Graph->SetMarkerStyle(20);
   Graph->GetXaxis()->SetTitle("#eta_{lab}");
   Graph->GetXaxis()->SetNdivisions(505);
   Graph->GetXaxis()->SetLabelFont(42);
   Graph->GetXaxis()->SetLabelOffset(0.007);
   Graph->GetXaxis()->SetLabelSize(0.1666667);
   Graph->GetXaxis()->SetTitleSize(0.1666667);
   Graph->GetXaxis()->SetTitleOffset(1.1);
   Graph->GetXaxis()->SetTitleFont(42);
   Graph->GetYaxis()->SetTitle("Ratio ");
   Graph->GetYaxis()->SetNdivisions(503);
   Graph->GetYaxis()->SetLabelFont(42);
   Graph->GetYaxis()->SetLabelOffset(0.007);
   Graph->GetYaxis()->SetLabelSize(0.1666667);
   Graph->GetYaxis()->SetTitleSize(0.1666667);
   Graph->GetYaxis()->SetTitleOffset(0.45);
   Graph->GetYaxis()->SetTitleFont(42);
   Graph->GetZaxis()->SetLabelFont(42);
   Graph->GetZaxis()->SetLabelOffset(0.007);
   Graph->GetZaxis()->SetLabelSize(0.05);
   Graph->GetZaxis()->SetTitleSize(0.06);
   Graph->GetZaxis()->SetTitleFont(42);
   Graph->Draw("");
   
   Double_t Graph0_fx1013[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph0_fy1013[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph0_fex1013[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph0_fey1013[10] = {
   0.0644708,
   0.06365122,
   0.06354681,
   0.06481966,
   0.06320752,
   0.0622177,
   0.05991862,
   0.05949606,
   0.06001632,
   0.06142499};
   gre = new TGraphErrors(10,Graph0_fx1013,Graph0_fy1013,Graph0_fex1013,Graph0_fey1013);
   gre->SetName("Graph0");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   
   TH1F *Graph_Graph1013 = new TH1F("Graph_Graph1013","Graph",100,-2.88,2.88);
   Graph_Graph1013->SetMinimum(0.9222164);
   Graph_Graph1013->SetMaximum(1.077784);
   Graph_Graph1013->SetDirectory(0);
   Graph_Graph1013->SetStats(0);
   Graph_Graph1013->SetLineStyle(0);
   Graph_Graph1013->SetMarkerStyle(20);
   Graph_Graph1013->GetXaxis()->SetLabelFont(42);
   Graph_Graph1013->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1013->GetXaxis()->SetTitleFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelFont(42);
   Graph_Graph1013->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1013->GetYaxis()->SetTitleFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelFont(42);
   Graph_Graph1013->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1013->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1013->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1013->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1013);
   
   gre->Draw("2");
   
   Double_t Graph1_fx1014[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph1_fy1014[10] = {
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1,
   1};
   Double_t Graph1_fex1014[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph1_fey1014[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph1_fx1014,Graph1_fy1014,Graph1_fex1014,Graph1_fey1014);
   gre->SetName("Graph1");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#ffff00");
   gre->SetFillColor(ci);

   ci = TColor::GetColor("#ff0000");
   gre->SetLineColor(ci);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->SetMarkerSize(0);
   gre->Draw("z");
   
   Double_t Graph2_fx1015[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph2_fy1015[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph2_fex1015[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph2_fey1015[10] = {
   0.05296218,
   0.042007,
   0.03326947,
   0.02116912,
   0.0170915,
   0.01890429,
   0.01672622,
   0.01681633,
   0.01541551,
   0.01597539};
   gre = new TGraphErrors(10,Graph2_fx1015,Graph2_fy1015,Graph2_fex1015,Graph2_fey1015);
   gre->SetName("Graph2");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1015 = new TH1F("Graph_Graph1015","Graph",100,-2.88,2.88);
   Graph_Graph1015->SetMinimum(0.8098732);
   Graph_Graph1015->SetMaximum(1.069463);
   Graph_Graph1015->SetDirectory(0);
   Graph_Graph1015->SetStats(0);
   Graph_Graph1015->SetLineStyle(0);
   Graph_Graph1015->SetMarkerStyle(20);
   Graph_Graph1015->GetXaxis()->SetLabelFont(42);
   Graph_Graph1015->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1015->GetXaxis()->SetTitleFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelFont(42);
   Graph_Graph1015->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1015->GetYaxis()->SetTitleFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelFont(42);
   Graph_Graph1015->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1015->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1015->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1015->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1015);
   
   gre->Draw("2");
   
   Double_t Graph3_fx1016[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph3_fy1016[10] = {
   0.8844678,
   0.9009383,
   0.9249909,
   0.9547005,
   0.9887677,
   1.01759,
   1.031104,
   1.025864,
   1.002086,
   0.9697318};
   Double_t Graph3_fex1016[10] = {
   0.2,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.25,
   0.2};
   Double_t Graph3_fey1016[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   gre = new TGraphErrors(10,Graph3_fx1016,Graph3_fy1016,Graph3_fex1016,Graph3_fey1016);
   gre->SetName("Graph3");
   gre->SetTitle("Graph");

   ci = TColor::GetColor("#009900");
   gre->SetFillColor(ci);
   gre->SetFillStyle(3375);

   ci = TColor::GetColor("#009900");
   gre->SetLineColor(ci);
   gre->SetLineStyle(7);
   gre->SetLineWidth(4);
   gre->SetMarkerStyle(20);
   gre->Draw("z");
   
   Double_t Graph4_fx1017[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph4_fy1017[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph4_fex1017[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph4_fey1017[10] = {
   0.06438575,
   0.04532301,
   0.03641199,
   0.03224499,
   0.03585407,
   0.03579123,
   0.03393516,
   0.041319,
   0.04255045,
   0.06625605};
   gre = new TGraphErrors(10,Graph4_fx1017,Graph4_fy1017,Graph4_fex1017,Graph4_fey1017);
   gre->SetName("Graph4");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetFillStyle(0);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   gre->Draw("||");
   
   Double_t Graph5_fx1018[10] = {
   2.2,
   1.75,
   1.25,
   0.75,
   0.25,
   -0.25,
   -0.75,
   -1.25,
   -1.75,
   -2.2};
   Double_t Graph5_fy1018[10] = {
   1.043581,
   0.9670498,
   0.9692137,
   1.017865,
   1.085583,
   1.056925,
   1.089164,
   1.042601,
   0.9556571,
   1.024122};
   Double_t Graph5_fex1018[10] = {
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0,
   0};
   Double_t Graph5_fey1018[10] = {
   0.02717523,
   0.02169205,
   0.02109434,
   0.02056743,
   0.02117723,
   0.02181947,
   0.02264241,
   0.02442196,
   0.02665755,
   0.03840124};
   gre = new TGraphErrors(10,Graph5_fx1018,Graph5_fy1018,Graph5_fex1018,Graph5_fey1018);
   gre->SetName("Graph5");
   gre->SetTitle("Graph");
   gre->SetFillColor(1);
   gre->SetLineWidth(2);
   gre->SetMarkerStyle(20);
   
   TH1F *Graph_Graph1018 = new TH1F("Graph_Graph1018","Graph",100,-2.64,2.64);
   Graph_Graph1018->SetMinimum(0.9107189);
   Graph_Graph1018->SetMaximum(1.130087);
   Graph_Graph1018->SetDirectory(0);
   Graph_Graph1018->SetStats(0);
   Graph_Graph1018->SetLineStyle(0);
   Graph_Graph1018->SetMarkerStyle(20);
   Graph_Graph1018->GetXaxis()->SetLabelFont(42);
   Graph_Graph1018->GetXaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetXaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetXaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetXaxis()->SetTitleOffset(1.1);
   Graph_Graph1018->GetXaxis()->SetTitleFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelFont(42);
   Graph_Graph1018->GetYaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetYaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetYaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetYaxis()->SetTitleOffset(1.5);
   Graph_Graph1018->GetYaxis()->SetTitleFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelFont(42);
   Graph_Graph1018->GetZaxis()->SetLabelOffset(0.007);
   Graph_Graph1018->GetZaxis()->SetLabelSize(0.05);
   Graph_Graph1018->GetZaxis()->SetTitleSize(0.06);
   Graph_Graph1018->GetZaxis()->SetTitleFont(42);
   gre->SetHistogram(Graph_Graph1018);
   
   gre->Draw("pz");
   
   TH1F *Graph_copy = new TH1F("Graph_copy","Graph",100,-2.5,2.5);
   Graph_copy->SetMinimum(0.75);
   Graph_copy->SetMaximum(1.35);
   Graph_copy->SetDirectory(0);
   Graph_copy->SetStats(0);
   Graph_copy->SetLineStyle(0);
   Graph_copy->SetMarkerStyle(20);
   Graph_copy->GetXaxis()->SetTitle("#eta_{lab}");
   Graph_copy->GetXaxis()->SetNdivisions(505);
   Graph_copy->GetXaxis()->SetLabelFont(42);
   Graph_copy->GetXaxis()->SetLabelOffset(0.007);
   Graph_copy->GetXaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetXaxis()->SetTitleOffset(1.1);
   Graph_copy->GetXaxis()->SetTitleFont(42);
   Graph_copy->GetYaxis()->SetTitle("Ratio ");
   Graph_copy->GetYaxis()->SetNdivisions(503);
   Graph_copy->GetYaxis()->SetLabelFont(42);
   Graph_copy->GetYaxis()->SetLabelOffset(0.007);
   Graph_copy->GetYaxis()->SetLabelSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleSize(0.1666667);
   Graph_copy->GetYaxis()->SetTitleOffset(0.45);
   Graph_copy->GetYaxis()->SetTitleFont(42);
   Graph_copy->GetZaxis()->SetLabelFont(42);
   Graph_copy->GetZaxis()->SetLabelOffset(0.007);
   Graph_copy->GetZaxis()->SetLabelSize(0.05);
   Graph_copy->GetZaxis()->SetTitleSize(0.06);
   Graph_copy->GetZaxis()->SetTitleFont(42);
   Graph_copy->Draw("sameaxis");
   pad2->Modified();
   c1->cd();
   c1->Modified();
   c1->cd();
   c1->SetSelected(c1);
}
Exemplo n.º 11
0
void eta()
{
//  TFile* f = TFile::Open("small.root");  // open the file
//    TFile* f = TFile::Open("Hgg_Moriond2013-Y2012_merge_200804_216432_Presel_1lepton.root");
  //  TFile* f = TFile::Open("Hgg_Moriond2013-Y2012_ZH900_Pythia_NoMassCut.root");  // open the file
 // TTree* tree = (TTree*)f->Get("tree");

  float m, me;
  photon p1, p2;
  electron e1, e2;
  muon m1, m2;
 

  float avg_m, sigma_m;
  const int N = 8;
  TFile *files[N];
  TTree *trees[N];
  int count[N];
  
  for(int k = 0; k < N; ++k)
  {
      char filename[128] = "";
      sprintf(filename, "Hgg_Moriond2013-Y2012_ZH%d00_Pythia_NoMassCut.root", k+2);
      files[k] = TFile::Open(filename);
      trees[k] = (TTree *)files[k]->Get("tree");
      count[k] = trees[k]->GetEntries();
      bind_attributes(trees[k], p1, p2, e1, e2, m1, m2);
  }
  
  const int n = 12;
  
  TF1 *fa = new TF1("fa1","(cos(x/2)/sin(x/2)  ) / ((cos(x/2)/sin(x/2)) *(cos(x/2)/sin(x/2)) + 1)",0,3.142);

  TH1F* h = new TH1F("h", "\\mbox{ erreur energie };\\Delta E_{T}/E_{T};\\mbox{count}", n, E_min, E_max); // create a histogram : 500 bins ranging from 100 to 600 GeV.
  TH1F* h2 = new TH1F("h2", "invariant mass gamma gamma", n, E_min, E_max); // create a histogram : 500 bins ranging from 100 to 600 GeV.
  //h2->SetLineColor(kRed);


  int totalEntries = 0;
  int looseEntries = 0;
  int keptEntries = 0;
  
  /*int n = 0, k = 0;
  
  for (unsigned int i = 0; i < tree->GetEntries(); i++) {
    //if(p1.true_E < 0) continue;
    tree->GetEntry(i);
    if(p1.true_mother==25 && p2.true_mother==25)
    {
        if(p1.true_E > 0)
        {
            ++n;
        }
    }
  }
  
  float *x = new float[n+1], *y = new float[n+1];*/
 
   //TF1 *f1 = new TF1("f1","gaus",122, 128);
   
   double *err[n];
   int elems[n], index[n];
   double en[n], den[n], xerr[n], yerr[n];
  for (unsigned a = 0; a < N; ++a)
  {
	  TTree *tree = trees[a];
	  for (unsigned int i = 0; i < count[a]; i++) {
		//if(p1.true_E < 0) continue;
		tree->GetEntry(i);

		//if(p1.mother==25 && p2.mother==25)
		{
		    //if(p1.true_E > 0)
		    {
		        vec imp1, imp2;
		        imp1.pr2c(p1.true_E, p1.true_phi, p1.true_eta);
		        imp2.pr2c(p2.true_E, p2.true_phi, p2.true_eta);
		        imp1.add(imp2);
		        float p = imp1.norm();
		        imp1.c2pr(imp1.x, imp1.y, imp1.z);
		        /*float px = p1.true_E * TMath::Cos(p1.true_phi) + p2.true_E * TMath::Cos(p2.true_phi);
		        float py = p1.true_E * TMath::Sin(p1.true_phi) + p2.true_E * TMath::Sin(p2.true_phi);
		        float pz = p1.true_E * TMath::SinH(p1.true_eta) + p2.true_E * TMath::SinH(p2.true_eta) ;
		        float p = TMath::Sqrt(px*px + py*py + pz*pz);
		        float eta = TMath::ATanH(pz/p);*/
		        //y[k] = invMassTrue(p1, p2);
		        //x[k] = eta;
		        //++k;
		        //printf("%.2f\n", imp1.z - eta);
		        //float theta = 2*atan(exp(-imp1.z));
		        // todo: par unité d'angle solide en fct de theta ?
		        //h->Fill(2*atan(exp(-imp1.z))/*+TMath::Pi()/2.0f*/);
		        /*float i1 = p1.true_E * cosh(p1.true_eta);
		        float i2 = p2.true_E * cosh(p2.true_eta);*/
		        
		        
		        /*if(p1.tight && p1.true_E > E_min && p1.true_E < E_max)
		        {
		            h->Fill(p1.true_E);   
		        }


		        if(p2.tight && p2.true_E > E_min && p2.true_E < E_max)
		        {
		            h->Fill(p1.true_E);   
		        }*/
		        
		        p1.E *= cosh(p1.true_eta);
		        p2.E *= cosh(p2.true_eta);
		        p1.true_E *= cosh(p1.true_eta);
		        p2.true_E *= cosh(p2.true_eta);
		        
		        if(keep_photon(p1))
		        {
		           h->Fill(p1.E);
		           if(abs(p1.E-p1.true_E) > 50) printf("%.3f %.3f %.3f %.3f\n", p1.true_E, p1.E, p1.eta, p1.isolTrack);
		        }
		        
		        if(keep_photon(p2))
		        {
		           h->Fill(p2.E);
		           if(abs(p2.E-p2.true_E) > 50) printf("%.3f %.3f %.3f %.3f\n", p2.true_E, p2.E, p2.eta, p2.isolTrack);
		        }
		    }
		}
	  }
   }
  
  for(int k = 0; k < n; ++k)
  {
      err[k] = NULL;
      elems[k] = 0;
  }
  
  for (unsigned a = 0; a < N; ++a)
  {
	  TTree *tree = trees[a];
	  for(unsigned int i = 0; i < count[a]; ++i)
	  {
		  tree->GetEntry(i);
		  TAxis *xaxis = h->GetXaxis();
		  int bin1 = xaxis->FindBin(p1.true_E)-1;
		  int bin2 = xaxis->FindBin(p2.true_E)-1;

		  if(keep_photon(p1) && bin1 >= 0 && bin1<n)
		  {
		      elems[bin1]++;
		  }
		  
		  if(keep_photon(p2) && bin2 >= 0 && bin2<n)
		  {
		      elems[bin2]++;
		  }
	  }
   }
  
  for(int k = 0; k < n; ++k)
  {
      err[k] = new double[elems[k]];
      index[k] = 0;
  }
  
  
  for (unsigned a = 0; a < N; ++a)
  {
	  TTree *tree = trees[a];
	  for(unsigned int i = 0; i < count[a]; ++i)
	  {
		  tree->GetEntry(i);
		  TAxis *xaxis = h->GetXaxis();
		  int bin1 = xaxis->FindBin(p1.true_E)-1;
		  int bin2 = xaxis->FindBin(p2.true_E)-1;
		  
		  

		  if(keep_photon(p1) && bin1 >= 0 &&  bin1 < n)
		  {
		      err[bin1][index[bin1]++] = p1.E-p1.true_E;
		  }
		  
		  if(keep_photon(p2) && bin2 >= 0 &&  bin2 < n)
		  {
		      err[bin2][index[bin2]++] = p2.E-p2.true_E;
		  }
	  }
   }
  
  for(int k = 0; k < n; ++k)
  {
      double mean = 0;
      for(int j = 0; j < elems[k]; ++j)
      {
         mean += err[k][j];
      }
      mean /= double(elems[k]);
      
      double tot = 0;
      //mean = 0;
      for(int j = 0; j < elems[k]; ++j)
      {
         //if(k == 2) printf("err: %.3f \n", err[k][j]);
         tot += (err[k][j]-mean) * (err[k][j]-mean);
      }
      tot /= double(elems[k]);
      double E = float(E_min + float(k)/float(n) * (E_max-E_min));
      /*printf("%.2f %.6f %.6f %.6f %% %.7f %% %.7f %d\n", E, float(mean), float(sqrt(tot)), 100 * float(sqrt(tot))/float(E), 100 * float(sqrt(tot))/float(E)/sqrt(index[k]-1), float(1)/float(n) * (E_max-E_min)/2.0, index[k]);*/
      printf("%.2f %.6f %% %.7f %% %.7f %d\n", E, 100 * float(sqrt(tot))/float(E), 100 * float(sqrt(tot))/float(E)/sqrt(index[k]-1), float(1)/float(n) * (E_max-E_min)/2.0, index[k]);
      en[k] = E;
      den[k] = 100 * float(sqrt(tot))/float(E);
      yerr[k] = 100 * float(sqrt(tot))/float(E)/sqrt(index[k]-1);
      xerr[k] = float(1)/float(n) * (E_max-E_min)/2.0;
  }
  
   TF1 *energy = new TF1("energy", " [0]/sqrt(x) + [1]", 100, 1000);
   TGraphErrors *gr = new TGraphErrors(n,en,den,xerr,yerr);
   gr->Fit("energy");
   gr->SetTitle("\\mbox{Resolution en energie};E\\mbox{ (GeV) };\\sigma_{E} / E \\mbox{ \\% }");
   gr->SetLineStyle(0);
   gr->SetLineWidth(0);
   /* h->Sumw2();
  h2->Sumw2();
  
  h->Fit("f1");

  TH1F *r = (TH1F *)h->Clone();
  r->Divide(h, h2, 1., 1., "B");
  //r->Draw();
  h->Draw();*/
  gr->Draw("AP");
  

  printf("tight ratio: %.6f\n", float(keptEntries)/float(totalEntries));
    /*h->Multiply(fa);
    h->Draw("E");*/
 // h->Draw(); // plot the histogram
  //h2->Draw();
}
Exemplo n.º 12
0
void PlotPhCal(const char *filename = "phCalibration_C0.dat", int col, int row)
{

  Init();

  int value, a, b, n;
  double x[10], y[10];
  char string[200];
  double aovergain, gain, par1;


  TF1 *pol2Fit = new TF1("pol2Fit", "pol2");
  pol2Fit->SetRange(50,500);
  TF1 *linFit = new TF1("linFit", "pol1");
  linFit->SetRange(150,600);
  TF1 *ursFit = new TF1("ursFit", Fitfcn, 40., 1500., 4);
  ursFit->SetParameter(0,0.00382);
  ursFit->SetParameter(1,0.886);
  ursFit->SetParameter(2,112.7);
  ursFit->SetParameter(3,113.0);


  TGraphErrors *graph = new TGraphErrors();
  TGraph *gSlope = new TGraph();

  FILE *inputFile = fopen(filename, "r");

  for (int i = 0; i < 4; i++) fgets(string, 200, inputFile);
  
  for (int icol = 0; icol < 52; ++icol)
    {
      for (int irow = 0; irow < 80; ++irow)
	{
	  n = 0;
	  for (int point = 0; point < 10; point++)
	    {
	      fscanf(inputFile, "%s", string);
	      
	      if (strcmp(string, "N/A") == 0)  value = 7777;
	      else 
		{
		  value  = atoi(string);
		}		      
	      if ((icol == col) && (irow == row))
		{

		  if (point == 0) x[n] = 50;
		  else if (point == 1) x[n] = 100;
		  else if (point == 2) x[n] = 150;
		  else if (point == 3) x[n] = 200;
		  else if (point == 4) x[n] = 250;
		  else if (point == 5) x[n] = 210;
		  else if (point == 6) x[n] = 350;
		  else if (point == 7) x[n] = 490;
		  else if (point == 8) x[n] = 560;
		  else if (point == 9) x[n] = 1400;
		  
		  if (value != 7777)
		    {
		      //  y[n] = value;  // in testboard adc range
		      y[n] = (value + 400) / 7;  // in 8 bit experiment adc range
		      graph->SetPoint(n, x[n], y[n]);	
		      //  graph->SetPointError(n, 2, 10);   // in testboard adc range
		      graph->SetPointError(n, 2, 10/6);   // in 8 bit experiment adc range

		      n++;
		    }
		}
	    }
	  fscanf(inputFile, "%s %2i %2i", string, &a, &b);  //comment
	}
    }
  graph->GetXaxis()->SetTitle("Vcal [low range DAC units]");
  graph->GetYaxis()->SetTitle("PH [ADC units]");
  graph->GetYaxis()->SetTitleOffset(1.2);


  graph->GetXaxis()->SetTitleSize(0.055);
  graph->GetYaxis()->SetTitleSize(0.055);
  graph->GetXaxis()->SetLabelSize(0.04);
  graph->GetYaxis()->SetLabelSize(0.05);
  graph->GetXaxis()->SetTitleOffset(1.15);
  graph->GetYaxis()->SetTitleOffset(1.2);
  graph->SetTitle("");
  graph->SetLineStyle(1);
  graph->SetLineWidth(2);

  //   graph->Fit("linFit","R");
//   gain = linFit->GetParameter(1);


  graph->Fit("ursFit","R");
  graph->Draw("A*");
  par1 = ursFit->GetParameter(1);

  
  NewLatex()->DrawLatex(0.55, 0.5, Form("p_{1} = %.1f ", par1));
  //  NewLatex()->DrawLatex(0.45, 0.4, "NON-LINEAR pixel");       // PlotPhCal("/home/l_tester/ptr/moduleDB/M0567-070115.08:23/T-10a/phCalibration_C12.dat",7,23)
  NewLatex()->DrawLatex(0.5, 0.4, "LINEAR pixel");                // PlotPhCal("/home/l_tester/ptr/moduleDB/M0493-061206.10:45/T-10a/phCalibration_C1.dat",7,23)
}
Exemplo n.º 13
0
void CommandMSUGRA(TString plotName_,Int_t tanBeta_, Bool_t plotLO_){
  
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  
  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  TString tanb( tmp.str() );
  
  // Output file
  cout << " create " << plotName_ << endl;
  TFile* output = new TFile( plotName_, "RECREATE" );
  if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  
  //-----------------------------------
  //set old exclusion Limits
  //-----------------------------------

  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);             //slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);     //squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);       //squark gluino d0
  //TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_); //trilepton cdf
  //TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);   //trilepton d0
  TGraph* stau = set_tev_stau(tanBeta_);             //stau 
  //TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  //-----------------------------------
  // constant sqquark and gluino lines
  //-----------------------------------

  const unsigned int nlines = 4;

  TF1* lnsq[nlines];
  TF1* lngl[nlines];
  
  TLatex* sq_text[nlines];
  TLatex* gl_text[nlines];

  for(unsigned int i = 0; i < nlines; i++){
    lnsq[i]    = constant_squark(tanBeta_,i);
    sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
    lngl[i]    = constant_gluino(tanBeta_,i);
    gl_text[i] = constant_gluino_text(i,*lngl[i]);
  }

  //-----------------------------------
  // Legends
  //-----------------------------------

  TLegend* legst     = makeStauLegend(0.05,tanBeta_);
  TLegend* legexp    = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  //TLegend* legNoEWSB = makeNoEWSBLegend(0.05,tanBeta_);

  //-----------------------------------
  // make Canvas
  //-----------------------------------

  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,500);
  //cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);
  cvsSys->SetTitle("tan#beta="+tanb);
 
  output->cd();
  
  //and now
  //the exclusion limits
  TGraphErrors* First ;
  //TGraphErrors* FirstDummy ;
  TGraphErrors* Second;
  TGraphErrors* Third;
  TGraphErrors* Second_up;
  TGraphErrors* Second_low;
  TGraphErrors* expband;
  TGraphErrors* obs2010;

  if (tanBeta_		== 3) {
    //First		= getObserved_NLOunc();
    //FirstDummy	= getObserved_NLOunc();
  } else {
    //First		= getNLOobsTanbeta10();
    //First		= getNLOobsTanbeta10_smooth();
    //First		= getNLOobsTanbeta10_funky();
    First		= getNLOobsTanbeta10();
    //FirstDummy	= getObserved_NLOunc();
    //Second		= getNLOexpTanbeta10();
    Second		= getNLOexpTanbeta10();
    Second_up		= getNLOexpUpTanbeta10();
    Second_low		= getNLOexpDownTanbeta10();
    Third		= getNLOexpTanbeta10();
    expband		= getNLOexpTanbeta10_band();
    obs2010		= getNLOobsTanbeta10_2010();
    //Second_up		= getExpected_NLO_tanBeta3_up();
    //Second_low	= getExpected_NLO_tanBeta3_low();
  }
  //Third		= getExpected_NLOunc();//getLO_jetMultis();
  //Second		= getLO_signalCont();

  TGraph *grObserved3p5_shape = getObserved3p5_shape();
  TGraph *grExpected3p5_shape = getExpected3p5_shape();

//   First->SetMarkerColor(kWhite);
//   First->GetXaxis()->SetRangeUser(2.,500.);
//   First->GetYaxis()->SetRangeUser(80,500);
//   if(tanBeta_ == 50) First->GetXaxis()->SetRangeUser(200,500);
//   First->GetXaxis()->SetTitle("m_{0} (GeV)");
//   First->GetYaxis()->SetTitle("m_{1/2} (GeV)");
//   First->GetYaxis()->SetTitleOffset(0.8);

  double m0min = 0;
  if (tanBeta_ == 50) m0min=200;
  TH2D* hist = new TH2D("h","h",100,m0min,m0max,100,120,m12max);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} (GeV/c^{2})");
  hist->GetYaxis()->SetTitle("m_{1/2} (GeV/c^{2})");
  hist->GetYaxis()->SetTitleOffset(1.);
  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  //int col[]={2,3,4};

  
  //TFile *f = TFile::Open("exclusion_Spring11_CLs.root");        
  //TFile *f = TFile::Open("exclusion_Fall10_tcmet_JPT.root"); 
  //TFile *f = TFile::Open("exclusion_Fall10_pfmet_pfjets.root"); 
  //TFile *f = new TFile("exclusion_Fall10_pfmet_pfjets_CLs.root");
  
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_obs");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_exp");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expp1");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expm1");

  //h->SetMaximum(3);
  //h->Draw("samecolz");
  
  TSpline3 *sFirst = new TSpline3("sFirst",First);
  sFirst->SetLineColor(kRed);
  sFirst->SetLineWidth(3);
  First->SetLineColor(kRed);
  First->SetLineWidth(3);

  TSpline3 *sSecond = new TSpline3("sSecond",Second);
  sSecond->SetLineColor(kBlue);
  sSecond->SetLineStyle(2);
  sSecond->SetLineWidth(3);
  Second->SetLineColor(kBlue);
  Second->SetLineStyle(2);
  Second->SetLineWidth(3);

  TSpline3 *sSecond_up = new TSpline3("sSecond_up",Second_up);
  sSecond_up->SetLineColor(kCyan);
  sSecond_up->SetLineStyle(1);
  sSecond_up->SetLineWidth(3);
  Second_up->SetLineColor(kBlue);
  //Second_up->SetLineColor(1);
  Second_up->SetLineWidth(2);

  TSpline3 *sSecond_low = new TSpline3("sSecond_low",Second_low);
  sSecond_low->SetLineColor(kCyan);
  sSecond_low->SetLineStyle(1);
  sSecond_low->SetLineWidth(3);
  Second_low->SetLineColor(kBlue);
  //Second_low->SetLineColor(1);
  Second_low->SetLineWidth(2);

  Third->SetLineColor(kCyan);
  Third->SetLineWidth(30);

  
  // TSpline3 *sThird = new TSpline3("sThird",Third);
  // sThird->SetLineColor(kGreen+2);
  // sThird->SetLineStyle(4);
  // sThird->SetLineWidth(3);
  // Third->SetLineColor(kGreen+2);
  // Third->SetLineStyle(4);
  // Third->SetLineWidth(3);

  //  First->Draw("AP");
  
  /*
 for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy();
	(*at)->SetTitle("tan#beta="+tanBeta_);
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }*/

  
  TLegend* myleg;

  if( plotLO_ ) myleg = new TLegend(0.3,0.75,0.54,0.9,NULL,"brNDC");
  else          myleg = new TLegend(0.25,0.75,0.54,0.9,NULL,"brNDC");



  myleg->SetFillColor(0); 
  myleg->SetShadowColor(0);
  myleg->SetTextSize(0.03);
  myleg->SetBorderSize(0);
  
  TH1F* hdummy = new TH1F();
  hdummy->SetLineColor(4);
  hdummy->SetFillColor(4);
  hdummy->SetFillStyle(3002);
  hdummy->SetLineWidth(2);
  hdummy->SetLineStyle(2);

  //  myleg->AddEntry(sSecond,"NLO Expected Limit","L");
  if (tanBeta_ == 3 && plotLO_) {
    myleg->AddEntry(sSecond,"LO Observed Limit","L");
    myleg->AddEntry(sFirst,"NLO Observed Limit","L"); 
  } else {
    //myleg->AddEntry(sFirst,"CMS OS Dilepton Limit","L"); 
    myleg->AddEntry(sFirst,"NLO observed limit","L"); 
    //myleg->AddEntry(hdummy,"NLO expected limit","LF"); 
    myleg->AddEntry(hdummy,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond_up,"NLO expected limit (+/-1#sigma)","L"); 
    myleg->AddEntry(obs2010,"2010 NLO observed limit","L"); 
  }
  
  //sSecond_up->Draw("h same");
  //sSecond_low->Draw("h same");
      
 
  //constant squark and gluino mass contours
  for (unsigned int it=1;it<nlines;it++) {   
    lngl[it]->Draw("same");   
    lnsq[it]->Draw("same");
    sq_text[it]->Draw();
    gl_text[it]->Draw();
  }

  sSecond_up->SetFillStyle(4010);
  sSecond_up->SetFillColor(kCyan-10);

  sSecond_low->SetFillStyle(1001);
  sSecond_low->SetFillColor(10);

  //expected and observed (LO & NLO) contours
  //sFirst->Draw("same");    
  //sSecond->Draw("same");   
  //sThird->Draw("same");
  //Third->Draw("samec");

  //expband->Draw("samecf"); // summer11 expected band
  //First->Draw("samec");    // summer11 observed exclusion
  
  //First->SetMarkerColor(1);
  //First->Draw("samep");
  //Second->Draw("samec");   // summer11 expected limit
  obs2010->Draw("samec");
  //Second_up->Draw("samec");
  //Second_low->Draw("samec");

  grObserved3p5_shape->SetLineColor(2);
  grExpected3p5_shape->SetLineColor(4);
  grExpected3p5_shape->SetLineStyle(2);
  grObserved3p5_shape->Draw("same");
  grExpected3p5_shape->Draw("same");

  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");

   
    
  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  LEP_ch->Draw("fsame");
  if (tanBeta_ != 50) LEP_sl->Draw("fsame");

  //remove CDF/D0 excluded regions
  TEV_sg_cdf->Draw("fsame");
  TEV_sg_d0->Draw("same");  
  TEV_sg_d0->Draw("fsame");


  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 50) xposi = 100;
  if(tanBeta_ == 50) xpos = 200;
  if(tanBeta_ == 50) ypos = -10;
  
  //TLatex* lumilabel = new TLatex(135.+xposi,510.,"L_{int} = 34 pb^{-1}, #sqrt{s} = 7 TeV");
  //TLatex* lumilabel = new TLatex(305.+xposi + 100,510.,"L_{int} = 976 pb^{-1}, #sqrt{s} = 7 TeV");
  TLatex* lumilabel = new TLatex(490,m12max+15,"#sqrt{s} = 7 TeV, #scale[0.6]{#int} L dt = 3.5 fb^{-1}");

  lumilabel->SetTextSize(0.05);
  lumilabel->Draw("same");

  TLatex* cmslabel = new TLatex(10.,m12max+15,"CMS Preliminary");
  cmslabel->SetTextSize(0.05);
  cmslabel->Draw("same");

  TString text_tanBeta;
  //text_tanBeta =  "tan#beta = "+tanb+", A_{0} = 0, sign(#mu) > 0";
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = 0,  #mu > 0";
  //TLatex* cmssmpars = new TLatex(70.+xpos,340.+ypos,text_tanBeta);
 
  TLatex* cmssmpars = new TLatex(120,540,text_tanBeta);
  //TLatex* cmssmpars = new TLatex(200,370,text_tanBeta);
  cmssmpars->SetTextSize(0.045);

  cmssmpars->Draw("same");

  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }
  if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
  }

    /*
   Int_t n = 0;
    for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy("same");
	(*at)->SetTitle("tan#beta=3");
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }
  
    */



  //stau=LSP contour
  stau->Draw("fsame");
  //NoEWSB->Draw("fsame");

  //legends
  legexp->Draw();
  legst->Draw();
  myleg->Draw();
  //legNoEWSB->Draw();

  //First->Draw("samec");
  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");
  
  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  cvsSys->Write();
  
  if( plotLO_ ){
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.png");
  }else{
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".eps");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".png");
  }
  
  output->Write();
  //output->Close();
  //delete output; 
  
}