示例#1
0
void plotRate(){
  //TFile * f_ttbar= new TFile("ttbar-output-2014-06-22.root");
  TFile * f= new TFile("./rateTest.root");
  std::vector<TString> jetnum;
  //jetnum.push_back("0");
  //jetnum.push_back("1");
  //jetnum.push_back("2");
  jetnum.push_back("3");
  std::vector<TString> truejetnum;
  //truejetnum.push_back("1");
//  truejetnum.push_back("2");
//  truejetnum.push_back("3");
  truejetnum.push_back("4");
  //jetType.push_back("calib_gct");
  int i = -1;
  for (iNum = jetnum.begin();iNum != jetnum.end(); iNum++)
  {
    i++;
    std::cout <<"jetNumber_"+*iNum+"/5400_calib_nopus_"+*iNum+"_Rate" << std::endl;
    TH1D* nopus = f->Get("jetNumber_"+*iNum+"/5400_calib_nopus_"+*iNum+"_Rate");
    TH1D* donutseed = f->Get("jetNumber_"+*iNum+"/5450_calib_donut_"+*iNum+"_Rate");
    TH1D* nopusseed = f->Get("jetNumber_"+*iNum+"/5450_calib_nopus_"+*iNum+"_Rate");
    TH1D* global = f->Get("jetNumber_"+*iNum+"/5400_calib_global_"+*iNum+"_Rate");
    TH1D* gct = f->Get("jetNumber_"+*iNum+"/gct_calib_gen_"+*iNum+"_Rate");


    TLegend* leg = new TLegend(0.55,0.55,0.85,0.85);
    leg->SetFillColor(0);
    TCanvas * c = new TCanvas("Turn on Curve "+*iNum+" (p_{T} ","",600,600);

    c->cd();
    nopus->GetXaxis()->SetTitle("Pt/GeV");
    nopus->SetTitle("");
    gStyle->SetOptStat(0);
    nopus->GetXaxis()->SetTitleOffset(1.4);
    nopus->GetYaxis()->SetTitle("Rate for jet "+truejetnum.at(i)+"/Hz");
    nopus->GetYaxis()->SetTitleOffset(1.4);
    nopus->SetLineColor(1);
    nopus->GetXaxis()->SetRangeUser(25,45);
    nopusseed->SetLineStyle(2);
    donutseed->SetLineColor(2);
    donutseed->SetMarkerColor(2);
    global->SetLineColor(4);
    gct->SetLineColor(8);
    global->SetMarkerColor(4);
    nopus->Draw();
    nopusseed->Draw("same");
    donutseed->Draw("same");
    global->Draw("same");
    gct->Draw("same");
    leg->AddEntry(nopus,"No PUS","l");
    leg->AddEntry(nopusseed,"No PUS (Seed 5)","l");
    leg->AddEntry(donutseed,"Donut Sub (Seed 5)","l");
    leg->AddEntry(global,"Global Sub","l");
    leg->AddEntry(gct,"GCT","l");
    leg->Draw("L");
    c->SaveAs("output/cmsweek/rate"+*iNum+".png");
  }
  return;
}
示例#2
0
文件: invertedMuonID.C 项目: Bmm4/Bmm
// ----------------------------------------------------------------------
void plotRatioRaw(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatioRaw("2011");
    plotRatioRaw("2012");
    plotRatioRaw("2016BF");
    plotRatioRaw("2016GH");
    return;
  }


  double eps(0.00001);
  TH1D *hresult = new TH1D("hresult", Form("%s", era.c_str()), 80, 0., 0.4);
  hresult->GetXaxis()->SetTitle("BDT > ");
  hresult->SetMarkerStyle(24); hresult->SetLineColor(kRed+2); hresult->SetMarkerColor(kRed+2);
  TH1D *hsresult = new TH1D("hsresult", Form("%s", era.c_str()), 80, 0.+eps, 0.4+eps);
  hsresult->SetMarkerStyle(25); hsresult->SetLineColor(kBlue);  hsresult->SetMarkerColor(kBlue);

  TH1D *hbdtcut = new TH1D("hbdtcut", Form("%s", era.c_str()), 80, 0., 0.4);
  hbdtcut->SetMarkerColor(kRed+2);  hbdtcut->SetMarkerStyle(20);
  TH1D *hsbdtcut = new TH1D("hsbdtcut", Form("%s", era.c_str()), 80, 0.+eps, 0.4+eps);
  hsbdtcut->SetMarkerColor(kBlue);  hsbdtcut->SetMarkerStyle(21);

  invertedMuonIDRaw(era, 0.15, hresult, hsresult);
  invertedMuonIDRaw(era, 0.20, hresult, hsresult);
  invertedMuonIDRaw(era, 0.25, hresult, hsresult);
  invertedMuonIDRaw(era, 0.30, hresult, hsresult);
  invertedMuonIDRaw(era, -99., hbdtcut, hsbdtcut);

  c0->Clear();
  double ymax(50.);
  double smax = hresult->GetMaximum();
  double dmax = hsresult->GetMaximum();
  double themax = (smax>dmax? smax: dmax);
  if (themax < 50.)  ymax = 50.;
  if (themax < 20.)  ymax = 30.;
  if (themax < 5.)  ymax = 10.;
  if (themax < 0.5) ymax = 1.0;
  hresult->SetMinimum(-ymax);
  hresult->SetMaximum(ymax);
  hresult->Draw();
  hsresult->Draw("same");
  hbdtcut->Draw("same");
  hsbdtcut->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);

  TLegend *tle = new TLegend(0.25, 0.2, 0.50, 0.5);
  tle->SetFillStyle(0);
  tle->SetBorderSize(0);
  tle->SetHeader(era.c_str());
  tle->AddEntry(hresult, "yield at B0", "p");
  tle->AddEntry(hsresult, "yield at Bs", "p");
  tle->Draw();

  c0->SaveAs(Form("invertedMuonIDRaw-%s-result.pdf", era.c_str()));
}
示例#3
0
void testCorr3D(Int_t corrLevel=0,
    TString mod="B2InConeGluon",
    TString modref="B2InConeQuark",
    TString app="_jtv3_2_cv4qg",
    TString appref="_jtv3_2_cv4qg",
    Int_t isample=0, // -1 for all samples
    Int_t etaPM=2 // +/- 2 for |eta|<1
    )
{
  Int_t mode=1; // 0 for write, 1 for read
  Int_t cbin=0;
  Float_t ptHatMin=110;

  Corrector3D trkCorr("trkCorrHisAna_djuq",app,mod);
  trkCorr.ptHatMin_.clear();
  trkCorr.ptHatMin_.push_back(ptHatMin);
  trkCorr.sampleMode_ = 0; // 0 for choosing individual sample, 1 for merge samples
  trkCorr.Init();
  Double_t corr[4];
  cout << trkCorr.GetCorr(10,0,110,0,corr) << endl;

  Corrector3D trkCorrRef("trkCorrHisAna_djuq",appref,modref);
  trkCorrRef.ptHatMin_.clear();
  trkCorrRef.ptHatMin_.push_back(ptHatMin);
  trkCorrRef.sampleMode_ = 0; // 0 for choosing individual sample, 1 for merge samples
  trkCorrRef.Init();

  /*
  // Plot 2D Corr.
  gStyle->SetPadRightMargin(0.15);

  TCanvas * c2 = new TCanvas("c2","c2",500,500);
  TH2D *hCorr2D = (TH2D*)trkCorr.InspectCorr(corrLevel,isample,cbin,4,30,0);
  hCorr2D->Draw("colz");
  */

  TCanvas * cEff = new TCanvas("cEff","cEff",500,500);
  TH1D * hCorrPtRef = (TH1D*) trkCorrRef.InspectCorr(corrLevel,isample,cbin,3,15,2,7-etaPM,7+etaPM);
  hCorrPtRef->SetAxisRange(0,120,"X");
  hCorrPtRef->SetMarkerStyle(0);
  hCorrPtRef->SetMarkerColor(kBlack);
  hCorrPtRef->SetLineColor(kBlack);
  hCorrPtRef->Draw("histE");
  TH1D * hCorrPt = (TH1D*) trkCorr.InspectCorr(corrLevel,isample,cbin,3,15,2,7-etaPM,7+etaPM);
  hCorrPt->SetMarkerStyle(0);
  hCorrPt->SetMarkerColor(kRed);
  hCorrPt->SetLineColor(kRed);
  hCorrPt->Draw("hist same E");

  /*
  TCanvas * cEffEta = new TCanvas("cEffEta","cEffEta",500,500);
  TH1D * hCorrEta = (TH1D*)trkCorr.InspectCorr(corrLevel,isample,cbin,4,30,1);
  hCorrEta->Draw("histE");
  */
}
示例#4
0
void anaFragShape(TString infile="dj_HCPR-GoodTrkAndPixel_CleanEvt1130.root")
{
  TChain * djcalo = new TChain("djcalo/djTree");
  djcalo->Add(infile);
  aliases_dijet(djcalo);
  TChain * djcalopix = new TChain("djcalo_pxl/djTree");
  djcalopix->Add(infile);
  aliases_dijet(djcalopix);
  TString evtSel("(cent<10 && nljet>120 && abs(nljeta)<2 && aljet>50 && abs(aljeta)<2 && jdphi>2.5 && Aj>0.24)");
  TH1::SetDefaultSumw2();

  TCanvas * c0 = new TCanvas("c0","c0",500,500);
  djcalo->Draw("Aj>>hAj(20,0,1)",evtSel);
  djcalopix->Draw("Aj",evtSel,"Esame");

  TCanvas * c2 = new TCanvas("c2","c2",500,500);
  TH1D * hJDPhi = new TH1D("hJDPhi","hJDPhi",50,0,3.1416);
  TH1D * hJDPhi2 = new TH1D("hJDPhi2","hJDPhi",50,0,3.1416);
  Float_t numDJ = djcalo->Draw("jdphi>>hJDPhi",evtSel);
  Float_t numDJ2 = djcalopix->Draw("jdphi>>hJDPhi2",evtSel);
  cout << "num djs: " << numDJ << "  djs(pix)" << numDJ2 << endl;

  TH1D * hPNDRTrk = new TH1D("hPNDRTrk",";R(trk,jet);1/(N_{DJ} 2#piR) dp_{T}^{Trk}/dR",10,0,TMath::PiOver2());
  TH1D * hPNDRPix = new TH1D("hPNDRPix",";R(trk,jet);1/(N_{DJ} 2#piR) dp_{T}^{Trk}/dR",10,0,TMath::PiOver2());
  TH1D * hPADRTrk = new TH1D("hPADRTrk",";R(trk,jet);1/(N_{DJ} 2#piR) dp_{T}^{Trk}/dR",10,0,TMath::PiOver2());
  TH1D * hPADRPix = new TH1D("hPADRPix",";R(trk,jet);1/(N_{DJ} 2#piR) dp_{T}^{Trk}/dR",10,0,TMath::PiOver2());
  djcalo->Draw("pndr>>hPNDRTrk",Form("(%s&&ppt>=1.2)*(ppt/(TMath::TwoPi()*pndr))",evtSel.Data()));
  djcalopix->Draw("pndr>>hPNDRPix",Form("(%s&&ppt>=0.3&&ppt<1.2)*(ppt/(TMath::TwoPi()*pndr))",evtSel.Data()));
  djcalo->Draw("padr>>hPADRTrk",Form("(%s&&ppt>=1.2)*(ppt/(TMath::TwoPi()*padr))",evtSel.Data()));
  djcalopix->Draw("padr>>hPADRPix",Form("(%s&&ppt>=0.3&&ppt<1.2)*(ppt/(TMath::TwoPi()*padr))",evtSel.Data()));
  hPNDRTrk->Scale(1./(numDJ*hPNDRTrk->GetBinWidth(1)));
  hPNDRPix->Scale(1./(numDJ*hPNDRPix->GetBinWidth(1)));
  hPADRTrk->Scale(1./(numDJ*hPADRTrk->GetBinWidth(1)));
  hPADRPix->Scale(1./(numDJ*hPADRPix->GetBinWidth(1)));
  hPNDRPix->SetMinimum(50);
  hPNDRPix->SetMaximum(100);
  hPNDRTrk->SetMinimum(10);
  hPNDRTrk->SetMaximum(2000);
  hPNDRPix->SetMarkerStyle(kFullCircle);
  hPNDRTrk->SetMarkerStyle(kFullSquare);
  hPNDRPix->SetMarkerColor(kRed);
  hPNDRTrk->SetMarkerColor(kRed);
  hPADRPix->SetMarkerStyle(kOpenCircle);
  hPADRTrk->SetMarkerStyle(kOpenSquare);
  hPADRPix->SetMarkerColor(kBlue);
  hPADRTrk->SetMarkerColor(kBlue);
  TCanvas * c3 = new TCanvas("c3","c3",500,500);
  hPNDRPix->Draw("E");
  hPADRPix->Draw("Esame");
  TCanvas * c3_2 = new TCanvas("c3_2","c3_2",500,500);
  c3_2->SetLogy();
  hPNDRTrk->Draw("E");
  hPADRTrk->Draw("Esame");
}
示例#5
0
void ptDependence()
{
   TFile *inf = new TFile("histos/ppMC.root");
   TTree *t = (TTree*) inf->Get("nt");

   const int nBins = 4;
   double ptBin[nBins+1] = {100,120,140,160,200};
//   const int nBins = 1;
//   double ptBin[nBins+1] = {100,400};
   
   TH1D *hProb = new TH1D("hProb","",nBins,ptBin);
   TH1D *hCSV = new TH1D("hCSV","",nBins,ptBin);
   TH1D *hSVTXM = new TH1D("hSVTXM","",nBins,ptBin);
   TProfile *pGen = new TProfile("pGen","",nBins,ptBin);
   
   for (int n=0; n<nBins;n++)
   {
      RooRealVar f1 = bfractionFit("discr_prob",0,3.5,ptBin[n],ptBin[n+1]);
      RooRealVar f2 = bfractionFit("discr_csvSimple",0,1,ptBin[n],ptBin[n+1]);
      RooRealVar f3 = bfractionFit("svtxm",0,6,ptBin[n],ptBin[n+1]);
      hProb->SetBinContent(n+1,f1.getVal());    
      hProb->SetBinError(n+1,f1.getError());    
      hCSV->SetBinContent(n+1,f2.getVal());    
      hCSV->SetBinError(n+1,f2.getError());    
      hSVTXM->SetBinContent(n+1,f3.getVal());    
      hSVTXM->SetBinError(n+1,f3.getError());    
   }
   
   TCanvas *c2 = new TCanvas("c2","",600,600);
   hProb->SetAxisRange(0,0.05,"Y");
   hProb->SetXTitle("Jet p_{T} (GeV/c)");
   hProb->SetYTitle("b-jet fraction");
   hProb->SetTitleOffset(1.5,"Y");
   hProb->Draw();
   hCSV->SetLineColor(2);
   hCSV->SetMarkerColor(2);
   hCSV->SetMarkerStyle(24);
   hCSV->Draw("same");
   hSVTXM->SetLineColor(4);
   hSVTXM->SetMarkerColor(4);
   hSVTXM->SetMarkerStyle(24);
//   hSVTXM->Draw("same");
   t->Draw("abs(refparton_flavorForB)==5:jtpt","","prof same");
   
   TLegend *leg = new TLegend(0.2,0.7,0.5,0.9);
   leg->SetBorderSize(0);
   leg->SetFillStyle(0);
   leg->SetFillColor(0);
   leg->AddEntry(hProb,"Jet Probability","pl");
   leg->AddEntry(hCSV,"CSV","pl");
//   leg->AddEntry(hSVTXM,"SV mass","pl");
   leg->Draw();
}
示例#6
0
文件: Drawhisto.C 项目: XuQiao/HI
void Drawhisto() {
    gStyle->SetOptStat(kFALSE);
    gStyle->SetErrorX(0);
    TFile *fin = TFile::Open("PythiaMBhistos.root");
    TH1D* hratioplus = (TH1D*)fin->Get("NjetratioPlus");
    TCanvas *c1 = new TCanvas();
    c1->SetTickx(1);
    c1->SetTicky(1);
    hratioplus->GetXaxis()->SetTitle("#Sigma E_{T} (2.9<#eta<5.2) (GeV)");
    hratioplus->GetXaxis()->SetRangeUser(0,30);
    hratioplus->GetYaxis()->SetRangeUser(0,0.07);
    hratioplus->GetYaxis()->SetTitle("N_{jet}/N_{evt}");
    hratioplus->SetMarkerSize(1);
    hratioplus->SetMarkerStyle(20);
    hratioplus->SetMarkerColor(1);
    hratioplus->SetLineColor(1);
    hratioplus->Draw("P");
    TLatex *tl = new TLatex();
    tl->SetTextSize(0.045);
    tl->SetNDC();
    TLegend *tg = new TLegend(0.15,0.7,0.6,0.75);
    tg->SetTextSize(0.045);
    tg->SetFillColor(0);
    tg->SetBorderSize(0);
    tg->AddEntry(hratioplus,"5.02TeV, Z2Star Tune");
    tg->Draw("same");
    tl->DrawLatex(0.2,0.85,"Pythia 6");
    tl->DrawLatex(0.2,0.8,"anti-k_{T} R=0.3 PF jets, E_{T} > 20 GeV, |#eta| < 2.8");
    c1->Print("jetYratioHFPlus.png");
    c1->Print("jetYratioHFPlus.pdf");
}
示例#7
0
void mult()
{
  //TFile* f = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_pixeltracks_INCLMULT_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin500_centmax1000.root");
  TFile* f = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_pixeltracks_INCLMULTUCC010_nmin-1_nmax-1_etatrg-2.4-2.4_etaass-2.4-2.4_centmin-1_centmax-1.root");

  TNtuple* h = (TNtuple*)f->Get("higeninfontuple");
 
  TH1D* hMultAll = new TH1D("hMultAll",";nMult",300,0,6000); 
  TH1D* hMult = new TH1D("hMult",";nMult",300,0,6000);
  TH1D* hMult010 = new TH1D("hMult010",";nMult",300,0,6000);
  TH1D* hMult001 = new TH1D("hMult001",";nMult",300,0,6000);

  higeninfontuple->Draw("nmult>>hMultAll","","GOFF");
  higeninfontuple->Draw("nmult>>hMult","(7.0*hft+zdc)<36000","GOFF");
  higeninfontuple->Draw("nmult>>hMult010","(7.0*hft+zdc)<36000 && npixel>51400 && hft>3260","GOFF");
  higeninfontuple->Draw("nmult>>hMult001","(7.0*hft+zdc)<36000 && npixel>53450 && hft>3393","GOFF");

  hMult->SetMarkerColor(kRed);
  hMult010->SetMarkerColor(kBlue);
  hMult001->SetMarkerColor(kGreen);

  TCanvas* c = new TCanvas("c","c",550,500);
  c->SetLogy();
  hMultAll->Draw("PE");
  hMult->Draw("PESAME");
  hMult010->Draw("PESAME");
  hMult001->Draw("PESAME");
}
TH1D* Prediction::GetRatio(TH1D* h1, TH1D* h2, int mergenbins, bool binomial){
	// compute Zll/Photon ratio
	*fLogStream << "------------------------------------------------------------------------" << endl;
	*fLogStream << "Compute ratio between " << h1->GetName() << " and " << h2->GetName()      << endl;           

	
	if(h1==0 || h2==0 ){
		cout << "GetMCZnunuToPhotonRatio: received 0 pointer!" << endl;
		exit(-1);
	}

	// GetScaled histos with only one bin and probagated errors: stat error and error on scale factor
	TH1D *currh1   = GetScaledHisto(h1, 1, 0, mergenbins); 
	TH1D *currh2   = GetScaledHisto(h2, 1, 0, mergenbins); 

	TString name = h1->GetName();
	name         += "_";
	name         += h2->GetName();
	name         += "_Ratio";
	TH1D *ratio = (TH1D*) currh1->Clone(name);
	ratio->Divide(currh1, currh2, 1,1, binomial?"B":""); // binomial errors
	
	ratio->SetLineColor(kBlack);
	ratio->SetMarkerColor(kBlack);
	ratio->SetMarkerStyle(4);

	if(fWriteToFile){
		ratio ->Write();
	}
	delete currh1;
	delete currh2;
	return ratio;
}
示例#9
0
文件: invertedMuonID.C 项目: Bmm4/Bmm
// ----------------------------------------------------------------------
void plotRatio(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatio("2011");
    plotRatio("2012");
    plotRatio("2016BF");
    plotRatio("2016GH");
    return;
  }


  TH1D *hresult = new TH1D("hresult", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hresult->GetXaxis()->SetTitle("BDT > ");
  TH1D *hbdtcut = new TH1D("hbdtcut", Form("n(gauss(5.28))/n(gauss(5.37)) %s", era.c_str()), 40, 0., 0.4);
  hbdtcut->SetMarkerColor(kBlue);
  invertedMuonID(era, 0.15, hresult);
  invertedMuonID(era, 0.20, hresult);
  invertedMuonID(era, 0.25, hresult);
  invertedMuonID(era, 0.30, hresult);
  invertedMuonID(era, -99., hbdtcut);

  c0->Clear();
  double ymax(50.);
  if (hresult->GetMaximum() < 5.)  ymax = 10.;
  if (hresult->GetMaximum() < 0.5) ymax = 1.0;
  hresult->SetMinimum(-ymax);
  hresult->SetMaximum(ymax);
  hresult->Draw();
  hbdtcut->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);
  c0->SaveAs(Form("invertedMuonID-%s-result.pdf", era.c_str()));
}
示例#10
0
文件: invertedMuonID.C 项目: Bmm4/Bmm
// ----------------------------------------------------------------------
void plotRatio2Comb(string era = "2016BF") {
  gStyle->SetOptStat(0);

  if (era == "all") {
    plotRatio2Comb("2011");
    plotRatio2Comb("2012");
    plotRatio2Comb("2016BF");
    plotRatio2Comb("2016GH");
    return;
  }

  double eps(0.00001);
  TH1D *hresultBd = new TH1D("hresultBd", era.c_str(), 80, 0., 0.4);
  TH1D *hresultBs = new TH1D("hresultBs", era.c_str(), 80, 0.+eps, 0.4+eps);
  hresultBd->GetYaxis()->SetTitle("a.u.");
  hresultBd->GetXaxis()->SetTitle("BDT > "); hresultBd->SetMarkerStyle(24); hresultBd->SetLineColor(kRed+2); hresultBd->SetMarkerColor(kRed+2);
  hresultBs->GetXaxis()->SetTitle("BDT > "); hresultBs->SetMarkerStyle(25); hresultBs->SetLineColor(kBlue);  hresultBs->SetMarkerColor(kBlue);
  TH1D *hbdtcutBd = new TH1D("hbdtcutbd", "", 80, 0., 0.4);
  TH1D *hbdtcutBs = new TH1D("hbdtcutBs", "", 80, 0.+eps, 0.4+eps);
  hbdtcutBs->SetMarkerColor(kBlue);  hbdtcutBd->SetMarkerStyle(24); hbdtcutBs->SetLineColor(kBlue);
  hbdtcutBd->SetMarkerColor(kRed+2); hbdtcutBd->SetMarkerStyle(25); hbdtcutBd->SetLineColor(kRed+2);

  invertedMuonID2Comb(era, 0.15, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.20, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.25, hresultBd, hresultBs);
  invertedMuonID2Comb(era, 0.30, hresultBd, hresultBs);
  invertedMuonID2Comb(era, -99., hbdtcutBd, hbdtcutBs);

  c0->Clear();
  double ymax(5.);
  hresultBd->SetMinimum(-ymax);
  hresultBd->SetMaximum(ymax);
  hresultBd->Draw();
  hbdtcutBd->Draw("same");
  pl->DrawLine(0., 0., 0.4, 0.);

  tl->SetTextSize(0.035);
  tl->SetTextColor(kRed+2); tl->DrawLatexNDC(0.2, 0.85, "n(gauss(5.28))/combinatorial");
  tl->SetTextColor(kBlue);  tl->DrawLatexNDC(0.2, 0.81, "n(gauss(5.37))/combinatorial");
  tl->SetTextColor(kBlack);

  hresultBs->Draw("same");
  hbdtcutBs->Draw("same");

  c0->SaveAs(Form("invertedMuonID2Comb-%s-result.pdf", era.c_str()));

}
void plotCorrectionGenNested(){

	for(int deta = 0; deta < NdEtaBins+1; deta++){
		dEtaBins[deta] = dEtaBins[deta] - 0.00001;//fix bin boundary
	}


	TFile* file = new TFile("../rootfiles/CME_QvsdEta_pPb_EPOS_GEN_NestedLoop_v3.root");

	TH1D* QvsdEta[48];

	for(int deta = 0; deta < NdEtaBins; deta++){
		  
	  QvsdEta[deta] = (TH1D*) file->Get( Form("ana/QvsdEta_%d",deta) );
			
	}


	TH1D* hist1[3][2];
	TH1D* hist2[3][2];
	for(int sign = 0; sign < 1; sign++){
		for(int HF = 0; HF < 1; HF++){
			hist1[sign][HF] = new TH1D(Form("hist1_%d_%d",sign,HF),"test", NdEtaBins, dEtaBins);
			hist2[sign][HF] = new TH1D(Form("hist2_%d_%d",sign,HF),"test", NdEtaBins, dEtaBins);
		}
	}

	for(int deta = 0; deta < NdEtaBins; deta++){

		double Q_total_real_dEta = QvsdEta[deta]->GetMean();
		double Q_total_real_dEta_error = QvsdEta[deta]->GetMeanError();

		hist1[0][0]->SetBinContent(deta+1, Q_total_real_dEta );
		hist1[0][0]->SetBinError(deta+1,  Q_total_real_dEta_error);
	
	}

	TH1D* base3 = makeHist("base3","like sign(++)","#Delta#eta", "cos(#phi_{1}+#phi_{2}-2#phi_{3})/v2_{3}", 48,0,4.8);
    base3->GetXaxis()->SetTitleColor(kBlack);
    base3->GetYaxis()->SetRangeUser(-0.0015,0.001);
    base3->GetYaxis()->SetTitleOffset(1.9);

    TH1D* base4 = (TH1D*) base3->Clone("base4");

    TCanvas* c4 = makeCanvas("c4","c4");
	gPad->SetTicks();
	gPad->SetLeftMargin(0.20);
	gPad->SetBottomMargin(0.16);
	base3->Draw();
	TH1D* temp = (TH1D*)hist1[0][0]->Clone("temp");
	temp->Scale(1.0/0.20);
	temp->SetMarkerColor(kRed);
	temp->SetLineColor(kRed);
	temp->SetMarkerStyle(20);
	temp->Draw("Psame");


}
示例#12
0
void dmesondecaylength()
{


    //gStyle->SetOptStat("nemruoi");
    gStyle->SetTitleSize(.04,"S");
    gStyle->SetOptTitle(1);
    gStyle->SetTitleOffset(1.0,"X");
    gStyle->SetTitleOffset(.88,"Y");
    gStyle->SetTitleSize(.04,"X");
    gStyle->SetTitleSize(.04,"Y");
    gStyle->SetLabelSize(.035,"X");
    gStyle->SetLabelSize(.035,"Y");
    gStyle->SetHistLineWidth(2);
    gStyle->SetOptFit(1);
    gStyle->SetOptStat(0);
// -----   Timer   --------------------------------------------------------
    TStopwatch timer;
    timer.Start();
    // ------------------------------------------------------------------------
    double c= 3* std::pow(10.,8.);
    double mt= 1040*std::pow(10.,-15.); // mean decay time
    double mass= 1.869; // rest mass in GeV/c^2
//TCanvas* can = new TCanvas("can","Radiation Length for start detector",0,0,100,100);
    TCanvas *c1 = new TCanvas("c1", "c1",0,52,1191,692);
    TH1D* h = new TH1D("hist","D-meson, D-meson decay length",24,0,24);
    h->SetTitle("D^{+} meson decay length = c#tau#sqrt{(#gamma_{D^{+}}^{2}-1)};Momentum (GeV/c); Decay length (mm)");
    Int_t ci;   // for color index setting
    ci = TColor::GetColor("#000099");
    for (int p=1; p<=24; p++)
    {
        double E = p*p + mass*mass;
        E= std:: sqrt(E);

        double gamma = E/mass;
        double decaylength = c* std::sqrt(gamma*gamma -1)*mt*1000;
        std:: cout<<" Decay length=" <<decaylength<<std::endl;
        h->SetLineColor(ci);
        h->GetXaxis()->CenterTitle(true);
        h->GetYaxis()->CenterTitle(true);
        h->SetMarkerColor(2);
        h->SetMarkerStyle(20);
        h->SetBinContent(p,decaylength);
        h->Draw("E2-text");
    }
// -----  Finish   -------------------------------------------------------
    timer.Stop();
    Double_t rtime = timer.RealTime();
    Double_t ctime = timer.CpuTime();
    cout << endl << endl;
    cout << "Macro finished succesfully." << endl;
    cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
    cout << endl;
    // ------------------------------------------------------------------------

}
示例#13
0
TH1D * DrawHistogram(TList *list, char *name,char *option, Int_t rebin, Int_t color, Int_t marker, Float_t scale, Bool_t draw = kTRUE){

  TH1D *histo = list->FindObject(name);
  histo->SetMarkerColor(color);
  histo->SetMarkerStyle(marker);
  histo->SetLineColor(color);
  histo->Rebin(rebin);
  histo->Scale(1.0/((Float_t)rebin));
  histo->Scale(scale);
  histo->SetMarkerSize(1.2);
  if(draw) histo->Draw(option);
  return histo;
}
示例#14
0
TH1D *
GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE)
{
  /* pt limits for combined spectra */
  Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3};
  Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6};

  TList *list = (TList *)file->Get("output");
  TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent));
  if (!hin) return NULL;  

  /* get systematics */
  TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root");
  TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part]));
			
  TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin);
  Double_t pt, width, value, error, sys;
  Int_t bin;
  for (Int_t ipt = 0; ipt < NptBins; ipt++) {
    /* get input bin */
    pt = h->GetBinCenter(ipt + 1);
    width = h->GetBinWidth(ipt + 1);
    bin = hin->FindBin(pt);
    /* sanity check */
    if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
	TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
      continue;
    /* check pt limits */
    if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue;
    /* copy bin */
    value = hin->GetBinContent(bin);
    error = hin->GetBinError(bin);
    /*** TEMP ADD SYS ***/
    if (addSystematicError) {
      sys = hsys->GetBinContent(bin) * value;
      error = TMath::Sqrt(error * error + sys * sys);
    }
    h->SetBinContent(ipt + 1, value);
    h->SetBinError(ipt + 1, error);
  }

  h->SetTitle("ITSsa");
  h->SetLineWidth(1);
  h->SetLineColor(1);
  h->SetMarkerStyle(20);
  h->SetMarkerColor(1);
  h->SetFillStyle(0);
  h->SetFillColor(0);

  return h;
}
示例#15
0
TH1D *
GetITSTPCSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent)
{
  TList *list = (TList *)file->Get("output");
  TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSTPCPartName[part], ITSTPCChargeName[charge], cent + 1));
  if (!hin) return NULL;

  TH1D *h = new TH1D(Form("hITSTPC_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSTPC", NptBins, ptBin);
  Double_t pt, width, value, error;
  Int_t bin;
  for (Int_t ipt = 0; ipt < NptBins; ipt++) {
    /* get input bin */
    pt = h->GetBinCenter(ipt + 1);
    width = h->GetBinWidth(ipt + 1);
    bin = hin->FindBin(pt);
    /* sanity check */
    if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
	TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
      continue;
    /* copy bin */
    value = hin->GetBinContent(bin);
    error = hin->GetBinError(bin);
    h->SetBinContent(ipt + 1, value);
    h->SetBinError(ipt + 1, error);
  }
  
#if 0
  /* add systematic error */
  Double_t sys;
  if (part == 2) sys = 0.5;
  else sys = 0.1;
  Double_t cont, conte;
  for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) {
    cont = h->GetBinContent(ipt + 1);
    conte = h->GetBinError(ipt + 1);
    conte = TMath::Sqrt(conte * conte + sys * sys * cont * cont);
    h->SetBinError(ipt + 1, conte);
  }
#endif
  
  h->SetTitle("ITSTPC");
  h->SetLineWidth(1);
  h->SetLineColor(1);
  h->SetMarkerStyle(21);
  h->SetMarkerColor(2);
  h->SetFillStyle(0);
  h->SetFillColor(0);
  return h;
}
示例#16
0
TH1D* DrawTH1(int isOld, TString var, int pthat, int hibinmin, int hibinmax, int color, int marker){
	if(pthat!=0){
		if(isOld==0)
			TFile *f = TFile::Open(Form("/cms/store/user/ymao/pA5TEV/Mixing/STARTHI53V27/merged/QCD_Pt_%d_TuneZ2_Mix_5p02TeV_pythia.root",pthat));
		else if(isOld==1)
			TFile *f = TFile::Open(Form("/cms/store/user/qixu/jetRpA/OldForest/pPb_Full_BTagForest%d_Fix3output.root",pthat));
		TTree *t = (TTree*)f->Get("hiEvtAnalyzer/HiTree");
	}
	else{
		if(isOld==0)
			TFile *f = TFile::Open(Form("/store/user/qixu/jetRpA/skimTree/MC%sakPu3PFskimfile0_10.root",coll.Data()));
		else if(isOld==1)
			TFile *f = TFile::Open(Form("/store/user/qixu/jetRpA/skimTree/MC%sakPu3PFskimfile0_8.root",coll.Data()));
		else if(isOld==2)
			TFile *f = TFile::Open(Form("/store/user/qixu/jetRpA/skimTree/DATA%sakPu3PFskimfile.root",coll.Data()));
		TTree *t = (TTree*)f->Get("nt");
		
	}
	Float_t hiHFplusEta4, hiHFminusEta4, vz;
	Int_t hiBin;
	TH1D* h = new TH1D("h","h",100,0,100);
	h->Sumw2();
	t->SetBranchAddress("hiHFplusEta4",&hiHFplusEta4);
	t->SetBranchAddress("hiHFminusEta4",&hiHFminusEta4);
	t->SetBranchAddress("vz",&vz);
	t->SetBranchAddress("hiBin",&hiBin);
	cout<<"Total Events="<<t->GetEntries()<<endl;
	for(int Ev=0;Ev<t->GetEntries();Ev++){
		if(Ev%1000000==0) cout<<"has processed "<<Ev<<endl;
		t->GetEntry(Ev);
		if(hiBin > hibinmax || hiBin < hibinmin) continue;
		if(TMath::Abs(vz)>=15) continue;
		if(var == "hiBin")
		h->Fill(hiBin);
		else if(var == "hiHFplusEta4")
		h->Fill(hiHFplusEta4);
		else if(var == "hiHFEta4")
		h->Fill(hiHFplusEta4+hiHFminusEta4);
	}
//	t->Draw(Form("%s>>h",var.Data()),"TMath::Abs(vz)<15");
//	h = (TH1D*)gDirectory->Get("h");
//	h->Scale(1.0/h->Integral());
	h->SetMarkerColor(color);
	h->SetMarkerStyle(marker);
	h->SetLineColor(color);
	h->SetMarkerSize(1.3);
	return h;
}
示例#17
0
文件: plotter.C 项目: UHH2/MTopJet
void plotter::draw_bias(TH1* output_, TH1D* truth_, TH1* bias_, TString file_name){
  TH1D* bias = (TH1D*) bias_->Clone("bias");
  TH1D* truth = (TH1D*) truth_->Clone("truth");
  TH1D* output = (TH1D*) output_->Clone("output");

  double ymax_temp = 0;
  if(truth->GetMaximum() > ymax_temp) ymax_temp = truth->GetMaximum();
  if(bias->GetMaximum() > ymax_temp) ymax_temp = bias->GetMaximum();
  if(output->GetMaximum() > ymax_temp) ymax_temp = output->GetMaximum();
  double ymax = 1.5 * ymax_temp;

  TCanvas *c= new TCanvas("Bias Distribution","",600,600);
  TGaxis::SetMaxDigits(3);
  gPad->SetLeftMargin(0.15);
  truth->SetTitle(file_name);
  truth->GetYaxis()->SetRangeUser(0., ymax);
  truth->GetXaxis()->SetTitle("Leading-jet mass [GeV]");
  truth->GetYaxis()->SetTitle("events");
  truth->GetYaxis()->SetTitleOffset(1.1);
  truth->GetXaxis()->SetTitleOffset(0.9);
  truth->GetYaxis()->SetTitleSize(0.05);
  truth->GetXaxis()->SetTitleSize(0.05);
  truth->GetYaxis()->SetNdivisions(505);

  truth->SetLineWidth(4);
  truth->SetLineColor(kRed);
  bias->SetLineWidth(4);
  bias->SetLineColor(kAzure+7);
  output->SetLineColor(kBlack);
  output->SetMarkerColor(kBlack);
  output->SetMarkerStyle(8);
  output->SetMarkerSize(1);

  truth->Draw("HIST SAME");
  bias->Draw("HIST SAME");
  output->Draw("E1 SAME");
  TLegend *l=new TLegend(0.55,0.6,0.85,0.85);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(output,"unfolded result","pl");
  l->AddEntry(truth,"truth","pl");
  l->AddEntry(bias,"bias distribution","pl");
  l->SetTextSize(0.04);
  l->Draw();
  gPad->RedrawAxis();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
示例#18
0
void plotCentrality(){

  
  TFile* f4 = new TFile("histogram_test_MB_2760GeV.root");
  TH1D* cent  = f4->Get("demo/centhist");
  TCanvas* cd = new TCanvas("cd","",600,500);
  cd->SetLeftMargin(0.12);
  cd->SetRightMargin(0.02);
  cd->SetTopMargin(0.02);
  cd->SetBottomMargin(0.12);
  cd->SetTicks(1);
  cent->SetTitle("");
  cent->SetXTitle("Centrality (200 bins)");
  cent->SetYTitle("# of Events");
  cent->GetYaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->SetTitleOffset(1.2);
  cent->GetXaxis()->CenterTitle(1);
  cent->GetYaxis()->CenterTitle(1);
  cent->GetXaxis()->SetTitleSize(0.046);
  cent->GetYaxis()->SetTitleSize(0.046);
  cent->GetXaxis()->SetTitleFont(62);
  cent->GetYaxis()->SetTitleFont(62);
  cent->SetAxisRange(0,209,"Y");
  cent->SetAxisRange(0,203,"X");
  cent->SetMarkerStyle(20);
  cent->Sumw2();
  cent->SetMarkerSize(1);
  cent->SetMarkerColor(1);
  cent->SetLineColor(1);
  //cent->SetStats(0);
  cent->Draw("Pez");

    TLatex *tex1= new TLatex(55.5,125.060,"Hydjet 2.76TeV MB");
    tex1->SetTextColor(1);
    tex1->SetTextSize(0.05);
    tex1->SetTextFont(42);
    tex1->Draw();

    TLatex *tex2= new TLatex(55.5,99.054,"CMSSW_7_5_0_pre5");
    tex2->SetTextColor(1);
    tex2->SetTextSize(0.05);
    tex2->SetTextFont(42);
    //tex2->Draw();
  cd->SaveAs("centralityDist750x2760GeV.png");

}
示例#19
0
 TH1D* GetDiff(TH1D* hEM,TH1D* hME,double xmin, double xmax)
 {
 	TH1D* diff = (TH1D*)hEM->Clone("diff");
 	diff->Add(hME,-1);
 	diff->GetYaxis()->SetTitle("Diff"); diff->GetYaxis()->SetTitleSize(0.1);
 	diff->GetYaxis()->SetTitleOffset(0.3);
 	diff->GetYaxis()->CenterTitle();
 	diff->GetXaxis()->SetRangeUser(xmin,xmax); diff->SetLineColor(kBlack);
 	diff->GetYaxis()->SetLabelSize(0.08);
 	diff->SetLineWidth(2); diff->SetMarkerStyle(8); diff->SetMarkerSize(0.7);
 	diff->SetMarkerColor(kBlack);
 	diff->GetXaxis()->SetTitle("M_{coll} (GeV)"); diff->GetXaxis()->SetTitleSize(0.15);
 	diff->GetXaxis()->SetTitleOffset(0.8);
 	diff->GetXaxis()->SetLabelOffset();
 	diff->GetXaxis()->SetLabelSize(0.1);
 	return diff;
 }
示例#20
0
文件: GetRandomTest.C 项目: XuQiao/HI
void GetRandomTest(){
	double k0=1.39;
	double k1 = 0.425;
	double theta0 = 3.41;
	double theta1 = 1.30;
	int iNpart=2;
	double k_=k0+k1*(iNpart-2);
        double theta_=theta0+theta1*TMath::Log(iNpart-1);
	TF1 *f = new TF1("f","TMath::GammaDist(x,[0],0,[1])",0,200);
	f->SetParameters(k1,theta_);
	cout<<"Value at 0 = "<<f->Eval(0)<<endl;
	cout<<"Value at 1e-11 = "<<f->Eval(1e-11)<<endl;
	cout<<"Integral 1= "<<f->Integral(f->GetXmin(),f->GetXmax())<<endl;
	f->SetRange(1e-12,200);
	cout<<"Integral 2= "<<f->Integral(f->GetXmin(),f->GetXmax())<<endl;
	cout<<"fXmin = "<<f->GetXmin()<<"\tfXmax = "<<f->GetXmax()<<"\tfNpx = "<<f->GetNpx()<<endl;
	f->SetNpx(1e5);
	TCanvas *c1 = new TCanvas();
	c1->SetLogy();
	cout<<"f mean = "<<f->Mean(0,200)<<endl;
	cout<<"math mean = "<<f->GetParameter(0)*f->GetParameter(1)<<endl;
	TH1D* h = new TH1D("h","h",1000,0,200);
	for(int i=0;i<1e6;i++){
		double para = f->GetRandom();
		h->Fill(para);
	}
	h->Scale(1.0/h->Integral()*1000/200);
	h->GetYaxis()->SetRangeUser(1e-10,1);
	h->SetMarkerStyle(24);
	h->SetMarkerColor(4);
	h->SetMarkerSize(1.1);
	TLegend *leg = new TLegend(0.6,0.7,0.8,0.9);
        leg->SetFillColor(0);
        leg->SetFillStyle(0);
        leg->SetBorderSize(0);
        leg->SetTextFont(42);
        leg->SetTextSize(0.03);
        leg->AddEntry(f,"function","lp");
        leg->AddEntry(h,"filled histogram","lp");
	h->Draw("P");
	f->Draw("same");
        leg->Draw("same");
	cout<<"h mean = "<<h->GetMean(1)<<endl;
	c1->Print("TestGetRandom.png");
	}
示例#21
0
文件: rcp.cpp 项目: jdbrice/rcpMaker
void rcp( string en, int c, int p, string cpf = "/Users/danielbrandenburg/bnl/local/work/rcpMaker/products/presentation/11GeV/data.root" ){


	TCanvas * cc = new TCanvas( "c1", "c2", 250, 250 );

	gStyle->SetOptStat( 0 );
	
	vector<double> c6 = readSpectra( c, p, 0, 1, en );
	vector<double> c6e = readSpectraE1( c, p, 0, 1, en );

	TH1D * hc6 = makeHisto( "cen6", c6, c6e );

	vector<double> c0 = readSpectra( c, p, 8, 8, en );
	vector<double> c0e = readSpectraE1( c, p, 8, 8, en );
	TH1D * hc0 = makeHisto( "cen0", c0, c0e );

	hc0->Scale( 19.0 );
	hc6->Scale( 784.0 );

	hc0->Divide( hc6 );

	hc0->SetTitle( (plcName( p ) + " : " + hCharge( c )).c_str()  );
	hc0->GetYaxis()->SetRangeUser( 0.1, 5 );
	hc0->GetXaxis()->SetRangeUser( 0.0, 4 );
	hc0->SetMarkerStyle( 20 );
	hc0->SetMarkerColor( kBlue );
	hc0->Draw();
	gPad->SetLogy(1);	

	string name = "rcp_" + plcName( p ) + "_" + charge( c ) + "_0_Over_6";
	TFile * f = new TFile( cpf.c_str(), "READ" );

	TH1D * crcp = (TH1D*)f->Get( ("rcp/"+name).c_str() );
	crcp->SetMarkerStyle( 22 );
	crcp->SetMarkerColor( kRed );
	crcp->Scale( 1.08 );
	crcp->Draw( "same" );

	cc->SetGrid(1, 1);

	cc->Print( (name + ".pdf").c_str());



}
示例#22
0
TH1D *
GetTPCTOFSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE)
{
  /* pt limits for combined spectra */
  Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0., 0., 0.};
  Double_t ptMax[AliPID::kSPECIES] = {0., 0., 1.2, 1.2, 1.8};

  TH1D *hin = (TH1D *)file->Get(Form("%sFinal%s%d", TPCTOFPartName[part], TPCTOFChargeName[charge], cent));
  if (!hin) return NULL;

  TH1D *h = new TH1D(Form("hTPCTOF_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "TPCTOF", NptBins, ptBin);
  Double_t pt, width, value, error;
  Int_t bin;
  for (Int_t ipt = 0; ipt < NptBins; ipt++) {
    /* get input bin */
    pt = h->GetBinCenter(ipt + 1);
    width = h->GetBinWidth(ipt + 1);
    bin = hin->FindBin(pt);
    /* sanity check */
    if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
	TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
      continue;
    /* check pt limits */
    if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue;
    /* copy bin */
    value = hin->GetBinContent(bin);
    error = hin->GetBinError(bin);
    h->SetBinContent(ipt + 1, value);
    h->SetBinError(ipt + 1, error);
  }
  
  h->SetTitle("TPCTOF");
  h->SetLineWidth(1);
  h->SetLineColor(1);
  h->SetMarkerStyle(22);
  h->SetMarkerColor(8);
  h->SetFillStyle(0);
  h->SetFillColor(0);
  
  return h;
}
示例#23
0
void closureTesterFSR(void) {

   TString REGIME = ""; //_corr

    //2D case
    TFile* g = new TFile("../Inputs/unfold/unfoldData_HLT_Double_2D_NoTRM.root");
    g->cd();
    TH1F* unfolded = (TH1F*)gDirectory->Get("hunfolded");
    //FSR correction
    TFile* gg = new TFile("../Inputs/FSR/BinByBin.root"); 
    gg->cd();
    TH1F* FSRcorr_num = (TH1F*)gDirectory->Get("hpostFSR2");
    TH1F* FSRcorr_den = (TH1F*)gDirectory->Get("hpreFSR2");
    TH1F* FSRcorr = (TH1F*)FSRcorr_num->Clone();
    FSRcorr->Divide(FSRcorr_num,FSRcorr_den);
    for (int i = 0; i < 132; i++) {
       unfolded->SetBinContent(i+1,unfolded->GetBinContent(i+1)*FSRcorr->GetBinContent(i+1));
    }  
    unfolded->SetMarkerStyle(22);
    unfolded->GetXaxis()->SetTitle("Bin number");
    unfolded->GetYaxis()->SetTitle("Events");
    unfolded->Draw("hist");
    TH1D* other = (TH1D*)unfolded->Clone();
    other->SetMarkerStyle(22);
    other->SetMarkerColor(kRed);
    other->SetLineColor(kRed);
    other->Draw("Psame"); 

    TCanvas* c = new TCanvas();
    c->cd();
    TH1D* ratio = (TH1D*)unfolded->Clone();
    ratio->Divide(other,unfolded);
    ratio->SetMarkerStyle(22);
    ratio->GetXaxis()->SetTitle("N_{unfolded}/N_{preunfolded}");
    ratio->GetXaxis()->SetTitle("Bin number");
    ratio->Draw("P");  


    
}
示例#24
0
TH1D *drawDifference(TH1D *hTrue,TH1D *hist, const TString YLabel,const Double_t range,const Int_t nMarker,const Int_t nColor)
{
  TH1D *hDiff = new TH1D(YLabel,"",20,0,100); hDiff->Sumw2();
  Double_t diff,ratio,errDiff,errSubtr,errTrue;

  TAxis *xaxis = hTrue->GetXaxis();
  for(int ibin=1; ibin<=hTrue->GetNbinsX(); ibin++) {
    diff = hist->GetBinContent(ibin)-hTrue->GetBinContent(ibin);
    if (hTrue->GetBinContent(ibin)==0){
      ratio=hist->GetBinContent(ibin);
      errSubtr = hTrue->GetBinError(ibin);
      //errDiff=sqrt(errSubtr);
      errDiff=errSubtr;
    }else{
      ratio = diff/hTrue->GetBinContent(ibin);
      errSubtr = sqrt(hTrue->GetBinError(ibin)*hTrue->GetBinError(ibin)+hist->GetBinError(ibin)*hist->GetBinError(ibin));
      errTrue = hTrue->GetBinError(ibin);
      errDiff=ratio*errSubtr/diff;
    }
    hDiff->SetBinContent(ibin,ratio);
    hDiff->SetBinError(ibin,errDiff);
  }
  hDiff->GetYaxis()->SetRangeUser(-2,range);
  hDiff->GetYaxis()->SetTitleOffset(0.6);
  hDiff->GetYaxis()->SetTitleSize(0.08);
  hDiff->GetYaxis()->SetLabelSize(0.08);
  hDiff->GetYaxis()->CenterTitle();
  hDiff->GetXaxis()->SetTitleOffset(1.2);
  hDiff->GetXaxis()->SetTitleSize(0.10);
  hDiff->GetXaxis()->SetLabelSize(0.04);
  hDiff->GetXaxis()->SetTitle("#slash{E}_{T} [GeV]");
  hDiff->GetYaxis()->SetTitle(YLabel);
  
  hDiff->SetMarkerStyle(nMarker);
  hDiff->SetMarkerColor(nColor);
  hDiff->SetLineColor(nColor);
  hDiff->SetMarkerSize(0.9);

  return hDiff;
}
示例#25
0
  TH1D* GetRatio(TH1D* hEM,TH1D* hME,double xmin, double xmax)
  {
  	TH1D* ratio = (TH1D*)hEM->Clone("ratio");
  	ratio->Divide(hME);
//  	ratio->GetYaxis()->SetTitle("Ratio"); //ratio->SetTitleFont(64);
  	ratio->GetYaxis()->SetTitle("Ratio"); ratio->GetYaxis()->SetTitleSize(0.1);
  	ratio->GetYaxis()->SetTitleOffset(0.3);
  	ratio->GetYaxis()->CenterTitle();
//  	ratio->SetTitleSize(0.1);
  	ratio->GetXaxis()->SetRangeUser(xmin,xmax); ratio->SetLineColor(kBlack);
  	ratio->GetYaxis()->SetRangeUser(0,2);
  	ratio->SetLineWidth(2); ratio->SetMarkerStyle(8); ratio->SetMarkerSize(0.7);
  	ratio->SetMarkerColor(kBlack);
  	ratio->GetXaxis()->SetTitle("M_{coll} (GeV)"); ratio->GetXaxis()->SetTitleSize(0.15);
  	ratio->GetXaxis()->SetTitleOffset(0.8);
	ratio->GetXaxis()->SetLabelOffset();
  	ratio->GetYaxis()->SetLabelSize(0.1);
  	ratio->GetYaxis()->SetNdivisions(5);
  	ratio->GetXaxis()->SetLabelSize(0.1);

  	ratio->GetXaxis()->SetRangeUser(xmin,xmax);
  	for (int i=1; i<=hEM->GetXaxis()->FindBin(99); i++){
  		double n = hEM->GetBinContent(i);
  		double m = hME->GetBinContent(i);
  		double deltaN = hEM->GetBinError(i);
  		double deltaM = hME->GetBinError(i);
  		double err = (1./m)*TMath::Sqrt(TMath::Power(deltaN,2)+TMath::Power(n*deltaM/m,2));
  		ratio->SetBinError(i,err);
  	}
	for (int i=hEM->GetXaxis()->FindBin(151); i<=hEM->GetXaxis()->GetNbins(); i++){
  		double n = hEM->GetBinContent(i);
  		double m = hME->GetBinContent(i);
  		double deltaN = hEM->GetBinError(i);
  		double deltaM = hME->GetBinError(i);
  		double err = (1./m)*TMath::Sqrt(TMath::Power(deltaN,2)+TMath::Power(n*deltaM/m,2));
  		ratio->SetBinError(i,err);
  	}
  	return ratio;
  }
示例#26
0
文件: plotter.C 项目: UHH2/MTopJet
void plotter::draw_rec(TH1D* data_, TH1D* sig_, TH1D* bgr_, TString file_name){
  TH1D* data = (TH1D*) data_->Clone("data");
  TH1D* sig = (TH1D*) sig_->Clone("sig");
  TH1D* bgr = (TH1D*) bgr_->Clone("bgr");

  TCanvas *c= new TCanvas("c","",1200,600);
  gPad->SetLeftMargin(0.15);
  sig->Add(bgr, 1.);
  sig->SetTitle(" ");
  sig->GetYaxis()->SetRangeUser(0., 250);
  sig->GetXaxis()->SetTitle("detector binning");
  sig->GetYaxis()->SetTitle("events");
  sig->GetYaxis()->SetTitleOffset(1.5);
  sig->GetYaxis()->SetNdivisions(505);
  sig->SetFillColor(810);
  sig->SetLineColor(810);
  sig->Draw("HIST");
  bgr->SetFillColor(kGray);
  bgr->SetLineColor(kBlack);
  bgr->SetFillStyle(1001);
  bgr->Draw("HIST SAME");
  data->SetLineColor(kBlack);
  data->SetLineColor(kBlack);
  data->SetLineStyle(1);
  data->SetMarkerColor(kBlack);
  data->SetMarkerStyle(20);
  data->Draw("E SAME");
  TLegend *l=new TLegend(0.2,0.7,0.4,0.88);
  l->SetBorderSize(0);
  l->SetFillStyle(0);
  l->AddEntry(data,"Data","pl");
  l->AddEntry(sig,"t#bar{t}","f");
  l->AddEntry(bgr,"Background","f");
  l->Draw();
  gPad->RedrawAxis();
  c->SaveAs(directory + file_name + ".pdf");
  delete c;
}
示例#27
0
void trksplit()
{
  TFile* f = new TFile("../cfg/dihadroncorrelation_wsplit_real_cent010_mc.root");
  TFile* f1 = new TFile("../cfg/dihadroncorrelation_wosplit_cent010_mc.root");
 
  TH1D* hpt = (TH1D*)f->Get("corr_ana_HI/ptall_trg");
  TH1D* hpt1 = (TH1D*)f1->Get("corr_ana_HI/ptall_trg");
  hpt->SetMarkerStyle(20);
  hpt1->SetMarkerStyle(20);
  hpt->SetMarkerColor(4);
  hpt->Rebin(4);
  hpt1->Rebin(4);

  TCanvas* c = new TCanvas("c","c",500,450);
  hpt->SetAxisRange(0,5.0,"X");
  hpt->Draw("PE");
  hpt1->Draw("PESAME");

  TH1D* hratio = (TH1D*)hpt->Clone("hratio");
  hratio->Divide(hpt1);

  TCanvas* c1 = new TCanvas("c1","c1",500,450);
  hratio->Draw("PE");
}
示例#28
0
void makeEtaSliceComparisonPlots(   vector<mithep::TH2DAsymErr*> efficiencyGraphs,
                                    vector<string> efficiencyGraphLabels,
                                    string filename, string plotname,                                     
                                    string xAxisLabel = "" , string yAxisLabel = "", double maxY = -1,
                                    double legendX1 = -99, double legendY1 = -99, 
                                    double legendX2 = -99, double legendY2 = -99) {
   
  TCanvas *cv = MakeCanvas("cv", plotname.c_str(), 800, 900);
//   cv->Divide(2,3);

  int padIndex = 1;
    

  for(UInt_t j=1; j <= efficiencyGraphs[0]->GetYaxis()->GetNbins(); j++) {
  
    cout << "Start " << j << endl;
    char tmp[20]; 
    sprintf(tmp, "_Eta%.2fTo%.2f",  efficiencyGraphs[0]->GetYaxis()->GetBinLowEdge(j), 
            efficiencyGraphs[0]->GetYaxis()->GetBinUpEdge(j));
    string sliceEta = tmp;

    TLegend *leg1=0;
    if (legendX1 > -99) {
      leg1 = new TLegend(legendX1,legendY1,legendX2,legendY2);   
    } else {
      leg1 = new TLegend(0.25,0.75,0.55,0.9);   
    }
    leg1->SetBorderSize(0);
    leg1->SetTextSize(0.03);
    
    vector<TH1D*> slices;
    for(int s=0; s < efficiencyGraphs.size(); ++s) {
      char tmp1[20];
      sprintf(tmp, "%d", s);
      string sliceString = tmp;

      cout << efficiencyGraphs[s]->GetName() << endl;
      TH1D *slice = efficiencyGraphs[s]->ProjectionX(("projectionX1" + sliceString).c_str() , j,j);
      slices.push_back(slice);
      cout << "here1 \n";

      slice->SetTitle((plotname + " " + sliceEta).c_str());

      if (xAxisLabel != "") slice->GetXaxis()->SetTitle(xAxisLabel.c_str());
      slice->GetXaxis()->SetTitleOffset(1.0);
      slice->GetXaxis()->SetLabelSize(0.03);
      if (yAxisLabel != "") slice->GetYaxis()->SetTitle(yAxisLabel.c_str());
      slice->GetYaxis()->SetTitleOffset(1.75);
      double MAXY = 0.04;
      if (maxY > 0) MAXY = maxY;
      slice->SetMaximum(MAXY);
      slice->SetMinimum(0.0);
      cout << "here2 \n";

      leg1->AddEntry(slice, efficiencyGraphLabels[s].c_str(), "LP"); 
      slice->SetMarkerColor(COLORS[s]);
      slice->SetLineColor(COLORS[s]);
      slice->SetMarkerSize(0.75);
      slice->SetMarkerStyle(MARKERS[s]);
      cout << "here3 \n";

      if (s==0) {
        slice->Draw();
      } else {
        slice->Draw("same");
      }
    }
    leg1->Draw();
    cv->SaveAs((filename + sliceEta + ".gif").c_str());
    cv->SaveAs((filename + sliceEta + ".eps").c_str());
  }

  return;
}
TCanvas* plotHistswSomeUncAndAbsUncertainty(std::vector<TH1D*> fit_func_list, TH1D* baseHist, TString title="", TString xTitle="", TString yTitle="", TH1D* pt_uncertainty_band=0) {

  int numberOfFitFuncs = fit_func_list.size();
  if (numberOfFitFuncs>5) {
    cout << "Too many histograms for numerator (currently only supports up to 5)" << endl;
    exit;
  }
  if (!baseHist) {
    cout << "baseHist provided does not exist" << endl;
    exit;
  }

  //*************************************************
  // Variables
  bool topPlotLogY = 0;      // 0 = no log; 1= log
  TString yTitle2 = "ratio"; // bottom plot y axis title

  std::vector<int> histColors; 
  histColors.push_back(kBlue);  // change colors as you like
  histColors.push_back(kRed);
  histColors.push_back(kGreen-1);
  histColors.push_back(8);
  histColors.push_back(33);
  //  histColors.push_back(kGreen-1);

  std::vector<int> fillStyles; 
  fillStyles.push_back(3002);
  fillStyles.push_back(3004);
  //  fillStyles.push_back(3305);
  //  fillStyles.push_back(3490);
  fillStyles.push_back(3004);
  fillStyles.push_back(3005);
  fillStyles.push_back(3006);

  std::vector<int> good_markers; 
   good_markers.push_back(20);
   good_markers.push_back(25);
   good_markers.push_back(21);
   good_markers.push_back(24);
   good_markers.push_back(22);
   good_markers.push_back(26);
   good_markers.push_back(29);
   good_markers.push_back(30);
   good_markers.push_back(23);
   good_markers.push_back(28);
   good_markers.push_back(34);


  int histDenominatorColor = kBlack;

  float defaultRatioYmin = 1.02;
  float defaultRatioYmax = 0.60;
  // END of Variables
  //*************************************************

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

  TH1D* baseHistogram = (TH1D*)baseHist->Clone();


  // Create ratio histograms
  std::vector<TH1D*> hists_with_fitted_uncertainties;
  for (int i=0; i<numberOfFitFuncs; i++) {
    ////    hists_with_fitted_uncertainties.push_back( (TH1D*)fit_func_list.at(i)->Clone() );
//    hists_with_fitted_uncertainties.push_back( (TH1D*)baseHist->Clone() );
//    hists_with_fitted_uncertainties[i]->GetTitle();   
//    for(unsigned int bin_i=1;bin_i<= hists_with_fitted_uncertainties[i]->GetNbinsX();bin_i++){
//      //Get uncertainty from fitted function
//      Double_t x_bc=baseHist->GetBinCenter(bin_i);
//      Double_t uncertainty=fit_func_list.at(i)->Eval(x_bc);
//      hists_with_fitted_uncertainties[i]->SetBinError(bin_i,uncertainty);
//    }
    hists_with_fitted_uncertainties.push_back( (TH1D*)baseHist->Clone() );
    hists_with_fitted_uncertainties[i]->GetTitle();   
    for(unsigned int bin_i=1;bin_i<= hists_with_fitted_uncertainties[i]->GetNbinsX();bin_i++){
      Double_t uncertainty=fit_func_list.at(i)->GetBinContent(bin_i);
      hists_with_fitted_uncertainties[i]->SetBinError(bin_i,uncertainty);
    }
  }

  for(unsigned int bin_i=1;bin_i<= baseHist->GetNbinsX();bin_i++){
    Double_t uncertainty= pt_uncertainty_band->GetBinError(bin_i)*baseHist->GetBinContent(bin_i);
    pt_uncertainty_band->SetBinError(bin_i,uncertainty);
    pt_uncertainty_band->SetBinContent(bin_i,baseHist->GetBinContent(bin_i));
  }
 
  TH1D* abs_uncertainty_otf = (TH1D*)baseHist->Clone();
  for(unsigned int bin_i=1;bin_i<= abs_uncertainty_otf->GetNbinsX();bin_i++){
    Double_t sum_x2=0;
    for (int i=0; i<numberOfFitFuncs; i++) {
      sum_x2+=TMath::Power(hists_with_fitted_uncertainties[i]->GetBinError(bin_i),2);
    }
    abs_uncertainty_otf->SetBinError(bin_i,TMath::Sqrt(sum_x2));
  }
  abs_uncertainty_otf->SetFillStyle(3001);
  abs_uncertainty_otf->SetFillColor(kGray);
  abs_uncertainty_otf->SetMarkerStyle(1);
 

  baseHistogram->SetLineWidth(2);
  baseHistogram->SetLineColor(histDenominatorColor);
  baseHistogram->SetMarkerColor(histDenominatorColor);
  baseHistogram->Draw();
  abs_uncertainty_otf->Draw("same e3");
  pt_uncertainty_band->Draw("same e3");
  baseHistogram->Draw("same");
  //      baseHistogram->SetLabelSize(0.0);
  //      //  baseHistogram->GetYaxis()->SetNdivisions(10);
//      baseHistogram->GetYaxis()->SetRangeUser(0.95,1.25);
//      baseHistogram->GetXaxis()->SetTitleSize(0.00);
//      baseHistogram->GetYaxis()->SetLabelSize(0.07);
//      baseHistogram->GetYaxis()->SetTitleSize(0.08);
//      baseHistogram->GetYaxis()->SetTitleOffset(0.76);
  baseHistogram->SetTitle(title+";"+xTitle+";"+yTitle);
  //      
  for (int i=0; i<numberOfFitFuncs; i++) {
    hists_with_fitted_uncertainties[i]->SetLineWidth(2);
    hists_with_fitted_uncertainties[i]->SetLineColor(histColors[i]);
    hists_with_fitted_uncertainties[i]->SetFillColor(histColors[i]);
    hists_with_fitted_uncertainties[i]->SetFillStyle(fillStyles[i]);
    hists_with_fitted_uncertainties[i]->SetMarkerColor(histColors[i]);
    //    hists_with_fitted_uncertainties[i]->SetMarkerStyle(good_markers[i+1]);
    hists_with_fitted_uncertainties[i]->SetMarkerStyle(1);
    hists_with_fitted_uncertainties[i]->Draw("same e3");
  }
  c->SetLogy(topPlotLogY);
  return c;


}
示例#30
0
void plotEfficiency() {

  TCut PtCut="Pt>10";
  TCut EtaCut ="abs(Eta)<2.5";
  TCut Signal ="MatchedGen && MatchedGenFromWZ";
  TCut Bkg ="(!MatchedGen || (MatchedGen && !MatchedGenFromWZ ))";
  TCut barr = "abs(Eta)<1.479";
  TCut endc = "abs(Eta)>1.550&&abs(Eta)<2.5";
  TCut qcd ="(processID==11 || processID==12 || processID==13 || processID==28 || processID==53 || processID==68)";

  TFile *_file2 = TFile::Open("Data/Gumbo/New/Gumbo_All.root"); 
  TTree* g = _file2->Get("ElTree");
  TFile *_file1 = TFile::Open("Data/WZ_3l/New/WZCSA07-WZ.root");        
  TTree* s = _file1->Get("ElTree");

  TH1D* h1 = new TH1D("h1","",100,0,100);
  TH1D* h2 = new TH1D("h2","",100,0,100);
  TH1D* sig = new TH1D("sig","",100,0,100);
  h1->Sumw2();
  h2->Sumw2();

  TH1D* b1 = new TH1D("b1","",100,0,100);
  TH1D* b2 = new TH1D("b2","",100,0,100);
  b1->Sumw2();
  b2->Sumw2();
  TH1D* bkg = new TH1D("bkg","",100,0,100);

  TCut sig_preselection = PtCut && Signal && barr;
  TCut bkg_preselection = PtCut && Bkg && qcd && barr;

  // Barrel- Loose Id
  TCut eb_deta = "DeltaEtaVtx <  0.009"; 
  TCut eb_dphi = "DeltaPhiVtx < 0.05";  
  TCut eb_sEE = "sqrt(CovEtaEta)<0.012";
  TCut eb_trkIso = "(IsoKFTrackDR030 - IsoKFTrackDR005)/Pt<0.1";
  TCut eb_EseedPout = "ESeed/Trk_P_Out>0.9";
  // additional cut for Tight criteria
  TCut eb_EmHadIso = "(IsoEmCaloRecHitDR030 + IsoHadCaloRecHitDR030 - ESC)/ESC<0.18";   

  
  TCut eb_id = eb_deta && eb_dphi && eb_sEE && eb_trkIso && eb_EseedPout; // && eb_EmHadIso; 

  s->Draw("Pt>>h1", sig_preselection);
  s->Draw("Pt>>h2", sig_preselection && eb_id);

  g->Draw("Pt>>b1", "weight"*(bkg_preselection));
  g->Draw("Pt>>b2", "weight"*(bkg_preselection && eb_id));

  sig->Divide(h2, h1, 1, 1, "B");
  bkg->Divide(b2, b1, 1, 1, "B");

  sig->SetMarkerColor(2);
  sig->SetMarkerStyle(21);
  sig->SetMarkerSize(1);

  bkg->SetMarkerColor(4);
  bkg->SetMarkerStyle(22);
  bkg->SetMarkerSize(1);
  
  gStyle->SetOptStat(0);
  sig->GetXaxis()->SetTitle("P_{T} (GeV)");
  sig->GetYaxis()->SetTitle("Efficiency");
  sig->Draw("E");
  bkg->Draw("SAMEE");

  TLegend* leg = new TLegend(0.5,0.5,0.8,0.8);
  leg->AddEntry(sig, "Signal electron");
  leg->AddEntry(bkg, "mis-identified jet (Gumbo)");
  leg->SetLineColor(0);
  leg->SetBorderSize(0);
  leg->Draw();
}