Skip to content

Commit

Permalink
fix: suggestions from Denise & fix semilep selection
Browse files Browse the repository at this point in the history
- improve documentation & implemented suggestion from Denise
- make ctag_ttsemilep selection sync with Wc
  • Loading branch information
Ming-Yan committed Feb 2, 2023
1 parent 5ca1048 commit 776e60e
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 35 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ More options for `runner.py`
files
--isCorr Run with SFs
--isJERC JER/JEC implemented to jet
--isSyst Run with systematics for SF
--executor {iterative,futures,parsl/slurm,parsl/condor,parsl/condor/naf_lite,dask/condor,dask/slurm,dask/lpc,dask/lxplus,dask/casa}
The type of executor to use (default: futures).
-j WORKERS, --workers WORKERS
Expand Down Expand Up @@ -283,8 +284,10 @@ WW_TuneCP5_13p6TeV-pythia8
:exclamation: Do not make the file list greater than 4k files to avoid scaleout issues in various site

## Correction files configurations
:heavy_exclamation_mark: If the correction files are not supported yet by jsonpog-integration, you can still try with custom input data.

### Options with custom input data

### Options with custom input data (deprecated)
All the `lumiMask`, correction files (SFs, pileup weight), and JEC, JER files are under `BTVNanoCommissioning/src/data/` following the substructure `${type}/${campaign}/${files}`(except `lumiMasks` and `Prescales`)

| Type | File type | Comments|
Expand Down Expand Up @@ -335,7 +338,7 @@ Create a `dict` entry under `correction_config` with dedicated campaigns in `BTV
</p>
</details>

### Use central maintained jsonpog-integration
### Use central maintained jsonpog-integration
The official correction files collected in [jsonpog-integration](https://gitlab.cern.ch/cms-nanoAOD/jsonpog-integration) is updated by POG except `lumiMask` and `JME` still updated by maintainer. No longer to request input files in the `correction_config`.

<details><summary>See the example with `2017_UL`.</summary>
Expand Down
4 changes: 2 additions & 2 deletions runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ def get_main_parser():
)
parser.add_argument(
"--memory",
type=str,
default="4GB",
type=int,
default=4,
help="Memory used in jobs default ``(default: %(default)s)",
)
parser.add_argument(
Expand Down
1 change: 0 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ project_urls =
packages = find:
install_requires =
vector
# scipy==1.9.3
coffea>=0.7.20


Expand Down
20 changes: 0 additions & 20 deletions src/BTVNanoCommissioning/utils/correction.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,16 +232,6 @@ def load_lumi(campaign):


##JEC
def load_jetfactory(campaign, path):
_jet_path = f"BTVNanoCommissioning.data.JME.{campaign}"
with importlib.resources.path(_jet_path, path) as filename:
with gzip.open(filename) as fin:
jmestuff = cloudpickle.load(fin)

jet_factory = jmestuff["jet_factory"]
return jet_factory


def load_jmefactory(campaign):
_jet_path = f"BTVNanoCommissioning.data.JME.{campaign}"
with importlib.resources.path(
Expand All @@ -263,16 +253,6 @@ def add_jec_variables(jets, event_rho):
return jets


def load_metfactory(campaign, path):
_jet_path = f"BTVNanoCommissioning.data.JME.{campaign}"
with importlib.resources.path(_jet_path, path) as filename:
with gzip.open(filename) as fin:
jmestuff = cloudpickle.load(fin)

met_factory = jmestuff["met_factory"]
return met_factory


## PU weight
def load_pu(campaign, path):
_pu_path = f"BTVNanoCommissioning.data.PU.{campaign}"
Expand Down
23 changes: 17 additions & 6 deletions src/BTVNanoCommissioning/workflows/ctag_ettsemilep_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,12 @@ def process(self, events):
req_ele = ak.count(iso_ele.pt, axis=1) == 1
iso_ele = ak.pad_none(iso_ele, 1, axis=1)
iso_ele = iso_ele[:, 0]

iso_eindx = ak.mask(
ak.local_index(events.Electron.pt),
((events.Electron.pt > 34) & ele_mvatightid(events, self._campaign)) == 1,
)
iso_eindx = ak.pad_none(iso_eindx, 1)
iso_eindx = iso_eindx[:, 0]
## Jet cuts
event_jet = events.Jet[
jet_id(events, self._campaign)
Expand Down Expand Up @@ -140,12 +145,18 @@ def process(self, events):

req_QCDveto = (
(iso_ele.pfRelIso03_all < 0.05)
& (abs(iso_ele.dz) < 0.01)
& (abs(iso_ele.dxy) < 0.002)
& (iso_ele.ip3d < 0.2)
& (abs(iso_ele.dz) < 0.02)
& (abs(iso_ele.dxy) < 0.01)
& (iso_ele.sip3d < 2.5)
& (
(iso_ele.pt / mu_jet[:, 0].pt < 0.0)
| (iso_ele.pt / mu_jet[:, 0].pt > 0.75)
iso_ele.pt
/ ak.firsts(
events.Jet[
(events.Jet.electronIdx1 == iso_eindx)
| ((events.Jet.electronIdx2 == iso_eindx))
].pt
)
> 0.75
)
)

Expand Down
21 changes: 17 additions & 4 deletions src/BTVNanoCommissioning/workflows/ctag_semileptt_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,16 +99,22 @@ def process(self, events):
req_muon = ak.count(iso_muon.pt, axis=1) == 1
iso_muon = ak.pad_none(iso_muon, 1, axis=1)
iso_muon = iso_muon[:, 0]
iso_muindx = ak.mask(
ak.local_index(events.Muon.pt),
((events.Muon.pt > 30) & mu_idiso(events, self._campaign)) == 1,
)
iso_muindx = ak.pad_none(iso_muindx, 1)
iso_muindx = iso_muindx[:, 0]

## Jet cuts
event_jet = events.Jet[
jet_id(events, self._campaign)
& (ak.all(events.Jet.metric_table(iso_muon) > 0.5, axis=2))
& ((events.Jet.muEF + events.Jet.neEmEF) < 0.7)
]
req_jets = ak.num(event_jet.pt) >= 4

## Soft Muon cuts

soft_muon = events.Muon[softmu_mask(events, self._campaign)]
req_softmu = ak.count(soft_muon.pt, axis=1) >= 1
soft_muon = ak.pad_none(soft_muon, 1, axis=1)
Expand All @@ -117,6 +123,7 @@ def process(self, events):
mu_jet = event_jet[
(ak.all(event_jet.metric_table(soft_muon) <= 0.4, axis=2))
& ((event_jet.muonIdx1 != -1) | (event_jet.muonIdx2 != -1))
& ((event_jet.muEF + event_jet.neEmEF) < 0.7)
]
req_mujet = ak.num(mu_jet.pt, axis=1) >= 1
mu_jet = ak.pad_none(mu_jet, 1, axis=1)
Expand Down Expand Up @@ -144,10 +151,16 @@ def process(self, events):
(iso_muon.pfRelIso04_all < 0.05)
& (abs(iso_muon.dz) < 0.01)
& (abs(iso_muon.dxy) < 0.002)
& (iso_muon.ip3d < 0.2)
& (iso_muon.sip3d < 2)
& (
(iso_muon.pt / mu_jet[:, 0].pt < 0.0)
| (iso_muon.pt / mu_jet[:, 0].pt > 0.75)
iso_muon.pt
/ ak.firsts(
events.Jet[
(events.Jet.muonIdx1 == iso_muindx)
| ((events.Jet.muonIdx2 == iso_muindx))
].pt
)
> 0.75
)
)

Expand Down

0 comments on commit 776e60e

Please sign in to comment.