Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:33:09

0001 void showEfficiency(TCanvas& canvas, TH1* hTauJetPtDiscrPassed, const char* paramName, const char* xAxisLabel)
0002 {
0003 //--- auxiliary function to show a single efficiency plot
0004 //    and save the result in an .eps file
0005 
0006   TString plotTitle = TString("Tau Id. Efficiency as function of").Append(" ").Append(paramName);
0007   hTauJetPtDiscrPassed->SetTitle(plotTitle.Data());
0008 
0009   hTauJetPtDiscrPassed->SetMinimum(0.);
0010   hTauJetPtDiscrPassed->SetMaximum(1.2);
0011 
0012   hTauJetPtDiscrPassed->SetXTitle(paramName);
0013   hTauJetPtDiscrPassed->SetYTitle("#varepsilon");
0014 
0015   hTauJetPtDiscrPassed->Draw("e1p");
0016 
0017   canvas.Update();
0018 
0019   TString outputFileName = TString("tauIdEff").Append("_").Append(paramName).Append(".eps");
0020   canvas.Print(outputFileName.Data());
0021 }
0022 
0023 void patTau_idEfficiency()
0024 {
0025 //--- open ROOT file
0026   TFile inputFile("patTau_Histograms.root");
0027 
0028 //--- descend into directory containing histograms 
0029 //    written by TFileService
0030   TDirectory* inputDir = (TDirectory*)inputFile.Get("analyzePatTau");
0031 
0032   TH1* hTauJetPt = (TH1*)inputDir->Get("TauJetPt");
0033   TH1* hTauJetEta = (TH1*)inputDir->Get("TauJetEta");
0034   TH1* hTauJetPhi = (TH1*)inputDir->Get("TauJetPhi");
0035 
0036   TH1* hTauJetPtDiscrPassed = (TH1*)inputDir->Get("TauJetPtIsoPassed");
0037   TH1* hTauJetEtaDiscrPassed = (TH1*)inputDir->Get("TauJetEtaIsoPassed");
0038   TH1* hTauJetPhiDiscrPassed = (TH1*)inputDir->Get("TauJetPhiIsoPassed");
0039 
0040 //--- compute tau id. efficiency as function of Pt, Eta and Phi
0041 //    by dividing histograms;
0042 //    enable computation of uncertainties (binomial errors) 
0043 //    by calling TH1::Sumw2 before TH1::Divide
0044   hTauJetPtDiscrPassed->Sumw2();
0045   hTauJetPtDiscrPassed->Divide(hTauJetPtDiscrPassed, hTauJetPt, 1., 1., "B");
0046   hTauJetEtaDiscrPassed->Sumw2();
0047   hTauJetEtaDiscrPassed->Divide(hTauJetEtaDiscrPassed, hTauJetEta, 1., 1., "B");
0048   hTauJetPhiDiscrPassed->Sumw2();
0049   hTauJetPhiDiscrPassed->Divide(hTauJetPhiDiscrPassed, hTauJetPhi, 1., 1., "B");
0050 
0051 //--- create canvas on which to draw the plots;
0052 //    switch background color from (light)grey to white
0053   TCanvas canvas("plotPatTauEff", "plotPatTauEff", 800, 600);
0054   canvas.SetFillColor(10);
0055 
0056 //--- draw efficiciency plots
0057   showEfficiency(canvas, hTauJetPtDiscrPassed, "Pt", "P_{T} / GeV");
0058   showEfficiency(canvas, hTauJetEtaDiscrPassed, "Eta", "#eta");
0059   showEfficiency(canvas, hTauJetPhiDiscrPassed, "Phi", "#phi");
0060 
0061 //--- close ROOT file
0062   inputFile.Close();
0063 }