test
CMS 3D CMS Logo

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