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