CMS 3D CMS Logo

Classes | Functions

ValidationUtils Namespace Reference

Classes

class  Scanner

Functions

def CreatePlotEntry
def DisableQCuts
def NameVariable
def PlotAnalyzer
def SetpByStep
def SetPlotSequence
def SpawnDrawJobs
def SpawnPSet

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

00005                                                                  :
00006     """CreatePlotEntry(analyzer, discriminatorLabel)\n
00007     Creates a PSet with the informations used by TauDQMHistEffProducer\n
00008     where to find the numerator and denominator\n
00009     where to put the new plot and how to name it\n
00010     which variables control"""
00011 
00012     producer = analyzer.TauProducer.pythonValue()[1:-1]
00013     ext = analyzer.ExtensionName.pythonValue()[1:-1]
00014     if discriminatorLabel == None:
00015         num = 'RecoTauV/%s%s_Matched/%sMatched_vs_#PAR#TauVisible'%(producer,ext,producer)
00016         #out = 'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
00017         if producer.find('caloReco') != -1:
00018             out = 'RecoTauV/%s%s_Matched/CaloJetMatchingEff#PAR#'%(producer,ext)
00019         else:
00020             out = 'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
00021     else:
00022         num = 'RecoTauV/%s%s_%s/%s_vs_#PAR#TauVisible'%(producer,ext,discriminatorLabel,discriminatorLabel)
00023         if discriminatorLabel.find('DiscriminationBy') != -1:
00024             hname = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
00025         else:
00026             hname = discriminatorLabel[(discriminatorLabel.find('Discrimination')+len('Discrimination')):]
00027         out = 'RecoTauV/%s%s_%s/%sEff#PAR#'%(producer,ext,discriminatorLabel,hname)
00028 
00029     den = 'RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible'%(producer,ext)
00030     ret = cms.PSet(
00031         numerator = cms.string(num),
00032         denominator = cms.string(den),
00033         efficiency = cms.string(out),
00034         parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
00035         stepByStep = cms.bool(step)
00036         )
00037     return ret

def ValidationUtils::DisableQCuts (   sequence)

Definition at line 97 of file ValidationUtils.py.

00098                           :
00099    scanner = Scanner()
00100    sequence.visit(scanner)
00101    disabled = cms.PSet(
00102     isolationQualityCuts = cms.PSet(
00103         minTrackHits = cms.uint32(0),
00104         minTrackVertexWeight = cms.double(-1),
00105         minTrackPt = cms.double(0),
00106         maxTrackChi2 = cms.double(9999),
00107         minTrackPixelHits = cms.uint32(0),
00108         minGammaEt = cms.double(0),
00109         maxDeltaZ = cms.double(0.2),
00110         maxTransverseImpactParameter = cms.double(9999)
00111         ),
00112     pvFindingAlgo = cms.string('highestWeightForLeadTrack'),
00113     primaryVertexSrc = cms.InputTag("offlinePrimaryVertices"),
00114     signalQualityCuts = cms.PSet(
00115         minTrackHits = cms.uint32(0),
00116         minTrackVertexWeight = cms.double(-1),
00117         minTrackPt = cms.double(0),
00118         maxTrackChi2 = cms.double(9999),
00119         minTrackPixelHits = cms.uint32(0),
00120         minGammaEt = cms.double(0),
00121         maxDeltaZ = cms.double(0.2),
00122         maxTransverseImpactParameter = cms.double(9999)
00123         )
00124     )
00125    for module in scanner.modules():
00126       if hasattr(module,'qualityCuts'):
00127          setattr(module,'qualityCuts',disabled)
00128 

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

00039                                                    :
00040     """NameVariable(analyzer, discriminatorLabel)\n
00041     returns a string with the name of the pset created by CreatePlotEntry"""
00042     #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!
00043     if analyzer.TauProducer.pythonValue()[1:-1] == 'shrinkingConePFTauProducer':
00044         if analyzer.ExtensionName.pythonValue()[1:-1] == 'Tanc':
00045             first='ShrinkingConeTanc'
00046         elif analyzer.ExtensionName.pythonValue()[1:-1] == 'LeadingPion':
00047             first='PFTauHighEfficiencyLeadingPion'
00048         elif analyzer.ExtensionName.pythonValue()[1:-1] == "":
00049             first='PFTauHighEfficiency'
00050         else:
00051             #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
00052             first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
00053     elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsPFTauProducer':
00054         first='HPS'
00055     elif analyzer.TauProducer.pythonValue()[1:-1] == 'hpsTancTaus':
00056         first='HPSTanc'+analyzer.ExtensionName.value()
00057     elif analyzer.TauProducer.pythonValue()[1:-1] == 'caloRecoTauProducer':
00058         first='CaloTau'
00059     else:
00060         #print 'Case not found check the available cases in Validation/RecoTau/python/ValidationUtils.py -- NameVariable'
00061         first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
00062     
00063     if discriminatorLabel == None:
00064         last = 'Matching'
00065     else:
00066         if discriminatorLabel.find('DiscriminationBy') != -1:
00067             last = discriminatorLabel[(discriminatorLabel.find('DiscriminationBy')+len('DiscriminationBy')):]
00068             if last.find('TaNCfr') != -1:
00069                 last = last[len('TaNCfr'):]
00070         else:
00071             last = discriminatorLabel[(discriminatorLabel.find('DiscriminationAgainst')+len('DiscriminationAgainst')):]+"Rejection"
00072 
00073     return first+"ID"+last+"Efficiencies"

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

00075                                 :
00076     """PlotAnalyzer(pset, analyzer)\n
00077     fills a PSet that contains all the performance plots for a anlyzer\n
00078     pset is the PSet to fill/add"""
00079 
00080     setattr(pset,NameVariable(analyzer),CreatePlotEntry(analyzer))
00081 
00082     for currentDiscriminator in analyzer.discriminators:
00083         label = currentDiscriminator.discriminator.pythonValue()[1:-1]
00084         step = currentDiscriminator.plotStep.value()
00085         setattr(pset,NameVariable(analyzer,label),CreatePlotEntry(analyzer,label,step))

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.

00169                                            :
00170     """SetpByStep(analyzer, plotPset) --> PSet\n
00171      This function produces the parameter set stepBystep for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot"""
00172     standardEfficiencyOverlay = cms.PSet(
00173         parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
00174         title = cms.string('TauId step by step efficiencies'),
00175         xAxis = cms.string('#PAR#'),
00176         yAxis = cms.string('efficiency'),
00177         legend = cms.string('efficiency_overlay'),
00178         labels = cms.vstring('pt', 'eta')
00179         )
00180     ret = cms.PSet(
00181         standardEfficiencyOverlay,
00182         plots = cms.VPSet()
00183         )
00184     producer = analyzer.TauProducer.pythonValue()[1:-1]
00185     ext = analyzer.ExtensionName.pythonValue()[1:-1]
00186     keyword = producer + ext + "_"
00187     counter = 0
00188     tancDisc = ['Matching','DecayModeSelection','LeadingPionPtCut','LeadingTrackFinding','LeadingTrackPtCut','Tanc','TancVLoose','TancLoose','TancMedium','TancRaw','TancTight','AgainstElectron','AgainstMuon']
00189     hpsDisc = ['Matching','DecayModeSelection','LooseIsolation','MediumIsolation','TightIsolation']
00190     for parName in plotPset.parameterNames_():
00191         isToBePlotted = getattr(plotPset,parName).stepByStep.value()
00192         if isToBePlotted:
00193             effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
00194             discriminator = parName[parName.find('ID')+len('ID'):-len('Efficiencies')]
00195             if useOnly == 'tanc':
00196                 useThis = discriminator in tancDisc
00197             elif useOnly == 'hps':
00198                 useThis = discriminator in hpsDisc
00199             else :
00200                 useThis = True
00201             if (effplot.find(keyword) != -1) and useThis:
00202                 monEl = '#PROCESSDIR#/'+effplot
00203                 counter = counter + 1
00204                 drawOpt = 'eff_overlay0%s'%(counter)
00205                 psetName = effplot[effplot.rfind('/')+1:-8]
00206                 ret.plots.append(cms.PSet(
00207                     dqmMonitorElements = cms.vstring(monEl),
00208                     process = cms.string('test'),
00209                     drawOptionEntry = cms.string(drawOpt),
00210                     legendEntry = cms.string(psetName)
00211                     ))
00212     return ret

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

Definition at line 129 of file ValidationUtils.py.

00130                              :
00131     """SetSequence(seqence)\n
00132     This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer"""
00133     pset = cms.PSet()
00134     scanner = Scanner()
00135     sequence.visit(scanner)
00136     for analyzer in scanner.modules():#The first one is the sequence itself
00137         if type(analyzer) is cms.EDAnalyzer:
00138             PlotAnalyzer(pset, analyzer)
00139     return pset

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.

00214                                                    :
00215     """SpwnDrawJobs(analyzer, plotPset) --> cms.PSet\n
00216     This function produces the parameter set drawJobs for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot"""
00217     standardEfficiencyParameters = cms.PSet(
00218         parameter = cms.vstring('pt', 'eta', 'phi', 'pileup'),
00219         xAxis = cms.string('#PAR#'),
00220         yAxis = cms.string('efficiency'),
00221         legend = cms.string('efficiency'),
00222         labels = cms.vstring('pt', 'eta'),
00223         drawOptionSet = cms.string('efficiency')
00224         )
00225     ret = cms.PSet()
00226     tancDisc = ['Matching','DecayModeSelection','LeadingPionPtCut','LeadingTrackFinding','LeadingTrackPtCut','Tanc','TancVLoose','TancLoose','TancMedium','TancRaw','TancTight','AgainstElectron','AgainstMuon']
00227     hpsDisc = ['Matching','DecayModeSelection','LooseIsolation','MediumIsolation','TightIsolation']
00228     producer = analyzer.TauProducer.pythonValue()[1:-1]
00229     ext = analyzer.ExtensionName.pythonValue()[1:-1]
00230     keyword = producer + ext + "_"
00231     for parName in plotPset.parameterNames_():
00232         effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
00233         discriminator = parName[parName.find('ID')+len('ID'):-len('Efficiencies')]
00234         if useOnly == 'tanc':
00235             useThis = discriminator in tancDisc
00236         elif useOnly == 'hps':
00237             useThis = discriminator in hpsDisc
00238         else :
00239             useThis = True
00240         if (effplot.find(keyword) != -1) and useThis:
00241             monEl = '#PROCESSDIR#/'+effplot
00242             psetName = effplot[effplot.rfind('/')+1:-5]
00243             psetVal = cms.PSet(
00244                 standardEfficiencyParameters,
00245                 plots = cms.PSet(
00246                     dqmMonitorElements = cms.vstring(monEl),
00247                     processes = cms.vstring('test', 'reference')
00248                     )
00249             )
00250             setattr(ret,psetName,psetVal)
00251     setattr(ret,'TauIdEffStepByStep',SetpByStep(analyzer, plotPset,useOnly))
00252     return ret #control if it's ok
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.

00141                                  :
00142     """SpawnPSet(lArgument, subPset) --> cms.PSet\n
00143     lArgument is a list containing a list of three strings/values:\n
00144            1-name to give to the spawned pset\n
00145            2-variable(s) to be changed\n
00146            3-value(s) of the variable(s): SAME LENGTH OF 2-!\n
00147            Supported types: int string float(converted to double)"""
00148     ret = cms.PSet()
00149     for spawn in lArgument:
00150         if len(spawn) != 3:
00151             print "ERROR! SpawnPSet uses argument of three data\n"
00152             print self.__doc__
00153             return None
00154         if len(spawn[1]) != len(spawn[2]):
00155             print "ERROR! Lists of arguments to replace must have the same length"
00156             print self.__doc__
00157             return None
00158         spawnArg = copy.deepcopy(subPset)
00159         for par, val in zip(spawn[1],spawn[2]):
00160             if type(val) is str :
00161                 setattr(spawnArg,par,cms.string(val))
00162             elif type(val) is int :
00163                 setattr(spawnArg,par,cms.int32(val))
00164             elif type(val) is float :
00165                 setattr(spawnArg,par,cms.double(val))
00166         setattr(ret,spawn[0],spawnArg)
00167     return ret