Skip to content

kelleyrw/DrellYan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CMS2 Analysis Example

Goal is the reproduce the result for DY --> ee/µµ xsec measurement using cms2 ntuples documented in AN-12-067 [1] using subset of the 2012 data with L = 82 pb^-1

To checkout and setup:

scramv1 p -n CMSSW_6_1_2_drellyan CMSSW CMSSW_6_1_2
cd CMSSW_6_1_2_drellyan/src
cmsenv

git clone https://github.com/kelleyrw/DrellYan.git Analysis/DrellYan
source Analysis/DrellYan/scripts/setup.sh

To make the histograms directly from cms2 ntuples

cd $CMSSW_BASE/src/Analysis/DrellYan
./scripts/dy_create_plots.py  --label label 

To make the histograms directly from babies

# to make babies
cd $CMSSW_BASE/src/Analysis/DrellYan
./scripts/dy_create_babies.py 

to make the plots from the ntuples, add the following lines to your .rootlogon.C (or load them manually):
gROOT->ProcessLine(".x $CMSSW_BASE/src/Analysis/DrellYan/macros/load_dy_tools.C");

# from root:
cd $CMSSW_BASE/src/Analysis/DrellYan
[rwk7t@tensor DrellYan]$  root -b         
Loading CMSSW FWLite.
Loading AnalysisTools
Loading DY tools
root [0] .L macros/CreatePlotsFromBabies.C++
Info in <TUnixSystem::ACLiC>: creating shared library /Users/rwk7t/temp/.rootbuild//Users/rwk7t/Development/newbies/CMSSW_6_1_2_drellyan/src/Analysis/DrellYan/./macros/CreatePlotsFromBabies_C.so
root [1] CreatePlotsFromBabies("label")
[CreatePlotsFromBabies] create histograms for data
[CreatePlotsFromBabies] create histograms for dyll
[CreatePlotsFromBabies] create histograms for dytt
[CreatePlotsFromBabies] create histograms for wjets
[CreatePlotsFromBabies] create histograms for ttdil
[CreatePlotsFromBabies] create histograms for ttslq
[CreatePlotsFromBabies] create histograms for tthad
[CreatePlotsFromBabies] create histograms for qcdmu15
[CreatePlotsFromBabies] create histograms for ww2l2nu
[CreatePlotsFromBabies] create histograms for wz2l2q
[CreatePlotsFromBabies] create histograms for wz3lnu
[CreatePlotsFromBabies] create histograms for zz2l2nu
[CreatePlotsFromBabies] create histograms for zz2l2q
[CreatePlotsFromBabies] create histograms for zz4l

To make a yield table (reco)
root [2] .L macros/CreateYieldTable.C++
root [4] CreateYieldTable("label")
+----------------------------------------------------------------------------------+
| yields for Drell-Yan Exercise                                                    |
+----------------------------------------------------------------------------------+

                        |               ee |                mm |                ll | 
 dyll                   | 20636.1 +/- 93.0 | 24306.4 +/- 100.9 | 44942.5 +/- 137.2 | 
 dyll (no tau --> e/mu) | 20616.0 +/- 93.0 | 24286.7 +/- 100.9 | 44902.8 +/- 137.3 | 
 dytt                   | 20.1 +/-  2.9    | 19.7 +/-  2.9     | 39.8 +/-  4.1     | 
 wjets                  |  8.8 +/-  6.2    |  0.0 +/-  0.0     |  8.8 +/-  6.2     | 
 ttdil                  | 31.4 +/-  0.4    | 35.1 +/-  0.4     | 66.5 +/-  0.5     | 
 ttslq                  |  0.2 +/-  0.1    |  0.1 +/-  0.0     |  0.3 +/-  0.1     | 
 tthad                  |  0.0 +/-  0.0    |  0.0 +/-  0.0     |  0.0 +/-  0.0     | 
 qcdmu15                |  0.0 +/-  0.0    |  0.0 +/-  0.0     |  0.0 +/-  0.0     | 
 ww2l2nu                |  6.4 +/-  0.1    |  7.5 +/-  0.1     | 13.9 +/-  0.1     | 
 wz2l2q                 | 11.7 +/-  0.1    | 13.3 +/-  0.1     | 25.0 +/-  0.1     | 
 wz3lnu                 |  6.3 +/-  0.0    |  7.5 +/-  0.0     | 13.8 +/-  0.0     | 
 zz2l2nu                |  2.4 +/-  0.0    |  2.9 +/-  0.0     |  5.3 +/-  0.0     | 
 zz2l2q                 | 15.7 +/-  0.1    | 17.6 +/-  0.1     | 33.2 +/-  0.1     | 
 zz4l                   |  1.4 +/-  0.0    |  1.8 +/-  0.0     |  3.2 +/-  0.0     | 
 Background Pred        | 104.6 +/-  6.9   | 105.4 +/-  2.9    | 209.9 +/-  7.5    | 
 MC Pred                | 20740.7 +/- 93.2 | 24411.8 +/- 100.9 | 45152.5 +/- 137.4 | 
 data                   | 18729 +/-  137   | 22184 +/-  149    | 40913 +/-  202    | 

To make a latex version, use the 4th argument:

root [7] CreateYieldTable("label", "h_reco_full_yield", "", true)
\begin{table}[ht!]
\begin{center}
\begin{tabular}{l|cccc} \hline\hline
source & $ee$ & $\mu\mu$ & $\ell\ell $ \\
\hline
   $Z/\gamma \rightarrow \ell \ell$ & 20636.1 $\pm$  93.0 & 24306.4 $\pm$ 100.9 & 44942.5 $\pm$ 137.2 \\
$Z\gamma\ \rightarrow ee/\mu\mu\ (no\ \tau)$ & 20616.0 $\pm$  93.0 & 24286.7 $\pm$ 100.9 & 44902.8 $\pm$ 137.3 \\
   $Z/\gamma \rightarrow \tau \tau$ &  20.1 $\pm$   2.9 &  19.7 $\pm$   2.9 &  39.8 $\pm$   4.1 \\
      $W+jets \rightarrow \ell \nu$ &   8.8 $\pm$   6.2 &   0.0 $\pm$   0.0 &   8.8 $\pm$   6.2 \\
$t\overline{t} \rightarrow \ell \ell X$ &  31.4 $\pm$   0.4 &  35.1 $\pm$   0.4 &  66.5 $\pm$   0.5 \\
$t\overline{t} \rightarrow \ell (q \rightarrow \ell) X$ &   0.2 $\pm$   0.1 &   0.1 $\pm$   0.0 &   0.3 $\pm$   0.1 \\
$t\overline{t} \rightarrow hadrons$ &   0.0 $\pm$   0.0 &   0.0 $\pm$   0.0 &   0.0 $\pm$   0.0 \\
             QCD ($\mu$15 enriched) &   0.0 $\pm$   0.0 &   0.0 $\pm$   0.0 &   0.0 $\pm$   0.0 \\
      $WW \rightarrow 2\ell + 2\nu$ &   6.4 $\pm$   0.1 &   7.5 $\pm$   0.1 &  13.9 $\pm$   0.1 \\
        $WZ \rightarrow 2\ell + 2q$ &  11.7 $\pm$   0.1 &  13.3 $\pm$   0.1 &  25.0 $\pm$   0.1 \\
       $WZ \rightarrow 3\ell + \nu$ &   6.3 $\pm$   0.0 &   7.5 $\pm$   0.0 &  13.8 $\pm$   0.0 \\
      $ZZ \rightarrow 2\ell + 2\nu$ &   2.4 $\pm$   0.0 &   2.9 $\pm$   0.0 &   5.3 $\pm$   0.0 \\
        $ZZ \rightarrow 2\ell + 2q$ &  15.7 $\pm$   0.1 &  17.6 $\pm$   0.1 &  33.2 $\pm$   0.1 \\
             $ZZ \rightarrow 4\ell$ &   1.4 $\pm$   0.0 &   1.8 $\pm$   0.0 &   3.2 $\pm$   0.0 \\
              Background Prediction & 104.6 $\pm$   6.9 & 105.4 $\pm$   2.9 & 209.9 $\pm$   7.5 \\
                      MC Prediction & 20740.7 $\pm$  93.2 & 24411.8 $\pm$ 100.9 & 45152.5 $\pm$ 137.4 \\
\hline\hline
                               data & 18729 & 22184 & 40913 \\
\hline\hline
\end{tabular}
\caption{Drell-Yan Exercise Yields}
\end{center}
\end{table}

To make a yield table (gen)
 root [2] CreateYieldTable("label", "h_gen_yield")
+--------------------------------------------------------------------------------------+
| yields for Drell-Yan Exercise                                                        |
+--------------------------------------------------------------------------------------+

                        |                 ee |                 mm |                 ll | 
 dyll                   | 99815.7 +/- 204.5  | 99462.1 +/- 204.1  | 199277.8 +/- 288.9 | 
 dyll (no tau --> e/mu) | 96574.7 +/- 207.8  | 96400.9 +/- 207.2  | 192975.6 +/- 293.5 | 
 dytt                   | 3240.9 +/- 36.8    | 3061.2 +/- 35.8    | 6302.2 +/- 51.4    | 
 wjets                  |  0.0 +/-  0.0      |  0.0 +/-  0.0      |  0.0 +/-  0.0      | 
 ttdil                  | 310.1 +/-  1.1     | 309.0 +/-  1.1     | 619.1 +/-  1.6     | 
 ttslq                  |  0.0 +/-  0.0      |  0.0 +/-  0.0      |  0.0 +/-  0.0      | 
 tthad                  |  0.0 +/-  0.0      |  0.0 +/-  0.0      |  0.0 +/-  0.0      | 
 qcdmu15                |  0.0 +/-  0.0      |  0.0 +/-  0.0      |  0.0 +/-  0.0      | 
 ww2l2nu                | 74.0 +/-  0.2      | 73.2 +/-  0.2      | 147.2 +/-  0.3     | 
 wz2l2q                 | 62.5 +/-  0.1      | 62.7 +/-  0.1      | 125.2 +/-  0.2     | 
 wz3lnu                 | 31.3 +/-  0.1      | 31.2 +/-  0.1      | 62.5 +/-  0.1      | 
 zz2l2nu                | 10.3 +/-  0.0      | 10.3 +/-  0.0      | 20.6 +/-  0.0      | 
 zz2l2q                 | 69.1 +/-  0.2      | 69.0 +/-  0.2      | 138.1 +/-  0.2     | 
 zz4l                   |  5.1 +/-  0.0      |  8.1 +/-  0.0      | 13.2 +/-  0.0      | 
 Background Pred        | 3803.4 +/- 36.9    | 3624.8 +/- 35.8    | 7428.2 +/- 51.4    | 
 MC Pred                | 103619.1 +/- 207.8 | 103087.0 +/- 207.2 | 206706.0 +/- 293.5 | 
 data                   |    0 +/-    0      |    0 +/-    0      |    0 +/-    0      | 

To make overlay plots 
root [5] .L macros/OverlayPlots.C++
Info in <TUnixSystem::ACLiC>: creating shared library /Users/rwk7t/temp/.rootbuild//Users/rwk7t/Development/newbies/CMSSW_6_1_2_drellyan/src/Analysis/DrellYan/./macros/OverlayPlots_C.so
root [8] OverlayPlots("label")

To make cross section:
root [5] .L macros/CreateCrossSectionTable.C+
root [6] CreateCrossSectionTable("label")
+-----------------------------------------------------------+
| Cross-Sectoin for Drell-Yan Exercise                      |
+-----------------------------------------------------------+

            |                    ee |                    mm | 
 N_obs      | 18729 +/-  137        | 22184 +/-  149        | 
 N_mc       | 20740.7 +/- 93.2      | 24411.8 +/- 100.9     | 
 N_dyll     | 20636.1 +/- 93.0      | 24306.4 +/- 100.9     | 
 N_bkgd     | 104.6 +/-  6.9        | 105.4 +/-  2.9        | 
 N_sig      | 18624.4 +/- 137.0     | 22078.6 +/- 149.0     | 
 Num Acc    | 20585.856 +/- 92.861  | 24263.697 +/- 100.816 | 
 Den Acc    | 93056.916 +/- 197.435 | 92927.899 +/- 197.298 | 
 Acc        | 0.221 +/- 0.001       | 0.261 +/- 0.001       | 
 Sigma (nb) | 1.027 +/- 0.009       | 1.031 +/- 0.008       |

Also, there is a crude functionality to apply a data/mc scale factor to get better data/mc agreement:

root [1] CreatePlotsFromBabies("full_sf", /*apply_sf=*/true)
[CreatePlotsFromBabies] create histograms for data
[CreatePlotsFromBabies] create histograms for dyll
[CreatePlotsFromBabies] create histograms for dytt
[CreatePlotsFromBabies] create histograms for wjets
[CreatePlotsFromBabies] create histograms for ttdil
[CreatePlotsFromBabies] create histograms for ttslq
[CreatePlotsFromBabies] create histograms for tthad
[CreatePlotsFromBabies] create histograms for qcdmu15
[CreatePlotsFromBabies] create histograms for ww2l2nu
[CreatePlotsFromBabies] create histograms for wz2l2q
[CreatePlotsFromBabies] create histograms for wz3lnu
[CreatePlotsFromBabies] create histograms for zz2l2nu
[CreatePlotsFromBabies] create histograms for zz2l2q
[CreatePlotsFromBabies] create histograms for zz4l

root [2] .L macros/CreateCrossSectionTable.C+
void CreateCrossSectionTable(const string& label, const string& hist_name = "h_reco_full_yield", const string& output_file = "", bool print_latex = false)
root [3] CreateCrossSectionTable("full_sf")
+-----------------------------------------------------------+
| Cross-Sectoin for Drell-Yan Exercise                      |
+-----------------------------------------------------------+

            |                    ee |                    mm | 
 N_obs      | 18729 +/-  137        | 22184 +/-  149        | 
 N_mc       | 18718.5 +/- 84.1      | 22031.6 +/- 91.1      | 
 N_dyll     | 18624.1 +/- 83.9      | 21936.5 +/- 91.1      | 
 N_bkgd     | 94.4 +/-  6.2         | 95.1 +/-  2.6         | 
 N_sig      | 18634.6 +/- 137.0     | 22088.9 +/- 149.0     | 
 Num Acc    | 20585.856 +/- 92.861  | 24263.697 +/- 100.816 | 
 Den Acc    | 93056.916 +/- 197.435 | 92927.899 +/- 197.298 | 
 Acc        | 0.221 +/- 0.001       | 0.261 +/- 0.001       | 
 Sigma (nb) | 1.027 +/- 0.009       | 1.032 +/- 0.008       | 

[1] http://www.t2.ucsd.edu/twiki2/pub/UCSDTier2/AnalysisTutorial/AN2012_067_v6.pdf