Ejemplo n.º 1
0
// draws the decay vertices of the Lambda_s
void genDisplay(std::string fullPath, int iGen, int iReco = -1, bool savePdf = false)
{
    const int fVerbose(0);
    setTDRStyle();
    //gStyle->SetOptStat(112211);
    gStyle->SetOptStat(0);
    gStyle->SetPalette(1);
    // Canvases
    crz = new TCanvas("crz","crz",1000,600);
    TPad* padrz = (TPad*)crz->cd(1);
    setPadMargins(padrz, 0.02, 0.05, 0.02, 0.05);
    crphi = new TCanvas("crphi","crphi",600,600);
    TPad* padrphi = (TPad*)crphi->cd(1);
    setPadMargins(padrphi, 0.02, 0.05, 0.02, 0.05);
    // Open file
    TFile *f = TFile::Open(fullPath.c_str());
    if (f==0)
    {
	cout << "File " << fullPath << " not found -- exiting" << endl;
	return;
    }
    if(fVerbose>0)
	cout << "Succesfully opened file " << fullPath << endl;
    // Get TTree with GenEvents
    TTree* tgen = (TTree*) f->Get("genevents");
    if(fVerbose>0) cout << "Got TTree with " << tgen->GetEntries() << " entries" << endl;
    // Do a cut, if needed
    tgen->Draw(">>lst","ptmu1>3&&ptmu2>3&&TMath::Abs(etamu1)<2.5&&TMath::Abs(etamu2)<2.5");
    TEventList *lst;
    lst = (TEventList*)gDirectory->Get("lst");
    tgen->SetEventList(lst);

    // Get TTree with iRecoEvents
    TTree* treco = (TTree*) f->Get("events");
    if(fVerbose>0) cout << "Got TTree with " << treco->GetEntries() << " entries" << endl;

    // Do plots
    const int nbins(30);
    const double rangeR(30), rangeZ(100); // standard
    //const double rangeR(60), rangeZ(200); // zoomed out
    //const double rangeR(100), rangeZ(200); // zoomed in
    //const double rangeR(12), rangeZ(30); // zoomed further in
    padrz->cd();
    TH2F *hrz = new TH2F("hdisp","", nbins,-rangeZ,rangeZ,nbins,-rangeR,rangeR);
    hrz->Draw();
    padrphi->cd();
    TH2F *hrphi = new TH2F("hdisp","", nbins,-rangeR,rangeR,nbins,-rangeR,rangeR);
    hrphi->Draw();

    // add tracker
    padrz->Modified();
    padrz->Update();
    drawTrackerRZ(padrz);
    padrphi->Modified();
    padrphi->Update();
    drawTrackerRPhi(padrphi);

    // set branch addresses for gentree
    double vrl0,vxl0,vyl0,vzl0,vrlb,vxlb,vylb,vzlb;
    double pmu1,phimu1,etamu1,pmu2,phimu2,etamu2;
    double ppr,ppi,phipr,phipi,etapr,etapi;
    tgen->SetBranchAddress("vrl0",&vrl0);
    tgen->SetBranchAddress("vxl0",&vxl0);
    tgen->SetBranchAddress("vyl0",&vyl0);
    tgen->SetBranchAddress("vzl0",&vzl0);
    tgen->SetBranchAddress("vrlb",&vrlb);
    tgen->SetBranchAddress("vxlb",&vxlb);
    tgen->SetBranchAddress("vylb",&vylb);
    tgen->SetBranchAddress("vzlb",&vzlb);
    tgen->SetBranchAddress("pmu1",&pmu1);
    tgen->SetBranchAddress("etamu1",&etamu1);
    tgen->SetBranchAddress("phimu1",&phimu1);
    tgen->SetBranchAddress("pmu2",&pmu2);
    tgen->SetBranchAddress("etamu2",&etamu2);
    tgen->SetBranchAddress("phimu2",&phimu2);
    tgen->SetBranchAddress("ppr",&ppr);
    tgen->SetBranchAddress("etapr",&etapr);
    tgen->SetBranchAddress("phipr",&phipr);
    tgen->SetBranchAddress("ppi",&ppi);
    tgen->SetBranchAddress("etapi",&etapi);
    tgen->SetBranchAddress("phipi",&phipi);
    int genrun, genls, genevt;
    tgen->SetBranchAddress("run",&genrun);
    tgen->SetBranchAddress("LS",&genls);
    tgen->SetBranchAddress("event",&genevt);

    // set branch addresses for recotree
    double rvrl0,rvxl0,rvyl0,rvzl0,rvrlb,rvxlb,rvylb,rvzlb;
    double rpmu1,retamu1,rphimu1,rpmu2,retamu2,rphimu2;
    double rppr,rppi,retapr,retapi,rphipr,rphipi;
    treco->SetBranchAddress("vrl0",&rvrl0);
    treco->SetBranchAddress("vxl0",&rvxl0);
    treco->SetBranchAddress("vyl0",&rvyl0);
    treco->SetBranchAddress("vzl0",&rvzl0);
    treco->SetBranchAddress("vrlb",&rvrlb);
    treco->SetBranchAddress("vxlb",&rvxlb);
    treco->SetBranchAddress("vylb",&rvylb);
    treco->SetBranchAddress("vzlb",&rvzlb);
    treco->SetBranchAddress("rpt1m",&rpmu1);
    treco->SetBranchAddress("reta1m",&retamu1);
    treco->SetBranchAddress("rphi1m",&rphimu1);
    treco->SetBranchAddress("rpt2m",&rpmu2);
    treco->SetBranchAddress("reta2m",&retamu2);
    treco->SetBranchAddress("rphi2m",&rphimu2);
    treco->SetBranchAddress("rptpr",&rppr);
    treco->SetBranchAddress("retapr",&retapr);
    treco->SetBranchAddress("rphipr",&rphipr);
    treco->SetBranchAddress("rptpi",&rppi);
    treco->SetBranchAddress("retapi",&retapi);
    treco->SetBranchAddress("rphipi",&rphipi);

    drawArrowLegend(padrz);
    drawArrowLegend(padrphi,.8);
    // write the event indices
    writeLatex(padrz,.1,.9,("iGen: " + toString(iGen)).c_str());
    writeLatex(padrphi,.1,.9,("iGen: " + toString(iGen)).c_str());
    if (iReco >= 0)
    {
	writeLatex(padrz,.1,.85,("iReco: " + toString(iReco)).c_str());
	writeLatex(padrphi,.1,.85,("iReco: " + toString(iReco)).c_str());
    }

    if (iGen<0) return;
    if (iGen>tgen->GetEntries()) return;
    if (iReco>treco->GetEntries()) return;
    tgen->GetEntry(iGen);
    cout << "iGen: " << iGen << " - " << genrun << " " << genls << " " << genevt << endl;
    padrz->cd();
    drawEventZR(vrlb, vzlb, vrl0, vzl0, pmu1, etamu1, pmu2, etamu2, ppr, etapr, ppi, etapi, 0);
    padrphi->cd();
    drawEventRPhi(vxlb, vylb, vxl0, vyl0, pmu1, phimu1, pmu2, phimu2, ppr, phipr, ppi, phipi, 0);
    if(iReco>=0)
    {
        treco->GetEntry(iReco);
        cout << "iReco: " << iReco << endl;
	padrz->cd();
        drawEventZR(rvrlb, rvzlb, rvrl0, rvzl0, rpmu1, retamu1, rpmu2, retamu2, rppr, retapr, rppi, retapi, 1);
	padrphi->cd();
        drawEventRPhi(rvxlb, rvylb, rvxl0, rvyl0, rpmu1, rphimu1, rpmu2, rphimu2, rppr, rphipr, rppi, rphipi, 1);
	cout << phimu1 << " " << rphimu1 << endl;
    }

    if(savePdf)
    {
	padrz->Update();
	padrphi->Update();
	std::string filename = "genDisplay_" + toString(iGen);
	if(iReco >= 0) filename += "_" + toString(iReco);
	crz->SaveAs((filename+"_rz.pdf").c_str());
	crphi->SaveAs((filename+"_rphi.png").c_str()); // weiss der Geier warum auf PDF die Kreise und die Skala fehlen...
    }

    return;
}
Ejemplo n.º 2
0
void getAiZ() 
{
  TFile *data1 = new TFile("results/CSFrame_ZJets_madgraph_0_inf_plus.root");
  TFile *data2 = new TFile("results/CSFrame_ZJets_madgraph_0_inf_minus.root");

  TString HistPA0 = "MC_CSFramePlots_0toinf/MC_CSWPlusA0Numerator";
  TString HistPA1 = "MC_CSFramePlots_0toinf/MC_CSWPlusA1Numerator";
  TString HistPA2 = "MC_CSFramePlots_0toinf/MC_CSWPlusA2Numerator";
  TString HistPA3 = "MC_CSFramePlots_0toinf/MC_CSWPlusA3Numerator";
  TString HistPA4 = "MC_CSFramePlots_0toinf/MC_CSWPlusA4Numerator";
  TString HistPD = "MC_CSFramePlots_0toinf/MC_CSWPlusAiDenominator";

  TString HistMA0 = "MC_CSFramePlots_0toinf/MC_CSWMinusA0Numerator";
  TString HistMA1 = "MC_CSFramePlots_0toinf/MC_CSWMinusA1Numerator";
  TString HistMA2 = "MC_CSFramePlots_0toinf/MC_CSWMinusA2Numerator";
  TString HistMA3 = "MC_CSFramePlots_0toinf/MC_CSWMinusA3Numerator";
  TString HistMA4 = "MC_CSFramePlots_0toinf/MC_CSWMinusA4Numerator";
  TString HistMD = "MC_CSFramePlots_0toinf/MC_CSWMinusAiDenominator";

  TH1D *hPA0 = (TH1D*)data1->Get(HistPA0);
  TH1D *hPA1 = (TH1D*)data1->Get(HistPA1);
  TH1D *hPA2 = (TH1D*)data1->Get(HistPA2);
  TH1D *hPA3 = (TH1D*)data1->Get(HistPA3);
  TH1D *hPA4 = (TH1D*)data1->Get(HistPA4);
  TH1D *hPD = (TH1D*)data1->Get(HistPD);

  TH1D *hMA0 = (TH1D*)data2->Get(HistMA0);
  TH1D *hMA1 = (TH1D*)data2->Get(HistMA1);
  TH1D *hMA2 = (TH1D*)data2->Get(HistMA2);
  TH1D *hMA3 = (TH1D*)data2->Get(HistMA3);
  TH1D *hMA4 = (TH1D*)data2->Get(HistMA4);
  TH1D *hMD = (TH1D*)data2->Get(HistMD);

  hPA0->Rebin(20);
  hPA1->Rebin(20);
  hPA2->Rebin(20);
  hPA3->Rebin(20);
  hPA4->Rebin(20);
  hPD->Rebin(20);

  hMA0->Rebin(20);
  hMA1->Rebin(20);
  hMA2->Rebin(20);
  hMA3->Rebin(20);
  hMA4->Rebin(20);
  hMD->Rebin(20);

  TCanvas * aCanvas = new TCanvas("CSAiZ", "CSAiZ", 1100, 500);
  aCanvas->SetFillColor(0);
  aCanvas->SetFrameFillColor(0);
  aCanvas->SetFrameBorderMode(0);
  aCanvas->Divide(2,1);

  setPadMargins(aCanvas->cd(1));

  TLegend * aLegend = new TLegend(0.23,0.92,0.4,0.62);
  aLegend->SetFillColor(0);
  aLegend->SetLineColor(0);
  aLegend->SetTextSize(0.0625);

  aLegend->AddEntry(hPA0,"A0", "L");
  //aLegend->AddEntry(hPA1,"A1", "L");
  aLegend->AddEntry(hPA2,"A2", "L");
  aLegend->AddEntry(hPA3,"A3", "L");
  //aLegend->AddEntry(hPA4,"A4", "L");

  hPA0->Scale(20.0/3.0);
  hPA0->Divide(hPD);
  for(unsigned int i=0; i<hPA0->GetNbinsX(); i++) {
    hPA0->SetBinContent(i, (2.0/3.0) + hPA0->GetBinContent(i));
  }
  hPA0->SetLineWidth(3);
  hPA0->GetYaxis()->SetRangeUser(-1.,2.);
  hPA0->GetXaxis()->SetTitle("P_{T}(Z) [GeV]");
  hPA0->GetXaxis()->SetRangeUser(0,220);
  hPA0->GetYaxis()->SetTitle("A_{i}");
  hPA0->GetXaxis()->SetTitleSize(0.0625);
  hPA0->GetYaxis()->SetTitleSize(0.0625);
  hPA0->GetXaxis()->SetTitleOffset(1.00);
  hPA0->GetYaxis()->SetTitleOffset(1.20);
  hPA0->GetXaxis()->SetLabelSize(0.052);
  hPA0->GetYaxis()->SetLabelSize(0.052);
  hPA0->GetXaxis()->SetLabelOffset(0.01);
  hPA0->GetYaxis()->SetLabelOffset(0.01);
  hPA0->DrawCopy("hist");

  hPA1->Scale(5.0);
  hPA1->Divide(hPD);
  hPA1->SetLineColor(kRed);
  hPA1->SetLineWidth(3);
  //hPA1->DrawCopy("histsame");//we don't have sensitivity to A1 - sign of cos(theta_CS)

  hPA2->Scale(10.0);
  hPA2->Divide(hPD);
  hPA2->SetLineColor(kBlue);
  hPA2->SetLineWidth(3);
  hPA2->DrawCopy("histsame");

  hPA3->Scale(4.0);
  hPA3->Divide(hPD);
  hPA3->SetLineColor(kGreen);
  hPA3->SetLineWidth(3);
  hPA3->DrawCopy("histsame");

  hPA4->Scale(4.0);
  hPA4->Divide(hPD);
  hPA4->SetLineColor(kCyan);
  hPA4->SetLineWidth(3);
  //hPA4->DrawCopy("histsame");//we don't have sensitivity to A4 - sign of cos(theta_CS)

  TLatex *tplus = labelLatex(0.25,0.25,"Lepton Plus Charge");
  tplus->DrawClone("same");

  aLegend->DrawClone("same");  

  setPadMargins(aCanvas->cd(2));

  hMA0->Scale(20.0/3.0);
  hMA0->Divide(hMD);
  for(unsigned int i=0; i<hMA0->GetNbinsX(); i++) {
    hMA0->SetBinContent(i, (2.0/3.0) + hMA0->GetBinContent(i));
  }
  hMA0->SetLineWidth(3);
  hMA0->GetYaxis()->SetRangeUser(-1.,2.);
  hMA0->GetXaxis()->SetTitle("P_{T}(Z) [GeV]");
  hMA0->GetXaxis()->SetRangeUser(0,220);
  hMA0->GetYaxis()->SetTitle("A_{i}");
  hMA0->GetXaxis()->SetTitleSize(0.0625);
  hMA0->GetYaxis()->SetTitleSize(0.0625);
  hMA0->GetXaxis()->SetTitleOffset(1.00);
  hMA0->GetYaxis()->SetTitleOffset(1.20);
  hMA0->GetXaxis()->SetLabelSize(0.052);
  hMA0->GetYaxis()->SetLabelSize(0.052);
  hMA0->GetXaxis()->SetLabelOffset(0.01);
  hMA0->GetYaxis()->SetLabelOffset(0.01);
  hMA0->DrawCopy("hist");

  hMA1->Scale(5.0);
  hMA1->Divide(hMD);
  hMA1->SetLineColor(kRed);
  hMA1->SetLineWidth(3);
  //hMA1->DrawCopy("histsame");

  hMA2->Scale(10.0);
  hMA2->Divide(hMD);
  hMA2->SetLineColor(kBlue);
  hMA2->SetLineWidth(3);
  hMA2->DrawCopy("histsame");

  hMA3->Scale(4.0);
  hMA3->Divide(hMD);
  hMA3->SetLineColor(kGreen);
  hMA3->SetLineWidth(3);
  hMA3->DrawCopy("histsame");

  hMA4->Scale(4.0);
  hMA4->Divide(hMD);
  hMA4->SetLineColor(kCyan);
  hMA4->SetLineWidth(3);
  //hMA4->DrawCopy("histsame");

  TLatex *tminus = labelLatex(0.25,0.25,"Lepton Minus Charge");
  tminus->DrawClone("same");

  aLegend->DrawClone("same");  

  aCanvas->Print(".png");

  return;
}