-
Notifications
You must be signed in to change notification settings - Fork 5
/
analyzeConfig_hh.py
91 lines (80 loc) · 4.16 KB
/
analyzeConfig_hh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from tthAnalysis.HiggsToTauTau.configs.analyzeConfig import *
from hhAnalysis.multilepton.common import is_nonresonant
import re
RR_PRODUCTION_MODE = 'production_mode'
RR_SPIN = 'spin'
RR_MASS_POINT = 'mass_point'
RR_DECAY_CHANNEL = 'decay_channel'
RESONANT_REGEX_PATTERN = r'signal_(?P<%s>[ggf|vbf]+)_spin(?P<%s>[0|2]{1})_(?P<%s>\d+)_hh_(?P<%s>[0-9A-Za-z]+)' % (
RR_PRODUCTION_MODE, RR_SPIN, RR_MASS_POINT, RR_DECAY_CHANNEL
)
RESONANT_REGEX = re.compile(RESONANT_REGEX_PATTERN)
def get_signal_per_masspoint(samples):
io_pairs = {}
for sample_key, sample_info in samples.items():
process_cat = sample_info['sample_category']
if not sample_info['use_it']:
continue
resonant_match = RESONANT_REGEX.match(process_cat)
if not resonant_match:
continue
signal_base = '_'.join(['signal', 'spin%s' % resonant_match.group(RR_SPIN), resonant_match.group(RR_MASS_POINT), 'hh'])
if signal_base not in io_pairs:
io_pairs[signal_base] = []
if process_cat not in io_pairs[signal_base]:
io_pairs[signal_base].append(process_cat)
return io_pairs
class analyzeConfig_hh(analyzeConfig):
def __init__(self, **kwargs):
super(analyzeConfig_hh, self).__init__(**kwargs)
self.signal_io = get_signal_per_masspoint(self.samples)
# CV: switch top pT reweighting to new parametrization given on slide 12 of the presentation by Dennis Roy in the Higgs PAG meeting on 12/05/2020:
# https://indico.cern.ch/event/904971/contributions/3857701/attachments/2036949/3410728/TopPt_20.05.12.pdf
if not self.do_sync:
self.topPtRwgtChoice = "HighPt"
def get_samples_categories_HH(self):
sample_categories_HH = []
couplings = self.kl_weights + self.BM_weights
for sample_key, sample_info in self.samples.items():
if sample_key == 'sum_events':
continue
process_category = sample_info["sample_category"]
if sample_info["use_it"] and is_nonresonant(process_category, allow_nlo = False):
for coupling in couplings:
sample_categories_HH.append("{}{}".format(process_category, coupling))
return sample_categories_HH
def createCfg_makePlots(self, jobOptions):
"""Fills the template of python configuration file for making control plots
Args:
histogram_file: name of the input ROOT file
"""
lines = []
lines.append("process.fwliteInput.fileNames = cms.vstring('%s')" % jobOptions['inputFile'])
lines.append("process.makePlots.outputFileName = cms.string('%s')" % jobOptions['outputFile'])
lines.append("process.makePlots.processesBackground = cms.vstring(%s)" % jobOptions['make_plots_backgrounds'])
lines.append("process.makePlots.categories = cms.VPSet(")
lines.append(" cms.PSet(")
lines.append(" name = cms.string('%s')," % jobOptions['histogramDir'])
lines.append(" label = cms.string('%s')" % jobOptions['label'])
lines.append(" )")
lines.append(")")
lines.append("process.makePlots.intLumiData = cms.double(%.1f)" % (self.lumi / 1000))
create_cfg(self.cfgFile_make_plots, jobOptions['cfgFile_modified'], lines)
def createCfg_makePlots_mcClosure(self, jobOptions): #TODO
"""Fills the template of python configuration file for making control plots
Args:
histogramFile: name of the input ROOT file
"""
lines = []
lines.append("process.fwliteInput.fileNames = cms.vstring('%s')" % jobOptions['inputFile'])
lines.append("process.makePlots.outputFileName = cms.string('%s')" % jobOptions['outputFile'])
lines.append("process.makePlots.processesBackground = cms.vstring(%s)" % self.make_plots_backgrounds)
lines.append("process.makePlots.categories = cms.VPSet(")
lines.append(" cms.PSet(")
lines.append(" signal = cms.string('%s')," % self.histogramDir_prep_dcard)
lines.append(" sideband = cms.string('%s')," % self.histogramDir_prep_dcard.replace("Tight", "Fakeable_mcClosure_wFakeRateWeights"))
lines.append(" label = cms.string('%s')" % self.channel)
lines.append(" )")
lines.append(")")
lines.append("process.makePlots.intLumiData = cms.double(%.1f)" % self.lumi)
create_cfg(self.cfgFile_make_plots_mcClosure, jobOptions['cfgFile_modified'], lines)