|
1 | 1 | import argparse |
2 | | -import topcoffea.modules.utils as utils |
3 | | -import cloudpickle |
4 | | -from collections import defaultdict |
5 | | -import re |
6 | 2 | import gzip |
| 3 | +import logging |
| 4 | +import re |
| 5 | +from collections import defaultdict |
| 6 | + |
| 7 | +import cloudpickle |
| 8 | +import topcoffea.modules.utils as utils |
7 | 9 |
|
8 | 10 | from topeft.modules.paths import topeft_path |
| 11 | +from topeft.modules.utils import canonicalize_process_name |
9 | 12 | from topcoffea.modules.get_param_from_jsons import GetParam |
10 | 13 | get_te_param = GetParam(topeft_path("params/params.json")) |
11 | 14 |
|
| 15 | + |
| 16 | +logger = logging.getLogger(__name__) |
| 17 | + |
12 | 18 | class DataDrivenProducer: |
13 | 19 | def __init__(self, inputHist, outputName): |
14 | 20 | if isinstance(inputHist, str) and inputHist.endswith('.pkl.gz'): # we are plugging a pickle file |
@@ -74,11 +80,14 @@ def DDFakes(self): |
74 | 80 | sampleName=match.group('process') |
75 | 81 | year=match.group('year') |
76 | 82 | if year.startswith("202"): |
77 | | - nonPromptName='flips%s'%year |
| 83 | + raw_flips_name = f"flips{year}" |
78 | 84 | else: |
79 | | - nonPromptName='flipsUL%s'%year |
| 85 | + raw_flips_name = f"flipsUL{year}" |
| 86 | + flips_name = canonicalize_process_name(raw_flips_name) |
| 87 | + if raw_flips_name == flips_name: |
| 88 | + logger.debug("Process name '%s' already canonical", raw_flips_name) |
80 | 89 | if self.dataName==sampleName: |
81 | | - newNameDictData[nonPromptName].append(process) |
| 90 | + newNameDictData[flips_name].append(process) |
82 | 91 | hFlips=hAR.group('process', newNameDictData) |
83 | 92 |
|
84 | 93 | # remove any up/down FF variations from the flip histo since we don't use that info |
@@ -107,13 +116,16 @@ def DDFakes(self): |
107 | 116 | year=match.group('year') |
108 | 117 |
|
109 | 118 | if "2022" in year or "2023" in year: |
110 | | - nonPromptName='nonprompt%s'%year |
| 119 | + raw_nonprompt_name = f"nonprompt{year}" |
111 | 120 | else: |
112 | | - nonPromptName='nonpromptUL%s'%year |
| 121 | + raw_nonprompt_name = f"nonpromptUL{year}" |
| 122 | + nonprompt_name = canonicalize_process_name(raw_nonprompt_name) |
| 123 | + if raw_nonprompt_name == nonprompt_name: |
| 124 | + logger.debug("Process name '%s' already canonical", raw_nonprompt_name) |
113 | 125 | if self.dataName==sampleName: |
114 | | - newNameDictData[nonPromptName].append(process) |
| 126 | + newNameDictData[nonprompt_name].append(process) |
115 | 127 | elif sampleName in self.promptSubtractionSamples: |
116 | | - newNameDictNoData[nonPromptName].append(process) |
| 128 | + newNameDictNoData[nonprompt_name].append(process) |
117 | 129 | else: |
118 | 130 | print(f"We won't consider {sampleName} for the prompt subtraction in the appl. region") |
119 | 131 | hFakes=hAR.group('process', newNameDictData) |
|
0 commit comments