7
7
from __future__ import annotations
8
8
9
9
import os
10
- import re
11
10
12
11
import yaml
13
12
from scinum import Number
14
13
import law
15
14
import order as od
16
15
17
16
from columnflow .util import DotDict
17
+ from columnflow .config_util import add_shift_aliases
18
18
from hbw .config .styling import stylize_processes
19
19
from hbw .config .categories import add_categories_selection
20
20
from hbw .config .variables import add_variables
@@ -139,14 +139,14 @@ def add_config(
139
139
jerc_postfix = ""
140
140
if year == 2016 and campaign .x .vfp == "post" :
141
141
jerc_postfix = "APV"
142
- elif year == 2022 :
143
- jerc_postfix = f" { campaign . x . EE } EE"
142
+ elif year == 2022 and campaign . x . EE == "post" :
143
+ jerc_postfix = " EE"
144
144
145
145
if cfg .x .run == 2 :
146
146
jerc_campaign = f"Summer19UL{ year2 } { jerc_postfix } "
147
147
jet_type = "AK4PFchs"
148
148
elif cfg .x .run == 3 :
149
- jerc_campaign = f"Winter { year2 } Run3 "
149
+ jerc_campaign = f"Summer { year2 } { jerc_postfix } _22Sep2023 "
150
150
jet_type = "AK4PFPuppi"
151
151
152
152
cfg .x .jec = DotDict .wrap ({
@@ -219,8 +219,8 @@ def add_config(
219
219
# https://twiki.cern.ch/twiki/bin/view/CMS/JetResolution?rev=107
220
220
# TODO: get jerc working for Run3
221
221
cfg .x .jer = DotDict .wrap ({
222
- "campaign" : jerc_campaign if cfg . x . run == 2 else f"JR_ { jerc_campaign } " ,
223
- "version" : {2016 : "JRV3" , 2017 : "JRV2" , 2018 : "JRV2" , 2022 : "V1 " }[year ],
222
+ "campaign" : jerc_campaign ,
223
+ "version" : {2016 : "JRV3" , 2017 : "JRV2" , 2018 : "JRV2" , 2022 : "V2 " }[year ],
224
224
"jet_type" : jet_type ,
225
225
})
226
226
@@ -297,19 +297,6 @@ def add_config(
297
297
# (used in the muon producer)
298
298
cfg .x .muon_sf_names = ("NUM_TightRelIso_DEN_TightIDandIPCut" , f"{ cfg .x .cpn_tag } _UL" )
299
299
300
- # helper to add column aliases for both shifts of a source
301
- # TODO: switch to the columnflow function (but what happened to *selection_dependent*?)
302
- def add_shift_aliases (shift_source : str , aliases : dict [str ], selection_dependent : bool ):
303
-
304
- for direction in ["up" , "down" ]:
305
- shift = cfg .get_shift (od .Shift .join_name (shift_source , direction ))
306
- # format keys and values
307
- inject_shift = lambda s : re .sub (r"\{([^_])" , r"{_\1" , s ).format (** shift .__dict__ )
308
- _aliases = {inject_shift (key ): inject_shift (value ) for key , value in aliases .items ()}
309
- alias_type = "column_aliases_selection_dependent" if selection_dependent else "column_aliases"
310
- # extend existing or register new column aliases
311
- shift .set_aux (alias_type , shift .get_aux (alias_type , {})).update (_aliases )
312
-
313
300
# register shifts
314
301
# TODO: make shifts year-dependent
315
302
cfg .add_shift (name = "nominal" , id = 0 )
@@ -320,27 +307,28 @@ def add_shift_aliases(shift_source: str, aliases: dict[str], selection_dependent
320
307
cfg .add_shift (name = "minbias_xs_up" , id = 7 , type = "shape" )
321
308
cfg .add_shift (name = "minbias_xs_down" , id = 8 , type = "shape" )
322
309
add_shift_aliases (
310
+ cfg ,
323
311
"minbias_xs" ,
324
312
{
325
313
"pu_weight" : "pu_weight_{name}" ,
326
314
"normalized_pu_weight" : "normalized_pu_weight_{name}" ,
327
315
},
328
- selection_dependent = False )
316
+ )
329
317
cfg .add_shift (name = "top_pt_up" , id = 9 , type = "shape" )
330
318
cfg .add_shift (name = "top_pt_down" , id = 10 , type = "shape" )
331
- add_shift_aliases ("top_pt" , {"top_pt_weight" : "top_pt_weight_{direction}" }, selection_dependent = False )
319
+ add_shift_aliases (cfg , "top_pt" , {"top_pt_weight" : "top_pt_weight_{direction}" })
332
320
333
321
cfg .add_shift (name = "e_sf_up" , id = 40 , type = "shape" )
334
322
cfg .add_shift (name = "e_sf_down" , id = 41 , type = "shape" )
335
323
cfg .add_shift (name = "e_trig_sf_up" , id = 42 , type = "shape" )
336
324
cfg .add_shift (name = "e_trig_sf_down" , id = 43 , type = "shape" )
337
- add_shift_aliases ("e_sf" , {"electron_weight" : "electron_weight_{direction}" }, selection_dependent = False )
325
+ add_shift_aliases (cfg , "e_sf" , {"electron_weight" : "electron_weight_{direction}" })
338
326
339
327
cfg .add_shift (name = "mu_sf_up" , id = 50 , type = "shape" )
340
328
cfg .add_shift (name = "mu_sf_down" , id = 51 , type = "shape" )
341
329
cfg .add_shift (name = "mu_trig_sf_up" , id = 52 , type = "shape" )
342
330
cfg .add_shift (name = "mu_trig_sf_down" , id = 53 , type = "shape" )
343
- add_shift_aliases ("mu_sf" , {"muon_weight" : "muon_weight_{direction}" }, selection_dependent = False )
331
+ add_shift_aliases (cfg , "mu_sf" , {"muon_weight" : "muon_weight_{direction}" })
344
332
345
333
btag_uncs = [
346
334
"hf" , "lf" , f"hfstats1_{ year } " , f"hfstats2_{ year } " ,
@@ -350,12 +338,12 @@ def add_shift_aliases(shift_source: str, aliases: dict[str], selection_dependent
350
338
cfg .add_shift (name = f"btag_{ unc } _up" , id = 100 + 2 * i , type = "shape" )
351
339
cfg .add_shift (name = f"btag_{ unc } _down" , id = 101 + 2 * i , type = "shape" )
352
340
add_shift_aliases (
341
+ cfg ,
353
342
f"btag_{ unc } " ,
354
343
{
355
344
"normalized_btag_weight" : f"normalized_btag_weight_{ unc } _" + "{direction}" ,
356
345
"normalized_njet_btag_weight" : f"normalized_njet_btag_weight_{ unc } _" + "{direction}" ,
357
346
},
358
- selection_dependent = False ,
359
347
)
360
348
361
349
cfg .add_shift (name = "mur_up" , id = 201 , type = "shape" )
@@ -368,28 +356,40 @@ def add_shift_aliases(shift_source: str, aliases: dict[str], selection_dependent
368
356
cfg .add_shift (name = "pdf_down" , id = 208 , type = "shape" )
369
357
370
358
for unc in ["mur" , "muf" , "murf_envelope" , "pdf" ]:
371
- # add_shift_aliases(unc, {f"{unc}_weight": f"{unc}_weight_" + "{direction}"}, selection_dependent=False )
359
+ # add_shift_aliases(cfg, unc, {f"{unc}_weight": f"{unc}_weight_" + "{direction}"})
372
360
add_shift_aliases (
361
+ cfg ,
373
362
unc ,
374
363
{f"normalized_{ unc } _weight" : f"normalized_{ unc } _weight_" + "{direction}" },
375
- selection_dependent = False ,
376
364
)
377
365
378
366
with open (os .path .join (thisdir , "jec_sources.yaml" ), "r" ) as f :
379
367
all_jec_sources = yaml .load (f , yaml .Loader )["names" ]
380
368
for jec_source in cfg .x .jec ["uncertainty_sources" ]:
381
369
idx = all_jec_sources .index (jec_source )
382
- cfg .add_shift (name = f"jec_{ jec_source } _up" , id = 5000 + 2 * idx , type = "shape" )
383
- cfg .add_shift (name = f"jec_{ jec_source } _down" , id = 5001 + 2 * idx , type = "shape" )
370
+ cfg .add_shift (
371
+ name = f"jec_{ jec_source } _up" ,
372
+ id = 5000 + 2 * idx ,
373
+ type = "shape" ,
374
+ tags = {"jec" },
375
+ aux = {"jec_source" : jec_source },
376
+ )
377
+ cfg .add_shift (
378
+ name = f"jec_{ jec_source } _down" ,
379
+ id = 5001 + 2 * idx ,
380
+ type = "shape" ,
381
+ tags = {"jec" },
382
+ aux = {"jec_source" : jec_source },
383
+ )
384
384
add_shift_aliases (
385
+ cfg ,
385
386
f"jec_{ jec_source } " ,
386
387
{"Jet.pt" : "Jet.pt_{name}" , "Jet.mass" : "Jet.mass_{name}" },
387
- selection_dependent = True ,
388
388
)
389
389
390
- cfg .add_shift (name = "jer_up" , id = 6000 , type = "shape" , tags = {"selection_dependent " })
391
- cfg .add_shift (name = "jer_down" , id = 6001 , type = "shape" , tags = {"selection_dependent " })
392
- add_shift_aliases ("jer" , {"Jet.pt" : "Jet.pt_{name}" , "Jet.mass" : "Jet.mass_{name}" }, selection_dependent = True )
390
+ cfg .add_shift (name = "jer_up" , id = 6000 , type = "shape" , tags = {"jer " })
391
+ cfg .add_shift (name = "jer_down" , id = 6001 , type = "shape" , tags = {"jer " })
392
+ add_shift_aliases (cfg , "jer" , {"Jet.pt" : "Jet.pt_{name}" , "Jet.mass" : "Jet.mass_{name}" })
393
393
394
394
def make_jme_filename (jme_aux , sample_type , name , era = None ):
395
395
"""
@@ -409,11 +409,13 @@ def make_jme_filename(jme_aux, sample_type, name, era=None):
409
409
json_mirror = "/afs/cern.ch/user/m/mrieger/public/mirrors/jsonpog-integration-9ea86c4c"
410
410
corr_tag = f"{ cfg .x .cpn_tag } _UL"
411
411
elif cfg .x .run == 3 :
412
- # TODO: Update when possible
413
- json_mirror = "/afs/desy.de/user/p/paaschal/public/mirrors/jsonpog-integration"
414
- corr_tag = f"{ year } _Prompt"
412
+ json_mirror = "/afs/cern.ch/user/m/mfrahm/public/mirrors/jsonpog-integration-f35ab53e"
413
+ corr_tag = f"{ year } _Summer22{ jerc_postfix } "
415
414
416
415
cfg .x .external_files = DotDict .wrap ({
416
+ # pileup weight corrections
417
+ "pu_sf" : (f"{ json_mirror } /POG/LUM/{ corr_tag } /puWeights.json.gz" , "v1" ),
418
+
417
419
# jet energy correction
418
420
"jet_jerc" : (f"{ json_mirror } /POG/JME/{ corr_tag } /jet_jerc.json.gz" , "v1" ),
419
421
@@ -431,21 +433,20 @@ def make_jme_filename(jme_aux, sample_type, name, era=None):
431
433
})
432
434
433
435
# temporary fix due to missing corrections in run 3
436
+ # electron, muon and met still missing, btag, and pu are TODO
434
437
if cfg .x .run == 3 :
438
+ cfg .add_tag ("skip_pu_weights" )
439
+
435
440
cfg .add_tag ("skip_btag_weights" )
441
+ cfg .x .external_files .pop ("btag_sf_corr" )
442
+
436
443
cfg .add_tag ("skip_electron_weights" )
437
- cfg .add_tag ("skip_muon_weights" )
438
- cfg .add_tag ("skip_pu_weights" )
439
444
cfg .x .external_files .pop ("electron_sf" )
445
+
446
+ cfg .add_tag ("skip_muon_weights" )
440
447
cfg .x .external_files .pop ("muon_sf" )
441
- cfg .x .external_files .pop ("btag_sf_corr" )
442
- cfg .x .external_files .pop ("met_phi_corr" )
443
448
444
- # NOTE: we should mirror and gzip them
445
- if campaign .x .EE == "pre" :
446
- cfg .x .external_files ["muon_sf" ] = ("https://gitlab.cern.ch/cms-muonPOG/muonefficiencies/-/raw/master/Run3/2022/2022_Z/ScaleFactors_Muon_Z_ID_ISO_2022_schemaV2.json" , "v1" ) # noqa
447
- elif campaign .x .EE == "post" :
448
- cfg .x .external_files ["muon_sf" ] = ("https://gitlab.cern.ch/cms-muonPOG/muonefficiencies/-/raw/master/Run3/2022_EE/2022_Z/ScaleFactors_Muon_Z_ID_ISO_2022_EE_schemaV2.json" , "v1" ) # noqa
449
+ cfg .x .external_files .pop ("met_phi_corr" )
449
450
450
451
cfg .x .met_filters = {
451
452
"Flag.goodVertices" ,
0 commit comments