1 import FWCore.ParameterSet.Config
as cms
5 """CreatePlotEntry(analyzer, discriminatorLabel)\n 6 Creates a PSet with the informations used by TauDQMHistEffProducer\n 7 where to find the numerator and denominator\n 8 where to put the new plot and how to name it\n 9 which variables control""" 11 producer = analyzer.TauProducer.pythonValue()[1:-1]
12 ext = analyzer.ExtensionName.pythonValue()[1:-1]
13 if discriminatorLabel ==
None:
14 num =
'RecoTauV/%s%s_Matched/%sMatched_vs_#PAR#TauVisible'%(producer,ext,producer)
16 if producer.find(
'caloReco') != -1:
17 out =
'RecoTauV/%s%s_Matched/CaloJetMatchingEff#PAR#'%(producer,ext)
19 out =
'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
21 num =
'RecoTauV/%s%s_%s/%s_vs_#PAR#TauVisible'%(producer,ext,discriminatorLabel,discriminatorLabel)
22 if discriminatorLabel.find(
'DiscriminationBy') != -1:
23 hname = discriminatorLabel[(discriminatorLabel.find(
'DiscriminationBy')+len(
'DiscriminationBy')):]
25 hname = discriminatorLabel[(discriminatorLabel.find(
'Discrimination')+len(
'Discrimination')):]
26 out =
'RecoTauV/%s%s_%s/%sEff#PAR#'%(producer,ext,discriminatorLabel,hname)
28 den =
'RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible'%(producer,ext)
30 numerator = cms.string(num),
31 denominator = cms.string(den),
32 efficiency = cms.string(out),
33 parameter = cms.vstring(
'pt',
'eta',
'phi',
'pileup'),
34 stepByStep = cms.bool(step)
39 """NameVariable(analyzer, discriminatorLabel)\n 40 returns a string with the name of the pset created by CreatePlotEntry""" 42 if analyzer.TauProducer.pythonValue()[1:-1] ==
'shrinkingConePFTauProducer':
43 if analyzer.ExtensionName.pythonValue()[1:-1] ==
'Tanc':
44 first=
'ShrinkingConeTanc' 45 elif analyzer.ExtensionName.pythonValue()[1:-1] ==
'LeadingPion':
46 first=
'PFTauHighEfficiencyLeadingPion' 47 elif analyzer.ExtensionName.pythonValue()[1:-1] ==
"":
48 first=
'PFTauHighEfficiency' 51 first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
52 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'hpsPFTauProducer':
54 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'hpsTancTaus':
55 first=
'HPSTanc'+analyzer.ExtensionName.value()
56 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'caloRecoTauProducer':
60 first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
62 if discriminatorLabel ==
None:
65 if discriminatorLabel.find(
'DiscriminationBy') != -1:
66 last = discriminatorLabel[(discriminatorLabel.find(
'DiscriminationBy')+len(
'DiscriminationBy')):]
67 if last.find(
'TaNCfr') != -1:
68 last = last[len(
'TaNCfr'):]
70 last = discriminatorLabel[(discriminatorLabel.find(
'DiscriminationAgainst')+len(
'DiscriminationAgainst')):]+
"Rejection" 72 return first+
"ID"+last+
"Efficiencies" 75 """PlotAnalyzer(pset, analyzer)\n 76 fills a PSet that contains all the performance plots for a anlyzer\n 77 pset is the PSet to fill/add""" 81 for currentDiscriminator
in analyzer.discriminators:
82 label = currentDiscriminator.discriminator.pythonValue()[1:-1]
83 step = currentDiscriminator.plotStep.value()
87 """Class to scan a sequence and give a list of analyzer used and a list of their names""" 91 self._analyzerRef.append(visitee)
99 sequence.visit(scanner)
101 isolationQualityCuts = cms.PSet(
102 minTrackHits = cms.uint32(0),
103 minTrackVertexWeight = cms.double(-1),
104 minTrackPt = cms.double(0),
105 maxTrackChi2 = cms.double(9999),
106 minTrackPixelHits = cms.uint32(0),
107 minGammaEt = cms.double(0),
108 maxDeltaZ = cms.double(0.2),
109 maxTransverseImpactParameter = cms.double(9999)
111 pvFindingAlgo = cms.string(
'highestWeightForLeadTrack'),
112 primaryVertexSrc = cms.InputTag(
"offlinePrimaryVertices"),
113 signalQualityCuts = cms.PSet(
114 minTrackHits = cms.uint32(0),
115 minTrackVertexWeight = cms.double(-1),
116 minTrackPt = cms.double(0),
117 maxTrackChi2 = cms.double(9999),
118 minTrackPixelHits = cms.uint32(0),
119 minGammaEt = cms.double(0),
120 maxDeltaZ = cms.double(0.2),
121 maxTransverseImpactParameter = cms.double(9999)
124 for module
in scanner.modules():
125 if hasattr(module,
'qualityCuts'):
126 setattr(module,
'qualityCuts',disabled)
130 """SetSequence(seqence)\n 131 This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer""" 134 sequence.visit(scanner)
135 for analyzer
in scanner.modules():
140 """SpawnPSet(lArgument, subPset) --> cms.PSet\n 141 lArgument is a list containing a list of three strings/values:\n 142 1-name to give to the spawned pset\n 143 2-variable(s) to be changed\n 144 3-value(s) of the variable(s): SAME LENGTH OF 2-!\n 145 Supported types: int string float(converted to double)""" 147 for spawn
in lArgument:
149 print "ERROR! SpawnPSet uses argument of three data\n" 152 if len(spawn[1]) != len(spawn[2]):
153 print "ERROR! Lists of arguments to replace must have the same length" 156 spawnArg = copy.deepcopy(subPset)
157 for par, val
in zip(spawn[1],spawn[2]):
158 if type(val)
is str :
159 setattr(spawnArg,par,cms.string(val))
160 elif type(val)
is int :
161 setattr(spawnArg,par,cms.int32(val))
162 elif type(val)
is float :
163 setattr(spawnArg,par,cms.double(val))
164 setattr(ret,spawn[0],spawnArg)
168 """SetpByStep(analyzer, plotPset) --> PSet\n 169 This function produces the parameter set stepBystep for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot""" 170 standardEfficiencyOverlay = cms.PSet(
171 parameter = cms.vstring(
'pt',
'eta',
'phi',
'pileup'),
172 title = cms.string(
'TauId step by step efficiencies'),
173 xAxis = cms.string(
'#PAR#'),
174 yAxis = cms.string(
'efficiency'),
175 legend = cms.string(
'efficiency_overlay'),
176 labels = cms.vstring(
'pt',
'eta')
179 standardEfficiencyOverlay,
182 producer = analyzer.TauProducer.pythonValue()[1:-1]
183 ext = analyzer.ExtensionName.pythonValue()[1:-1]
184 keyword = producer + ext +
"_" 186 tancDisc = [
'Matching',
'DecayModeSelection',
'LeadingPionPtCut',
'LeadingTrackFinding',
'LeadingTrackPtCut',
'Tanc',
'TancVLoose',
'TancLoose',
'TancMedium',
'TancRaw',
'TancTight',
'AgainstElectron',
'AgainstMuon']
187 hpsDisc = [
'Matching',
'DecayModeSelection',
'LooseIsolation',
'MediumIsolation',
'TightIsolation']
188 for parName
in plotPset.parameterNames_():
189 isToBePlotted = getattr(plotPset,parName).stepByStep.value()
191 effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
192 discriminator = parName[parName.find(
'ID')+len(
'ID'):-len(
'Efficiencies')]
193 if useOnly ==
'tanc':
194 useThis = discriminator
in tancDisc
195 elif useOnly ==
'hps':
196 useThis = discriminator
in hpsDisc
199 if (effplot.find(keyword) != -1)
and useThis:
200 monEl =
'#PROCESSDIR#/'+effplot
201 counter = counter + 1
202 drawOpt =
'eff_overlay0%s'%(counter)
203 psetName = effplot[effplot.rfind(
'/')+1:-8]
204 ret.plots.append(cms.PSet(
205 dqmMonitorElements = cms.vstring(monEl),
206 process = cms.string(
'test'),
207 drawOptionEntry = cms.string(drawOpt),
208 legendEntry = cms.string(psetName)
213 """SpwnDrawJobs(analyzer, plotPset) --> cms.PSet\n 214 This function produces the parameter set drawJobs for the EDAnalyzer TauDQMHistPlotter starting from the PSet produced for TauDQMHistEffProducer and the analyzer to plot""" 215 standardEfficiencyParameters = cms.PSet(
216 parameter = cms.vstring(
'pt',
'eta',
'phi',
'pileup'),
217 xAxis = cms.string(
'#PAR#'),
218 yAxis = cms.string(
'efficiency'),
219 legend = cms.string(
'efficiency'),
220 labels = cms.vstring(
'pt',
'eta'),
221 drawOptionSet = cms.string(
'efficiency')
224 tancDisc = [
'Matching',
'DecayModeSelection',
'LeadingPionPtCut',
'LeadingTrackFinding',
'LeadingTrackPtCut',
'Tanc',
'TancVLoose',
'TancLoose',
'TancMedium',
'TancRaw',
'TancTight',
'AgainstElectron',
'AgainstMuon']
225 hpsDisc = [
'Matching',
'DecayModeSelection',
'LooseIsolation',
'MediumIsolation',
'TightIsolation']
226 producer = analyzer.TauProducer.pythonValue()[1:-1]
227 ext = analyzer.ExtensionName.pythonValue()[1:-1]
228 keyword = producer + ext +
"_" 229 for parName
in plotPset.parameterNames_():
230 effplot = getattr(plotPset,parName).efficiency.pythonValue()[1:-1]
231 discriminator = parName[parName.find(
'ID')+len(
'ID'):-len(
'Efficiencies')]
232 if useOnly ==
'tanc':
233 useThis = discriminator
in tancDisc
234 elif useOnly ==
'hps':
235 useThis = discriminator
in hpsDisc
238 if (effplot.find(keyword) != -1)
and useThis:
239 monEl =
'#PROCESSDIR#/'+effplot
240 psetName = effplot[effplot.rfind(
'/')+1:-5]
242 standardEfficiencyParameters,
244 dqmMonitorElements = cms.vstring(monEl),
245 processes = cms.vstring(
'test',
'reference')
248 setattr(ret,psetName,psetVal)
249 setattr(ret,
'TauIdEffStepByStep',
SetpByStep(analyzer, plotPset,useOnly))
def PlotAnalyzer(pset, analyzer)
def SpawnDrawJobs(analyzer, plotPset, useOnly=None)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def SetpByStep(analyzer, plotPset, useOnly)
def SpawnPSet(lArgument, subPset)
def NameVariable(analyzer, discriminatorLabel=None)
def SetPlotSequence(sequence)
def DisableQCuts(sequence)
def CreatePlotEntry(analyzer, discriminatorLabel=None, step=True)