6 from string
import Template
8 stripDiscName =
lambda x: (x.split(
'/')[-1]).
split(
'Eff')[0]
11 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByDecayModeFinding/DecayModeFindingEff%s',
12 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseChargedIsolation/LooseChargedIsolationEff%s',
13 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr/LooseCombinedIsolationDBSumPtCorrEff%s'],
14 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr/MediumCombinedIsolationDBSumPtCorrEff%s',
15 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr/TightCombinedIsolationDBSumPtCorrEff%s',
16 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByVLooseCombinedIsolationDBSumPtCorr/VLooseCombinedIsolationDBSumPtCorrEff%s'],
19 muonrejplots = [
'RecoTauV/hpsPFTauProducerRealMuonsData_hpsPFTauDiscriminationByLooseMuonRejection/LooseMuonRejectionEff%s',
'RecoTauV/hpsPFTauProducerRealMuonsData_hpsPFTauDiscriminationByMediumMuonRejection/MediumMuonRejectionEff%s',
'RecoTauV/hpsPFTauProducerRealMuonsData_hpsPFTauDiscriminationByTightMuonRejection/TightMuonRejectionEff%s']
22 [
'RecoTauV/hpsPFTauProducerRealElectronsData_hpsPFTauDiscriminationByLooseElectronRejection/LooseElectronRejectionEff%s',
23 'RecoTauV/hpsPFTauProducerRealElectronsData_hpsPFTauDiscriminationByMVAElectronRejection/MVAElectronRejectionEff%s',],
24 [
'RecoTauV/hpsPFTauProducerRealElectronsData_hpsPFTauDiscriminationByMediumElectronRejection/MediumElectronRejectionEff%s',
25 'RecoTauV/hpsPFTauProducerRealElectronsData_hpsPFTauDiscriminationByTightElectronRejection/TightElectronRejectionEff%s']
28 variables = {
'a':
'pt',
'b':
'pileup',
'c':
'eta',
'd':
'phi'}
30 datasetNames = {
'RealData' :
'QCD Jets',
'RealMuonsData' :
'muons from Z',
'RealElectronsData' :
'electrons from Z'}
32 outputFileString =
'def shiftpftaulayout(i, p, *rows): i["00 Shift/Tau/" + p] = DQMItem(layout=rows)\n\n%s' 33 stdFill=Template(
'shiftpftaulayout(\n\tdqmitems,\n\t"$locpath",\n\t$rows\n\t)')
36 rows = [[{
'path': plot % (dataType,var),
'description':
'%s fake rate from %s' % (
stripDiscName(plot), datasetNames[dataType]),
'draw': {
'drawopts':
"e"}}
for plot
in row]
for row
in defaultPlots]
37 strow =
',\n\t'.
join([row.__repr__()
for row
in rows])
38 return stdFill.substitute(locpath=locpath,rows=strow)
41 rows = [{
'path': plot % var,
'description':
'%s fake rate' % (
stripDiscName(plot)),
'draw': {
'drawopts':
"e"}}
for plot
in muonrejplots]
42 return stdFill.substitute(locpath=locpath,rows=rows.__repr__())
45 rows = [[{
'path': plot % var,
'description':
'%s fake rate' % (
stripDiscName(plot)),
'draw': {
'drawopts':
"e"}}
for plot
in row]
for row
in elerejplots]
46 strow =
',\n\t'.
join([row.__repr__()
for row
in rows])
47 return stdFill.substitute(locpath=locpath,rows=strow)
52 toAdd = [
defaults(
'SingleMu/00%s - Fake rate from muons vs %s' % item,
'RealMuonsData',item[1])
for item
in variables.items() ]
53 toAdd.extend( [
muRej(
'SingleMu/01%s - Muon rejection fake rate vs %s' % item,item[1])
for item
in variables.items() ] )
54 toAdd.extend( [
defaults(
'SingleMu/02%s - Fake rate from jets vs %s' % item,
'RealData',item[1])
for item
in variables.items() ] )
59 toAdd.extend([
defaults(
'Jet/00%s - Fake rate from jets vs %s' % item,
'RealData',item[1])
for item
in variables.items() ] )
64 toAdd.extend([
defaults(
'DoubleElectron_OR_TauPlusX/00%s - Fake rate from electrons vs %s' % item,
'RealElectronsData',item[1])
for item
in variables.items() ] )
65 toAdd.extend( [
eleRej(
'DoubleElectron_OR_TauPlusX/01%s - Electron rejection fake rate vs %s' % item,item[1])
for item
in variables.items() ] )
67 layout = open(
'shift_pftau_T0_layout.py',
'w')
68 layout.write(outputFileString %
'\n'.
join(toAdd) )
74 layoutString =
'def pftaulayout(i, p, *rows): i["RecoTauV/Layouts/" + p] = DQMItem(layout=rows)\n\n%s' 75 stdFill=Template(
'pftaulayout(\n\tdqmitems,\n\t"$locpath",\n\t$rows\n\t)')
77 layoutDefaultPlots = [
79 [
'RecoTauV/hpsPFTauProducer%s_Matched/PFJetMatchingEff%s',
80 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByDecayModeFinding/DecayModeFindingEff%s'],
81 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseChargedIsolation/LooseChargedIsolationEff%s',
82 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr/LooseCombinedIsolationDBSumPtCorrEff%s'],
85 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseIsolation/LooseIsolationEff%s',
86 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByMediumCombinedIsolationDBSumPtCorr/MediumCombinedIsolationDBSumPtCorrEff%s'],
87 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByTightCombinedIsolationDBSumPtCorr/TightCombinedIsolationDBSumPtCorrEff%s',
88 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByVLooseCombinedIsolationDBSumPtCorr/VLooseCombinedIsolationDBSumPtCorrEff%s'],
93 [
'RecoTauV/shrinkingConePFTauProducerLeadingPion%s_shrinkingConePFTauDiscriminationByECALIsolationUsingLeadingPion/ECALIsolationUsingLeadingPionEff%s',
94 'RecoTauV/shrinkingConePFTauProducerLeadingPion%s_shrinkingConePFTauDiscriminationByLeadingPionPtCut/LeadingPionPtCutEff%s'],
95 [
'RecoTauV/shrinkingConePFTauProducerLeadingPion%s_shrinkingConePFTauDiscriminationByLeadingTrackFinding/LeadingTrackFindingEff%s',
96 'RecoTauV/shrinkingConePFTauProducerLeadingPion%s_shrinkingConePFTauDiscriminationByTrackIsolationUsingLeadingPion/TrackIsolationUsingLeadingPionEff%s']
100 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByDecayModeFinding/hpsPFTauDiscriminationByDecayModeFinding_Size_%s',
101 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseChargedIsolation/hpsPFTauDiscriminationByLooseChargedIsolation_Size_%s',
102 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr/hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr_Size_%s'],
103 [
'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByDecayModeFinding/hpsPFTauDiscriminationByDecayModeFinding_SumPt_%s',
104 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseChargedIsolation/hpsPFTauDiscriminationByLooseChargedIsolation_SumPt_%s',
105 'RecoTauV/hpsPFTauProducer%s_hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr/hpsPFTauDiscriminationByLooseCombinedIsolationDBSumPtCorr_SumPt_%s'],
111 framerows = [[[{
'path': plot % (dataType,var),
'description':
'%s fake rate from %s' % (
stripDiscName(plot), datasetNames[dataType]),
'draw': {
'drawopts':
"e"}}
for plot
in row]
for row
in frame]
for frame
in layoutDefaultPlots]
112 strows = [
',\n\t'.
join([row.__repr__()
for row
in rows])
for rows
in framerows]
113 ret = [stdFill.substitute(locpath=locpath % postfix, rows=strow)
for postfix,strow
in zip(string.letters,strows)]
114 return '\n'.
join(ret)
117 rows = [[{
'path': plot % (dataType,var),
'description':
'%s fake rate from %s' % (
stripDiscName(plot), datasetNames[dataType]),
'draw': {
'drawopts':
"e"}}
for plot
in row]
for row
in layoutscone]
118 strow =
',\n\t'.
join([row.__repr__()
for row
in rows])
119 return stdFill.substitute(locpath=locpath,rows=strow)
122 typ =
lambda x: x.split(
'_')[-2]
124 typ +=
' distribution' 125 rows = [[{
'path': plot % (dataType,var),
'description':
'%s faking taus %s of %s' % (datasetNames[dataType],typ(plot), var),
'draw': {
'drawopts':
"e"}}
for plot
in row]
for row
in layoutSizeSumpt]
126 strow =
',\n\t'.
join([row.__repr__()
for row
in rows])
127 return stdFill.substitute(locpath=locpath,rows=strow)
129 variables = {
'a%s':
'pt',
'b%s':
'pileup',
'c%s':
'eta',
'd%s':
'phi'}
130 sumVar = dict( list(
zip(string.letters,[elem
for elem
in [
'signalCands',
'isolationChargedHadrCands',
'isolationGammaCands',
'isolationNeutrHadrCands'] ])) )
136 toAdd = [
layDefaults(
'SingleMu/00%s - Fake rate from muons vs %s' % item,
'RealMuonsData',item[1])
for item
in variables.items() ]
137 toAdd.extend( [
muRej(
'SingleMu/01%s - Muon rejection fake rate vs %s' % (item[0]%
'',item[1]),item[1])
for item
in variables.items() ] )
138 toAdd.extend( [
layDefaults(
'SingleMu/02%s - Fake rate from jets vs %s' % item,
'RealData',item[1])
for item
in variables.items() ] )
139 toAdd.extend( [
sizeSumpt(
'SingleMu/03%s - Distributions of size and sumPt for %s, %s faking taus' % (item[0], item[1],datasetNames[
'RealMuonsData']),
'RealMuonsData',item[1])
for item
in sumVar.items() ] )
140 toAdd.extend( [
sizeSumpt(
'SingleMu/04%s - Distributions of size and sumPt for %s, %s faking taus' % (item[0], item[1],datasetNames[
'RealData']),
'RealData',item[1])
for item
in sumVar.items() ] )
145 toAdd.extend([
layDefaults(
'Jet/00%s - Fake rate from jets vs %s' % item,
'RealData',item[1])
for item
in variables.items() ] )
146 toAdd.extend( [
sizeSumpt(
'Jet/01%s - Distributions of size and sumPt for %s, %s faking taus' % (item[0], item[1],datasetNames[
'RealData']),
'RealData',item[1])
for item
in sumVar.items() ] )
151 toAdd.extend([
layDefaults(
'DoubleElectron_OR_TauPlusX/00%s - Fake rate from electrons vs %s' % item,
'RealElectronsData',item[1])
for item
in variables.items() ] )
152 toAdd.extend( [
eleRej(
'DoubleElectron_OR_TauPlusX/01%s - Electron rejection fake rate vs %s' % (item[0].
replace(
'%s',
''),item[1]),item[1])
for item
in variables.items() ] )
153 toAdd.extend( [
sizeSumpt(
'DoubleElectron_OR_TauPlusX/04%s - Distributions of size and sumPt for %s, %s faking taus' % (item[0], item[1],datasetNames[
'RealElectronsData']),
'RealElectronsData',item[1])
for item
in sumVar.items() ] )
155 layout = open(
'pftatau_T0_layouts.py',
'w')
156 layout.write(layoutString %
'\n'.
join(toAdd) )
def replace(string, replacements)
def sCone(locpath, dataType, var)
def defaults(locpath, dataType, var)
OutputIterator zip(InputIterator1 first1, InputIterator1 last1, InputIterator2 first2, InputIterator2 last2, OutputIterator result, Compare comp)
def layDefaults(locpath, dataType, var)
def split(sequence, size)
static std::string join(char **cmd)
def sizeSumpt(locpath, dataType, var)