CMS 3D CMS Logo

Classes | Functions
ValidationUtils Namespace Reference

Classes

class  Scanner
 

Functions

def CreatePlotEntry (analyzer, discriminatorLabel=None, step=True)
 
def DisableQCuts (sequence)
 
def NameVariable (analyzer, discriminatorLabel=None)
 
def PlotAnalyzer (pset, analyzer)
 
def SetpByStep (analyzer, plotPset, useOnly)
 
def SetPlotSequence (sequence)
 
def SpawnDrawJobs (analyzer, plotPset, useOnly=None)
 
def SpawnPSet (lArgument, subPset)
 

Function Documentation

def ValidationUtils.CreatePlotEntry (   analyzer,
  discriminatorLabel = None,
  step = True 
)
CreatePlotEntry(analyzer, discriminatorLabel)\n
Creates a PSet with the informations used by TauDQMHistEffProducer\n
where to find the numerator and denominator\n
where to put the new plot and how to name it\n
which variables control

Definition at line 5 of file ValidationUtils.py.

Referenced by PlotAnalyzer().

5 def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True):
6  """CreatePlotEntry(analyzer, discriminatorLabel)\n
7  Creates a PSet with the informations used by TauDQMHistEffProducer\n
8  where to find the numerator and denominator\n
9  where to put the new plot and how to name it\n
10  which variables control"""
11 
12  producer = analyzer.TauProducer.pythonValue()[1:-1]
13  ext = analyzer.ExtensionName.pythonValue()[1:-1]
14  if discriminatorLabel == None:
15  num = 'RecoTauV/%s%s_Matched/%sMatched_vs_#PAR#TauVisible'%(producer,ext,producer)
16  #out = 'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
17  if producer.find('caloReco') != -1:
18  out = 'RecoTauV/%s%s_Matched/CaloJetMatchingEff#PAR#'%(producer,ext)
19  else:
20  out = 'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
21  else:
22  num = 'RecoTauV/%s%s_%s/%s_vs_#PAR#TauVisible'%(producer,ext,discriminatorLabel,discriminatorLabel)
23  if discriminatorLabel.find('DiscriminationBy') != -1:
24  hname = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
25  else:
26  hname = discriminatorLabel[(discriminatorLabel.find('Discrimination')+len('Discrimination')):]
27  out = 'RecoTauV/%s%s_%s/%sEff#PAR#'%(producer,ext,discriminatorLabel,hname)
28 
29  den = 'RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible'%(producer,ext)
30  ret = cms.PSet(
31  numerator = cms.string(num),
32  denominator = cms.string(den),
33  efficiency = cms.string(out),
34  parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
35  stepByStep = cms.bool(step)
36  )
37  return ret
38 
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True)
def ValidationUtils.DisableQCuts (   sequence)

Definition at line 98 of file ValidationUtils.py.

98 def DisableQCuts(sequence):
99  scanner = Scanner()
100  sequence.visit(scanner)
101  disabled = cms.PSet(
102  isolationQualityCuts = cms.PSet(
103  minTrackHits = cms.uint32(0),
104  minTrackVertexWeight = cms.double(-1),
105  minTrackPt = cms.double(0),
106  maxTrackChi2 = cms.double(9999),
107  minTrackPixelHits = cms.uint32(0),
108  minGammaEt = cms.double(0),
109  maxDeltaZ = cms.double(0.2),
110  maxTransverseImpactParameter = cms.double(9999)
111  ),
112  pvFindingAlgo = cms.string('highestWeightForLeadTrack'),
113  primaryVertexSrc = cms.InputTag("offlinePrimaryVertices"),
114  signalQualityCuts = cms.PSet(
115  minTrackHits = cms.uint32(0),
116  minTrackVertexWeight = cms.double(-1),
117  minTrackPt = cms.double(0),
118  maxTrackChi2 = cms.double(9999),
119  minTrackPixelHits = cms.uint32(0),
120  minGammaEt = cms.double(0),
121  maxDeltaZ = cms.double(0.2),
122  maxTransverseImpactParameter = cms.double(9999)
123  )
124  )
125  for module in scanner.modules():
126  if hasattr(module,'qualityCuts'):
127  setattr(module,'qualityCuts',disabled)
128 
129 
def DisableQCuts(sequence)
def ValidationUtils.NameVariable (   analyzer,
  discriminatorLabel = None 
)
NameVariable(analyzer, discriminatorLabel)\n
returns a string with the name of the pset created by CreatePlotEntry

Definition at line 39 of file ValidationUtils.py.

Referenced by PlotAnalyzer().

39 def NameVariable(analyzer, discriminatorLabel=None):
40  """NameVariable(analyzer, discriminatorLabel)\n
41  returns a string with the name of the pset created by CreatePlotEntry"""
42  #This part is messy, there is no way to directly link the producer and the name of the variable. There are more exception than rules! IF THE DISCRIMINATOR NAME CHANGES YOU HAVE TO CHANHE IT HERE TOO!
43  if analyzer.TauProducer.pythonValue()[1:-1] == 'shrinkingConePFTauProducer':
44  if analyzer.ExtensionName.pythonValue()[1:-1] == 'Tanc':
45  first='ShrinkingConeTanc'
46  elif analyzer.ExtensionName.pythonValue()[1:-1] == 'LeadingPion':
47  first='PFTauHighEfficiencyLeadingPion'
48  elif analyzer.ExtensionName.pythonValue()[1:-1] == "":
49  first='PFTauHighEfficiency'
50  else:
51  #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
52  first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
53  elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsPFTauProducer':
54  first='HPS'
55  elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsTancTaus':
56  first='HPSTanc'+analyzer.ExtensionName.value()
57  elif analyzer.TauProducer.pythonValue()[1:-1] == 'caloRecoTauProducer':
58  first='CaloTau'
59  else:
60  #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
61  first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
62 
63  if discriminatorLabel == None:
64  last = 'Matching'
65  else:
66  if discriminatorLabel.find('DiscriminationBy') != -1:
67  last = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
68  if last.find('TaNCfr') != -1:
69  last = last[len('TaNCfr'):]
70  else:
71  last = discriminatorLabel[(discriminatorLabel.find('DiscriminationAgainst')+len('DiscriminationAgainst')):]+"Rejection"
72 
73  return first+"ID"+last+"Efficiencies"
74 
def NameVariable(analyzer, discriminatorLabel=None)
def ValidationUtils.PlotAnalyzer (   pset,
  analyzer 
)
PlotAnalyzer(pset, analyzer)\n
fills a PSet that contains all the performance plots for a anlyzer\n
pset is the PSet to fill/add

Definition at line 75 of file ValidationUtils.py.

References CreatePlotEntry(), and NameVariable().

Referenced by SetPlotSequence().

75 def PlotAnalyzer(pset, analyzer):
76  """PlotAnalyzer(pset, analyzer)\n
77  fills a PSet that contains all the performance plots for a anlyzer\n
78  pset is the PSet to fill/add"""
79 
80  setattr(pset,NameVariable(analyzer),CreatePlotEntry(analyzer))
81 
82  for currentDiscriminator in analyzer.discriminators:
83  label = currentDiscriminator.discriminator.pythonValue()[1:-1]
84  step = currentDiscriminator.plotStep.value()
85  setattr(pset,NameVariable(analyzer,label),CreatePlotEntry(analyzer,label,step))
86 
def PlotAnalyzer(pset, analyzer)
def NameVariable(analyzer, discriminatorLabel=None)
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True)
def ValidationUtils.SetpByStep (   analyzer,
  plotPset,
  useOnly 
)
SetpByStep(analyzer, plotPset) --> PSet\n
 This function produces the parameter set stepBystep for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot

Definition at line 168 of file ValidationUtils.py.

Referenced by SpawnDrawJobs().

168 def SetpByStep(analyzer, plotPset, useOnly):
169  """SetpByStep(analyzer, plotPset) --> PSet\n
170  This function produces the parameter set stepBystep for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot"""
171  standardEfficiencyOverlay = cms.PSet(
172  parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
173  title = cms.string('TauId step by step efficiencies'),
174  xAxis = cms.string('#PAR#'),
175  yAxis = cms.string('efficiency'),
176  legend = cms.string('efficiency_overlay'),
177  labels = cms.vstring('pt', 'eta')
178  )
179  ret = cms.PSet(
180  standardEfficiencyOverlay,
181  plots = cms.VPSet()
182  )
183  producer = analyzer.TauProducer.pythonValue()[1:-1]
184  ext = analyzer.ExtensionName.pythonValue()[1:-1]
185  keyword = producer + ext + "_"
186  counter = 0
187  tancDisc = ['Matching','DecayModeSelection','LeadingPionPtCut','LeadingTrackFinding','LeadingTrackPtCut','Tanc','TancVLoose','TancLoose','TancMedium','TancRaw','TancTight','AgainstElectron','AgainstMuon']
188  hpsDisc = ['Matching','DecayModeSelection','LooseIsolation','MediumIsolation','TightIsolation']
189  for parName in plotPset.parameterNames_():
190  isToBePlotted = getattr(plotPset,parName).stepByStep.value()
191  if isToBePlotted:
192  effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
193  discriminator = parName[parName.find('ID')+len('ID'):-len('Efficiencies')]
194  if useOnly == 'tanc':
195  useThis = discriminator in tancDisc
196  elif useOnly == 'hps':
197  useThis = discriminator in hpsDisc
198  else :
199  useThis = True
200  if (effplot.find(keyword) != -1) and useThis:
201  monEl = '#PROCESSDIR#/'+effplot
202  counter = counter + 1
203  drawOpt = 'eff_overlay0%s'%(counter)
204  psetName = effplot[effplot.rfind('/')+1:-8]
205  ret.plots.append(cms.PSet(
206  dqmMonitorElements = cms.vstring(monEl),
207  process = cms.string('test'),
208  drawOptionEntry = cms.string(drawOpt),
209  legendEntry = cms.string(psetName)
210  ))
211  return ret
212 
def SetpByStep(analyzer, plotPset, useOnly)
def ValidationUtils.SetPlotSequence (   sequence)
SetSequence(seqence)\n
This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer

Definition at line 130 of file ValidationUtils.py.

References PlotAnalyzer().

130 def SetPlotSequence(sequence):
131  """SetSequence(seqence)\n
132  This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer"""
133  pset = cms.PSet()
134  scanner = Scanner()
135  sequence.visit(scanner)
136  for analyzer in scanner.modules():#The first one is the sequence itself
137  PlotAnalyzer(pset, analyzer)
138  return pset
139 
def PlotAnalyzer(pset, analyzer)
def SetPlotSequence(sequence)
def ValidationUtils.SpawnDrawJobs (   analyzer,
  plotPset,
  useOnly = None 
)
SpwnDrawJobs(analyzer, plotPset) --> cms.PSet\n
This function produces the parameter set drawJobs for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot

Definition at line 213 of file ValidationUtils.py.

References SetpByStep().

213 def SpawnDrawJobs(analyzer, plotPset, useOnly=None):
214  """SpwnDrawJobs(analyzer, plotPset) --> cms.PSet\n
215  This function produces the parameter set drawJobs for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot"""
216  standardEfficiencyParameters = cms.PSet(
217  parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
218  xAxis = cms.string('#PAR#'),
219  yAxis = cms.string('efficiency'),
220  legend = cms.string('efficiency'),
221  labels = cms.vstring('pt', 'eta'),
222  drawOptionSet = cms.string('efficiency')
223  )
224  ret = cms.PSet()
225  tancDisc = ['Matching','DecayModeSelection','LeadingPionPtCut','LeadingTrackFinding','LeadingTrackPtCut','Tanc','TancVLoose','TancLoose','TancMedium','TancRaw','TancTight','AgainstElectron','AgainstMuon']
226  hpsDisc = ['Matching','DecayModeSelection','LooseIsolation','MediumIsolation','TightIsolation']
227  producer = analyzer.TauProducer.pythonValue()[1:-1]
228  ext = analyzer.ExtensionName.pythonValue()[1:-1]
229  keyword = producer + ext + "_"
230  for parName in plotPset.parameterNames_():
231  effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
232  discriminator = parName[parName.find('ID')+len('ID'):-len('Efficiencies')]
233  if useOnly == 'tanc':
234  useThis = discriminator in tancDisc
235  elif useOnly == 'hps':
236  useThis = discriminator in hpsDisc
237  else :
238  useThis = True
239  if (effplot.find(keyword) != -1) and useThis:
240  monEl = '#PROCESSDIR#/'+effplot
241  psetName = effplot[effplot.rfind('/')+1:-5]
242  psetVal = cms.PSet(
243  standardEfficiencyParameters,
244  plots = cms.PSet(
245  dqmMonitorElements = cms.vstring(monEl),
246  processes = cms.vstring('test', 'reference')
247  )
248  )
249  setattr(ret,psetName,psetVal)
250  setattr(ret,'TauIdEffStepByStep',SetpByStep(analyzer, plotPset,useOnly))
251  return ret #control if it's ok
252 
def SpawnDrawJobs(analyzer, plotPset, useOnly=None)
def SetpByStep(analyzer, plotPset, useOnly)
def ValidationUtils.SpawnPSet (   lArgument,
  subPset 
)
SpawnPSet(lArgument, subPset) --> cms.PSet\n
lArgument is a list containing a list of three strings/values:\n
       1-name to give to the spawned pset\n
       2-variable(s) to be changed\n
       3-value(s) of the variable(s): SAME LENGTH OF 2-!\n
       Supported types: int string float(converted to double)

Definition at line 140 of file ValidationUtils.py.

References edm.print(), and ComparisonHelper.zip().

140 def SpawnPSet(lArgument, subPset):
141  """SpawnPSet(lArgument, subPset) --> cms.PSet\n
142  lArgument is a list containing a list of three strings/values:\n
143  1-name to give to the spawned pset\n
144  2-variable(s) to be changed\n
145  3-value(s) of the variable(s): SAME LENGTH OF 2-!\n
146  Supported types: int string float(converted to double)"""
147  ret = cms.PSet()
148  for spawn in lArgument:
149  if len(spawn) != 3:
150  print("ERROR! SpawnPSet uses argument of three data\n")
151  print(self.__doc__)
152  return None
153  if len(spawn[1]) != len(spawn[2]):
154  print("ERROR! Lists of arguments to replace must have the same length")
155  print(self.__doc__)
156  return None
157  spawnArg = copy.deepcopy(subPset)
158  for par, val in zip(spawn[1],spawn[2]):
159  if isinstance(val, str) :
160  setattr(spawnArg,par,cms.string(val))
161  elif isinstance(val, int) :
162  setattr(spawnArg,par,cms.int32(val))
163  elif isinstance(val, float) :
164  setattr(spawnArg,par,cms.double(val))
165  setattr(ret,spawn[0],spawnArg)
166  return ret
167 
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def SpawnPSet(lArgument, subPset)