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():
136 if type(analyzer)
is cms.EDAnalyzer:
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)"""
148 for spawn
in lArgument:
150 print "ERROR! SpawnPSet uses argument of three data\n"
153 if len(spawn[1]) != len(spawn[2]):
154 print "ERROR! Lists of arguments to replace must have the same length"
157 spawnArg = copy.deepcopy(subPset)
158 for par, val
in zip(spawn[1],spawn[2]):
159 if type(val)
is str :
160 setattr(spawnArg,par,cms.string(val))
161 elif type(val)
is int :
162 setattr(spawnArg,par,cms.int32(val))
163 elif type(val)
is float :
164 setattr(spawnArg,par,cms.double(val))
165 setattr(ret,spawn[0],spawnArg)
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')
180 standardEfficiencyOverlay,
183 producer = analyzer.TauProducer.pythonValue()[1:-1]
184 ext = analyzer.ExtensionName.pythonValue()[1:-1]
185 keyword = producer + ext +
"_"
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()
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
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)
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')
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
239 if (effplot.find(keyword) != -1)
and useThis:
240 monEl =
'#PROCESSDIR#/'+effplot
241 psetName = effplot[effplot.rfind(
'/')+1:-5]
243 standardEfficiencyParameters,
245 dqmMonitorElements = cms.vstring(monEl),
246 processes = cms.vstring(
'test',
'reference')
249 setattr(ret,psetName,psetVal)
250 setattr(ret,
'TauIdEffStepByStep',
SetpByStep(analyzer, plotPset,useOnly))