CMS 3D CMS Logo

hltHiggsPostProcessors_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
4 
5 # Build the standard strings to the DQM
6 def make_efficiency_string(objtype,plot_type,triggerpath):
7  # --- IMPORTANT: Add here a elif if you are introduce a new collection
8  # (see EVTColContainer::getTypeString)
9  if objtype == "Mu":
10  objtypeLatex="#mu"
11  elif objtype == "Photon":
12  objtypeLatex="#gamma"
13  elif objtype == "Ele":
14  objtypeLatex="e"
15  elif objtype == "MET" :
16  objtypeLatex="MET"
17  elif objtype == "PFMET" :
18  objtypeLatex="PFMET"
19  elif objtype == "PFTau":
20  objtypeLatex="#tau"
21  elif objtype == "Jet":
22  objtypeLatex="jet"
23  else:
24  objtypeLatex=objtype
25 
26  numer_description = "# gen %s passed the %s" % (objtypeLatex,triggerpath)
27  denom_description = "# gen %s " % (objtypeLatex)
28 
29  if plot_type == "TurnOn1":
30  title = "pT Turn-On"
31  xAxis = "p_{T} of Leading Generated %s (GeV/c)" % (objtype)
32  input_type = "gen%sMaxPt1" % (objtype)
33  elif plot_type == "TurnOn2":
34  title = "Next-to-Leading pT Turn-On"
35  xAxis = "p_{T} of Next-to-Leading Generated %s (GeV/c)" % (objtype)
36  input_type = "gen%sMaxPt2" % (objtype)
37  elif plot_type == "EffEta":
38  title = "#eta Efficiency"
39  xAxis = "#eta of Generated %s " % (objtype)
40  input_type = "gen%sEta" % (objtype)
41  elif plot_type == "EffPhi":
42  title = "#phi Efficiency"
43  xAxis = "#phi of Generated %s " % (objtype)
44  input_type = "gen%sPhi" % (objtype)
45  elif "TurnOn" in plot_type:
46  title = "%sth Leading pT Turn-On" % (plot_type[-1])
47  xAxis = "p_{T} of %sth Leading Generated %s (GeV/c)" % (plot_type[-1], objtype)
48  input_type = "gen%sMaxPt%s" % (objtype, plot_type[-1])
49  elif plot_type == "EffdEtaqq":
50  title = "#Delta #eta_{qq} Efficiency"
51  xAxis = "#Delta #eta_{qq} of Generated %s " % (objtype)
52  input_type = "gen%sdEtaqq" % (objtype)
53  elif plot_type == "Effmqq":
54  title = "m_{qq} Efficiency"
55  xAxis = "m_{qq} of Generated %s " % (objtype)
56  input_type = "gen%smqq" % (objtype)
57  elif plot_type == "EffdPhibb":
58  title = "#Delta #phi_{bb} Efficiency"
59  xAxis = "#Delta #phi_{bb} of Generated %s " % (objtype)
60  input_type = "gen%sdPhibb" % (objtype)
61  elif plot_type == "EffCSV1":
62  title = "CSV1 Efficiency"
63  xAxis = "CSV1 of Generated %s " % (objtype)
64  input_type = "gen%sCSV1" % (objtype)
65  elif plot_type == "EffCSV2":
66  title = "CSV2 Efficiency"
67  xAxis = "CSV2 of Generated %s " % (objtype)
68  input_type = "gen%sCSV2" % (objtype)
69  elif plot_type == "EffCSV3":
70  title = "CSV3 Efficiency"
71  xAxis = "CSV3 of Generated %s " % (objtype)
72  input_type = "gen%sCSV3" % (objtype)
73  elif plot_type == "EffmaxCSV":
74  title = "max CSV Efficiency"
75  xAxis = "max CSV of Generated %s " % (objtype)
76  input_type = "gen%smaxCSV" % (objtype)
77 
78  yAxis = "%s / %s" % (numer_description, denom_description)
79  all_titles = "%s for trigger %s; %s; %s" % (title, triggerpath,
80  xAxis, yAxis)
81  return "Eff_%s_%s '%s' %s_%s %s" % (input_type,triggerpath,
82  all_titles,input_type,triggerpath,input_type)
83 
84 #--- IMPORTANT: Trigger are extracted from the hltHiggsValidator_cfi.py module
85 from HLTriggerOffline.Higgs.hltHiggsValidator_cfi import hltHiggsValidator as _config
86 def make_higgs_postprocessor(analysis_name, plot_types=["TurnOn1", "TurnOn2", "EffEta", "EffPhi"], object_types=["Mu","Ele","Photon","MET","PFMET","PFTau","Jet"], extra_str_templates=[]):
87  postprocessor = hltHiggsPostProcessor.clone()
88  postprocessor.subDirs = ["HLT/Higgs/" + analysis_name]
89  efficiency_strings = [] # List of plots to look for. This is quite a bit larger than the number of plots that will be made.
90 
91  efficiency_summary_string = "EffSummaryPaths_" + analysis_name + "_gen ' Efficiency of paths used in " + analysis_name + " ; trigger path ' SummaryPaths_" + analysis_name + "_gen_passingHLT SummaryPaths_" + analysis_name + "_gen"
92  efficiency_strings.append(efficiency_summary_string)
93  efficiency_strings.append(efficiency_summary_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
94 
95  for plot_type in plot_types:
96  for object_type in object_types:
97  for trigger in [x.replace("_v", "") for x in _config.__getattribute__(analysis_name).hltPathsToCheck]:
98  this_efficiency_string = make_efficiency_string(object_type, plot_type, trigger)
99  efficiency_strings.append(this_efficiency_string)
100  efficiency_strings.append(this_efficiency_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
101 
102  for str_template in extra_str_templates:
103  this_extra_string = str_template.replace("@ANALYSIS@", analysis_name).replace("@TRIGGER@", trigger)
104  efficiency_strings.append(this_extra_string)
105  efficiency_strings.append(this_extra_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
106 
107  postprocessor.efficiencyProfile = efficiency_strings
108  return postprocessor
109 
110 truevtx_string_template = "Eff_trueVtxDist_@ANALYSIS@_gen_@TRIGGER@ ' Efficiency of @TRIGGER@ vs nb of interactions ; nb events passing each path ' trueVtxDist_@ANALYSIS@_gen_@TRIGGER@ trueVtxDist_@ANALYSIS@_gen"
111 hltHiggsPostHWW = make_higgs_postprocessor("HWW", extra_str_templates=[truevtx_string_template])
112 hltHiggsPostHZZControlPaths = make_higgs_postprocessor("HZZControlPaths", extra_str_templates=[truevtx_string_template])
113 hltHiggsPostHZZ = make_higgs_postprocessor("HZZ", extra_str_templates=[truevtx_string_template])
114 hltHiggsPostHgg = make_higgs_postprocessor("Hgg", extra_str_templates=[truevtx_string_template])
115 #hltHiggsPostHggControlPaths = make_higgs_postprocessor("HggControlPaths", extra_str_templates=[truevtx_string_template])
116 hltHiggsPostMuonJet = make_higgs_postprocessor("MuonJet", extra_str_templates=[truevtx_string_template])
117 hltHiggsPostDoubleHinTaus = make_higgs_postprocessor("DoubleHinTaus", extra_str_templates=[truevtx_string_template])
118 hltHiggsPostHiggsDalitz = make_higgs_postprocessor("HiggsDalitz", extra_str_templates=[truevtx_string_template])
119 hltHiggsPostH2tau = make_higgs_postprocessor("H2tau", extra_str_templates=[truevtx_string_template])
120 hltHiggsPostHtaunu = make_higgs_postprocessor("Htaunu", extra_str_templates=[truevtx_string_template])
121 hltHiggsPostVBFHToInv = make_higgs_postprocessor("VBFHToInv", extra_str_templates=[truevtx_string_template])
122 
123 TTHbbej_HtDist_template = "Eff_HtDist_@ANALYSIS@_gen_@TRIGGER@ ' Efficiency of @TRIGGER@ vs sum pT of jets ; sum pT of jets ' HtDist_@ANALYSIS@_gen_@TRIGGER@ HtDist_@ANALYSIS@_gen"
124 hltHiggsPostTTHbbej = make_higgs_postprocessor("TTHbbej", extra_str_templates=[truevtx_string_template, TTHbbej_HtDist_template])
125 hltHiggsPostAHttH = make_higgs_postprocessor("AHttH", extra_str_templates=[truevtx_string_template, TTHbbej_HtDist_template])
126 
127 #Specific plots for VBFHbb_2btag
128 #dEtaqq, mqq, dPhibb, CVS1, maxCSV_jets, maxCSV_E, MET, pt1, pt2, pt3, pt4
129 NminOneCutNames = ("EffdEtaqq", "Effmqq", "EffdPhibb", "EffCSV1", "EffCSV2", "EffCSV3", "EffmaxCSV", "", "", "TurnOn1", "TurnOn2", "TurnOn3", "TurnOn4")
130 VBFHbb_2btag_plot_types = []
131 NminOneCuts =_config.VBFHbb_2btag.NminOneCuts
132 if NminOneCuts:
133  for iCut in range(0,len(NminOneCuts)):
134  if( NminOneCuts[iCut] and NminOneCutNames[iCut] ):
135  if( NminOneCutNames[iCut] == "EffmaxCSV" ):
136  VBFHbb_2btag_plot_types.pop()
137  VBFHbb_2btag_plot_types.append(NminOneCutNames[iCut])
138 hltHiggsPostVBFHbb_2btag = make_higgs_postprocessor("VBFHbb_2btag", object_types=["Jet"], plot_types=VBFHbb_2btag_plot_types, extra_str_templates=[truevtx_string_template])
139 
140 #Specific plots for VBFHbb_1btag
141 #dEtaqq, mqq, dPhibb, CVS1, maxCSV_jets, maxCSV_E, MET, pt1, pt2, pt3, pt4
142 VBFHbb_1btag_plot_types = []
143 NminOneCuts = _config.VBFHbb_1btag.NminOneCuts
144 if NminOneCuts:
145  for iCut in range(0,len(NminOneCuts)):
146  if( NminOneCuts[iCut] and NminOneCutNames[iCut] ):
147  if( NminOneCutNames[iCut] == "EffmaxCSV" ):
148  VBFHbb_1btag_plot_types.pop()
149  VBFHbb_1btag_plot_types.append(NminOneCutNames[iCut])
150 hltHiggsPostVBFHbb_1btag = make_higgs_postprocessor("VBFHbb_1btag", plot_types=VBFHbb_1btag_plot_types, object_types=["Jet"], extra_str_templates=[truevtx_string_template])
151 
152 #Specific plots for VBFHbb_0btag
153 #dEtaqq, mqq, dPhibb, CVS1, maxCSV_jets, maxCSV_E, MET, pt1, pt2, pt3, pt4
154 VBFHbb_0btag_plot_types = []
155 NminOneCuts = _config.VBFHbb_0btag.NminOneCuts
156 if NminOneCuts:
157  for iCut in range(0,len(NminOneCuts)):
158  if( NminOneCuts[iCut] and NminOneCutNames[iCut] ):
159  if( NminOneCutNames[iCut] == "EffmaxCSV" ):
160  VBFHbb_0btag_plot_types.pop()
161  VBFHbb_0btag_plot_types.append(NminOneCutNames[iCut])
162 hltHiggsPostVBFHbb_0btag = make_higgs_postprocessor("VBFHbb_0btag", plot_types=VBFHbb_0btag_plot_types, object_types=["Jet"], extra_str_templates=[truevtx_string_template])
163 
164 
165 #Specific plots for ZnnHbb
166 ZnnHbb_plot_types = ["EffEta", "EffPhi", "TurnOn1"]
167 NminOneCuts = _config.ZnnHbb.NminOneCuts
168 if NminOneCuts:
169  for iCut in range(0,len(NminOneCuts)):
170  if( NminOneCuts[iCut] and NminOneCutNames[iCut] ):
171  ZnnHbb_plot_types.append(NminOneCutNames[iCut])
172 hltHiggsPostZnnHbb = make_higgs_postprocessor("ZnnHbb", plot_types=ZnnHbb_plot_types, object_types=["Jet", "PFMET"], extra_str_templates=[truevtx_string_template])
173 
174 #Specific plots for X4b
175 #Jet plots
176 X4b_plot_types = ["EffEta", "EffPhi", "TurnOn1"]
177 NminOneCuts = _config.X4b.NminOneCuts
178 if NminOneCuts:
179  for iCut in range(0,len(NminOneCuts)):
180  if( NminOneCuts[iCut] and NminOneCutNames[iCut] ):
181  X4b_plot_types.append(NminOneCutNames[iCut])
182 hltHiggsPostX4b = make_higgs_postprocessor("X4b", plot_types=X4b_plot_types, object_types=["Jet"], extra_str_templates=[truevtx_string_template])
183 
184 #Specific plots for WH -> ev + bb
185 hltHiggsPostWHToENuBB = make_higgs_postprocessor("WHToENuBB", extra_str_templates=[truevtx_string_template, TTHbbej_HtDist_template])
186 
187 hltHiggsPostProcessors = cms.Sequence(
188  hltHiggsPostHWW+
189  hltHiggsPostHZZ+
190  hltHiggsPostHZZControlPaths+
191  hltHiggsPostHgg+
192  #hltHiggsPostHggControlPaths+
193  hltHiggsPostMuonJet+
194  hltHiggsPostHtaunu+
195  hltHiggsPostH2tau+
196  hltHiggsPostTTHbbej+
197  hltHiggsPostAHttH+
198  hltHiggsPostVBFHbb_0btag+
199  hltHiggsPostVBFHbb_1btag+
200  hltHiggsPostVBFHbb_2btag+
201  hltHiggsPostZnnHbb+
202  hltHiggsPostDoubleHinTaus+
203  hltHiggsPostHiggsDalitz+
204  hltHiggsPostX4b+
205  hltHiggsPostWHToENuBB+
206  hltHiggsPostVBFHToInv
207 )
208 
209 
def make_higgs_postprocessor(analysis_name, plot_types=["TurnOn1", TurnOn2, EffEta, EffPhi, object_types=["Mu", Ele, Photon, MET, PFMET, PFTau, Jet, extra_str_templates=[])
def replace(string, replacements)
def make_efficiency_string(objtype, plot_type, triggerpath)
if(threadIdxLocalY==0 &&threadIdxLocalX==0)