Skip to content

Commit

Permalink
fix : simplify commands, remove isJERC, isCorr flag
Browse files Browse the repository at this point in the history
- workflow: remove isJERC,isCorr flags
- ci: change to run3 as default

Merge branch 'spandan_brux'

Conflicts:
	README.md
	src/BTVNanoCommissioning/workflows/ctag_Wc_valid_sf.py
	src/BTVNanoCommissioning/workflows/ctag_eWc_valid_sf.py
  • Loading branch information
Ming-Yan committed Sep 8, 2023
2 parents 3570b5c + 64613b9 commit c66835b
Show file tree
Hide file tree
Showing 23 changed files with 176 additions and 251 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/BTA_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ jobs:
- name: BTA workflow test
run: |
python runner.py --wf BTA --json metadata/test_bta_run3.json --campaign Summer22Run3 --executor iterative --isJERC
python runner.py --wf BTA --json metadata/test_bta_run3.json --campaign Summer22Run3 --executor iterative
- name: BTA_ttbar workflow test
run: |
python runner.py --wf BTA_ttbar --json metadata/test_bta_run3.json --campaign Summer22Run3 --executor iterative --isJERC
python runner.py --wf BTA_ttbar --json metadata/test_bta_run3.json --campaign Summer22Run3 --executor iterative
6 changes: 3 additions & 3 deletions .github/workflows/ctag_DY_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ jobs:
- name: Compile JEC
run: |
python -m BTVNanoCommissioning.utils.compile_jec 2017_UL jec_compiled
python -m BTVNanoCommissioning.utils.compile_jec Summer22Run3 jec_compiled
- name: ctag muon DY workflows with correctionlib
run: |
python runner.py --workflow ctag_DY_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --year 2017 --max 5 --chunk 50000
python runner.py --workflow ctag_DY_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray --year 2022

- name: ctag electron DY workflows with correctionlib
run: |
python runner.py --workflow ectag_DY_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --year 2017 --max 5 --chunk 50000
python runner.py --workflow ectag_DY_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray --year 2022
6 changes: 3 additions & 3 deletions .github/workflows/ctag_Wc_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,16 +88,16 @@ jobs:
- name: Compile JEC
run: |
python -m BTVNanoCommissioning.utils.compile_jec 2017_UL jec_compiled
python -m BTVNanoCommissioning.utils.compile_jec Summer22Run3 jec_compiled
- name: ctag muon W+c workflows with correctionlib
run: |
python runner.py --workflow ctag_Wc_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ctag_Wc_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag electron W+c workflows with correctionlib
run: |
python runner.py --workflow ectag_Wc_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ectag_Wc_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray


Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/ttbar_DL_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ jobs:
- name: Compile JEC
run: |
python -m BTVNanoCommissioning.utils.compile_jec 2017_UL jec_compiled
python -m BTVNanoCommissioning.utils.compile_jec Summer22Run3 jec_compiled
- name: btag dileptonic ttbar workflows with correctionlib
run: |
python runner.py --workflow ttdilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ttdilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag dileptonic muon ttbar workflows with correctionlib
run: |
python runner.py --workflow ctag_ttdilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ctag_ttdilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag dileptonic electron ttbar workflows with correctionlib
run: |
python runner.py --workflow ectag_ttdilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ectag_ttdilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag dileptonic emu ttbar workflows with correctionlib
run: |
python runner.py --workflow emctag_ttdilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow emctag_ttdilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
8 changes: 4 additions & 4 deletions .github/workflows/ttbar_SL_workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,19 @@ jobs:
- name: Compile JEC
run: |
python -m BTVNanoCommissioning.utils.compile_jec 2017_UL jec_compiled
python -m BTVNanoCommissioning.utils.compile_jec Summer22Run3 jec_compiled

- name: btag semileptonic ttbar workflows with correctionlib
run: |
python runner.py --workflow ttsemilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ttsemilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag semileptonic muon ttbar workflows with correctionlib
run: |
python runner.py --workflow ctag_ttsemilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ctag_ttsemilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
- name: ctag semileptonic electron ttbar workflows with correctionlib
run: |
python runner.py --workflow ectag_ttsemilep_sf --json metadata/nano_UL17_test.json --limit 1 --executor futures -j 6 --campaign 2017_UL --isCorr --isJERC --isSyst all --isArray --max 5 --chunk 50000
python runner.py --workflow ectag_ttsemilep_sf --json metadata/test_bta_run3.json --limit 1 --executor futures -j 6 --campaign Summer22Run3 --isSyst all --isArray
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ More options for `runner.py`
<p>

```
--wf {validation,ttcom,ttdilep_sf,ttsemilep_sf,emctag_ttdilep_sf,ctag_ttdilep_sf,ectag_ttdilep_sf,ctag_ttsemilep_sf,ectag_ttsemilep_sf,ctag_Wc_sf,ectag_Wc_sf,ctag_DY_sf,ectag_DY_sf,BTA,BTA_addPFMuons,BTA_addAllTracks}, --workflow {validation,ttcom,ttdilep_sf,ttsemilep_sf,emctag_ttdilep_sf,ctag_ttdilep_sf,ectag_ttdilep_sf,ctag_ttsemilep_sf,ectag_ttsemilep_sf,ctag_Wc_sf,ectag_Wc_sf,ctag_DY_sf,ectag_DY_sf,BTA,BTA_addPFMuons,BTA_addAllTracks}
--wf {validation,ttcom,ttdilep_sf,ttsemilep_sf,emctag_ttdilep_sf,ctag_ttdilep_sf,ectag_ttdilep_sf,ctag_ttsemilep_sf,ectag_ttsemilep_sf,ctag_Wc_sf,ectag_Wc_sf,ctag_DY_sf,ectag_DY_sf,BTA,BTA_addPFMuons,BTA_addAllTracks,BTA_ttbar}, --workflow {validation,ttcom,ttdilep_sf,ttsemilep_sf,emctag_ttdilep_sf,ctag_ttdilep_sf,ectag_ttdilep_sf,ctag_ttsemilep_sf,ectag_ttsemilep_sf,ctag_Wc_sf,ectag_Wc_sf,ctag_DY_sf,ectag_DY_sf,BTA,BTA_addPFMuons,BTA_addAllTracks,BTA_ttbar}
Which processor to run
-o OUTPUT, --output OUTPUT
Output histogram filename (default: hists.coffea)
Expand All @@ -73,14 +73,18 @@ More options for `runner.py`
--year YEAR Year
--campaign CAMPAIGN Dataset campaign, change the corresponding correction
files{ "Rereco17_94X","Winter22Run3","Summer22Run3","Summer22EERun3","2018_UL","2017_UL","2016preVFP_UL","2016postVFP_UL"}
--isCorr Run with SFs
--isJERC JER/JEC implemented to jet
--isSyst Run with systematics, all, weights_only(no JERC uncertainties included),JERC_split, None(not extract)
--isArray Output root files
--noHist Not save histogram coffea files
--overwrite Overwrite existing files
--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).
--executor {iterative,futures,parsl/slurm,parsl/condor,parsl/condor/naf_lite,dask/condor,dask/condor/brux,dask/slurm,dask/lpc,dask/lxplus,dask/casa}
The type of executor to use (default: futures). Other options can be implemented. For
example see https://parsl.readthedocs.io/en/stable/userguide/configuring.html-
`parsl/slurm` - tested at DESY/Maxwell- `parsl/condor` - tested at DESY, RWTH-
`parsl/condor/naf_lite` - tested at DESY- `dask/condor/brux` - tested at BRUX (Brown U)-
`dask/slurm` - tested at DESY/Maxwell- `dask/condor` - tested at DESY, RWTH- `dask/lpc` -
custom lpc/condor setup (due to write access restrictions)- `dask/lxplus` - custom
lxplus/condor setup (due to port restrictions)
-j WORKERS, --workers WORKERS
Number of workers (cores/threads) to use for multi- worker executors (e.g. futures or condor) (default:
3)
Expand Down Expand Up @@ -140,13 +144,13 @@ After a small test, you can run the full campaign for a dedicated phase space, s
- Dileptonic ttbar phase space : check performance for btag SFs, emu channel

```
python runner.py --workflow ttdilep_sf --json metadata/data_Winter22_emu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ttdilep_sf --json metadata/data_Winter22_emu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 (--executor ${scaleout_site})
```

- Semileptonic ttbar phase space : check performance for btag SFs, muon channel

```
python runner.py --workflow ttsemilep_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ttsemilep_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 (--executor ${scaleout_site})
```

</p>
Expand All @@ -159,26 +163,26 @@ python runner.py --workflow ttsemilep_sf --json metadata/data_Winter22_mu_BTV_Ru
- Dileptonic ttbar phase space : check performance for charm SFs, bjets enriched SFs, muon channel

```
python runner.py --workflow ctag_ttdilep_sf --json metadata/data_Winter22_mumu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ctag_ttdilep_sf --json metadata/data_Winter22_mumu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022(--executor ${scaleout_site})
```


- Semileptonic ttbar phase space : check performance for charm SFs, bjets enriched SFs, muon channel

```
python runner.py --workflow ctag_ttsemilep_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ctag_ttsemilep_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022(--executor ${scaleout_site})
```

- W+c phase space : check performance for charm SFs, cjets enriched SFs, muon channel

```
python runner.py --workflow ctag_Wc_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ctag_Wc_sf --json metadata/data_Winter22_mu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022(--executor ${scaleout_site})
```

- DY phase space : check performance for charm SFs, light jets enriched SFs, muon channel

```
python runner.py --workflow ctag_DY_sf --json metadata/data_Winter22_mumu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022 --isJERC --isCorr (--executor ${scaleout_site})
python runner.py --workflow ctag_DY_sf --json metadata/data_Winter22_mumu_BTV_Run3_2022_Comm_v1.json --campaign Winter22Run3 --year 2022(--executor ${scaleout_site})
```

</p>
Expand Down Expand Up @@ -612,7 +616,7 @@ python scripts/make_template.py -i "testfile/*.coffea" --lumi 7650 -o test.root

## Notes for developers
The BTV tutorial for coffea part is under `notebooks` and the template to construct new workflow is `src/BTVNanoCommissioning/workflows/example.py`
Here are some tips provided for developers working on their forked version of this repository.
Here are some tips provided for developers working on their forked version of this repository. Also some useful git commands can be found [here](https://codimd.web.cern.ch/wY3IrOBBT3i3GXIQxLMWPA)
### Setup CI pipeline for fork branch
Since the CI pipelines involve reading files via `xrootd` and access gitlab.cern.ch, you need to save some secrets in your forked directory.

Expand Down
6 changes: 0 additions & 6 deletions runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,13 @@ def get_main_parser():
],
help="Dataset campaign, change the corresponding correction files",
)
parser.add_argument("--isCorr", action="store_true", help="Run with SFs")
parser.add_argument(
"--isSyst",
default=None,
type=str,
choices=[None, "all", "weight_only", "JERC_split"],
help="Run with systematics, all, weights_only(no JERC uncertainties included),JERC_split, None",
)
parser.add_argument(
"--isJERC", action="store_true", help="JER/JEC implemented to jet"
)
parser.add_argument("--isArray", action="store_true", help="Output root files")
parser.add_argument(
"--noHist", action="store_true", help="Not output coffea histogram"
Expand Down Expand Up @@ -317,8 +313,6 @@ def get_main_parser():
args.year,
args.campaign,
f"{args.workflow}_{(sample_json).rstrip('.json')}",
args.isCorr,
args.isJERC,
args.isSyst,
args.isArray,
args.noHist,
Expand Down
6 changes: 2 additions & 4 deletions src/BTVNanoCommissioning/workflows/BTA_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ def __init__(
year="2022",
campaign="Summer22Run3",
name="",
isCorr=False,
isJERC=True,
isSyst=False,
isArray=True,
noHist=False,
Expand All @@ -36,7 +34,7 @@ def __init__(
self._year = year
self._campaign = campaign
self.chunksize = chunksize
self.isJERC = isJERC

self.SF_map = load_SF(self._campaign)
# addPFMuons: if true, include the TrkInc and PFMuon collections, used by QCD based SF methods
# addAllTracks: if true, include the Track collection used for JP calibration;
Expand All @@ -54,7 +52,7 @@ def process(self, events):
events = missing_branch(events)
shifts = []

if "JME" in self.SF_map.keys() and self.isJERC:
if "JME" in self.SF_map.keys():
shifts = JME_shifts(
shifts, self.SF_map, events, self._campaign, isRealData, False, True
)
Expand Down
8 changes: 4 additions & 4 deletions src/BTVNanoCommissioning/workflows/BTA_ttbar_producer.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ def __init__(
self,
year="2022",
campaign="Summer22Run3",
isCorr=False,
isJERC=True,
name="",
isSyst=False,
isArray=True,
noHist=False,
Expand All @@ -28,7 +27,8 @@ def __init__(
self._year = year
self._campaign = campaign
self.chunksize = chunksize
self.isJERC = isJERC

self.name = name
self.SF_map = load_SF(self._campaign)

### Custom initialzations for BTA_ttbar workflow ###
Expand All @@ -47,7 +47,7 @@ def process(self, events):
events = missing_branch(events)
shifts = []

if "JME" in self.SF_map.keys() and self.isJERC:
if "JME" in self.SF_map.keys():
shifts = JME_shifts(
shifts, self.SF_map, events, self._campaign, isRealData, False, True
)
Expand Down
19 changes: 8 additions & 11 deletions src/BTVNanoCommissioning/workflows/ctag_DY_valid_sf.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ def __init__(
year="2017",
campaign="Rereco17_94X",
name="",
isCorr=True,
isJERC=False,
isSyst=False,
isArray=False,
noHist=False,
Expand All @@ -42,17 +40,14 @@ def __init__(
self._year = year
self._campaign = campaign
self.name = name
self.isCorr = isCorr
self.isJERC = isJERC

self.isSyst = isSyst
self.isArray = isArray
self.noHist = noHist
self.lumiMask = load_lumi(self._campaign)
self.chunksize = chunksize
print(self._campaign)
## Load corrections
if isCorr:
self.SF_map = load_SF(self._campaign)
self.SF_map = load_SF(self._campaign)

@property
def accumulator(self):
Expand All @@ -63,7 +58,7 @@ def process(self, events):
dataset = events.metadata["dataset"]
events = missing_branch(events)
shifts = []
if "JME" in self.SF_map.keys() and self.isJERC:
if "JME" in self.SF_map.keys():
syst_JERC = True if self.isSyst != None else False
if self.isSyst == "JERC_split":
syst_JERC = "split"
Expand Down Expand Up @@ -120,7 +115,9 @@ def process_shift(self, events, shift_name):
req_lumi = np.ones(len(events), dtype="bool")
if isRealData:
req_lumi = self.lumiMask(events.run, events.luminosityBlock)
output = dump_lumi(events[req_lumi], output)
# only dump for nominal case
if shift_name is None:
output = dump_lumi(events[req_lumi], output)

## HLT
triggers = ["Mu17_TrkIsoVVL_Mu8_TrkIsoVVL_DZ_Mass8"]
Expand Down Expand Up @@ -255,7 +252,7 @@ def process_shift(self, events, shift_name):
weights.add("genweight", events[event_level].genWeight)
par_flav = (sel_jet.partonFlavour == 0) & (sel_jet.hadronFlavour == 0)
genflavor = sel_jet.hadronFlavour + 1 * par_flav
if self.isCorr:
if len(self.SF_map.keys()) > 0:
syst_wei = True if self.isSyst != None else False
if "PU" in self.SF_map.keys():
puwei(
Expand Down Expand Up @@ -368,7 +365,7 @@ def process_shift(self, events, shift_name):
),
weight=weights.partial_weight(exclude=exclude_btv),
)
if not isRealData and self.isCorr and "btag" in self.SF_map.keys():
if not isRealData and "btag" in self.SF_map.keys():
h.fill(
syst=syst,
flav=genflavor,
Expand Down
Loading

0 comments on commit c66835b

Please sign in to comment.