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 proc.templateAnalyzer = cms.EDAnalyzer(
115  "TauTagValidation",
116  StandardMatchingParameters,
117  GenericTriggerSelection = GenericTriggerSelectionParameters,
118  ExtensionName = cms.string(""),
119  TauProducer = cms.InputTag(''),
120  discriminators = cms.VPSet(
121  )
122 )
123 
124 
125 proc.RunHPSValidation = proc.templateAnalyzer.clone()
126 
127 #for fast sim we need to ignore the HLT TriggerResults
128 from Configuration.Eras.Modifier_fastSim_cff import fastSim
129 fastSim.toModify(
130  proc.RunHPSValidation,
131  hltInputTag = cms.InputTag(""),
132  GenericTriggerSelection=dict(hltInputTag = cms.InputTag(""))
133 )
134 
135 proc.RunHPSValidation.ExtensionName = ""
136 #RunHPSValidation.TauPtCut = cms.double(15.)
137 proc.RunHPSValidation.TauProducer = cms.InputTag('hpsPFTauProducer')
138 proc.RunHPSValidation.discriminators = cms.VPSet(
139  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFinding"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
140  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFindingNewDMs"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
141  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByDecayModeFindingOldDMs"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
142  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
143  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
144  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightChargedIsolation"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
145  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
146  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
147  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
148  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
149  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(True)),
150  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
151  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5VLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
152  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5LooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
153  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5MediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
154  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5TightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
155  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA5VTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
156  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseMuonRejection3"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
157  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightMuonRejection3"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
158  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLoosePileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
159  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumPileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
160  #cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightPileupWeightedIsolation3Hits"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
161  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6VLooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
162  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6LooseElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
163  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6MediumElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
164  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6TightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
165  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMVA6VTightElectronRejection"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
166  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
167  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
168  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
169  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
170  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
171  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
172  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
173  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
174  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
175  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
176  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
177  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
178  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
179  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
180  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
181  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
182  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
183  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWoldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
184  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
185  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
186  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
187  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
188  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
189  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWnewDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
190  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
191  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
192  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr3HitsdR03"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
193  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
194  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
195  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
196  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
197  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
198  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1DBdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
199  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVLooseIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
200  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByLooseIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
201  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByMediumIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
202  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
203  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False)),
204  cms.PSet( discriminator = cms.string("hpsPFTauDiscriminationByVVTightIsolationMVArun2v1PWdR03oldDMwLT"),selectionCut = cms.double(0.5),plotStep = cms.bool(False))
205 )
206 
207 proc.TauValNumeratorAndDenominator = cms.Sequence(
208  proc.RunHPSValidation
209  )
210 
211 """
212 
213 EFFICIENCY
214 
215  Tau efficiency calculations
216 
217  Define the Efficiency curves to produce. Each
218  efficiency producer takes the numberator and denominator
219  histograms and the dependent variables.
220 """
221 
222 plotPset = Utils.SetPlotSequence(proc.TauValNumeratorAndDenominator)
223 proc.efficiencies = cms.EDAnalyzer(
224  "TauDQMHistEffProducer",
225  plots = plotPset
226  )
227 
228 
229 ################################################
230 #
231 # Normalizes All the histograms
232 #
233 ################################################
234 
235 proc.normalizePlots = cms.EDAnalyzer(
236  "DQMHistNormalizer",
237  plotNamesToNormalize = cms.vstring('*_pTRatio_*','*_Size_*','*_SumPt_*','*_dRTauRefJet*'),
238  reference = cms.string('*_pTRatio_allHadronic')
239  )
240 
241 proc.TauEfficiencies = cms.Sequence(
242  proc.efficiencies*
243  proc.normalizePlots
244  )
245 
246 """
247 
248 PLOTTING
249 
250  loadTau: load two separate TauVal root files into the DQM
251  so the plotter can access them
252 
253 """
254 
255 loadTau = cms.EDAnalyzer("TauDQMFileLoader",
256  test = cms.PSet(
257  #inputFileNames = cms.vstring('/afs/cern.ch/user/f/friis/scratch0/MyValidationArea/310pre6NewTags/src/Validation/RecoTau/test/CMSSW_3_1_0_pre6_ZTT_0505Fixes.root'),
258  inputFileNames = cms.vstring('/opt/sbg/cms/ui4_data1/dbodin/CMSSW_3_5_1/src/TauID/QCD_recoFiles/TauVal_CMSSW_3_6_0_QCD.root'),
259  scaleFactor = cms.double(1.),
260  dqmDirectory_store = cms.string('test')
261  ),
262  reference = cms.PSet(
263  inputFileNames = cms.vstring('/opt/sbg/cms/ui4_data1/dbodin/CMSSW_3_5_1/src/TauID/QCD_recoFiles/TauVal_CMSSW_3_6_0_QCD.root'),
264  scaleFactor = cms.double(1.),
265  dqmDirectory_store = cms.string('reference')
266  )
267 )
268 
269 # Lots of junk to define the plot style
270 
271 # standard drawing stuff
272 xAxisStuff = cms.PSet(
273  xAxisTitle = cms.string('P_{T} / GeV'),
274  xAxisTitleOffset = cms.double(0.9),
275  xAxisTitleSize = cms.double(0.05)
276 )
277 xModifiers = [['pt',['xAxisTitle'],['P_{T} / GeV']],['eta',['xAxisTitle'],['#eta']],['phi',['xAxisTitle'],['#phi']],['pileup',['xAxisTitle'],['# of Reco Vertices']]]
278 
279 yAxisStuff =cms.PSet(
280  yScale = cms.string('linear'), # linear/log
281  minY_linear = cms.double(0.),
282  maxY_linear = cms.double(1.6),
283  minY_log = cms.double(0.001),
284  maxY_log = cms.double(1.8),
285  yAxisTitle = cms.string('#varepsilon'),
286  yAxisTitleOffset = cms.double(1.1),
287  yAxisTitleSize = cms.double(0.05)
288 )
289 yModifiers = [['efficiency',['yScale','yAxisTitle'],['linear','#varepsilon']],['fakeRate',['yScale','yAxisTitle'],['log','Fake rate']]]
290 
291 legStuff = cms.PSet(
292  posX = cms.double(0.50),
293  posY = cms.double(0.72),
294  sizeX = cms.double(0.39),
295  sizeY = cms.double(0.17),
296  header = cms.string(''),
297  option = cms.string('brNDC'),
298  borderSize = cms.int32(0),
299  fillColor = cms.int32(0)
300 )
301 legModifiers = [['efficiency',['posY','sizeY'],[0.72,0.17]],['efficiency_overlay',['posY','sizeY'],[0.66,0.23]]]
302 
303 drawOptStuff = cms.PSet(
304  markerColor = cms.int32(1),
305  markerSize = cms.double(1.),
306  markerStyle = cms.int32(20),
307  lineColor = cms.int32(1),
308  lineStyle = cms.int32(1),
309  lineWidth = cms.int32(2),
310  drawOption = cms.string('ex0'),
311  drawOptionLegend = cms.string('p')
312 )
313 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]]]
314 
315 standardDrawingStuff = cms.PSet(
316  canvasSizeX = cms.int32(640),
317  canvasSizeY = cms.int32(640),
318  indOutputFileName = cms.string('#PLOT#.png'),
319  xAxes = Utils.SpawnPSet(xModifiers,xAxisStuff),
320  yAxes = Utils.SpawnPSet(yModifiers,yAxisStuff),
321  legends = Utils.SpawnPSet(legModifiers,legStuff),
322  labels = cms.PSet(
323  pt = cms.PSet(
324  posX = cms.double(0.19),
325  posY = cms.double(0.77),
326  sizeX = cms.double(0.12),
327  sizeY = cms.double(0.04),
328  option = cms.string('brNDC'),
329  borderSize = cms.int32(0),
330  fillColor = cms.int32(0),
331  textColor = cms.int32(1),
332  textSize = cms.double(0.04),
333  textAlign = cms.int32(22),
334  text = cms.vstring('P_{T} > 5 GeV') #vstring not supported by SpawnPSet
335  ),
336  eta = cms.PSet(
337  posX = cms.double(0.19),
338  posY = cms.double(0.83),
339  sizeX = cms.double(0.12),
340  sizeY = cms.double(0.04),
341  option = cms.string('brNDC'),
342  borderSize = cms.int32(0),
343  fillColor = cms.int32(0),
344  textColor = cms.int32(1),
345  textSize = cms.double(0.04),
346  textAlign = cms.int32(22),
347  text = cms.vstring('-2.5 < #eta < +2.5')
348  )
349  ),
350  drawOptionSets = cms.PSet(
351  efficiency = cms.PSet(
352  test = cms.PSet(
353  markerColor = cms.int32(4),
354  markerSize = cms.double(1.),
355  markerStyle = cms.int32(20),
356  lineColor = cms.int32(1),
357  lineStyle = cms.int32(1),
358  lineWidth = cms.int32(1),
359  drawOption = cms.string('ep'),
360  drawOptionLegend = cms.string('p')
361  ),
362  reference = cms.PSet(
363  lineColor = cms.int32(1),
364  lineStyle = cms.int32(1),
365  lineWidth = cms.int32(1),
366  fillColor = cms.int32(41),
367  drawOption = cms.string('eBand'),
368  drawOptionLegend = cms.string('l')
369  )
370  )
371  ),
372  drawOptionEntries = Utils.SpawnPSet(drawOptModifiers,drawOptStuff)
373 )
374 
375 standardCompareTestAndReference = cms.PSet(
376  processes = cms.PSet(
377  test = cms.PSet(
378  dqmDirectory = cms.string('test'),
379  legendEntry = cms.string('no test label'),
380  type = cms.string('smMC') # Data/smMC/bsmMC/smSumMC
381  ),
382  reference = cms.PSet(
383  dqmDirectory = cms.string('reference'),
384  legendEntry = cms.string('no ref label'),
385  type = cms.string('smMC') # Data/smMC/bsmMC/smSumMC
386  )
387  ),
388 )
389 
390 
391 ##################################################
392 #
393 # The plotting of HPS Efficiencies
394 #
395 ##################################################
396 ## plotHPSEfficiencies = cms.EDAnalyzer("TauDQMHistPlotter",
397 ## standardDrawingStuff,
398 ## standardCompareTestAndReference,
399 ## drawJobs = Utils.SpawnDrawJobs(RunHPSValidation, plotPset),
400 ## outputFilePath = cms.string('./hpsPFTauProducer/'),
401 ## PrintToFile = cms.bool(True)
402 ## )
403 ## #clone for DQM
404 ## plotHPSEfficiencies2 = plotHPSEfficiencies.clone()
405 
406 
407 ##################################################
408 #
409 # The plotting of all the Shrinking cone leading pion efficiencies
410 #
411 ##################################################
412 ## plotPFTauHighEfficiencyEfficienciesLeadingPion = cms.EDAnalyzer("TauDQMHistPlotter",
413 ## standardDrawingStuff,
414 ## standardCompareTestAndReference,
415 ## drawJobs = Utils.SpawnDrawJobs(PFTausHighEfficiencyLeadingPionBothProngs, plotPset),
416 ## outputFilePath = cms.string('./shrinkingConePFTauProducerLeadingPion/'),
417 ## PrintToFile = cms.bool(True)
418 ## )
419 ## #clone for DQM
420 ## plotPFTauHighEfficiencyEfficienciesLeadingPion2 = plotPFTauHighEfficiencyEfficienciesLeadingPion.clone()
421 
422 
423 ## plotTauValidation = cms.Sequence(
424 ## plotPFTauHighEfficiencyEfficienciesLeadingPion
425 ## +plotHPSEfficiencies
426 ## )
427 
428 ## plotTauValidation2 = cms.Sequence(
429 ## plotPFTauHighEfficiencyEfficienciesLeadingPion2
430 ## +plotHPSEfficiencies2
431 ## )
432 
433 
434 ## loadAndPlotTauValidation = cms.Sequence(
435 ## loadTau
436 ## +plotTauValidation
437 ## )
438 
439 """
440 
441 UTILITIES
442 
443 """
444 
446  """ Helper class that applies a given function to all modules
447  in a sequence """
448  def __init__(self,function):
449  self.functor = function
450  def enter(self, module):
451  self.functor(module)
452  def leave(self, module):
453  pass
454 
456  input = re.sub('fixedConePFTauProducer', 'pfRecoTauProducer', input)
457  #fixedDiscriminationRegex = re.compile('fixedConePFTauDiscrimination( \w* )')
458  fixedDiscriminationRegex = re.compile('fixedConePFTauDiscrimination(\w*)')
459  input = fixedDiscriminationRegex.sub(r'pfRecoTauDiscrimination\1', input)
460  input = re.sub('shrinkingConePFTauProducer', 'pfRecoTauProducerHighEfficiency', input)
461  shrinkingDiscriminationRegex = re.compile('shrinkingConePFTauDiscrimination(\w*)')
462  input = shrinkingDiscriminationRegex.sub(r'pfRecoTauDiscrimination\1HighEfficiency', input)
463  return input
464 
465 
467  """ Converts a draw job defined to compare 31X named PFTau validtion efficiencies
468  to comapre a 31X to a 22X named validation """
469  # get the list of drawjobs { name : copyOfPSet }
470  if not hasattr(input, "drawJobs"):
471  return
472  myDrawJobs = input.drawJobs.parameters_()
473  for drawJobName, drawJobData in myDrawJobs.iteritems():
474  print drawJobData
475  if not drawJobData.plots.pythonTypeName() == "cms.PSet":
476  continue
477  pSetToInsert = cms.PSet(
478  standardEfficiencyParameters,
479  plots = cms.VPSet(
480  # test plot w/ modern names
481  cms.PSet(
482  dqmMonitorElements = drawJobData.plots.dqmMonitorElements,
483  process = cms.string('test'),
484  drawOptionEntry = cms.string('eff_overlay01'),
485  legendEntry = cms.string(input.processes.test.legendEntry.value())
486  ),
487  # ref plot w/ vintage name
488  cms.PSet(
489  # translate the name
490  dqmMonitorElements = cms.vstring(TranslateToLegacyProdNames(drawJobData.plots.dqmMonitorElements.value()[0])),
491  process = cms.string('reference'),
492  drawOptionEntry = cms.string('eff_overlay02'),
493  legendEntry = cms.string(input.processes.reference.legendEntry.value())
494  )
495  )
496  )
497  input.drawJobs.__setattr__(drawJobName, pSetToInsert)
498 
499 def MakeLabeler(TestLabel, ReferenceLabel):
500  def labeler(module):
501  if hasattr(module, 'processes'):
502  if module.processes.hasParameter(['test', 'legendEntry']) and module.processes.hasParameter([ 'reference', 'legendEntry']):
503  module.processes.test.legendEntry = TestLabel
504  module.processes.reference.legendEntry = ReferenceLabel
505  print "Set test label to %s and reference label to %s for plot producer %s" % (TestLabel, ReferenceLabel, module.label())
506  else:
507  print "ERROR in RecoTauValidation_cfi::MakeLabeler - trying to set test/reference label but %s does not have processes.(test/reference).legendEntry parameters!" % module.label()
508  return labeler
509 
510 def SetYmodulesToLog(matchingNames = []):
511  ''' set all modules whose name contains one of the matching names to log y scale'''
512  def yLogger(module):
513  ''' set a module to use log scaling in the yAxis'''
514  if hasattr(module, 'drawJobs'):
515  print "EK DEBUG"
516  drawJobParamGetter = lambda subName : getattr(module.drawJobs, subName)
517  #for subModule in [getattr(module.drawJobs, subModuleName) for subModuleName in dir(module.drawJobs)]:
518  attrNames = dir(module.drawJobs)
519  for subModuleName, subModule in zip(attrNames, map(drawJobParamGetter, attrNames)):
520  matchedNames = [name for name in matchingNames if subModuleName.find( name) > -1] # matching sub strings
521  if len(matchingNames) == 0:
522  matchedNames = ['take','everything','and','dont','bother']
523  if hasattr(subModule, "yAxis") and len(matchedNames):
524  print "Setting drawJob: ", subModuleName, " to log scale."
525  subModule.yAxis = cms.string('fakeRate') #'fakeRate' configuration specifies the log scaling
526  if len(matchingNames) == 0:
527  module.yAxes.efficiency.maxY_log = 40
528  module.yAxes.fakeRate.maxY_log = 40
529  return yLogger
530 
531 
532 def SetBaseDirectory(Directory):
533  def BaseDirectorizer(module):
534  newPath = Directory
535  #if module.hasParameter("outputFilePath"):
536  if hasattr(module, "outputFilePath"):
537  oldPath = module.outputFilePath.value()
538  newPath = os.path.join(newPath, oldPath)
539  if not os.path.exists(newPath):
540  os.makedirs(newPath)
541  print newPath
542  module.outputFilePath = cms.string("%s" % newPath)
543  return BaseDirectorizer
544 
546  if hasattr(module, 'drawJobs'):
547  #get draw job parameter names
548  drawJobs = module.drawJobs.parameterNames_()
549  for drawJob in drawJobs:
550  if drawJob != "TauIdEffStepByStep":
551  module.drawJobs.__delattr__(drawJob)
552  print "Removing comparison plot", drawJob
553 
554 def SetPlotDirectory(myPlottingSequence, directory):
555  myFunctor = ApplyFunctionToSequence(SetBaseDirectory(directory))
556  myPlottingSequence.visit(myFunctor)
557 
558 def SetTestAndReferenceLabels(myPlottingSequence, TestLabel, ReferenceLabel):
559  myFunctor = ApplyFunctionToSequence(MakeLabeler(TestLabel, ReferenceLabel))
560  myPlottingSequence.visit(myFunctor)
561 
562 def SetCompareToLegacyProductNames(myPlottingSequence):
563  myFunctor = ApplyFunctionToSequence(ConvertDrawJobToLegacyCompare)
564  myPlottingSequence.visit(myFunctor)
565 
566 def SetTestFileToPlot(myProcess, FileLoc):
567  myProcess.loadTau.test.inputFileNames = cms.vstring(FileLoc)
568 
569 def SetReferenceFileToPlot(myProcess, FileLoc):
570  if FileLoc == None:
571  del myProcess.loadTau.reference
572  else:
573  myProcess.loadTau.reference.inputFileNames = cms.vstring(FileLoc)
574 
575 def SetLogScale(myPlottingSequence):
577  myPlottingSequence.visit(myFunctor)
578 
579 def SetSmartLogScale(myPlottingSequence):
580  myFunctor = ApplyFunctionToSequence(SetYmodulesToLog(['Electron', 'Muon', 'Isolation', 'TaNC']))
581  myPlottingSequence.visit(myFunctor)
582 
583 def SetPlotOnlyStepByStep(myPlottingSequence):
584  myFunctor = ApplyFunctionToSequence(RemoveComparisonPlotCommands)
585  myPlottingSequence.visit(myFunctor)
586 
587 def SetValidationExtention(module, extension):
588  module.ExtensionName = module.ExtensionName.value()+extension
589 
590 def setBinning(module,pset):
591  if module._TypedParameterizable__type == 'TauTagValidation':
592  module.histoSettings = pset
593 
594 def setTrigger(module,pset):
595  if hasattr(module,'_TypedParameterizable__type') and module._TypedParameterizable__type == 'TauTagValidation':
596  setattr(module,'turnOnTrigger',cms.bool(True)) #Turns on trigger (in case is off)
597  for item in pset.parameters_().items():
598  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