Skip to content

Commit

Permalink
Initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
riga committed Aug 22, 2022
1 parent e26ca06 commit c9c0d11
Show file tree
Hide file tree
Showing 32 changed files with 2,269 additions and 2 deletions.
10 changes: 10 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[flake8]

# line length of 100 is recommended, but set it to a forgiving value
max-line-length = 120

# codes of errors to ignore
ignore = E128, E306, E402, E722, E731, W504

# enforce double quotes
inline-quotes = double
5 changes: 5 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.jpg filter=lfs diff=lfs merge=lfs -text
*.jpeg filter=lfs diff=lfs merge=lfs -text
*.root filter=lfs diff=lfs merge=lfs -text
36 changes: 36 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
*.sublime-project
*.sublime-workspace
*.pyc
*.log
*.DS_Store
*.egg-info
*.pkl
*.pdf
*.png
*.root
*.npy
*.npz
*.h5
*.hdf5
*.json
*.yaml
*.pb
*.out
*.parquet
.env_*.sh
.env_*.sh.tmp
.coverage
coverage*.xml
requirements_user.txt
__pycache__
dist
build
static
docs/_build
tmp
store
software
data
.data
.law
.setups
7 changes: 7 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[submodule "modules/columnflow"]
path = modules/columnflow
url = ../columnflow.git

[submodule "modules/cmsdb"]
path = modules/cmsdb
url = ../cmsdb.git
49 changes: 47 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,47 @@
# hh2bbtautau
HH → bb𝜏𝜏 analysis with CMS
# HH → bb𝜏𝜏

### Quickstart

A couple test tasks are listed below.
They might require a **valid voms proxy** for accessing input data.

```shell
# clone the project
git clone --recursive [email protected]:uhh-cms/hh2bbtautau.git
cd hh2bbtautau

# source the setup and store decisions in .setups/dev.sh (arbitrary name)
source setup.sh dev

# index existing tasks once to enable auto-completion for "law run"
law index --verbose

# run your first task
# (they are all shipped with columnflow and thus have the "cf." prefix)
law run cf.ReduceEvents \
--version v1 \
--dataset st_tchannel_t \
--branch 0

# create a plot
law run cf.PlotVariables \
--version v1 \
--datasets st_tchannel_t \
--producers features \
--variables jet1_pt \
--categories 1e \
--branch 0

# create a (test) datacard (CMS-style)
law run cf.CreateDatacards \
--version v1 \
--producers features \
--inference-model test \
--workers 3
```


### Development

- Source hosted at [GitHub](https://github.com/uhh-cms/hh2bbtautau)
- Report issues, questions, feature requests on [GitHub Issues](https://github.com/uhh-cms/hh2bbtautau/issues)
1 change: 1 addition & 0 deletions hbt/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# coding: utf-8
1 change: 1 addition & 0 deletions hbt/calibration/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# coding: utf-8
57 changes: 57 additions & 0 deletions hbt/calibration/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# coding: utf-8

"""
Calibration methods for testing purposes.
"""

from columnflow.calibration import Calibrator, calibrator
from columnflow.production.seeds import deterministic_seeds
from columnflow.util import maybe_import
from columnflow.columnar_util import set_ak_column

np = maybe_import("numpy")
ak = maybe_import("awkward")


@calibrator(
uses={
"nJet", "Jet.pt", "Jet.mass",
},
produces={
"Jet.pt", "Jet.mass",
"Jet.pt_jec_up", "Jet.mass_jec_up",
"Jet.pt_jec_down", "Jet.mass_jec_down",
},
)
def jec_test(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
# a) "correct" Jet.pt by scaling four momenta by 1.1 (pt<30) or 0.9 (pt<=30)
# b) add 4 new columns representing the effect of JEC variations

# a)
a_mask = ak.flatten(events.Jet.pt < 30)
n_jet_pt = np.asarray(ak.flatten(events.Jet.pt))
n_jet_mass = np.asarray(ak.flatten(events.Jet.mass))
n_jet_pt[a_mask] *= 1.1
n_jet_pt[~a_mask] *= 0.9
n_jet_mass[a_mask] *= 1.1
n_jet_mass[~a_mask] *= 0.9

# b)
set_ak_column(events, "Jet.pt_jec_up", events.Jet.pt * 1.05)
set_ak_column(events, "Jet.mass_jec_up", events.Jet.mass * 1.05)
set_ak_column(events, "Jet.pt_jec_down", events.Jet.pt * 0.95)
set_ak_column(events, "Jet.mass_jec_down", events.Jet.mass * 0.95)

return events


@calibrator(
uses={jec_test, deterministic_seeds},
produces={jec_test, deterministic_seeds},
)
def test(self: Calibrator, events: ak.Array, **kwargs) -> ak.Array:
self[jec_test](events, **kwargs)

self[deterministic_seeds](events, **kwargs)

return events
1 change: 1 addition & 0 deletions hbt/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# coding: utf-8
Loading

0 comments on commit c9c0d11

Please sign in to comment.