CMS 3D CMS Logo

RecoTauValidation_cfi.py
Go to the documentation of this file.
1 from __future__ import print_function
2 import FWCore.ParameterSet.Config as cms
3 import Validation.RecoTau.ValidationUtils as Utils
4 import copy
5 import re
6 import os
7 
8 #from Validation.RecoTau.ValidationOptions_cff import *
9 
10 
11 """
12 import six
13 
14  RecoTauValidation_cfi.py
15 
16  Contains the standard tau validation parameters. It is organized into
17  the following sections.
18 
19  DENOMINATOR
20 
21  Set common kinematic cuts (pt > 5 and eta < 2.5) on the denominator source.
22  Note that the denominator depends on the type of test (signal/background/e etc)
23 
24  The denominator kinematic cutter requires that
25 
26  HISTOGRAMS
27 
28  Produce numerator and denominator histgorams used to produce
29  tau efficiency plots
30 
31  Provides sequence:
32  TauValNumeratorAndDenominator
33  Requires:
34  tauValSelectedDenominator (filtered GenJet collection)
35 
36  EFFICIENCY
37 
38  Using numerator and denominators, calculate and store
39  the efficiency curves
40 
41  Provides sequence:
42  TauEfficiencies
43  Requires:
44  TauValNumeratorAndDenominator
45 
46  PLOTTING
47 
48  Plot curves calculated in efficiency, in both an overlay mode
49  showing overall performance for a release, and the indvidual
50  discriminator efficiency compared to a given release
51 
52  Provides sequence:
53  loadTau
54  plotTauValidation
55  loadAndPlotTauValidation
56 
57  Requires:
58  TauEfficiencies, external root file to compare to
59 
60  Plotting must be executed in a separate cmsRun job!
61 
62  UTILITIES
63 
64  Various scripts to automate things...
65 
66 
67 """
68 
69 """
70 
71 DENOMINATOR
72 
73 """
74 
75 kinematicSelectedTauValDenominatorCut = cms.string('pt > 5. && abs(eta) < 2.5')
76 denominator = cms.InputTag("kinematicSelectedTauValDenominator")
77 
78 """
79 
80 HISTOGRAMS
81 
82  Plot the pt/eta/energy/phi spectrum of PFTaus that pass
83  a series of PFTauDiscriminator cuts.
84 
85  These will be used as the numerator/denominators of the
86  efficiency calculations
87 """
88 
89 #Helper process to make future cloning easier
90 proc = cms.Process('helper')
91 
92 StandardMatchingParameters = cms.PSet(
93  DataType = cms.string('Leptons'),
94  MatchDeltaR_Leptons = cms.double(0.15),
95  MatchDeltaR_Jets = cms.double(0.3),
96  SaveOutputHistograms = cms.bool(False), #TRUE FOR TEST ONLY
97  #RefCollection = cms.InputTag("TauGenJetProducer","selectedGenTauDecaysToHadronsPt5Cumulative"),
98  RefCollection = denominator,
99  TauPtCut = cms.double(0.), #almost deprecated, since recoCuts provides more flexibility
100  recoCuts = cms.string(''), #filter reconstructed candidates. leave this empty to select all. or use sth like: pt > 20 & abs(eta) < 2.3
101  genCuts = cms.string(''), #filter generated candidates. leave this empty to select all. or use sth like: pt > 20 & abs(eta) < 2.3
102  chainCuts = cms.bool(False) #Decide whether to chain discriminators or not
103 )
104 
105 GenericTriggerSelectionParameters = cms.PSet(
106  andOr = cms.bool( False ),#specifies the logical combination of the single filters' (L1, HLT and DCS) decisions at top level (True=OR)
107  dbLabel = cms.string("PFTauDQMTrigger"),#specifies the label under which the DB payload is available from the ESSource or Global Tag
108  andOrHlt = cms.bool(True),#specifies the logical combination of the single HLT paths' decisions (True=OR)
109  hltInputTag = cms.InputTag("TriggerResults::HLT"),
110  #hltDBKey = cms.string('jetmet_highptjet'),#Tag of the record in the database, where IOV-based HLT paths are found. This record overwrites the configuration parameter hltPaths
111  hltPaths = cms.vstring('HLT_IsoMu*_eta*_LooseIsoPFTau*_v*','HLT_DoubleIsoPFTau*_Trk*_eta*_v*'),#Lists logical expressions of HLT paths, which should have accepted the event (fallback in case DB unaccessible)
112  errorReplyHlt = cms.bool(False),#specifies the desired return value of the HLT filter and the single HLT path filter in case of certain errors
113  verbosityLevel = cms.uint32(0) #0: complete silence (default), needed for T0 processing;
114 )
115 
116 from DQMServices.Core.DQMEDAnalyzer import DQMEDAnalyzer
117 proc.templateAnalyzer = DQMEDAnalyzer(
118  "TauTagValidation",
119  StandardMatchingParameters,
120  GenericTriggerSelection = GenericTriggerSelectionParameters,
121  ExtensionName = cms.string(""),
122  TauProducer = cms.InputTag(''),
123  discriminators = cms.VPSet(
124  )
125 )
126 
127 
128 proc.RunHPSValidation = proc.templateAnalyzer.clone()
129 
130 #for fast sim we need to ignore the HLT TriggerResults
131 from Configuration.Eras.Modifier_fastSim_cff import fastSim
132 fastSim.toModify(
133  proc.RunHPSValidation,
134  hltInputTag = cms.InputTag(""),
135  GenericTriggerSelection=dict(hltInputTag = cms.InputTag(""))
136 )
137 
138 proc.RunHPSValidation.ExtensionName = ""
139 #RunHPSValidation.TauPtCut = cms.double(15.)
140 proc.RunHPSValidation.TauProducer = cms.InputTag('hpsPFTauProducer')
141 proc.RunHPSValidation.discriminators = cms.VPSet(
142  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFinding"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
143  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFindingNewDMs"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
144  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFindingOldDMs"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
145  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
146  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
147  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
148  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
149  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
150  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
151  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
152  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
153  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
154  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5VLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
155  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5LooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
156  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5MediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
157  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5TightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
158  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5VTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
159  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseMuonRejection3"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
160  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightMuonRejection3"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
161  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
162  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
163  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
164  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6VLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
165  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6LooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
166  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6MediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
167  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6TightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
168  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6VTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
169  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
170  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
171  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
172  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
173  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
174  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
175  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
176  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
177  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
178  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
179  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
180  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
181  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
182  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
183  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
184  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
185  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
186  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
187  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
188  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
189  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
190  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
191  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
192  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
193  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
194  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
195  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
196  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
197  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
198  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
199  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
200  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
201  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
202  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
203  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
204  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
205  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
206  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
207  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False))
208 )
209 
210 proc.TauValNumeratorAndDenominator = cms.Sequence(
211  proc.RunHPSValidation
212  )
213 
214 """
215 
216 EFFICIENCY
217 
218  Tau efficiency calculations
219 
220  Define the Efficiency curves to produce. Each
221  efficiency producer takes the numberator and denominator
222  histograms and the dependent variables.
223 """
224 
225 plotPset = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominator)
226 from DQMServices.Core.DQMEDHarvester import DQMEDHarvester
227 proc.efficiencies = DQMEDHarvester(
228  "TauDQMHistEffProducer",
229  plots = plotPset
230  )
231 
232 
233 ################################################
234 #
235 # Normalizes All the histograms
236 #
237 ################################################
238 
239 proc.normalizePlots = cms.EDAnalyzer(
240  "DQMHistNormalizer",
241  plotNamesToNormalize = cms.vstring('*_pTRatio_*','*_Size_*','*_SumPt_*','*_dRTauRefJet*'),
242  reference = cms.string('*_pTRatio_allHadronic')
243  )
244 
245 proc.TauEfficiencies = cms.Sequence(
246  proc.efficiencies*
247  proc.normalizePlots
248  )
249 
250 """
251 
252 PLOTTING
253 
254  loadTau: load two separate TauVal root files into the DQM
255  so the plotter can access them
256 
257 """
258 
259 loadTau = DQMEDAnalyzer("TauDQMFileLoader",
260  test = cms.PSet(
261  #inputFileNames = cms.vstring('/afs/cern.ch/user/f/friis/scratch0/MyValidationArea/310pre6NewTags/src/Validation/RecoTau/test/CMSSW_3_1_0_pre6_ZTT_0505Fixes.root'),
262  inputFileNames = cms.vstring('/opt/sbg/cms/ui4_data1/dbodin/CMSSW_3_5_1/src/TauID/QCD_recoFiles/TauVal_CMSSW_3_6_0_QCD.root'),
263  scaleFactor = cms.double(1.),
264  dqmDirectory_store = cms.string('test')
265  ),
266  reference = cms.PSet(
267  inputFileNames = cms.vstring('/opt/sbg/cms/ui4_data1/dbodin/CMSSW_3_5_1/src/TauID/QCD_recoFiles/TauVal_CMSSW_3_6_0_QCD.root'),
268  scaleFactor = cms.double(1.),
269  dqmDirectory_store = cms.string('reference')
270  )
271 )
272 
273 # Lots of junk to define the plot style
274 
275 # standard drawing stuff
276 xAxisStuff = cms.PSet(
277  xAxisTitle = cms.string('P_{T} / GeV'),
278  xAxisTitleOffset = cms.double(0.9),
279  xAxisTitleSize = cms.double(0.05)
280 )
281 xModifiers = [['pt',['xAxisTitle'],['P_{T} / GeV']],['eta',['xAxisTitle'],['#eta']],['phi',['xAxisTitle'],['#phi']],['pileup',['xAxisTitle'],['# of Reco Vertices']]]
282 
283 yAxisStuff =cms.PSet(
284  yScale = cms.string('linear'), # linear/log
285  minY_linear = cms.double(0.),
286  maxY_linear = cms.double(1.6),
287  minY_log = cms.double(0.001),
288  maxY_log = cms.double(1.8),
289  yAxisTitle = cms.string('#varepsilon'),
290  yAxisTitleOffset = cms.double(1.1),
291  yAxisTitleSize = cms.double(0.05)
292 )
293 yModifiers = [['efficiency',['yScale','yAxisTitle'],['linear','#varepsilon']],['fakeRate',['yScale','yAxisTitle'],['log','Fake rate']]]
294 
295 legStuff = cms.PSet(
296  posX = cms.double(0.50),
297  posY = cms.double(0.72),
298  sizeX = cms.double(0.39),
299  sizeY = cms.double(0.17),
300  header = cms.string(''),
301  option = cms.string('brNDC'),
302  borderSize = cms.int32(0),
303  fillColor = cms.int32(0)
304 )
305 legModifiers = [['efficiency',['posY','sizeY'],[0.72,0.17]],['efficiency_overlay',['posY','sizeY'],[0.66,0.23]]]
306 
307 drawOptStuff = cms.PSet(
308  markerColor = cms.int32(1),
309  markerSize = cms.double(1.),
310  markerStyle = cms.int32(20),
311  lineColor = cms.int32(1),
312  lineStyle = cms.int32(1),
313  lineWidth = cms.int32(2),
314  drawOption = cms.string('ex0'),
315  drawOptionLegend = cms.string('p')
316 )
317 drawOptModifiers = [['eff_overlay01',['markerColor','lineColor'],[1,1]],['eff_overlay02',['markerColor','lineColor'],[2,2]],['eff_overlay03',['markerColor','lineColor'],[3,3]],['eff_overlay04',['markerColor','lineColor'],[4,4]],['eff_overlay05',['markerColor','lineColor'],[6,6]],['eff_overlay06',['markerColor','lineColor'],[5,5]],['eff_overlay07',['markerColor','lineColor'],[7,7]],['eff_overlay08',['markerColor','lineColor'],[28,28]],['eff_overlay09',['markerColor','lineColor','markerStyle'],[2,2,29]],['eff_overlay010',['markerColor','lineColor','markerStyle'],[4,4,29]],['eff_overlay011',['markerColor','lineColor','markerStyle'],[6,6,29]]]
318 
319 standardDrawingStuff = cms.PSet(
320  canvasSizeX = cms.int32(640),
321  canvasSizeY = cms.int32(640),
322  indOutputFileName = cms.string('#PLOT#.png'),
323  xAxes = Utils.SpawnPSet(xModifiers,xAxisStuff),
324  yAxes = Utils.SpawnPSet(yModifiers,yAxisStuff),
325  legends = Utils.SpawnPSet(legModifiers,legStuff),
326  labels = cms.PSet(
327  pt = cms.PSet(
328  posX = cms.double(0.19),
329  posY = cms.double(0.77),
330  sizeX = cms.double(0.12),
331  sizeY = cms.double(0.04),
332  option = cms.string('brNDC'),
333  borderSize = cms.int32(0),
334  fillColor = cms.int32(0),
335  textColor = cms.int32(1),
336  textSize = cms.double(0.04),
337  textAlign = cms.int32(22),
338  text = cms.vstring('P_{T} > 5 GeV') #vstring not supported by SpawnPSet
339  ),
340  eta = cms.PSet(
341  posX = cms.double(0.19),
342  posY = cms.double(0.83),
343  sizeX = cms.double(0.12),
344  sizeY = cms.double(0.04),
345  option = cms.string('brNDC'),
346  borderSize = cms.int32(0),
347  fillColor = cms.int32(0),
348  textColor = cms.int32(1),
349  textSize = cms.double(0.04),
350  textAlign = cms.int32(22),
351  text = cms.vstring('-2.5 < #eta < +2.5')
352  )
353  ),
354  drawOptionSets = cms.PSet(
355  efficiency = cms.PSet(
356  test = cms.PSet(
357  markerColor = cms.int32(4),
358  markerSize = cms.double(1.),
359  markerStyle = cms.int32(20),
360  lineColor = cms.int32(1),
361  lineStyle = cms.int32(1),
362  lineWidth = cms.int32(1),
363  drawOption = cms.string('ep'),
364  drawOptionLegend = cms.string('p')
365  ),
366  reference = cms.PSet(
367  lineColor = cms.int32(1),
368  lineStyle = cms.int32(1),
369  lineWidth = cms.int32(1),
370  fillColor = cms.int32(41),
371  drawOption = cms.string('eBand'),
372  drawOptionLegend = cms.string('l')
373  )
374  )
375  ),
376  drawOptionEntries = Utils.SpawnPSet(drawOptModifiers,drawOptStuff)
377 )
378 
379 standardCompareTestAndReference = cms.PSet(
380  processes = cms.PSet(
381  test = cms.PSet(
382  dqmDirectory = cms.string('test'),
383  legendEntry = cms.string('no test label'),
384  type = cms.string('smMC') # Data/smMC/bsmMC/smSumMC
385  ),
386  reference = cms.PSet(
387  dqmDirectory = cms.string('reference'),
388  legendEntry = cms.string('no ref label'),
389  type = cms.string('smMC') # Data/smMC/bsmMC/smSumMC
390  )
391  ),
392 )
393 
394 
395 ##################################################
396 #
397 # The plotting of HPS Efficiencies
398 #
399 ##################################################
400 ## plotHPSEfficiencies = DQMEDAnalyzer("TauDQMHistPlotter",
401 ## standardDrawingStuff,
402 ## standardCompareTestAndReference,
403 ## drawJobs = Utils.SpawnDrawJobs(RunHPSValidation, plotPset),
404 ## outputFilePath = cms.string('./hpsPFTauProducer/'),
405 ## PrintToFile = cms.bool(True)
406 ## )
407 ## #clone for DQM
408 ## plotHPSEfficiencies2 = plotHPSEfficiencies.clone()
409 
410 
411 ##################################################
412 #
413 # The plotting of all the Shrinking cone leading pion efficiencies
414 #
415 ##################################################
416 ## plotPFTauHighEfficiencyEfficienciesLeadingPion = DQMEDAnalyzer("TauDQMHistPlotter",
417 ## standardDrawingStuff,
418 ## standardCompareTestAndReference,
419 ## drawJobs = Utils.SpawnDrawJobs(PFTausHighEfficiencyLeadingPionBothProngs, plotPset),
420 ## outputFilePath = cms.string('./shrinkingConePFTauProducerLeadingPion/'),
421 ## PrintToFile = cms.bool(True)
422 ## )
423 ## #clone for DQM
424 ## plotPFTauHighEfficiencyEfficienciesLeadingPion2 = plotPFTauHighEfficiencyEfficienciesLeadingPion.clone()
425 
426 
427 ## plotTauValidation = cms.Sequence(
428 ## plotPFTauHighEfficiencyEfficienciesLeadingPion
429 ## +plotHPSEfficiencies
430 ## )
431 
432 ## plotTauValidation2 = cms.Sequence(
433 ## plotPFTauHighEfficiencyEfficienciesLeadingPion2
434 ## +plotHPSEfficiencies2
435 ## )
436 
437 
438 ## loadAndPlotTauValidation = cms.Sequence(
439 ## loadTau
440 ## +plotTauValidation
441 ## )
442 
443 """
444 
445 UTILITIES
446 
447 """
448 
450  """ Helper class that applies a given function to all modules
451  in a sequence """
452  def __init__(self,function):
453  self.functor = function
454  def enter(self, module):
455  self.functor(module)
456  def leave(self, module):
457  pass
458 
460  input = re.sub('fixedConePFTauProducer', 'pfRecoTauProducer', input)
461  #fixedDiscriminationRegex = re.compile('fixedConePFTauDiscrimination( \w* )')
462  fixedDiscriminationRegex = re.compile('fixedConePFTauDiscrimination(\w*)')
463  input = fixedDiscriminationRegex.sub(r'pfRecoTauDiscrimination\1', input)
464  input = re.sub('shrinkingConePFTauProducer', 'pfRecoTauProducerHighEfficiency', input)
465  shrinkingDiscriminationRegex = re.compile('shrinkingConePFTauDiscrimination(\w*)')
466  input = shrinkingDiscriminationRegex.sub(r'pfRecoTauDiscrimination\1HighEfficiency', input)
467  return input
468 
469 
471  """ Converts a draw job defined to compare 31X named PFTau validtion efficiencies
472  to comapre a 31X to a 22X named validation """
473  # get the list of drawjobs { name : copyOfPSet }
474  if not hasattr(input, "drawJobs"):
475  return
476  myDrawJobs = input.drawJobs.parameters_()
477  for drawJobName, drawJobData in six.iteritems(myDrawJobs):
478  print(drawJobData)
479  if not drawJobData.plots.pythonTypeName() == "cms.PSet":
480  continue
481  pSetToInsert = cms.PSet(
482  standardEfficiencyParameters,
483  plots = cms.VPSet(
484  # test plot w/ modern names
485  cms.PSet(
486  dqmMonitorElements = drawJobData.plots.dqmMonitorElements,
487  process = cms.string('test'),
488  drawOptionEntry = cms.string('eff_overlay01'),
489  legendEntry = cms.string(input.processes.test.legendEntry.value())
490  ),
491  # ref plot w/ vintage name
492  cms.PSet(
493  # translate the name
494  dqmMonitorElements = cms.vstring(TranslateToLegacyProdNames(drawJobData.plots.dqmMonitorElements.value()[0])),
495  process = cms.string('reference'),
496  drawOptionEntry = cms.string('eff_overlay02'),
497  legendEntry = cms.string(input.processes.reference.legendEntry.value())
498  )
499  )
500  )
501  input.drawJobs.__setattr__(drawJobName, pSetToInsert)
502 
503 def MakeLabeler(TestLabel, ReferenceLabel):
504  def labeler(module):
505  if hasattr(module, 'processes'):
506  if module.processes.hasParameter(['test', 'legendEntry']) and module.processes.hasParameter([ 'reference', 'legendEntry']):
507  module.processes.test.legendEntry = TestLabel
508  module.processes.reference.legendEntry = ReferenceLabel
509  print("Set test label to %s and reference label to %s for plot producer %s" % (TestLabel, ReferenceLabel, module.label()))
510  else:
511  print("ERROR in RecoTauValidation_cfi::MakeLabeler - trying to set test/reference label but %s does not have processes.(test/reference).legendEntry parameters!" % module.label())
512  return labeler
513 
514 def SetYmodulesToLog(matchingNames = []):
515  ''' set all modules whose name contains one of the matching names to log y scale'''
516  def yLogger(module):
517  ''' set a module to use log scaling in the yAxis'''
518  if hasattr(module, 'drawJobs'):
519  print("EK DEBUG")
520  drawJobParamGetter = lambda subName : getattr(module.drawJobs, subName)
521  #for subModule in [getattr(module.drawJobs, subModuleName) for subModuleName in dir(module.drawJobs)]:
522  attrNames = dir(module.drawJobs)
523  for subModuleName, subModule in zip(attrNames, map(drawJobParamGetter, attrNames)):
524  matchedNames = [name for name in matchingNames if subModuleName.find( name) > -1] # matching sub strings
525  if len(matchingNames) == 0:
526  matchedNames = ['take','everything','and','dont','bother']
527  if hasattr(subModule, "yAxis") and len(matchedNames):
528  print("Setting drawJob: ", subModuleName, " to log scale.")
529  subModule.yAxis = cms.string('fakeRate') #'fakeRate' configuration specifies the log scaling
530  if len(matchingNames) == 0:
531  module.yAxes.efficiency.maxY_log = 40
532  module.yAxes.fakeRate.maxY_log = 40
533  return yLogger
534 
535 
536 def SetBaseDirectory(Directory):
537  def BaseDirectorizer(module):
538  newPath = Directory
539  #if module.hasParameter("outputFilePath"):
540  if hasattr(module, "outputFilePath"):
541  oldPath = module.outputFilePath.value()
542  newPath = os.path.join(newPath, oldPath)
543  if not os.path.exists(newPath):
544  os.makedirs(newPath)
545  print(newPath)
546  module.outputFilePath = cms.string("%s" % newPath)
547  return BaseDirectorizer
548 
550  if hasattr(module, 'drawJobs'):
551  #get draw job parameter names
552  drawJobs = module.drawJobs.parameterNames_()
553  for drawJob in drawJobs:
554  if drawJob != "TauIdEffStepByStep":
555  module.drawJobs.__delattr__(drawJob)
556  print("Removing comparison plot", drawJob)
557 
558 def SetPlotDirectory(myPlottingSequence, directory):
559  myFunctor = ApplyFunctionToSequence(SetBaseDirectory(directory))
560  myPlottingSequence.visit(myFunctor)
561 
562 def SetTestAndReferenceLabels(myPlottingSequence, TestLabel, ReferenceLabel):
563  myFunctor = ApplyFunctionToSequence(MakeLabeler(TestLabel, ReferenceLabel))
564  myPlottingSequence.visit(myFunctor)
565 
566 def SetCompareToLegacyProductNames(myPlottingSequence):
567  myFunctor = ApplyFunctionToSequence(ConvertDrawJobToLegacyCompare)
568  myPlottingSequence.visit(myFunctor)
569 
570 def SetTestFileToPlot(myProcess, FileLoc):
571  myProcess.loadTau.test.inputFileNames = cms.vstring(FileLoc)
572 
573 def SetReferenceFileToPlot(myProcess, FileLoc):
574  if FileLoc == None:
575  del myProcess.loadTau.reference
576  else:
577  myProcess.loadTau.reference.inputFileNames = cms.vstring(FileLoc)
578 
579 def SetLogScale(myPlottingSequence):
581  myPlottingSequence.visit(myFunctor)
582 
583 def SetSmartLogScale(myPlottingSequence):
584  myFunctor = ApplyFunctionToSequence(SetYmodulesToLog(['Electron', 'Muon', 'Isolation', 'TaNC']))
585  myPlottingSequence.visit(myFunctor)
586 
587 def SetPlotOnlyStepByStep(myPlottingSequence):
588  myFunctor = ApplyFunctionToSequence(RemoveComparisonPlotCommands)
589  myPlottingSequence.visit(myFunctor)
590 
591 def SetValidationExtention(module, extension):
592  module.ExtensionName = module.ExtensionName.value()+extension
593 
594 def setBinning(module,pset):
595  if module._TypedParameterizable__type == 'TauTagValidation':
596  module.histoSettings = pset
597 
598 def setTrigger(module,pset):
599  if hasattr(module,'_TypedParameterizable__type') and module._TypedParameterizable__type == 'TauTagValidation':
600  setattr(module,'turnOnTrigger',cms.bool(True)) #Turns on trigger (in case is off)
601  for item in pset.parameters_().items():
602  setattr(module.GenericTriggerSelection,item[0],item[1])
def SetPlotOnlyStepByStep(myPlottingSequence)
def SetLogScale(myPlottingSequence)
def SetCompareToLegacyProductNames(myPlottingSequence)
def SetPlotDirectory(myPlottingSequence, directory)
def SetReferenceFileToPlot(myProcess, FileLoc)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
def setTrigger(module, pset)
def SetTestFileToPlot(myProcess, FileLoc)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def SetValidationExtention(module, extension)
def setBinning(module, pset)
def SetSmartLogScale(myPlottingSequence)
def MakeLabeler(TestLabel, ReferenceLabel)
def RemoveComparisonPlotCommands(module)
def SetTestAndReferenceLabels(myPlottingSequence, TestLabel, ReferenceLabel)
def SetYmodulesToLog(matchingNames=[])
dbl *** dir
Definition: mlp_gen.cc:35