1 from __future__
import print_function
2 import FWCore.ParameterSet.Config
as cms
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""" 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)
17 if producer.find(
'caloReco') != -1:
18 out =
'RecoTauV/%s%s_Matched/CaloJetMatchingEff#PAR#'%(producer,ext)
20 out =
'RecoTauV/%s%s_Matched/PFJetMatchingEff#PAR#'%(producer,ext)
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')):]
26 hname = discriminatorLabel[(discriminatorLabel.find(
'Discrimination')+len(
'Discrimination')):]
27 out =
'RecoTauV/%s%s_%s/%sEff#PAR#'%(producer,ext,discriminatorLabel,hname)
29 den =
'RecoTauV/%s%s_ReferenceCollection/nRef_Taus_vs_#PAR#TauVisible'%(producer,ext)
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)
40 """NameVariable(analyzer, discriminatorLabel)\n 41 returns a string with the name of the pset created by CreatePlotEntry""" 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' 52 first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
53 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'hpsPFTauProducer':
55 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'hpsTancTaus':
56 first=
'HPSTanc'+analyzer.ExtensionName.value()
57 elif analyzer.TauProducer.pythonValue()[1:-1] ==
'caloRecoTauProducer':
61 first=analyzer.TauProducer.pythonValue()[1:-1]+analyzer.ExtensionName.pythonValue()[1:-1]
63 if discriminatorLabel ==
None:
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'):]
71 last = discriminatorLabel[(discriminatorLabel.find(
'DiscriminationAgainst')+len(
'DiscriminationAgainst')):]+
"Rejection" 73 return first+
"ID"+last+
"Efficiencies" 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""" 82 for currentDiscriminator
in analyzer.discriminators:
83 label = currentDiscriminator.discriminator.pythonValue()[1:-1]
84 step = currentDiscriminator.plotStep.value()
88 """Class to scan a sequence and give a list of analyzer used and a list of their names""" 92 self._analyzerRef.append(visitee)
100 sequence.visit(scanner)
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)
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)
125 for module
in scanner.modules():
126 if hasattr(module,
'qualityCuts'):
127 setattr(module,
'qualityCuts',disabled)
131 """SetSequence(seqence)\n 132 This Function return a PSet of the sequence given to be used by TauDQMHistEffProducer""" 135 sequence.visit(scanner)
136 for analyzer
in scanner.modules():
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 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)
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))
def PlotAnalyzer(pset, analyzer)
def SpawnDrawJobs(analyzer, plotPset, useOnly=None)
S & print(S &os, JobReport::InputFile const &f)
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)