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

◆ CreatePlotEntry()

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  else:
18  num = 'RecoTauV/%s%s_%s/%s_vs_#PAR#TauVisible'%(producer,ext,discriminatorLabel,discriminatorLabel)
19  if discriminatorLabel.find('DiscriminationBy') != -1:
20  hname = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
21  else:
22  hname = discriminatorLabel[(discriminatorLabel.find('Discrimination')+len('Discrimination')):]
23  out = 'RecoTauV/%s%s_%s/%sEff#PAR#'%(producer,ext,discriminatorLabel,hname)
24 
25  den = 'RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible'%(producer,ext)
26  ret = cms.PSet(
27  numerator = cms.string(num),
28  denominator = cms.string(den),
29  efficiency = cms.string(out),
30  parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
31  stepByStep = cms.bool(step)
32  )
33  return ret
34 
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True)

◆ DisableQCuts()

def ValidationUtils.DisableQCuts (   sequence)

Definition at line 92 of file ValidationUtils.py.

92 def DisableQCuts(sequence):
93  scanner = Scanner()
94  sequence.visit(scanner)
95  disabled = cms.PSet(
96  isolationQualityCuts = cms.PSet(
97  minTrackHits = cms.uint32(0),
98  minTrackVertexWeight = cms.double(-1),
99  minTrackPt = cms.double(0),
100  maxTrackChi2 = cms.double(9999),
101  minTrackPixelHits = cms.uint32(0),
102  minGammaEt = cms.double(0),
103  maxDeltaZ = cms.double(0.2),
104  maxTransverseImpactParameter = cms.double(9999)
105  ),
106  pvFindingAlgo = cms.string('highestWeightForLeadTrack'),
107  primaryVertexSrc = cms.InputTag("offlinePrimaryVertices"),
108  signalQualityCuts = cms.PSet(
109  minTrackHits = cms.uint32(0),
110  minTrackVertexWeight = cms.double(-1),
111  minTrackPt = cms.double(0),
112  maxTrackChi2 = cms.double(9999),
113  minTrackPixelHits = cms.uint32(0),
114  minGammaEt = cms.double(0),
115  maxDeltaZ = cms.double(0.2),
116  maxTransverseImpactParameter = cms.double(9999)
117  )
118  )
119  for module in scanner.modules():
120  if hasattr(module,'qualityCuts'):
121  setattr(module,'qualityCuts',disabled)
122 
123 
def DisableQCuts(sequence)

◆ NameVariable()

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 35 of file ValidationUtils.py.

Referenced by PlotAnalyzer().

35 def NameVariable(analyzer, discriminatorLabel=None):
36  """NameVariable(analyzer, discriminatorLabel)\n
37  returns a string with the name of the pset created by CreatePlotEntry"""
38  #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!
39  if analyzer.TauProducer.pythonValue()[1:-1] == 'shrinkingConePFTauProducer':
40  if analyzer.ExtensionName.pythonValue()[1:-1] == 'Tanc':
41  first='ShrinkingConeTanc'
42  elif analyzer.ExtensionName.pythonValue()[1:-1] == 'LeadingPion':
43  first='PFTauHighEfficiencyLeadingPion'
44  elif analyzer.ExtensionName.pythonValue()[1:-1] == "":
45  first='PFTauHighEfficiency'
46  else:
47  #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
48  first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
49  elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsPFTauProducer':
50  first='HPS'
51  elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsTancTaus':
52  first='HPSTanc'+analyzer.ExtensionName.value()
53  else:
54  #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
55  first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
56 
57  if discriminatorLabel == None:
58  last = 'Matching'
59  else:
60  if discriminatorLabel.find('DiscriminationBy') != -1:
61  last = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
62  if last.find('TaNCfr') != -1:
63  last = last[len('TaNCfr'):]
64  else:
65  last = discriminatorLabel[(discriminatorLabel.find('DiscriminationAgainst')+len('DiscriminationAgainst')):]+"Rejection"
66 
67  return first+"ID"+last+"Efficiencies"
68 
def NameVariable(analyzer, discriminatorLabel=None)

◆ PlotAnalyzer()

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 69 of file ValidationUtils.py.

References CreatePlotEntry(), and NameVariable().

Referenced by SetPlotSequence().

69 def PlotAnalyzer(pset, analyzer):
70  """PlotAnalyzer(pset, analyzer)\n
71  fills a PSet that contains all the performance plots for a anlyzer\n
72  pset is the PSet to fill/add"""
73 
74  setattr(pset,NameVariable(analyzer),CreatePlotEntry(analyzer))
75 
76  for currentDiscriminator in analyzer.discriminators:
77  label = currentDiscriminator.discriminator.pythonValue()[1:-1]
78  step = currentDiscriminator.plotStep.value()
79  setattr(pset,NameVariable(analyzer,label),CreatePlotEntry(analyzer,label,step))
80 
def PlotAnalyzer(pset, analyzer)
def NameVariable(analyzer, discriminatorLabel=None)
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True)

◆ SetpByStep()

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 162 of file ValidationUtils.py.

Referenced by SpawnDrawJobs().

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

◆ SetPlotSequence()

def ValidationUtils.SetPlotSequence (   sequence)
SetSequence(seqence)\n
This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer

Definition at line 124 of file ValidationUtils.py.

References PlotAnalyzer().

124 def SetPlotSequence(sequence):
125  """SetSequence(seqence)\n
126  This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer"""
127  pset = cms.PSet()
128  scanner = Scanner()
129  sequence.visit(scanner)
130  for analyzer in scanner.modules():#The first one is the sequence itself
131  PlotAnalyzer(pset, analyzer)
132  return pset
133 
def PlotAnalyzer(pset, analyzer)
def SetPlotSequence(sequence)

◆ SpawnDrawJobs()

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 207 of file ValidationUtils.py.

References SetpByStep().

207 def SpawnDrawJobs(analyzer, plotPset, useOnly=None):
208  """SpwnDrawJobs(analyzer, plotPset) --> cms.PSet\n
209  This function produces the parameter set drawJobs for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot"""
210  standardEfficiencyParameters = cms.PSet(
211  parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
212  xAxis = cms.string('#PAR#'),
213  yAxis = cms.string('efficiency'),
214  legend = cms.string('efficiency'),
215  labels = cms.vstring('pt', 'eta'),
216  drawOptionSet = cms.string('efficiency')
217  )
218  ret = cms.PSet()
219  tancDisc = ['Matching','DecayModeSelection','LeadingPionPtCut','LeadingTrackFinding','LeadingTrackPtCut','Tanc','TancVLoose','TancLoose','TancMedium','TancRaw','TancTight','AgainstElectron','AgainstMuon']
220  hpsDisc = ['Matching','DecayModeSelection','LooseIsolation','MediumIsolation','TightIsolation']
221  producer = analyzer.TauProducer.pythonValue()[1:-1]
222  ext = analyzer.ExtensionName.pythonValue()[1:-1]
223  keyword = producer + ext + "_"
224  for parName in plotPset.parameterNames_():
225  effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
226  discriminator = parName[parName.find('ID')+len('ID'):-len('Efficiencies')]
227  if useOnly == 'tanc':
228  useThis = discriminator in tancDisc
229  elif useOnly == 'hps':
230  useThis = discriminator in hpsDisc
231  else :
232  useThis = True
233  if (effplot.find(keyword) != -1) and useThis:
234  monEl = '#PROCESSDIR#/'+effplot
235  psetName = effplot[effplot.rfind('/')+1:-5]
236  psetVal = cms.PSet(
237  standardEfficiencyParameters,
238  plots = cms.PSet(
239  dqmMonitorElements = cms.vstring(monEl),
240  processes = cms.vstring('test', 'reference')
241  )
242  )
243  setattr(ret,psetName,psetVal)
244  setattr(ret,'TauIdEffStepByStep',SetpByStep(analyzer, plotPset,useOnly))
245  return ret #control if it's ok
246 
def SpawnDrawJobs(analyzer, plotPset, useOnly=None)
def SetpByStep(analyzer, plotPset, useOnly)

◆ SpawnPSet()

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 134 of file ValidationUtils.py.

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

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