CMS 3D CMS Logo

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