Skip to content

Commit

Permalink
Merge pull request #64 from cms-l1-dpg/refactored_tools
Browse files Browse the repository at this point in the history
Refactored tools
  • Loading branch information
artlbv authored Mar 1, 2024
2 parents 5146601 + 07ce06d commit 73b1253
Show file tree
Hide file tree
Showing 296 changed files with 8,468 additions and 10,865 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[flake8]
ignore = W391, W503
max-line-length = 79
max-line-length = 88
extend-ignore = E203, E704, E266
exclude = menu_tools/object_performance/quality_obj.py,menu_tools/**/test_*.py
25 changes: 0 additions & 25 deletions .github/workflows/action.yml

This file was deleted.

41 changes: 41 additions & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Code quality
on: [push, pull_request, workflow_dispatch]

jobs:
black-lint:
runs-on: ubuntu-latest
name: black
steps:
- uses: actions/checkout@v3
- uses: psf/black@stable
with:
options: "--check --verbose"
src: "./menu_tools"
version: "~= 23.12"
flake8-lint:
runs-on: ubuntu-latest
name: flake8
steps:
- name: Check out source repository
uses: actions/checkout@v3
- name: Set up Python environment
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: flake8 Lint
uses: py-actions/flake8@v2
with:
path: "./menu_tools"
mypy-type-check:
runs-on: ubuntu-latest
name: mypy
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.11'
architecture: 'x64'
- run: |
python -m pip install --upgrade pip poetry
poetry install
poetry run mypy
11 changes: 8 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
**/__pycache__/*
*.pyc
pyenv/*
**/*.png
**/*.pdf
**/.DS_Store
**/*.parquet
**/rates.py
objectPerformance/**/*.root
objectPerformance/outputs/**/*
**/*.root
rates/table/out/*
rates/table/cache/**/*
rates/table/lib/*
rates/table/rates_tables/*
**/tmp/*
outputs
menu_tools.egg-info
dist
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@
Detailed instructions on how to run each step of the workflow are
provided in each folder.

## Setup of Python environment
**Note:** The code should run without any setup on `lxplus`.
## Setup

A standard venv with Python3.11 can be created on lxplus
via `python3.11 -m venv <name_of_venv>` and all necessary
dependencies installed via `pip install -r requirements.txt`.
dependencies installed via `pip install .`:

You can then execute the scripts either with `python <path_to_script>.py`
or by modifying the [shebang](https://en.wikipedia.org/wiki/Shebang_%28Unix%29).
(the very first line of the executable `.py` files which starts
with `#!`) to point
to your newly set up Python installation. To find the path run
```bash
python3.11 -m venv pyenv
source <name_of_venv>/bin/activate
pip install .
```

source <name_of_venv>/bin/activate
which python
**ATTENTION:** Whenever you pull changes you need to `pip install . --upgrade`

and replace the current path in the shebang with the output.
You can then execute the tools via

```python
cach_objects <path_to_config>
object_performance <path_to_config>
rate_plots <path_to_config>
```
1 change: 1 addition & 0 deletions cache
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ V29:
phase1PuppiHT: "all"
seededConePuppiJet: [Pt, Et, Eta, Phi]
seededConeExtendedPuppiJet: [Pt, Et, Eta, Phi, BJetNN]
seededConeExtendedPuppiHT: "all"
seededConePuppiHT: "all"
seededConePuppiMHT: "all"
tkElectron: [Pt, Et, Eta, Phi, Chg, Bx, TrkIso, PfIso, PuppiIso, zVtx, HwQual, HGC, PassesEleID, PassesPhoID]
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
ElectronsIsolation_Barrel:
sample: DYLL_M50
default_version: V27
version: V29
match_test_to_ref: True
iso_vs_efficiency: True
reference_object:
object: "part_e"
suffix: "Pt"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
Expand All @@ -13,13 +14,7 @@ ElectronsIsolation_Barrel:
object:
- "abs({eta}) < 1.479"
test_objects:
tkElectron:
suffix: "trkiso"
label: "TkElectron"
match_dR: 0.15
cuts:
- "abs({eta}) < 2.4"
- "{passeseleid} == 1"
tkElectron:NoIso: "trkiso"
xlabel: "Isolation"
ylabel: "Efficiency (Barrel)"
binning:
Expand All @@ -29,11 +24,12 @@ ElectronsIsolation_Barrel:

ElectronsIsolation_Endcap:
sample: DYLL_M50
default_version: V27
version: V29
match_test_to_ref: True
iso_vs_efficiency: True
reference_object:
object: "part_e"
suffix: "Pt"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
Expand All @@ -42,13 +38,7 @@ ElectronsIsolation_Endcap:
object:
- "abs({eta}) < 2.4"
test_objects:
tkElectron:
suffix: "trkiso"
label: "TkElectron"
match_dR: 0.15
cuts:
- "abs({eta}) < 2.4"
#- "{passeseleid} == 1"
tkElectron:NoIsoForIso: "trkiso"
xlabel: "Isolation"
ylabel: "Efficiency (Endcap)"
binning:
Expand Down
51 changes: 51 additions & 0 deletions configs/V29/object_performance/electron_matching.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
ElectronsMatchingBarrel:
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
- "{dr_0.3} < 0.15"
- "abs({eta}) < 1.5"
object:
- "abs({eta}) < 2.4"
test_objects:
EG:default: "Pt"
tkElectron:NoIso: "Pt"
tkElectron:NoIsoLowPt: "Pt"
tkElectron:Iso: "Pt"
xlabel: "Gen. $p_T$ (GeV)"
ylabel: "Matching Efficiency (Barrel)"
binning:
min: 0
max: 100
step: 3

ElectronsMatchingEndcap:
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
- "{dr_0.3} < 0.15"
- "abs({eta}) > 1.5"
object:
- "abs({eta}) < 2.4"
test_objects:
EG:default: "Pt"
tkElectron:NoIso: "Pt"
tkElectron:NoIsoLowPt: "Pt"
tkElectron:Iso: "Pt"
xlabel: "Gen. $p_T$ (GeV)"
ylabel: "Matching Efficiency (Endcap)"
binning:
min: 0
max: 100
step: 3
52 changes: 52 additions & 0 deletions configs/V29/object_performance/electron_matching_eta.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ElectronsMatching_Eta_Pt10to25:
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
x_arg: "Eta"
label: "Gen Electrons"
cuts:
event:
- "{dr_0.3} < 0.15"
- "{pt} < 25"
- "{pt} > 10"
object:
- "abs({eta}) < 3.0"
test_objects:
EG:default: "Eta"
tkElectron:NoIso: "Eta"
tkElectron:NoIsoLowPt: "Eta"
tkElectron:Iso: "Eta"
xlabel: "Gen. $\\eta$"
ylabel: "Matching Efficiency ($10 < p_T < 25$ GeV)"
binning:
min: -3
max: 3
step: 0.2

ElectronsMatching_Eta_Pt25toInf:
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
x_arg: "Eta"
label: "Gen Electrons"
cuts:
event:
- "{dr_0.3} < 0.15"
- "{pt} > 25"
object:
- "abs({eta}) < 3.0"
test_objects:
EG:default: "Eta"
tkElectron:NoIso: "Eta"
tkElectron:NoIsoLowPt: "Eta"
tkElectron:Iso: "Eta"
xlabel: "Gen. $\\eta$"
ylabel: "Matching Efficiency ($p_T > 25$ GeV)"
binning:
min: -3
max: 3
step: 0.2
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
ElectronsTriggerBarrel:
sample: Zee
default_version: V26
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
suffix: "Pt"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
Expand All @@ -12,21 +13,10 @@ ElectronsTriggerBarrel:
object:
- "abs({eta}) < 2.8"
test_objects:
EG:
suffix: "Pt"
label: "EG Electron"
match_dR: 0.2
quality_id: "QUAL_125x_EGID"
cuts:
- "abs({eta}) < 2.8"
# - "{passeseleid} == 1"
tkElectron:
suffix: "Pt"
label: "tkElectron"
match_dR: 0.15
cuts:
- "{passeseleid} == 1"
- "abs({eta}) < 2.8"
EG:default:barrel: "Pt"
tkElectron:NoIso:barrel: "Pt"
tkElectron:NoIsoLowPt:barrel: "Pt"
tkElectron:Iso:barrel: "Pt"
thresholds: [10, 20, 30, 40]
scalings:
method: "naive"
Expand All @@ -35,15 +25,16 @@ ElectronsTriggerBarrel:
ylabel: "Trigger Efficiency (barrel, L1 $p_T > <threshold>$ GeV)"
binning:
min: 0
max: 150
max: 100
step: 1.5

ElectronsTriggerEndcap:
sample: Zee
default_version: V26
sample: DYLL_M50
version: V29
match_test_to_ref: True
reference_object:
object: "part_e"
suffix: "Pt"
x_arg: "Pt"
label: "Gen Electrons"
cuts:
event:
Expand All @@ -52,21 +43,10 @@ ElectronsTriggerEndcap:
object:
- "abs({eta}) < 2.8"
test_objects:
EG:
suffix: "Pt"
label: "EG Electron"
match_dR: 0.2
quality_id: "QUAL_125x_EGID"
cuts:
- "abs({eta}) < 2.8"
# - "{passessaid} == 1"
tkElectron:
suffix: "Pt"
label: "tkElectron"
match_dR: 0.15
cuts:
- "{passeseleid} == 1"
- "abs({eta}) < 2.8"
EG:default:endcap: "Pt"
tkElectron:NoIso:endcap: "Pt"
tkElectron:NoIsoLowPt:endcap: "Pt"
tkElectron:Iso:endcap: "Pt"
thresholds: [10, 20, 30, 40]
scalings:
method: "naive"
Expand All @@ -75,5 +55,5 @@ ElectronsTriggerEndcap:
ylabel: "Trigger Efficiency (endcap, L1 $p_T > <threshold>$ GeV)"
binning:
min: 0
max: 150
max: 100
step: 1.5
Loading

0 comments on commit 73b1253

Please sign in to comment.