Skip to content

Commit

Permalink
update according to 0d94a61
Browse files Browse the repository at this point in the history
  • Loading branch information
jackaraz committed Jan 10, 2022
1 parent 0d94a61 commit 67d6eb2
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 110 deletions.
22 changes: 8 additions & 14 deletions Makefile
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,21 +1,15 @@
#! /usr/bin/env bash


.PHONY: clean
clean:
rm -rf ma5_expert.egg-info/


#.PHONY: requirements
#requirements: requirements.txt
# pip install -r requirements.txt
.PHONY: all
all:
make install


.PHONY: install
install:
pip install -e .


.PHONY: all
all:
make install
.PHONY: uninstall
uninstall:
pip uninstall ma5_expert


21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# MadAnalysis 5 Interpreter For Expert Mode
[![EPJC](https://img.shields.io/static/v1?style=plastic&label=DOI&message=10.1140/epjc/s10052-021-09052-5&color=blue)](https://doi.org/10.1140/epjc/s10052-021-09052-5)
[![arxiv](https://img.shields.io/static/v1?style=plastic&label=arXiv&message=2006.09387&color=brightgreen)](https://arxiv.org/abs/2006.09387)

MadAnalysis 5 output interpreter for expert mode. Parses the cutflow collection and
constructs it with an interactable interface (histogram interpreter coming soon).

Expand All @@ -24,23 +27,23 @@ Parsing a cutflow simply requires the path of the `CutFlows` folder and optional
and/or `Nevents`. Note that `xsec` overwrites the number of events option, if provided number of events
are always calculated using the cross section.
```python
from ma5_expert import CutFlowCollection
ma5 = CutFlowCollection(
import ma5_expert as ma5
sample = ma5.cutflow.Collection(
"examples/mass1000005_300.0_mass1000022_60.0_mass1000023_250.0_xs_5.689/Output/SAF/defaultset/atlas_susy_2018_31/Cutflows",
xsection=5.689, lumi=139.
)
```
Here the first input is the path of the `CutFlows` folder and the rest are simply cross section and
luminosity information. One can see the signal regions by simply printing the `keys` of the `CutFlowCollection` object;
```python
print(ma5.SRnames)
print(sample.SRnames)
# Output:
# ['SRC_28', 'SRA_M', 'SRA_L', 'SRA_H', 'SRA', 'SRC', 'SRB', 'SRC_26', 'SRC_24', 'SRC_22']
```
Each signal region is accessible through `CutFlowCollection` object. For instance one can get the names of
the cuts applied in one of the signal regions.
```python
print(ma5.SRA.CutNames)
print(sample.SRA.CutNames)
# Output:
# ['Initial', '$N_{lep} = 0$', '$N_{j} \\geq 6$', '$N_{b} \\geq 4$',
# '$\\slashed{E}_T > 350$ [GeV]', '$min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]',
Expand All @@ -49,7 +52,7 @@ print(ma5.SRA.CutNames)
```
Or simply print the entire cutflow;
```python
print(ma5.SRA)
print(sample.SRA)
# Output:
# * SRA :
# * Initial :
Expand Down Expand Up @@ -106,21 +109,21 @@ cut efficiency and relative efficiency. The error in number of events is the Mon

It is also possible to access practical information
```python
print(ma5.SRA.isAlive)
print(sample.SRA.isAlive)
# Output: True
```
which simply checks the number of entries in the final cut. Hence one can remove the SRs which does
not have any statistics;
```python
alive = ma5.get_alive()
alive = sample.get_alive()
print(f"Number of cutflows survived : {len(alive)},\nNames of the cutflows : { ', '.join([x.id for x in alive]) }")
# Output:
# Number of cutflows survived : 8,
# Names of the cutflows : SRA_M, SRA_L, SRA_H, SRA, SRC, SRB, SRC_24, SRC_22
```
Each cut is accessible through the interface;
```python
fifth = ma5.SRA[5]
fifth = sample.SRA[5]
print(f"Efficiency : {fifth.eff:.3f}, Relative MC efficiency {fifth.mc_rel_eff:.3f}, number of events {fifth.Nevents:.1f}, sum of weights {fifth.sumW:.3f}")
# Output:
# Efficiency : 0.0004, Relative MC efficiency 0.377, number of events 284.7, sum of weights 0.008
Expand All @@ -129,7 +132,7 @@ One can also construct independent signal regions for sake of comparisson with M
```python
SRA_presel = [319.7,230.5,192.3,87.9,45.1,20.9,19.3,18.2,17.6,15.0,13.7]

ATLAS = CutFlowCollection()
ATLAS = ma5.cutflow.Collection()

ATLAS.addSignalRegion('SRA', ma5.SRA.CutNames, SRA_presel+[13.7])
ATLAS.addSignalRegion('SRA_L', ma5.SRA_L.CutNames, SRA_presel+[0.4])
Expand Down
165 changes: 78 additions & 87 deletions examples/LaTeXoutput.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
"metadata": {},
"outputs": [],
"source": [
"from ma5_expert import CutFlowCollection\n",
"from ma5_expert import CutFlowTable"
"import ma5_expert as ma5"
]
},
{
Expand All @@ -23,7 +22,7 @@
"metadata": {},
"outputs": [],
"source": [
"ma5 = CutFlowCollection(\n",
"sample = ma5.cutflow.Collection(\n",
" \"mass1000005_300.0_mass1000022_60.0_mass1000023_250.0_xs_5.689/Output/SAF/defaultset/atlas_susy_2018_31/Cutflows\",\n",
" xsection=5.689, \n",
" lumi=139.\n",
Expand All @@ -38,12 +37,12 @@
"source": [
"SRA_presel = [319.7,230.5,192.3,87.9,45.1,20.9,19.3,18.2,17.6,15.0,13.7]\n",
"\n",
"ATLAS = CutFlowCollection() \n",
"ATLAS = ma5.cutflow.Collection() \n",
"\n",
"ATLAS.addSignalRegion('SRA', ma5.SRA.CutNames, SRA_presel+[13.7])\n",
"ATLAS.addSignalRegion('SRA_L', ma5.SRA_L.CutNames, SRA_presel+[0.4])\n",
"ATLAS.addSignalRegion('SRA_M', ma5.SRA_M.CutNames, SRA_presel+[6.4])\n",
"ATLAS.addSignalRegion('SRA_H', ma5.SRA_H.CutNames, SRA_presel+[7.0])"
"ATLAS.addSignalRegion('SRA', sample.SRA.CutNames, SRA_presel+[13.7])\n",
"ATLAS.addSignalRegion('SRA_L', sample.SRA_L.CutNames, SRA_presel+[0.4])\n",
"ATLAS.addSignalRegion('SRA_M', sample.SRA_M.CutNames, SRA_presel+[6.4])\n",
"ATLAS.addSignalRegion('SRA_H', sample.SRA_H.CutNames, SRA_presel+[7.0])"
]
},
{
Expand Down Expand Up @@ -174,9 +173,9 @@
}
],
"source": [
"CutFlowTable(ATLAS,ma5, \n",
" notes=r' Some notes here for the caption ',\n",
" sample_names=['ATLAS', '{\\sc Ma5 - SFS}']).write_comparison_table()"
"ma5.cutflow.CutFlowTable(ATLAS,sample, \n",
" notes=r' Some notes here for the caption ',\n",
" sample_names=['ATLAS', '{\\sc Ma5 - SFS}']).write_comparison_table()"
]
},
{
Expand All @@ -202,24 +201,22 @@
"\\begin{table}[h]\n",
" \\begin{center}\n",
" \\renewcommand{\\arraystretch}{1.}\n",
" \\begin{tabular}{l||cc|cc}\n",
" & \\multicolumn{2}{c|}{ATLAS} &\\multicolumn{2}{c}{{\\sc Ma5 - SFS}} \\\\ \\hline\\hline\n",
" & Events & $\\varepsilon$ &Events & $\\varepsilon$ \\\\ \\hline\n",
" Initial & 319.7 & - &790771.0 & - \\\\\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &499909.0 & 0.632 \\\\\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &209971.2 & 0.420 \\\\\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &63883.2 & 0.304 \\\\\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &755.1 & 0.012 \\\\\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &284.7 & 0.377 \\\\\n",
" $\\tau^h$ veto & 19.3 & 0.923 &268.9 & 0.944 \\\\\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &130.5 & 0.485 \\\\\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &98.8 & 0.758 \\\\\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &98.8 & 1.000 \\\\\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &39.5 & 0.400 \\\\\n",
" $m_{eff} > 1$ [TeV] & 13.7 & 1.000 &39.5 & 1.000 \\\\\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\\multicolumn{2}{c}{288.635\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/S+B$} &\\multicolumn{2}{c}{74.269\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\\multicolumn{2}{c}{10.683}\\\\\n",
" \\begin{tabular}{l||cc|}\n",
" & \\multicolumn{2}{c|}{Sample 0} & & Events & $\\varepsilon$ & Initial & 319.7 & - &\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &\n",
" $\\tau^h$ veto & 19.3 & 0.923 &\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &\n",
" $m_{eff} > 1$ [TeV] & 13.7 & 1.000 &\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\n",
" \\multicolumn{3}{c}{$S/S+B$} &\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\n",
" \\end{tabular}\n",
" \\caption{SRA}\n",
" \\end{center}\n",
Expand All @@ -232,24 +229,22 @@
"\\begin{table}[h]\n",
" \\begin{center}\n",
" \\renewcommand{\\arraystretch}{1.}\n",
" \\begin{tabular}{l||cc|cc}\n",
" & \\multicolumn{2}{c|}{ATLAS} &\\multicolumn{2}{c}{{\\sc Ma5 - SFS}} \\\\ \\hline\\hline\n",
" & Events & $\\varepsilon$ &Events & $\\varepsilon$ \\\\ \\hline\n",
" Initial & 319.7 & - &790771.0 & - \\\\\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &499909.0 & 0.632 \\\\\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &209971.2 & 0.420 \\\\\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &63883.2 & 0.304 \\\\\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &755.1 & 0.012 \\\\\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &284.7 & 0.377 \\\\\n",
" $\\tau^h$ veto & 19.3 & 0.923 &268.9 & 0.944 \\\\\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &130.5 & 0.485 \\\\\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &98.8 & 0.758 \\\\\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &98.8 & 1.000 \\\\\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &39.5 & 0.400 \\\\\n",
" $m_{eff} \\in [1,1.5]$ [TeV] & 0.4 & 0.029 &23.7 & 0.600 \\\\\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\\multicolumn{2}{c}{5930.515\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/S+B$} &\\multicolumn{2}{c}{98.342\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\\multicolumn{2}{c}{37.508}\\\\\n",
" \\begin{tabular}{l||cc|}\n",
" & \\multicolumn{2}{c|}{Sample 0} & & Events & $\\varepsilon$ & Initial & 319.7 & - &\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &\n",
" $\\tau^h$ veto & 19.3 & 0.923 &\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &\n",
" $m_{eff} \\in [1,1.5]$ [TeV] & 0.4 & 0.029 &\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\n",
" \\multicolumn{3}{c}{$S/S+B$} &\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\n",
" \\end{tabular}\n",
" \\caption{SRA L}\n",
" \\end{center}\n",
Expand All @@ -262,24 +257,22 @@
"\\begin{table}[h]\n",
" \\begin{center}\n",
" \\renewcommand{\\arraystretch}{1.}\n",
" \\begin{tabular}{l||cc|cc}\n",
" & \\multicolumn{2}{c|}{ATLAS} &\\multicolumn{2}{c}{{\\sc Ma5 - SFS}} \\\\ \\hline\\hline\n",
" & Events & $\\varepsilon$ &Events & $\\varepsilon$ \\\\ \\hline\n",
" Initial & 319.7 & - &790771.0 & - \\\\\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &499909.0 & 0.632 \\\\\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &209971.2 & 0.420 \\\\\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &63883.2 & 0.304 \\\\\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &755.1 & 0.012 \\\\\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &284.7 & 0.377 \\\\\n",
" $\\tau^h$ veto & 19.3 & 0.923 &268.9 & 0.944 \\\\\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &130.5 & 0.485 \\\\\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &98.8 & 0.758 \\\\\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &98.8 & 1.000 \\\\\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &39.5 & 0.400 \\\\\n",
" $m_{eff} \\in [1.5,2]$ [TeV] & 6.4 & 0.467 &11.9 & 0.300 \\\\\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\\multicolumn{2}{c}{185.388\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/S+B$} &\\multicolumn{2}{c}{64.960\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\\multicolumn{2}{c}{4.690}\\\\\n",
" \\begin{tabular}{l||cc|}\n",
" & \\multicolumn{2}{c|}{Sample 0} & & Events & $\\varepsilon$ & Initial & 319.7 & - &\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &\n",
" $\\tau^h$ veto & 19.3 & 0.923 &\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &\n",
" $m_{eff} \\in [1.5,2]$ [TeV] & 6.4 & 0.467 &\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\n",
" \\multicolumn{3}{c}{$S/S+B$} &\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\n",
" \\end{tabular}\n",
" \\caption{SRA M}\n",
" \\end{center}\n",
Expand All @@ -292,24 +285,22 @@
"\\begin{table}[h]\n",
" \\begin{center}\n",
" \\renewcommand{\\arraystretch}{1.}\n",
" \\begin{tabular}{l||cc|cc}\n",
" & \\multicolumn{2}{c|}{ATLAS} &\\multicolumn{2}{c}{{\\sc Ma5 - SFS}} \\\\ \\hline\\hline\n",
" & Events & $\\varepsilon$ &Events & $\\varepsilon$ \\\\ \\hline\n",
" Initial & 319.7 & - &790771.0 & - \\\\\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &499909.0 & 0.632 \\\\\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &209971.2 & 0.420 \\\\\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &63883.2 & 0.304 \\\\\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &755.1 & 0.012 \\\\\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &284.7 & 0.377 \\\\\n",
" $\\tau^h$ veto & 19.3 & 0.923 &268.9 & 0.944 \\\\\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &130.5 & 0.485 \\\\\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &98.8 & 0.758 \\\\\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &98.8 & 1.000 \\\\\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &39.5 & 0.400 \\\\\n",
" $m_{eff} > 2$ [TeV] & 7.0 & 0.511 &4.0 & 0.100 \\\\\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\\multicolumn{2}{c}{56.515\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/S+B$} &\\multicolumn{2}{c}{36.108\\%}\\\\\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\\multicolumn{2}{c}{1.495}\\\\\n",
" \\begin{tabular}{l||cc|}\n",
" & \\multicolumn{2}{c|}{Sample 0} & & Events & $\\varepsilon$ & Initial & 319.7 & - &\n",
" $N_{lep} = 0$ & 230.5 & 0.721 &\n",
" $N_{j} \\geq 6$ & 192.3 & 0.834 &\n",
" $N_{b} \\geq 4$ & 87.9 & 0.457 &\n",
" $\\slashed{E}_T > 350$ [GeV] & 45.1 & 0.513 &\n",
" $min(\\Delta\\phi(j_{1-4},\\slashed{E}_T))>0.4$ [rad]& 20.9 & 0.463 &\n",
" $\\tau^h$ veto & 19.3 & 0.923 &\n",
" $p^{b_1}_T > 200$ [GeV] & 18.2 & 0.943 &\n",
" $\\Delta R_{max}(b,b)>2.5$ & 17.6 & 0.967 &\n",
" $\\Delta R_{max-min}(b,b)<2.5$ & 15.0 & 0.852 &\n",
" $m(h_{cand})>80$ [GeV] & 13.7 & 0.913 &\n",
" $m_{eff} > 2$ [TeV] & 7.0 & 0.511 &\\hline\\hline\n",
" \\multicolumn{3}{c}{$S/B$} &\n",
" \\multicolumn{3}{c}{$S/S+B$} &\n",
" \\multicolumn{3}{c}{$S/\\sqrt{B}$} &\n",
" \\end{tabular}\n",
" \\caption{SRA H}\n",
" \\end{center}\n",
Expand All @@ -319,9 +310,9 @@
}
],
"source": [
"CutFlowTable(ATLAS,ma5, \n",
" notes=r' Some notes here for the caption ',\n",
" sample_names=['ATLAS', '{\\sc Ma5 - SFS}']).write_signal_comparison_table()"
"ma5.cutflow.CutFlowTable(ATLAS,ma5, \n",
" notes=r' Some notes here for the caption ',\n",
" sample_names=['ATLAS', '{\\sc Ma5 - SFS}']).write_signal_comparison_table()"
]
},
{
Expand All @@ -348,7 +339,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.8.2"
"version": "3.8.9"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 67d6eb2

Please sign in to comment.