CMS 3D CMS Logo

hltSMPPostProcessors_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 == "PFTau":
18  objtypeLatex="#tau"
19  else:
20  objtypeLatex=objtype
21 
22  numer_description = "# gen %s passed the %s" % (objtypeLatex,triggerpath)
23  denom_description = "# gen %s " % (objtypeLatex)
24 
25  if plot_type == "TurnOn1":
26  title = "pT Turn-On"
27  xAxis = "p_{T} of Leading Generated %s (GeV/c)" % (objtype)
28  input_type = "gen%sMaxPt1" % (objtype)
29  if plot_type == "TurnOn2":
30  title = "Next-to-Leading pT Turn-On"
31  xAxis = "p_{T} of Next-to-Leading Generated %s (GeV/c)" % (objtype)
32  input_type = "gen%sMaxPt2" % (objtype)
33  if plot_type == "EffEta":
34  title = "#eta Efficiency"
35  xAxis = "#eta of Generated %s " % (objtype)
36  input_type = "gen%sEta" % (objtype)
37  if plot_type == "EffPhi":
38  title = "#phi Efficiency"
39  xAxis = "#phi of Generated %s " % (objtype)
40  input_type = "gen%sPhi" % (objtype)
41 
42  yAxis = "%s / %s" % (numer_description, denom_description)
43  all_titles = "%s for trigger %s; %s; %s" % (title, triggerpath,
44  xAxis, yAxis)
45  return "Eff_%s_%s '%s' %s_%s %s" % (input_type,triggerpath,
46  all_titles,input_type,triggerpath,input_type)
47 
48 from HLTriggerOffline.SMP.hltSMPValidator_cfi import hltSMPValidator as _config
49 def make_smp_postprocessor(analysis_name, plot_types=["TurnOn1", "TurnOn2", "EffEta", "EffPhi"], object_types=["Mu","Ele","Photon","MET","PFMET","PFTau","Jet"], extra_str_templates=[]):
50  postprocessor = hltSMPPostProcessor.clone()
51  postprocessor.subDirs = ["HLT/SMP/" + analysis_name]
52  efficiency_strings = [] # List of plots to look for. This is quite a bit larger than the number of plots that will be made.
53 
54  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"
55  efficiency_strings.append(efficiency_summary_string)
56  efficiency_strings.append(efficiency_summary_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
57 
58  for plot_type in plot_types:
59  for object_type in object_types:
60  for trigger in [x.replace("_v", "") for x in _config.__getattribute__(analysis_name).hltPathsToCheck]:
61  this_efficiency_string = make_efficiency_string(object_type, plot_type, trigger)
62  efficiency_strings.append(this_efficiency_string)
63  efficiency_strings.append(this_efficiency_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
64 
65  for str_template in extra_str_templates:
66  this_extra_string = str_template.replace("@ANALYSIS@", analysis_name).replace("@TRIGGER@", trigger)
67  efficiency_strings.append(this_extra_string)
68  efficiency_strings.append(this_extra_string.replace("Generated", "Reconstructed").replace("Gen", "Reco").replace("gen", "rec"))
69 
70  postprocessor.efficiencyProfile = efficiency_strings
71  return postprocessor
72 
73 
74 plot_types = ["TurnOn1", "TurnOn2", "EffEta", "EffPhi"]
75 #--- IMPORTANT: Update this collection whenever you introduce a new object
76 # in the code (from EVTColContainer::getTypeString)
77 object_types = ["Mu","Ele","Photon","MET","PFTau"]
78 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"
79 
80 
81 hltSMPPostSingleEle = make_smp_postprocessor("SingleEle", plot_types=plot_types, object_types=object_types, extra_str_templates=[truevtx_string_template])
82 #hltSMPPostSingleMu = make_smp_postprocessor("SingleMu", plot_types=plot_types, object_types=object_types, extra_str_templates=[truevtx_string_template])
83 hltSMPPostSinglePhoton = make_smp_postprocessor("SinglePhoton", plot_types=plot_types, object_types=object_types, extra_str_templates=[truevtx_string_template])
84 
85 # hltSMPPostSingleMu = hltSMPPostProcessor.clone()
86 # hltSMPPostSingleMu.subDirs = ['HLT/SMP/SingleMu']
87 # hltSMPPostSingleMu.efficiencyProfile = efficiency_strings
88 
89 hltSMPPostProcessors = cms.Sequence(
90  hltSMPPostSingleEle+
91 # hltSMPPostSingleMu+
92  hltSMPPostSinglePhoton
93 )
94 
95 
hltSMPPostProcessors_cff.make_smp_postprocessor
def make_smp_postprocessor(analysis_name, plot_types=["TurnOn1", "TurnOn2", "EffEta", "EffPhi"], object_types=["Mu","Ele","Photon","MET","PFMET","PFTau","Jet"], extra_str_templates=[])
Definition: hltSMPPostProcessors_cff.py:49
hltSMPValidator_cfi
hltSMPPostProcessor_cfi
hltSMPPostProcessors_cff.make_efficiency_string
def make_efficiency_string(objtype, plot_type, triggerpath)
Definition: hltSMPPostProcessors_cff.py:6
python.rootplot.root2matplotlib.replace
def replace(string, replacements)
Definition: root2matplotlib.py:444