コード例 #1
0
ファイル: VisItDataServer.cpp プロジェクト: ahota/visit_intel
void
VisItDataServerPrivate::AddPlot(const std::string &id, const AttributeSubject *atts)
{
    std::string plotName(NewPlotName());
    std::vector<double> extents;
    engine.GetEngineMethods()->MakePlot(NewPlotName(),
                    id,
                    atts,
                    extents,
                    windowID);
}
コード例 #2
0
ファイル: doPlotsBtag.C プロジェクト: phy6phs/DailyCScripts
void doPlotsBtag_Log(bool logPlot){
setTDRStyle();

double lumi = 5800;
//stuff to choose
//bool logPlot = false; //true for log plot
int rebinFact = 1;

//isolation selection
//TString Isolation = "QCD No Iso/";
TString Isolation = "Ref selection/";
//TString Isolation = "QCD mu+jets PFRelIso/";
//TString Isolation = "QCD non iso mu+jets/";

TString Systematic = "central";

// number of btags
TString Nbtags = "2btags";  //standard  "2btags" , qcd "0btag"

//choose object
TString Obj = "";
//TString Obj = "MET/";

//muon variables
const int N = 2;
TString Variable;
TString Variables[N] = {"N_BJets", "N_BJets_reweighted"};
double MinXs[N] = {-0.5,-0.5};
double MaxXs[N] = {7.5,7.5};
TString XTitles[N] = {"B-tag Multiplicity", "B-tag Multiplicity"};



//loop over variables
for(int i = 0; i<2; i++){
double MinX = MinXs[i];
double MaxX = MaxXs[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];

//Data
TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central");

//MC
TH1D* tt = getSample("TTJet", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* wjets = getSample("W1Jet", lumi*37509/57708550, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",     lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5",   lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5",   lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5",   lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5",  lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5",     lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic);

//make combined top and single top template
TH1D* sing_top = (TH1D*)top_t->Clone("top");
sing_top->Add(top_tw);sing_top->Add(top_s); sing_top->Add(tbar_t); sing_top->Add(tbar_tw);sing_top->Add(tbar_s);

zjets->Add(z2jets);
zjets->Add(z3jets);
zjets->Add(z4jets);  

wjets->Add(w2jets);
wjets->Add(w3jets);
wjets->Add(w4jets);

//make combined top and single top template
TH1D* qcd_all = (TH1D*)qcd->Clone("qcd_all");
qcd_all->Add(qcd2);
qcd_all->Add(qcd3);
qcd_all->Add(qcd4);
qcd_all->Add(qcd5);
qcd_all->Add(qcd6);
qcd_all->Add(qcd7);
qcd_all->Add(qcd8);
qcd_all->Add(qcd9);
qcd_all->Add(qcd10);
qcd_all->Add(qcd11);
  
THStack *hs = new THStack("hs","test");

qcd_all->SetLineColor(kBlack);
zjets->SetLineColor(kBlack);
wjets->SetLineColor(kBlack);	
sing_top->SetLineColor(kBlack);
tt->SetLineColor(kBlack);	

  hs->Add(qcd_all);
  hs->Add(zjets);
  hs->Add(wjets);
  hs->Add(sing_top);
  hs->Add(tt);

  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
		
  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2);
  hs->SetMinimum(1.);
  
  hs->Draw();
  data->Draw("E same");
  data->SetMarkerStyle(20);

//events:
cout << "ttbar: " << tt->Integral() << endl;
cout << "data: " << data->Integral() << endl;
  
  if(logPlot == true){
  hs->GetXaxis()->SetLimits(MinX, MaxX);
  }else{
  hs->GetXaxis()->SetLimits(MinX, 4.5);
  }
  
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
  
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.7,0.7,0.8,0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(tt , "t#bar{t}", "f");
	tleg2->AddEntry(sing_top, "single top", "f");
	tleg2->AddEntry(wjets , "w+jets", "f");
	tleg2->AddEntry(zjets , "z+jets", "f");
	tleg2->AddEntry(qcd_all , "QCD", "f");
	
	//tleg2->AddEntry(singtEff, "single-t"      , "l");
	//tleg2->AddEntry(singtwEff, "single-tW"      , "l");
 	tleg2->Draw("same");	
	
	if(logPlot == true){
  	TText* textPrelim = doPrelim(0.12,0.96, "#geq 0 btags");
	textPrelim->Draw();
  	}else{
	TText* textPrelim = doPrelim(0.2,0.96, "");
	textPrelim->Draw();
	}
	
  if(logPlot ==true){
  c1->SetLogy();
  }	
  
  TString plotName("Plots/TTbarPlusVarAnalysis/Nbtags/");
  
  if(logPlot ==true){
    plotName += Variable+"_Log";  
  }else{
    plotName += Variable;  
  }
 
 
  c1->SaveAs(plotName+".pdf");
  c1->SaveAs(plotName+".png");
  delete c1;
  
  }
  	
}
コード例 #3
0
ファイル: make_sig_plots.cpp プロジェクト: manuelfs/ucsb_code
int main(){
  SetStyle();
  std::vector<std::string> plotName(0);
  plotName.push_back("sorb_MET");
  plotName.push_back("sorb_METSig");
  plotName.push_back("sorb_METSig2012");
  plotName.push_back("sorb_METOverSqrtHT");

  for(unsigned int i(0); i<plotName.size(); ++i){
    std::vector<TFile*> SM(0), signal400(0), signal250(0);
    
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-120to170_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v3_AODSIM_UCSB1513_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-170to300_TuneZ2star_8TeV_pythia6_v2_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1603_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-300to470_TuneZ2star_8TeV_pythia6_v3_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1609_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-470to600_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v2_AODSIM_UCSB1659_v67_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-600to800_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v2_AODSIM_UCSB1663_v67_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-800to1000_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v2_AODSIM_UCSB1559_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-1000to1400_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1664_v67_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-1400to1800_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1665_v67_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/QCD_Pt-1800_TuneZ2star_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1585_v66_Adam.root","read"));

    SM.push_back(new TFile("raw_plots_and_values/TTJets_FullLeptMGDecays_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A-v2_AODSIM_UCSB1596_v66_Jack.root","read"));

    SM.push_back(new TFile("raw_plots_and_values/TTJets_SemiLeptMGDecays_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A_ext-v1_AODSIM_UCSB1606_v66_Jack.root","read"));

    SM.push_back(new TFile("raw_plots_and_values/TTWJets_8TeV-madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1605_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/TTZJets_8TeV-madgraph_v2_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1604_v66_Adam.root","read"));

    SM.push_back(new TFile("raw_plots_and_values/WbbJetsToLNu_Massive_TuneZ2star_8TeV-madgraph-pythia6_tauola_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1677_v67_Adam.root","read"));
  
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_100_HT_200_TuneZ2Star_8TeV_madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1525_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_100_HT_200_TuneZ2Star_8TeV_madgraph_ext_Summer12_DR53X-PU_S10_START53_V7C-v1_AODSIM_UCSB1607_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_200_HT_400_TuneZ2Star_8TeV_madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1524_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_200_HT_400_TuneZ2Star_8TeV_madgraph_ext_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1594_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_400_HT_inf_TuneZ2Star_8TeV_madgraph_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1523_v66_Adam.root","read"));
    SM.push_back(new TFile("raw_plots_and_values/ZJetsToNuNu_400_HT_inf_TuneZ2Star_8TeV_madgraph_ext_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM_UCSB1602_v66_Adam.root","read"));

    SM.push_back(new TFile("raw_plots_and_values/TTH_Inclusive_M-125_8TeV_pythia6_Summer12_DR53X-PU_S10_START53_V7A-v1_AODSIM+_UCSB1783_v68_Jack.root","read"));

    signal400.push_back(new TFile("raw_plots_and_values/configurableAnalysis_TChihh_400_1_Adam.root","read"));

    signal250.push_back(new TFile("raw_plots_and_values/configurableAnalysis_TChihh_250_1_Adam.root","read"));
    TCanvas canvas;

    TH1D h_SM(GetTH1D(SM, plotName.at(i)));
    TH1D h_signal250(GetTH1D(signal250, plotName.at(i)));
    TH1D h_signal400(GetTH1D(signal400, plotName.at(i)));

    h_SM.SetStats(0);
    h_signal250.SetStats(0);
    h_signal400.SetStats(0);

    h_SM.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_SM_"+plotName.at(i)+".pdf").c_str());
    h_signal250.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_signal250_"+plotName.at(i)+".pdf").c_str());
    h_signal400.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_signal400_"+plotName.at(i)+".pdf").c_str());

    ConvertToIntegral(h_SM);
    ConvertToIntegral(h_signal250);
    ConvertToIntegral(h_signal400);

    h_SM.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_SM_Integral_"+plotName.at(i)+".pdf").c_str());
    h_signal250.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_signal250_Integral_"+plotName.at(i)+".pdf").c_str());
    h_signal400.Draw("hist");
    canvas.Print(("plots/SOverSqrtB_h_signal400_Integral_"+plotName.at(i)+".pdf").c_str());

    TH1D sorb250(GetSOverSqrtB(h_signal250, h_SM));
    TH1D sorb400(GetSOverSqrtB(h_signal400, h_SM));

    sorb250.SetLineColor(2);
    sorb400.SetLineColor(1);

    double max(sorb250.GetMaximum());
    if(sorb400.GetMaximum()>max){
      max=sorb400.GetMaximum();
    }
    max*=1.1;
    sorb250.SetMaximum(max);
    sorb400.SetMaximum(max);

    sorb250.Draw("hist");
    sorb400.Draw("histsame");

    canvas.Print(("plots/SOverSqrtB_"+plotName.at(i)+".pdf").c_str());
  }
}
コード例 #4
0
ファイル: doPlotsMuon.C プロジェクト: phy6phs/DailyCScripts
void doPlotsMuon(){
setTDRStyle();

//loop over variables
for(int i = 0; i<1; i++){
double MinX = MinXs[i];
double MaxX = MaxXs[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];

//Data
TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central");

//MC
TH1D* tt = getSample("TTJet", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);

//ttbar individual
// TH1D* tt_semi = getSample("TTJet_SemiLept", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);
// TH1D* tt_lep = getSample("TTJet_FullLept", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);
// TH1D* tt_had = getSample("TTJet_Hadronic", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* wjets = getSample("W1Jet", lumi*37509/57708550, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w1jets = getSample("W1Jet", lumi*5400.0/23140779, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z1jets = getSample("DY1JetsToLL", lumi*561.0/24042904, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785, Obj, Variable, Isolation, rebinFact, Systematic);

TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",     lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd1 = getSample("QCD_Pt-15to20_MuEnrichedPt5",   lumi*7.022e8 * 0.0039/1722678, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5",   lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5",   lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5",   lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5",  lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5",     lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic);


TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic);
TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic);

//make combined top and single top template
TH1D* sing_top = (TH1D*)top_t->Clone("top");
sing_top->Add(top_tw);sing_top->Add(top_s); sing_top->Add(tbar_t); sing_top->Add(tbar_tw);sing_top->Add(tbar_s);

  if(inclQ == true){
  qcd->Add(qcd);
  }else{
  qcd1->Add(qcd2);
  qcd1->Add(qcd3);
  qcd1->Add(qcd4);
  qcd1->Add(qcd5);
  qcd1->Add(qcd6);
  qcd1->Add(qcd7);
  qcd1->Add(qcd8);
  qcd1->Add(qcd9);
  qcd1->Add(qcd10);
  qcd1->Add(qcd11);
  }
  
TH1D* qcd_data = getQCD(Obj, Variable, rebinFact);
qcd_data->Scale(qcd1->Integral());

THStack *hs = new THStack("hs","test");
  if(inclQ == true){
  hs->Add(qcd_data);
  }else{
  hs->Add(qcd_data);
  }
    
  zjets->Add(z2jets);
  zjets->Add(z3jets);
  zjets->Add(z4jets);  

  wjets->Add(w2jets);
  wjets->Add(w3jets);
  wjets->Add(w4jets);
  
  hs->Add(zjets);
  hs->Add(wjets);
      
  hs->Add(top_t);
  hs->Add(top_tw);
  hs->Add(top_s);
  hs->Add(tbar_t);
  hs->Add(tbar_tw);
  hs->Add(tbar_s);
  
  hs->Add(tt);
  
  TH1D* allMC = (TH1D*)tt->Clone("allMC");
  allMC->Add(sing_top); allMC->Add(wjets); allMC->Add(zjets); allMC->Add(qcd1);
  
  cout << "tt: " << tt->Integral()  << " wjets: " << wjets->Integral() << " zjets: " << zjets->Integral() << " single top: " << sing_top->Integral() << " qcd: " << qcd1->Integral() << " all: " << allMC->Integral() << " data: " << data->Integral() << endl;
  	
  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);

  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);

  hs->Draw();
  data->Draw("E same");
  data->SetMarkerStyle(20);
  
  hs->GetXaxis()->SetLimits(MinX, MaxX);
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
  
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.6,0.6,0.8,0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(tt , "t#bar{t} l+jets", "lf");
	//tleg2->AddEntry(tt_lep , "t#bar{t} di-lepton", "lf");
	tleg2->AddEntry(top_t, "single top", "lf");
	tleg2->AddEntry(wjets , "w+jets", "lf");
	tleg2->AddEntry(zjets , "z+jets", "lf");
	tleg2->AddEntry(qcd , "QCD", "lf");

	//tleg2->AddEntry(singtEff, "single-t"      , "l");
	//tleg2->AddEntry(singtwEff, "single-tW"      , "l");
 	tleg2->Draw("same");	

	TText* textPrelim = doPrelim(0.12,0.96);
	textPrelim->Draw();

  if(logPlot ==true){
  c1->SetLogy();
  }	
  
  TString plotName("plots/Control/Muon/");
  
  if(logPlot ==true){
    plotName += Variable+"Log";
    plotName += Nbtags+".pdf";
    
  }else{
    plotName += Variable;  
    plotName += Nbtags+".pdf";
  }
 
 
  c1->SaveAs(plotName);
  delete c1;
  
  }
  	
}
コード例 #5
0
ファイル: drawRxResolutions.C プロジェクト: amarini/pandolf
void drawResolution_ptBin(std::string dataset,std::string varName, Int_t minPt, Int_t maxPt, bool logScale) {

  std::string fileName = "finalOutputFile_"+dataset+".root";
  TFile* file = TFile::Open(fileName.c_str());

  std::string xTitle;

  char histName[150];
  sprintf(histName, "%s_resolution_barrel_%d_%d_PFakt5", varName.c_str(), minPt, maxPt);
  TH1F* h1= (TH1F*)file->Get(histName);
  h1->SetTitle("");
  h1->GetXaxis()->SetTitleOffset(1.1);
  //h1->GetXaxis()->SetTitleSize(1.5);
  h1->GetYaxis()->SetTitleOffset(1.2);
  h1->GetYaxis()->SetTitle("Normalized Distribution");
  h1->SetLineWidth(1.5);
  if( varName=="Ech") {
    h1->SetFillColor(kRed);
    xTitle = "(E_{ch}^{RECO} - E_{ch}^{GEN}) / E_{ch}^{GEN}";
  }
  if( varName=="Egamma") {
    h1->SetFillColor(kGreen);
    xTitle = "(E_{#gamma}^{RECO} - E_{#gamma}^{GEN}) / E_{#gamma}^{GEN}";
  }
  if( varName=="Enh") {
    h1->SetFillColor(kBlue);
    xTitle = "(E_{nh}^{RECO} - E_{nh}^{GEN}) / E_{nh}^{GEN}";
  }
  if( varName=="Egammanh") {
    h1->SetFillColor(kCyan);
    xTitle = "(E_{#gamma+nh}^{RECO} - E_{#gamma+nh}^{GEN}) / E_{#gamma+nh}^{GEN}";
  }

  h1->GetXaxis()->SetTitle(xTitle.c_str());

  Float_t textSize = 0.04;

  char meanLabelText[100];
  sprintf(meanLabelText, "mean = %.3f", h1->GetMean());
  TPaveText* meanLabel = new TPaveText(0.15, 0.8, 0.3, 0.85, "brNDC");
  meanLabel->SetFillColor(kWhite);
  meanLabel->SetTextSize(textSize);
  meanLabel->AddText(meanLabelText);

  char rmsLabelText[100];
  sprintf(rmsLabelText, "RMS = %.3f", h1->GetRMS());
  TPaveText* rmsLabel = new TPaveText(0.15, 0.7, 0.3, 0.78, "brNDC");
  rmsLabel->SetFillColor(kWhite);
  rmsLabel->SetTextSize(textSize);
  rmsLabel->AddText(rmsLabelText);

  char ptLabelText[100];
  sprintf(ptLabelText, "%d < p_{T}^{GEN} < %d GeV/c", minPt, maxPt);
  TPaveText* ptLabel = new TPaveText(0.67, 0.8, 0.8, 0.88, "brNDC");
  ptLabel->SetFillColor(kWhite);
  ptLabel->SetTextSize(textSize);
  ptLabel->AddText(ptLabelText);

  TPaveText* etaLabel = new TPaveText(0.67, 0.7, 0.8, 0.78, "brNDC");
  etaLabel->SetFillColor(kWhite);
  etaLabel->SetTextSize(textSize);
  etaLabel->AddText("|#eta_{GEN}| < 1.4");

  TCanvas* c1 = new TCanvas("c1", "c1", 800, 600);
  c1->cd();
  c1->SetBottomMargin(0.105);
  if(logScale)
    c1->SetLogy();
  h1->DrawNormalized();
  meanLabel->Draw("same");
  rmsLabel->Draw("same");
  ptLabel->Draw("same");
  etaLabel->Draw("same");
  std::string plotName(histName);
  plotName = "Plots_"+dataset+"/"+plotName+"."+PICTURE_FORMAT;
  c1->SaveAs(plotName.c_str());

  delete c1;

}
コード例 #6
0
void doControlPlotsMuons(){
setTDRStyle();

//loop over variables
for(int i = 0; i<N; i++){
//double MinX = MinXs[i];
//double MaxX = MaxXs[i];
RebinFact = RebinFacts[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];

//Data
TH1D* data = getSample("DoubleMu", 1, Obj, Next, Variable, RebinFact, Systematic);

std::cout << data->Integral() << std::endl;

//MC
TH1D* tt = getSample("TTJet", 1, Obj, Next, Variable, RebinFact, Systematic);
TH1D* wjets = getSample("WJetsToLNu", 1, Obj, Next, Variable, RebinFact, Systematic);
TH1D* DY1 = getSample("DYJetsToLL_M-10To50", 1, Obj, Next, Variable, RebinFact, Systematic);
TH1D* DY2 = getSample("DYJetsToLL_M-50", 1, Obj, Next, Variable, RebinFact, Systematic);
TH1D* T_tW = getSample("T_tW-channel", 1, Obj, Next, Variable, RebinFact, Systematic);
TH1D* Tbar_tW = getSample("Tbar_tW-channel",1, Obj, Next, Variable, RebinFact, Systematic);

THStack *hs = new THStack("hs","test");

  hs->Add(wjets);
  hs->Add(DY1);
  hs->Add(DY2);
  hs->Add(T_tW); 
  hs->Add(Tbar_tW);
  hs->Add(tt); 
  
  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
		
  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);

  hs->Draw();
  data->Draw("E same");
  data->SetMarkerStyle(20);
  
//  hs->GetXaxis()->SetLimits(MinX, MaxX);
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
   
   
  if(logPlot == true){
  c1->SetLogy();
  }	
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.6,0.7,0.8,0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(tt , "t#bar{t}", "lf");
	tleg2->AddEntry(T_tW, "single-t", "lf");
	tleg2->AddEntry(Tbar_tW, "single-#bar{t}", "lf");	
	tleg2->AddEntry(DY1 , "DYJetsToLL-10To50", "lf");
	tleg2->AddEntry(DY2 , "DYJetsToLL-50", "lf");
	tleg2->AddEntry(wjets , "W+jets", "lf");
	
 	tleg2->Draw("same");	

  TString plotName("plots/Control/PassesCutsUpTo1Btag/Muons/");
  
  if(logPlot == true){
    plotName += Variable+"Log.pdf";
//    plotName += Nbtags+".pdf";
    
  }else{
    plotName += Variable+".pdf";  
//    plotName += Nbtags+".pdf";
  }
 
  TText* textPrelim = doPrelim(0.16,0.96); 
  textPrelim->Draw();
  
  c1->SaveAs(plotName);
  delete c1;
  
  }
  	
}
コード例 #7
0
ファイル: doPlotsBtag.C プロジェクト: nikberry/DailyCScripts
void doPlotsBtag(){
setTDRStyle();

//loop over variables
for(int i = 0; i<2; i++){
double MinX = MinXs[i];
double MaxX = MaxXs[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];

//Data
TH1D* data = getSample("SingleMu", 1);

//MC
TH1D* tt = getSample("TTJet", lumi*225.2/6920475);

TH1D* wjets = getSample("W1Jet", lumi*37509/57708550);
TH1D* w1jets = getSample("W1Jet", lumi*5400.0/23140779);
TH1D* w2jets = getSample("W2Jets", lumi*1750.0/34041404);
TH1D* w3jets = getSample("W3Jets", lumi*519.0/15536443);
TH1D* w4jets = getSample("W4Jets", lumi*214.0/13370904);

TH1D* zjets = getSample("DY1JetsToLL", lumi*5745.25/30457954);
TH1D* z1jets = getSample("DY1JetsToLL", lumi*561.0/24042904);
TH1D* z2jets = getSample("DY2JetsToLL", lumi*181.0/21835749);
TH1D* z3jets = getSample("DY3JetsToLL", lumi*51.1/11010628);
TH1D* z4jets = getSample("DY4JetsToLL", lumi*23.04/6391785);

TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",     lumi*34679.3/8500505);
TH1D* qcd1 = getSample("QCD_Pt-15to20_MuEnrichedPt5",   lumi*7.022e8 * 0.0039/1722678);
TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5",   lumi*2.87e8 * 0.0065/8486893);
TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5",   lumi*6.609e7 * 0.0122/8928999);
TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5",   lumi*8082000.0 * 0.0218/7256011);
TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5",  lumi*1024000.0 * 0.0395/9030624);
TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505);
TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483);
TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481);
TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767);
TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142);
TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5",     lumi*0.774 * 0.1097/3807263);

TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707);
TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395);
TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516);
TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817);
TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239);
TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948);

THStack *hs = new THStack("hs","test");
  if(inclQ == true){
  hs->Add(qcd);
  }else{
  hs->Add(qcd1);
  hs->Add(qcd2);
  hs->Add(qcd3);
  hs->Add(qcd4);
  hs->Add(qcd5);
  hs->Add(qcd6);
  hs->Add(qcd7);
  hs->Add(qcd8);
  hs->Add(qcd9);
  hs->Add(qcd10);
  hs->Add(qcd11);
  }
  
  
  if(inclZ == true){
  hs->Add(zjets);
  }else{
  hs->Add(z1jets);
  hs->Add(z2jets);
  hs->Add(z3jets);
  hs->Add(z4jets);  
  }
  
  if(inclW == true){
  hs->Add(wjets);
  }else{
  hs->Add(w1jets);
  hs->Add(w2jets);
  hs->Add(w3jets);
  hs->Add(w4jets);  
  }
      
  hs->Add(top_t);
  hs->Add(top_tw);
  hs->Add(top_s);
  hs->Add(tbar_t);
  hs->Add(tbar_tw);
  hs->Add(tbar_s);
  
  hs->Add(tt);

  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
		
  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.2);

  hs->Draw();
  data->Draw("E same");
  data->SetMarkerStyle(20);

//events:
cout << "ttbar: " << tt->Integral() << endl;
cout << "data: " << data->Integral() << endl;
  
  hs->GetXaxis()->SetLimits(MinX, MaxX);
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
  
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.7,0.7,0.8,0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(tt , "t#bar{t}", "lf");
	tleg2->AddEntry(top_t, "single top", "lf");
	tleg2->AddEntry(wjets , "w+jets", "lf");
	tleg2->AddEntry(zjets , "z+jets", "lf");
	tleg2->AddEntry(qcd , "QCD", "lf");
	
	//tleg2->AddEntry(singtEff, "single-t"      , "l");
	//tleg2->AddEntry(singtwEff, "single-tW"      , "l");
 	tleg2->Draw("same");	
	
	TText* textPrelim = doPrelim(0.17,0.96);
	textPrelim->Draw();
	
  if(logPlot ==true){
  c1->SetLogy();
  }	
  
  TString plotName("plots/Control/Btags/");
  
  if(logPlot ==true){
    plotName += Variable+"Test_Log";
    plotName += ".pdf";
    
  }else{
    plotName += Variable;  
    plotName += ".pdf";
  }
 
 
  c1->SaveAs(plotName);
  delete c1;
  
  }
  	
}
コード例 #8
0
void SignificanceTestDeltaR(){

setTDRStyle();
 
 //MC
TH1D* ttgamma = getSample("TTGamma", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* tt = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* wjets = getSample("WJetsToLNu", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* DY1 = getSample("DYJetsToLL_M-10To50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* DY2 = getSample("DYJetsToLL_M-50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* T_tW = getSample("T_tW-channel", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* Tbar_tW = getSample("Tbar_tW-channel",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* ZZ = getSample("ZZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* WW = getSample("WWtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* WZ = getSample("WZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);

//QCD
TH1D* QCD_Pt_20_30_BCtoE = getSample("QCD_Pt_20_30_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_20_30_EMEnriched = getSample("QCD_Pt_20_30_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
//TH1D* QCD_Pt_20_MuEnrichedPt_15 = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_30_80_BCtoE = getSample("QCD_Pt_30_80_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_30_80_EMEnriched = getSample("QCD_Pt_30_80_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_80_170_BCtoE = getSample("QCD_Pt_80_170_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_80_170_EMEnriched = getSample("QCD_Pt_80_170_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_all = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
  QCD_all->Add(QCD_Pt_20_30_BCtoE);
  QCD_all->Add(QCD_Pt_20_30_EMEnriched);
  QCD_all->Add(QCD_Pt_30_80_BCtoE);
  QCD_all->Add(QCD_Pt_30_80_EMEnriched);
  QCD_all->Add(QCD_Pt_80_170_BCtoE);
  QCD_all->Add(QCD_Pt_80_170_EMEnriched);

TH1D* allMC = (TH1D*)ttgamma->Clone("all MC");
  allMC->Add(tt);
  allMC->Add(wjets);
  allMC->Add(DY1);
  allMC->Add(DY2);
  allMC->Add(T_tW);
  allMC->Add(Tbar_tW);
  allMC->Add(ZZ);
  allMC->Add(WW);
  allMC->Add(WZ);
  allMC->Add(QCD_all); 

 
  	
TH1D* sigTest = new TH1D("sigTest", "#DeltaR(#gamma, jets) Significance Test", 500/RebinFact, 0, 5);
 	sigTest->GetYaxis()->SetTitle("Significance");
 	//sigTest->SetFillColor(kAzure);
 	//sigTest->SetLineColor(kAzure);
	
	if(Variable == "Photon_deltaR_muons_")
 		sigTest->GetXaxis()->SetTitle("#DeltaR(#gamma, #mu)");
	if(Variable == "Photon_deltaR_jets_")
 		sigTest->GetXaxis()->SetTitle("#DeltaR(#gamma, jets)"); 	
	if(Variable == "Photon_deltaR_electrons_")
 		sigTest->GetXaxis()->SetTitle("#DeltaR(#gamma, e)");
			
	for(int i = 1; i<ttgamma->GetNbinsX(); i++){	
 	
	double ttgammaErr, allErr;
	
	double sigVal = ttgamma->IntegralAndError(i,ttgamma->GetNbinsX(),ttgammaErr) / sqrt(ttgamma->IntegralAndError(i,allMC->GetNbinsX(), allErr));
	double sigErr = sigVal*sqrt(pow(ttgammaErr/ttgamma->Integral(i,ttgamma->GetNbinsX()),2)+pow(allErr/allMC->Integral(i,ttgamma->GetNbinsX()),2));
	
	if(sigVal > 0){
	 
 	sigTest->SetBinContent(i, sigVal);
	sigTest->SetBinError(i, sigErr);
	}
	
std::cout << sigVal << " , pm: " << sigErr << std::endl; 
	
 	}

TCanvas *c1 = new TCanvas("Plot");

	

	sigTest->Draw("E");

	TString plotName("plots/Control/" + Obj + Cut + Type + Next + Variable+"ge1b_sig");
	c1->SaveAs(plotName+".pdf");
	c1->SaveAs(plotName+".png");
	delete c1;

}
コード例 #9
0
bool
AccessViewerSession::GetSourceMap(stringVector &keys, stringVector &values,
    std::map<std::string, stringVector> &uses)
{
    const char *mName = "AccessViewerSession::GetSourceMap: ";

    DataNode *vsNode = GetVSNode();
    bool ret = false;
    if(vsNode != 0)
    {
        DataNode *smNode = vsNode->GetNode("SourceMap");
        if(smNode != 0)
        {
            keys.clear();
            values.clear();

            DataNode **children = smNode->GetChildren();
            for(int i = 0; i < smNode->GetNumChildren(); ++i)
            {
                if(children[i]->GetNodeType() == STRING_NODE)
                {
                    keys.push_back(children[i]->GetKey());
                    values.push_back(children[i]->AsString());
                }
            }

            ret = keys.size() > 0;            
        }
        else
        {
            debug1 << mName << "Could not find SourceMap node." << endl;
        }

        // NOTE: This section knows a lot about viewer session files, which
        //       means that if the viewer session format changes then this
        //       code must also change.
        //
        // Look through the plots in the session file and determine
        // where each source is used so we can give a little more
        // information to the user.
        DataNode *wmNode = vsNode->GetNode("ViewerWindowManager");
        if(wmNode != 0)
        {
            DataNode *winNode = wmNode->GetNode("Windows");
            if(winNode != 0)
            {
                DataNode **wins = winNode->GetChildren();
                for(int i = 0; i < winNode->GetNumChildren(); ++i)
                {
                    if(wins[i]->GetNodeType() == INTERNAL_NODE &&
                       wins[i]->GetKey() == "ViewerWindow")
                    {
                        DataNode *vpl = wins[i]->GetNode("ViewerPlotList");
                        if(vpl != 0)
                        {
                            char tmp[1000];
                            int ploti = 0;
                            DataNode *plotNode = 0;
                            do
                            {
                                SNPRINTF(tmp, 1000, "plot%02d", ploti++);
                                plotNode = vpl->GetNode(tmp);
                                if(plotNode != 0)
                                {
                                    DataNode *pluginIDNode = 0,
                                             *varNameNode = 0,
                                             *sourceIDNode = 0;
                                    pluginIDNode = plotNode->GetNode("pluginID");
                                    sourceIDNode = plotNode->GetNode("sourceID");
                                    varNameNode = plotNode->GetNode("variableName");

                                    if(sourceIDNode != 0 && 
                                       sourceIDNode->GetNodeType() == STRING_NODE &&
                                       pluginIDNode != 0 && 
                                       pluginIDNode->GetNodeType() == STRING_NODE &&
                                       varNameNode != 0 && 
                                       varNameNode->GetNodeType() == STRING_NODE)
                                    {
                                        std::string source(sourceIDNode->AsString());
                                        std::string varName(varNameNode->AsString());
                                        std::string plotName(pluginIDNode->AsString());

                                        std::string::size_type pos = plotName.rfind("_");
                                        if(pos != std::string::npos)
                                            plotName = plotName.substr(0, pos);

                                        SNPRINTF(tmp, 1000, "Window %d, %s plot of %s",
                                            i+1, plotName.c_str(), varName.c_str());

                                        if(uses.find(source) == uses.end())
                                            uses[source] = stringVector();
                                        uses[source].push_back(std::string(tmp));
                                    }
                                    else
                                    {
                                        debug1 << mName << "pluginID, sourceID, or "
                                        "variableName nodes not located or they "
                                        "were the wrong types." << endl;
                                    }
                                }
                            } while(plotNode != 0);
                        }
                    }
                }
            }
        }

    }

    return ret;
}
コード例 #10
0
void doControlPlotsMET(){
setTDRStyle();
gROOT->SetBatch();
gStyle->SetErrorX(0.5);

//loop over variables
for(int i = 0; i<N; i++){
double MinX = MinXs[i];
double MaxX = MaxXs[i];
Variable = Variables[i];
TString Xtitle = XTitles[i];
int RebinFact = RebinFacts[i];

//Data
TH1D* data;
if(Obj == "MuMu/")
data = getSample("DoubleMu", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
if(Obj == "EE/")
data = getSample("DoubleElectron", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
if(Obj == "EMu/")
data = getSample("MuEG", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);

//MC
TH1D* ttgamma = getSample("TTGamma", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);

//this to get all ttbar

TH1D* tt;
TH1D* tt_lep;
TH1D* tt_sig;
if(inclTop == false){
//fake ttgamma
tt = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "fake");
tt_lep = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "lep");
tt_sig = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut, "sig");
}else{
tt = getSample("TTJet", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
}

TH1D* wjets = getSample("WJetsToLNu", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* DY1 = getSample("DYJetsToLL_M-10To50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* DY2 = getSample("DYJetsToLL_M-50", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* T_tW = getSample("T_tW-channel", 1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* Tbar_tW = getSample("Tbar_tW-channel",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* ZZ = getSample("ZZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* WW = getSample("WWtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* WZ = getSample("WZtoAnything",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);

//QCD
TH1D* QCD_Pt_20_30_BCtoE = getSample("QCD_Pt_20_30_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_20_30_EMEnriched = getSample("QCD_Pt_20_30_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
//TH1D* QCD_Pt_20_MuEnrichedPt_15 = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_30_80_BCtoE = getSample("QCD_Pt_30_80_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_30_80_EMEnriched = getSample("QCD_Pt_30_80_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_80_170_BCtoE = getSample("QCD_Pt_80_170_BCtoE",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
TH1D* QCD_Pt_80_170_EMEnriched = getSample("QCD_Pt_80_170_EMEnriched",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);

TH1D* QCD_all = getSample("QCD_Pt_20_MuEnrichedPt_15",1, Obj, RefSelection, Type, Next, Variable, RebinFact, Systematic, Cut);
  QCD_all->Add(QCD_Pt_20_30_BCtoE);
  QCD_all->Add(QCD_Pt_20_30_EMEnriched);
  QCD_all->Add(QCD_Pt_30_80_BCtoE);
  QCD_all->Add(QCD_Pt_30_80_EMEnriched);
  QCD_all->Add(QCD_Pt_80_170_BCtoE);
  QCD_all->Add(QCD_Pt_80_170_EMEnriched);
  

TH1D* allMC = (TH1D*)ttgamma->Clone("ratio");
  allMC->Add(tt);
  
  if(inclTop == false){
  allMC->Add(tt_lep);
  allMC->Add(tt_sig);
  }

  allMC->Add(wjets);
  allMC->Add(DY1);
  allMC->Add(DY2);
  allMC->Add(T_tW);
  allMC->Add(Tbar_tW);
  allMC->Add(ZZ);
  allMC->Add(WW);
  allMC->Add(WZ);
  allMC->Add(QCD_all);
  
  allMC->SetFillColor(kBlack);
  allMC->SetFillStyle(3354);
  allMC->SetMarkerSize(0.);
  allMC->SetStats(0);

THStack *hs = new THStack("hs","test");
  hs->Add(QCD_all);
  hs->Add(wjets);
  hs->Add(WZ); 
  hs->Add(WW);
  hs->Add(ZZ);
  hs->Add(DY1);
  hs->Add(DY2);
  hs->Add(T_tW); 
  hs->Add(Tbar_tW);
  hs->Add(tt); 

  if(inclTop == false){
  hs->Add(tt_lep);
  hs->Add(tt_sig);
  }

  hs->Add(ttgamma);
  

std::cout << "Total number of events" << std::endl;
std::cout << "Data: " << data->Integral() << std::endl;
std::cout << "ttbar + gamma: " << ttgamma->Integral() << std::endl;
std::cout << "Inclusive ttbar: " << tt->Integral() << std::endl;
std::cout << "W+Jets: " << wjets->Integral() << std::endl;
std::cout << "Drell-Yan1: " << DY1->Integral() << std::endl;
std::cout << "Drell-Yan2: " << DY2->Integral() << std::endl;
std::cout << "Single top: " << T_tW->Integral() << std::endl;
std::cout << "Anti-Single top: " << Tbar_tW->Integral() << std::endl;
std::cout << "ZZ: " << ZZ->Integral() << std::endl;
std::cout << "WW: " << WW->Integral() << std::endl;
std::cout << "WZ: " << WZ->Integral() << std::endl;
std::cout << "QCD: " << QCD_all->Integral() << std::endl;


  //draw histos to files
  TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
  TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1);
  pad1->SetBottomMargin(0);
  pad1->Draw();
  pad1->cd();	  

  data->Draw("e x0");
  data->SetAxisRange(MinX, MaxX, "X");

  hs->Draw("hist");
  allMC->Draw("same e2");
	
  hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);

  data->Draw("E same");
  data->SetMarkerStyle(20);
  
  hs->GetXaxis()->SetLimits(MinX, MaxX);
  hs->GetXaxis()->SetTitle(Xtitle); hs->GetXaxis()->SetTitleSize(0.05);
  hs->GetYaxis()->SetTitle("Number of Events");hs->GetYaxis()->SetTitleSize(0.05);
   
  
  	TLegend *tleg2;
	tleg2 = new TLegend(0.7, 0.6, 0.8, 0.9);
	tleg2->SetTextSize(0.04);
	tleg2->SetBorderSize(0);
	tleg2->SetFillColor(10);
	tleg2->AddEntry(data , "2012 data", "lpe");
	tleg2->AddEntry(ttgamma , "t#bar{t}#gamma", "lf");

	if(inclTop == false){
        tleg2->AddEntry(tt_sig , "t#bar{t}#gamma (MG)", "lf");
        tleg2->AddEntry(tt_lep , "t#bar{t} l #rightarrow #gamma (MG)", "lf");
        tleg2->AddEntry(tt , "t#bar{t} fake (MG)", "lf");
        }else{
        tleg2->AddEntry(tt , "t#bar{t}", "lf");
        }
	tleg2->AddEntry(T_tW, "Single Top"      , "lf");
//	tleg2->AddEntry(Tbar_tW, "anti-single-tW"      , "lf");	
	tleg2->AddEntry(DY1 , "Z+Jets", "lf");
//	tleg2->AddEntry(DY2 , "DYJetsToLL", "lf");
	tleg2->AddEntry(ZZ, "Diboson", "lf");
//	tleg2->AddEntry(WW, "WW", "lf");
//	tleg2->AddEntry(WZ , "WZ", "lf");
	tleg2->AddEntry(wjets , "W+Jets", "lf");
	tleg2->AddEntry(QCD_all, "QCD", "lf");
	
 	tleg2->Draw("same");	

	TText* textPrelim = doPrelim(0.20, 0.96, Cut, Obj);
        textPrelim->Draw();

  c1->cd();

  if(logPlot == true){
     c1->SetLogy();
  }

   TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
   pad2->SetTopMargin(0);
   pad2->SetBottomMargin(0.4);
   pad2->Draw();
   pad2->cd();

   TH1D * ratio = (TH1D*)data->Clone("ratio plot");
   //ratio->Sumw2();
   ratio->SetStats(0);
   ratio->Divide(allMC);
   ratio->SetMinimum(0);
   ratio->SetMaximum(2);
   ratio->SetFillColor(kBlack);
   ratio->SetFillStyle(3354);
   ratio->SetMarkerSize(0.);

   cout << "width: " << ratio->GetBinWidth(1) << std::endl;
   
   if(MaxX <= 0.1){
   ratio->SetAxisRange(MinX, MaxX);
   }else{ 
   ratio->SetAxisRange(MinX, MaxX-ratio->GetBinWidth(1));
   }

   ratio->SetLabelSize(0.1, "X");
   ratio->SetTitleOffset(0.5, "Y");
   ratio->GetYaxis()->SetTitle("data/MC");ratio->GetYaxis()->SetTitleSize(0.1);
   ratio->GetXaxis()->SetTitle(Xtitle);ratio->GetXaxis()->SetTitleSize(0.15);
   ratio->Draw("ep");

   TLine *line;
   if(MaxX <= 0.1){
   line = new TLine(MinX,1,MaxX,1);
   }else{
   line = new TLine(MinX,1,MaxX-ratio->GetBinWidth(1),1);
   }
   
   line->Draw();

  TString plotName("plots/Control/"+ Obj + Cut  + Type + Next );
  
  if(logPlot == true){
    plotName += Variable+"ge1b_Log.pdf";   
  }else{
    plotName += Variable+"ge1b";  
  }
 
  c1->SaveAs(plotName+".pdf");
  c1->SaveAs(plotName+".png");
  
  delete c1;
  
  }
  	
}
コード例 #11
0
void controlPostFit() {
    setTDRStyle();



//loop over variables
    for(int i = 0; i<N; i++) {

        int rebinFact = rebinFactor[i];

        double MinX = MinXs[i];
        double MaxX = MaxXs[i];
        Variable = Variables[i];
        TString Xtitle = XTitles[i];

        Var = i;

//Data
        TH1D* data = getSample("SingleMu", 1, Obj, Variable, Isolation, rebinFact, "central");

//MC
        TH1D* tt = getSample("TTJetPTRW", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);
//TH1D* tt = getSample("TTJet_POWHEG", lumi*225.2/6920475, Obj, Variable, Isolation, rebinFact, Systematic);

        TH1D* vjets = getSample("VJets", lumi*5400.0/23140779, Obj, Variable, Isolation, rebinFact, Systematic);

//TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",     lumi*34679.3/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd = getSample("QCD_Pt-15to20_MuEnrichedPt5",   lumi*7.022e8 * 0.0039/1722678, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd2 = getSample("QCD_Pt-20to30_MuEnrichedPt5",   lumi*2.87e8 * 0.0065/8486893, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd3 = getSample("QCD_Pt-30to50_MuEnrichedPt5",   lumi*6.609e7 * 0.0122/8928999, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd4 = getSample("QCD_Pt-50to80_MuEnrichedPt5",   lumi*8082000.0 * 0.0218/7256011, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd5 = getSample("QCD_Pt-80to120_MuEnrichedPt5",  lumi*1024000.0 * 0.0395/9030624, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd6 = getSample("QCD_Pt-120to170_MuEnrichedPt5", lumi*157800.0 * 0.0473/8500505, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd7 = getSample("QCD_Pt-170to300_MuEnrichedPt5", lumi*34020.0 * 0.0676/7662483, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd8 = getSample("QCD_Pt-300to470_MuEnrichedPt5", lumi*1757.0 * 0.0864/7797481, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd9 = getSample("QCD_Pt-470to600_MuEnrichedPt5", lumi*115.2 * 0.1024/2995767, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd10 = getSample("QCD_Pt-800to1000_MuEnrichedPt5",lumi*3.57 * 0.1033/4047142, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* qcd11 = getSample("QCD_Pt-1000_MuEnrichedPt5",     lumi*0.774 * 0.1097/3807263, Obj, Variable, Isolation, rebinFact, Systematic);

        TH1D* single_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* top_t = getSample("T_t-channel", lumi*56.4/3757707, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* top_tw = getSample("T_tW-channel", lumi*11.1/497395, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* top_s = getSample("T_s-channel", lumi*3.79/249516, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* tbar_t = getSample("Tbar_t-channel", lumi*30.7/1934817, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* tbar_tw = getSample("Tbar_tW-channel", lumi*11.1/493239, Obj, Variable, Isolation, rebinFact, Systematic);
        TH1D* tbar_s = getSample("Tbar_s-channel", lumi*1.76/139948, Obj, Variable, Isolation, rebinFact, Systematic);

        single_t->Add(top_tw);
        single_t->Add(top_s);
        single_t->Add(tbar_t);
        single_t->Add(tbar_tw);
        single_t->Add(tbar_s);

        qcd->Add(qcd2);
        qcd->Add(qcd3);
        qcd->Add(qcd4);
        qcd->Add(qcd5);
        qcd->Add(qcd6);
        qcd->Add(qcd7);
        qcd->Add(qcd8);
        qcd->Add(qcd9);
        qcd->Add(qcd10);
        qcd->Add(qcd11);

        TH1D* qcd_data = getQCD(Obj, Variable, rebinFact);
        qcd_data->Scale(qcd->Integral());

//tt->Add(single_t);

//scales from fits with V constraint
// tt->Scale(17771.9/tt->Integral());
// vjets->Scale(600.4/vjets->Integral());
// qcd_data->Scale(1801.9/qcd_data->Integral());

//tt->Scale(17541.7/tt->Integral());
//vjets->Scale(1557.4/vjets->Integral());
//qcd_data->Scale(1078.0/qcd_data->Integral());

//50% mad and 200% qcd
// tt->Scale(19190.3/tt->Integral());
// vjets->Scale(774.0/vjets->Integral());
// qcd_data->Scale(198.0/qcd_data->Integral());

//no consts new
// tt->Scale(70722.9/tt->Integral());
// vjets->Scale(5290.4/vjets->Integral());
// qcd_data->Scale(6006.9/qcd_data->Integral());
//all 50% mad and 200% qcd consts new
        tt->Scale(76278.2/tt->Integral());
        vjets->Scale(3597.5/vjets->Integral());
        qcd_data->Scale(2086.8/qcd_data->Integral());

        TH1D * allMC = (TH1D*)tt->Clone("ratio");
        allMC->Add(vjets);
        allMC->Add(qcd_data);

//powheg
// tt->Scale(18629.55/tt->Integral());
// vjets->Scale(1055.54/vjets->Integral());
// qcd_data->Scale(492.10/qcd_data->Integral());
// //powheg ST fit
// tt->Scale(18668.3634/tt->Integral());
// vjets->Scale(1139.9548/vjets->Integral());
// qcd_data->Scale(368.7360/qcd_data->Integral());

        THStack *hs = new THStack("hs","test");

        hs->Add(qcd_data);

        hs->Add(vjets);

        hs->Add(top_t);
        hs->Add(top_tw);
        hs->Add(top_s);
        hs->Add(tbar_t);
        hs->Add(tbar_tw);
        hs->Add(tbar_s);

        single_t->Add(top_tw);
        single_t->Add(top_s);
        single_t->Add(tbar_t);
        single_t->Add(tbar_tw);
        single_t->Add(tbar_s);

        hs->Add(tt);


        std::cout << "tot data: " << data->Integral() << std::endl;
        std::cout << "tot tt & " << "tot v & " << "sing & "<<  "qcd & " << std::endl;
        std::cout <<  tt->Integral() << " & " << vjets->Integral() << " & " << single_t->Integral() << " & "<< qcd->Integral()<< " & "<< std::endl;

        //draw histos to files
        TCanvas *c1 = new TCanvas("Plot","Plot",900, 600);
        TPad *pad1 = new TPad("pad1","pad1",0,0.3,1,1);
        pad1->SetBottomMargin(0);
        pad1->Draw();
        pad1->cd();


        data->Draw();
        data->SetAxisRange(MinX, MaxX, "X");
        data->Draw();

        hs->Draw("H");
        hs->GetXaxis()->SetLimits(MinX, MaxX);

        data->SetMarkerStyle(20);

        hs->SetMaximum(data->GetBinContent(data->GetMaximumBin())*1.3);

        hs->GetXaxis()->SetTitle(Xtitle);
        hs->GetXaxis()->SetTitleSize(0.05);
        hs->GetYaxis()->SetTitle("Number of Events");
        hs->GetYaxis()->SetTitleSize(0.05);

        hs->Draw("H");
        data->Draw("E same");

        TLegend *tleg2;
        tleg2 = new TLegend(0.7,0.7,0.8,0.9);
        tleg2->SetTextSize(0.04);
        tleg2->SetBorderSize(0);
        tleg2->SetFillColor(10);
        tleg2->AddEntry(data , "2012 data", "lpe");
        tleg2->AddEntry(tt , "t#bar{t}", "lf");
        tleg2->AddEntry(top_t, "single top"      , "lf");
        tleg2->AddEntry(vjets , "v+jets", "lf");
        tleg2->AddEntry(qcd, "QCD"      , "lf");
        //tleg2->AddEntry(singtwEff, "single-tW"      , "l");
        tleg2->Draw("same");

        TText* textPrelim = doPrelim(0.12,0.96);
        textPrelim->Draw();

        c1->cd();

        if(logPlot ==true) {
            c1->SetLogy();
        }

        TPad *pad2 = new TPad("pad2","pad2",0,0,1,0.3);
        pad2->SetTopMargin(0);
        pad2->SetBottomMargin(0.4);
        pad2->Draw();
        pad2->cd();

        TH1D * ratio = (TH1D*)data->Clone("ratio plot");
        ratio->Sumw2();
        ratio->SetStats(0);
        ratio->Divide(allMC);
        ratio->SetMinimum(0.5);
        ratio->SetMaximum(1.5);

        cout << "width: " << ratio->GetBinWidth(1);
        ratio->SetAxisRange(MinX, MaxX-ratio->GetBinWidth(1));
        //ratio->GetXaxis()->SetLimits(MinX, MaxX);

        ratio->SetLabelSize(0.1, "X");
        ratio->SetTitleOffset(0.5, "Y");
        ratio->GetYaxis()->SetTitle("data/MC");
        ratio->GetYaxis()->SetTitleSize(0.1);
        ratio->GetXaxis()->SetTitle(Xtitle);
        ratio->GetXaxis()->SetTitleSize(0.15);
        ratio->Draw("ep");

        TLine *line = new TLine(MinX,1,MaxX,1);
        line->Draw();

//    c1->cd();
//    pad1->cd();
//    pad1->Draw();
//    hs->Draw("H");
//    data->Draw("E same");

        TString plotName("plots/Control/"+Obj);

        if(logPlot == true) {
            plotName += Variable+"_Log";
            plotName += Nbtags+"_ptreweight.pdf";

        } else {
            plotName += Variable +Systematic+ "_" ;
            plotName += Nbtags+"_ptreweight.pdf";
            //plotName += Nbtags+"_postfit.pdf";
        }


        c1->SaveAs(plotName);
        delete c1;

    }

}