예제 #1
0
파일: config.c 프로젝트: RWTH-OS/rumprun
static int
handle_rc(jsmntok_t *t, int left, char *data)
{
	int onesize, totsize, rem;

	T_CHECKTYPE(t, data, JSMN_ARRAY, __func__);

	rem = t->size;
	for (t++, totsize = 1; rem; rem--) {
		onesize = addbin(t, data);
		totsize += onesize;
		t += onesize;
	}

	return totsize;
}
예제 #2
0
파일: fake.C 프로젝트: kskovpen/bTag
void fake()
{
   gROOT->SetBatch();
   gROOT->SetStyle("Plain");
   
   gStyle->SetOptStat(0);

   SetStyle();
   
   TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500);
   c1->Draw();
   c1->cd();

   TPad *c1_1;
   
   gStyle->SetHistTopMargin(0);

   TLegend *leg = new TLegend(0.65,0.90,0.90,0.70);
   leg->SetFillColor(253);
   leg->SetBorderSize(0);

   std::string fpath = "histTEST_MERGED/QCD_Pt_170to300_TuneCUETP8M1_13TeV_pythia8/data.root";

//   std::string histnameFake = "h_muFake_pt";
//   std::string histnameReal = "h_muReal_pt";

//   std::string histnameFake = "h_muFake_trackerLayersWithMeasurement";
//   std::string histnameReal = "h_muReal_trackerLayersWithMeasurement";

//   std::string histnameFake = "h_muFake_numberOfValidMuonHits";
//   std::string histnameReal = "h_muReal_numberOfValidMuonHits";

//   std::string histnameFake = "h_muFake_numberOfMatches";
//   std::string histnameReal = "h_muReal_numberOfMatches";

//   std::string histnameFake = "h_muFake_numberOfMatchedStations";
//   std::string histnameReal = "h_muReal_numberOfMatchedStations";

//   std::string histnameFake = "h_muFake_numberOfValidHits";
//   std::string histnameReal = "h_muReal_numberOfValidHits";

//   std::string histnameFake = "h_muFake_numberOfValidPixelHits";
//   std::string histnameReal = "h_muReal_numberOfValidPixelHits";

   std::string histnameFake = "h_muFake_numberOfHits";
   std::string histnameReal = "h_muReal_numberOfHits";

//   std::string histnameFake = "h_muFake_normalizedChi2GlobalTrack";
//   std::string histnameReal = "h_muReal_normalizedChi2GlobalTrack";

//   std::string histnameFake = "h_muFake_normalizedChi2InnerTrack";
//   std::string histnameReal = "h_muReal_normalizedChi2InnerTrack";
   
   TFile *f;

   TH1D *hFake;
   TH1D *hReal;
   
   f = TFile::Open(fpath.c_str());
   
     {	
	TH1D *hFake_c = (TH1D*)f->Get(histnameFake.c_str());
	hFake_c->SetMarkerSize(0.0);

	TH1D *hReal_c = (TH1D*)f->Get(histnameReal.c_str());
	hReal_c->SetMarkerSize(0.0);

	hFake = (TH1D*)hFake_c->Clone("hFake");
	hReal = (TH1D*)hReal_c->Clone("hReal");
     }
   
   addbin(hFake);
   addbin(hReal);
   
   std::cout << hReal->Integral() << std::endl;
   std::cout << hFake->Integral() << std::endl;
   
   double iFake = hFake->Integral();
   double iReal = hReal->Integral();
//   double iAll = iFake+iReal;
   
//   hFake->Scale(1./iAll);
//   hReal->Scale(1./iAll);
   
   hFake->SetLineColor(9);
   hFake->SetFillColor(9);
   hReal->SetLineColor(46);
   hReal->SetFillColor(46);
   
   THStack *hst = new THStack();
   hst->Add(hReal);
   hst->Add(hFake);
   
   hst->Draw("hist e1");

   float max = hst->GetMaximum();
   
   hst->SetMaximum(1.3*max);
   hst->SetMinimum(0.);

   if( histnameFake == "h_muFake_pt" ) hst->GetXaxis()->SetTitle("p_{T} [GeV]");
   
   hst->GetYaxis()->SetTitle("Number of muons");
   
   leg->AddEntry(hFake,"Fake","f");
   leg->AddEntry(hReal,"Real","f");
   
   leg->Draw();
   
   c1->Print("pics/fake.eps");
   c1->Clear();

   TH1F *hRealScaled = (TH1F*)hReal->Clone("hRealScaled");
   hRealScaled->Scale(1./iReal);

   TH1F *hFakeScaled = (TH1F*)hFake->Clone("hFakeScaled");
   hFakeScaled->Scale(1./iFake);

   hFakeScaled->SetLineColor(9);
   hFakeScaled->SetFillColor(0);
   hRealScaled->SetLineColor(46);
   hRealScaled->SetFillColor(0);
   
   hRealScaled->Draw("hist e1");
   hFakeScaled->Draw("hist e1 same");

   float max1 = hRealScaled->GetMaximum();
   float max2 = hFakeScaled->GetMaximum();
   max = (max1 > max2) ? max1 : max2;
   
   hRealScaled->SetMaximum(1.3*max);
   hRealScaled->SetMinimum(0.);

   if( histnameFake == "h_muFake_pt" ) hRealScaled->GetXaxis()->SetTitle("p_{T} [GeV]");
   if( histnameFake == "h_muFake_trackerLayersWithMeasurement" ) hRealScaled->GetXaxis()->SetTitle("trackerLayersWithMeasurement");
   if( histnameFake == "h_muFake_numberOfValidMuonHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidMuonHits");
   if( histnameFake == "h_muFake_numberOfMatches" ) hRealScaled->GetXaxis()->SetTitle("numberOfMatches");
   if( histnameFake == "h_muFake_numberOfMatchedStations" ) hRealScaled->GetXaxis()->SetTitle("numberOfMatchedStations");
   if( histnameFake == "h_muFake_numberOfValidHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidHits");
   if( histnameFake == "h_muFake_numberOfValidPixelHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfValidPixelHits");
   if( histnameFake == "h_muFake_numberOfHits" ) hRealScaled->GetXaxis()->SetTitle("numberOfHits");
   if( histnameFake == "h_muFake_normalizedChi2GlobalTrack" ) hRealScaled->GetXaxis()->SetTitle("normalizedChi2GlobalTrack");
   if( histnameFake == "h_muFake_normalizedChi2InnerTrack" ) hRealScaled->GetXaxis()->SetTitle("normalizedChi2InnerTrack");
   
   hRealScaled->GetYaxis()->SetTitle("Normalized to unity");
   
   leg->Draw();
   
   c1->Print("pics/fakeComp.eps");
   c1->Clear();
   
   gApplication->Terminate();
}
예제 #3
0
파일: shapeComp.C 프로젝트: kskovpen/bTag
void shapeComp()
{
   gROOT->SetBatch();
   gROOT->SetStyle("Plain");
   
   gStyle->SetOptStat(0);

   gROOT->ProcessLine("#include <string>");
   gROOT->ProcessLine("#include <TH1F.h>");
   
   gROOT->ProcessLine(".x common.C");
   gROOT->ProcessLine(".x def.C");
   
   gROOT->ProcessLine(".L addbin.C");

   TCanvas *c1 = new TCanvas("c1","c1",0,0,600,500);
   
   gStyle->SetHistTopMargin(0);
   
   TH1F *h_MC_preTag_ljet;
   TH1F *h_MC_postTag_ljet;
   TH1F *h_MC_preTag_bjet;
   TH1F *h_MC_postTag_bjet;
   TH1F *h_MC_preTag_cjet;
   TH1F *h_MC_postTag_cjet;
   TH1F *h_DATA;

   for(int ih=0;ih<nhist;ih++)
     {	
	for(int ipt=0;ipt<nptbin;ipt++)
	  {	
	     std::string varhMC_preTag_ljet = "h_j1_"+hist[ih]+"_ljet_"+ptbin[ipt]+"_nosel_nosel";
	     std::string varhMC_postTag_ljet = "h_j1_"+hist[ih]+"_ljet_"+ptbin[ipt]+"_nosel_" + tag;
	     std::string varhMC_preTag_bjet = "h_j1_"+hist[ih]+"_bjet_"+ptbin[ipt]+"_nosel_nosel";
	     std::string varhMC_postTag_bjet = "h_j1_"+hist[ih]+"_bjet_"+ptbin[ipt]+"_nosel_" + tag;
	     std::string varhMC_preTag_cjet = "h_j1_"+hist[ih]+"_cjet_"+ptbin[ipt]+"_nosel_nosel";
	     std::string varhMC_postTag_cjet = "h_j1_"+hist[ih]+"_cjet_"+ptbin[ipt]+"_nosel_" + tag;
	     std::string varhDATA = "h_j1_"+hist[ih]+"_ajet_"+ptbin[ipt]+"_nosel_UNTAGbc";
	     
	     for(int i=0;i<v_mc_unfilt.size();i++)
	       {
		  std::string fname = fpathMC+v_mc_unfilt.at(i);
		  fbatch_MC_unfilt[i] = TFile::Open(fname.c_str());
		  
		  TH1F *hf_preTag_ljet = (TH1F*)fbatch_MC_unfilt[i]->Get(varhMC_preTag_ljet.c_str());
		  TH1F *hf_postTag_ljet = (TH1F*)fbatch_MC_unfilt[i]->Get(varhMC_postTag_ljet.c_str());

		  if( i == 0 ) 
		    {
		       h_MC_preTag_ljet = (TH1F*)hf_preTag_ljet->Clone("h_MC_preTag_ljet");
		       h_MC_postTag_ljet = (TH1F*)hf_postTag_ljet->Clone("h_MC_postTag_ljet");
		    }	
		  else 
		    {
		       h_MC_preTag_ljet->Add(hf_preTag_ljet);
		       h_MC_postTag_ljet->Add(hf_postTag_ljet);
		    }   
	       }

	     for(int i=0;i<v_mc_filt.size();i++)
	       {
		  std::string fname = fpathMC+v_mc_filt.at(i);
		  fbatch_MC_filt[i] = TFile::Open(fname.c_str());
		  
		  TH1F *hf_preTag_bjet = (TH1F*)fbatch_MC_filt[i]->Get(varhMC_preTag_bjet.c_str());
		  TH1F *hf_postTag_bjet = (TH1F*)fbatch_MC_filt[i]->Get(varhMC_postTag_bjet.c_str());

		  TH1F *hf_preTag_cjet = (TH1F*)fbatch_MC_filt[i]->Get(varhMC_preTag_cjet.c_str());
		  TH1F *hf_postTag_cjet = (TH1F*)fbatch_MC_filt[i]->Get(varhMC_postTag_cjet.c_str());
		  
		  if( i == 0 ) 
		    {
		       h_MC_preTag_bjet = (TH1F*)hf_preTag_bjet->Clone("h_MC_preTag_bjet");
		       h_MC_postTag_bjet = (TH1F*)hf_postTag_bjet->Clone("h_MC_postTag_bjet");

		       h_MC_preTag_cjet = (TH1F*)hf_preTag_cjet->Clone("h_MC_preTag_cjet");
		       h_MC_postTag_cjet = (TH1F*)hf_postTag_cjet->Clone("h_MC_postTag_cjet");
		    }	
		  else 
		    {
		       h_MC_preTag_bjet->Add(hf_preTag_bjet);
		       h_MC_postTag_bjet->Add(hf_postTag_bjet);

		       h_MC_preTag_cjet->Add(hf_preTag_cjet);
		       h_MC_postTag_cjet->Add(hf_postTag_cjet);
		    }   
	       }
	     
	     for(int i=0;i<v_data.size();i++)
	       {
		  std::string fname = fpathDATA+v_data.at(i);
		  fbatch_DATA[i] = TFile::Open(fname.c_str());
		  
		  TH1F *hf = (TH1F*)fbatch_DATA[i]->Get(varhDATA.c_str());

		  if( i == 0 ) 
		    {
		       h_DATA = (TH1F*)hf->Clone("h_DATA");
		    }	
		  else 
		    {
		       h_DATA->Add(hf);
		    }   
	       }
	     
	     addbin(h_MC_preTag_ljet);
	     addbin(h_MC_postTag_ljet);
	     addbin(h_MC_preTag_bjet);
	     addbin(h_MC_postTag_bjet);
	     addbin(h_MC_preTag_cjet);
	     addbin(h_MC_postTag_cjet);
	     addbin(h_DATA);
	     
	     h_MC_preTag_ljet = (TH1F*)h_MC_preTag_ljet->Rebin(nbm1d,"");
	     h_MC_postTag_ljet = (TH1F*)h_MC_postTag_ljet->Rebin(nbm1d,"");
	     h_MC_preTag_bjet = (TH1F*)h_MC_preTag_bjet->Rebin(nbm1d,"");
	     h_MC_postTag_bjet = (TH1F*)h_MC_postTag_bjet->Rebin(nbm1d,"");
	     h_MC_preTag_cjet = (TH1F*)h_MC_preTag_cjet->Rebin(nbm1d,"");
	     h_MC_postTag_cjet = (TH1F*)h_MC_postTag_cjet->Rebin(nbm1d,"");
	     h_DATA = (TH1F*)h_DATA->Rebin(nbm1d,"");

	     if( h_MC_preTag_ljet->Integral() ) h_MC_preTag_ljet->Scale(1./h_MC_preTag_ljet->Integral());
	     if( h_MC_postTag_ljet->Integral() ) h_MC_postTag_ljet->Scale(1./h_MC_postTag_ljet->Integral());
	     if( h_MC_preTag_bjet->Integral() ) h_MC_preTag_bjet->Scale(1./h_MC_preTag_bjet->Integral());
	     if( h_MC_postTag_bjet->Integral() ) h_MC_postTag_bjet->Scale(1./h_MC_postTag_bjet->Integral());
	     if( h_MC_preTag_cjet->Integral() ) h_MC_preTag_cjet->Scale(1./h_MC_preTag_cjet->Integral());
	     if( h_MC_postTag_cjet->Integral() ) h_MC_postTag_cjet->Scale(1./h_MC_postTag_cjet->Integral());
	     if( h_DATA->Integral() ) h_DATA->Scale(1./h_DATA->Integral());

	     h_MC_preTag_ljet->GetXaxis()->SetTitle(xtit[ih].c_str());
	     h_MC_preTag_bjet->GetXaxis()->SetTitle(xtit[ih].c_str());
	     h_MC_preTag_cjet->GetXaxis()->SetTitle(xtit[ih].c_str());
	     
	     h_MC_preTag_ljet->SetLineColor(kRed);
	     h_MC_preTag_ljet->SetMarkerColor(kRed);
	     h_MC_preTag_bjet->SetLineColor(kRed);
	     h_MC_preTag_bjet->SetMarkerColor(kRed);
	     h_MC_preTag_cjet->SetLineColor(kRed);
	     h_MC_preTag_cjet->SetMarkerColor(kRed);
	     h_MC_postTag_ljet->SetLineColor(kBlue);
	     h_MC_postTag_ljet->SetMarkerColor(kBlue);
	     h_MC_postTag_bjet->SetLineColor(kBlue);
	     h_MC_postTag_bjet->SetMarkerColor(kBlue);
	     h_MC_postTag_cjet->SetLineColor(kBlue);
	     h_MC_postTag_cjet->SetMarkerColor(kBlue);
	     h_DATA->SetLineColor(kBlack);
	     h_DATA->SetMarkerColor(kBlack);

	     TLegend *leg = new TLegend(0.65,0.90,0.88,0.75);
	     leg->SetFillColor(253);
	     leg->SetBorderSize(0);
	     leg->AddEntry(h_DATA,"Data","f");
	     leg->AddEntry(h_MC_preTag_ljet,"pre-Tag MC","f");
	     
	     float m_MC_preTag_ljet = h_MC_preTag_ljet->GetMaximum();
	     float m_DATA = h_DATA->GetMaximum();
	     float max = (m_MC_preTag_ljet > m_DATA) ? m_MC_preTag_ljet : m_DATA;

	     h_MC_preTag_ljet->SetMaximum(1.4*max);
	     
	     h_MC_preTag_ljet->Draw("hist e1");
	     h_DATA->Draw("hist e1 same");
	     leg->Draw();	     
	     std::string fsave = "pics/"+hist[ih]+"_"+ptbin[ipt]+"_ljet.eps";
	     c1->Print(fsave.c_str());
	     leg->Clear();
	     c1->Clear();
	     
	     leg->AddEntry(h_MC_postTag_bjet,"post-Tag MC","f");
	     leg->AddEntry(h_MC_preTag_bjet,"pre-Tag MC","f");
	     
	     float m_MC_preTag_bjet = h_MC_preTag_bjet->GetMaximum();
	     float m_MC_postTag_bjet = h_MC_postTag_bjet->GetMaximum();
	     float max_bjet = (m_MC_preTag_bjet > m_MC_postTag_bjet) ? m_MC_preTag_bjet : m_MC_postTag_bjet;

	     h_MC_preTag_bjet->SetMaximum(1.4*max_bjet);
	     
	     h_MC_preTag_bjet->Draw("hist e1");
	     h_MC_postTag_bjet->Draw("hist e1 same");
	     leg->Draw();	     
	     std::string fsave = "pics/"+hist[ih]+"_"+ptbin[ipt]+"_bjet.eps";
	     c1->Print(fsave.c_str());
	     leg->Clear();
	     c1->Clear();	     

	     leg->AddEntry(h_MC_postTag_cjet,"post-Tag MC","f");
	     leg->AddEntry(h_MC_preTag_cjet,"pre-Tag MC","f");
	     
	     float m_MC_preTag_cjet = h_MC_preTag_cjet->GetMaximum();
	     float m_MC_postTag_cjet = h_MC_postTag_cjet->GetMaximum();
	     float max_cjet = (m_MC_preTag_cjet > m_MC_postTag_cjet) ? m_MC_preTag_cjet : m_MC_postTag_cjet;

	     h_MC_preTag_cjet->SetMaximum(1.4*max_cjet);
	     
	     h_MC_preTag_cjet->Draw("hist e1");
	     h_MC_postTag_cjet->Draw("hist e1 same");
	     leg->Draw();	     
	     std::string fsave = "pics/"+hist[ih]+"_"+ptbin[ipt]+"_cjet.eps";
	     c1->Print(fsave.c_str());
	     leg->Clear();
	     c1->Clear();	     
	     
	     delete leg;
	  }
     }   
   
   gApplication->Terminate();
}