1 import FWCore.ParameterSet.Config
as cms
3 from math
import ceil,log
11 egmPhotonIDSequence = cms.Sequence(cms.Task(egmPhotonIsolationMiniAODTask,photonIDValueMapProducer,photonMVAValueMapProducer,egmPhotonIDs,photonRegressionValueMapProducer))
12 egmPhotonIDs.physicsObjectIDs = cms.VPSet()
13 egmPhotonIDs.physicsObjectSrc = cms.InputTag(
'slimmedPhotons')
14 _photon_id_vid_modules=[
15 'RecoEgamma.PhotonIdentification.Identification.cutBasedPhotonID_Spring16_V2p2_cff',
16 'RecoEgamma.PhotonIdentification.Identification.mvaPhotonID_Spring16_nonTrig_V1_cff',
18 _bitmapVIDForPho_WorkingPoints = cms.vstring(
19 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose",
20 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium",
21 "egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight",
23 _bitmapVIDForPho_docstring =
'' 24 for modname
in _photon_id_vid_modules:
25 ids= __import__(modname, globals(), locals(), [
'idName',
'cutFlow'])
27 _id = getattr(ids,name)
28 if hasattr(_id,
'idName')
and hasattr(_id,
'cutFlow'):
30 if (len(_bitmapVIDForPho_WorkingPoints)>0
and _id.idName==_bitmapVIDForPho_WorkingPoints[0].
split(
':')[-1]):
31 _bitmapVIDForPho_docstring =
'VID compressed bitmap (%s), %d bits per cut'%(
','.
join([cut.cutName.value()
for cut
in _id.cutFlow]),
int(ceil(
log(len(_bitmapVIDForPho_WorkingPoints)+1,2))))
33 bitmapVIDForPho = cms.EDProducer(
"PhoVIDNestedWPBitmapProducer",
34 src = cms.InputTag(
"slimmedPhotons"),
35 WorkingPoints = _bitmapVIDForPho_WorkingPoints,
38 isoForPho = cms.EDProducer(
"PhoIsoValueMapProducer",
39 src = cms.InputTag(
"slimmedPhotons"),
40 relative = cms.bool(
False),
41 rho_PFIso = cms.InputTag(
"fixedGridRhoFastjetAll"),
42 mapIsoChg = cms.InputTag(
"photonIDValueMapProducer:phoChargedIsolation"),
43 mapIsoNeu = cms.InputTag(
"photonIDValueMapProducer:phoNeutralHadronIsolation"),
44 mapIsoPho = cms.InputTag(
"photonIDValueMapProducer:phoPhotonIsolation"),
45 EAFile_PFIso_Chg = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfChargedHadrons_90percentBased.txt"),
46 EAFile_PFIso_Neu = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfNeutralHadrons_90percentBased.txt"),
47 EAFile_PFIso_Pho = cms.FileInPath(
"RecoEgamma/PhotonIdentification/data/Spring16/effAreaPhotons_cone03_pfPhotons_90percentBased.txt"),
50 from EgammaAnalysis.ElectronTools.calibratedPhotonsRun2_cfi
import calibratedPatPhotons
51 calibratedPatPhotons.correctionFile = cms.string(
"PhysicsTools/NanoAOD/data/80X_ichepV2_2016_pho")
52 calibratedPatPhotons.semiDeterministic = cms.bool(
True)
54 energyCorrForPhoton = cms.EDProducer(
"PhotonEnergyVarProducer",
55 srcRaw = cms.InputTag(
"slimmedPhotons"),
56 srcCorr = cms.InputTag(
"calibratedPatPhotons"),
59 slimmedPhotonsWithUserData = cms.EDProducer(
"PATPhotonUserDataEmbedder",
60 src = cms.InputTag(
"slimmedPhotons"),
61 userFloats = cms.PSet(
62 mvaID = cms.InputTag(
"photonMVAValueMapProducer:PhotonMVAEstimatorRun2Spring16NonTrigV1Values"),
63 PFIsoChg = cms.InputTag(
"isoForPho:PFIsoChg"),
64 PFIsoAll = cms.InputTag(
"isoForPho:PFIsoAll"),
65 eCorr = cms.InputTag(
"energyCorrForPhoton:eCorr"),
67 userIntFromBools = cms.PSet(
68 cutbasedID_loose = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-loose"),
69 cutbasedID_medium = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-medium"),
70 cutbasedID_tight = cms.InputTag(
"egmPhotonIDs:cutBasedPhotonID-Spring16-V2p2-tight"),
71 mvaID_WP90 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp90"),
72 mvaID_WP80 = cms.InputTag(
"egmPhotonIDs:mvaPhoID-Spring16-nonTrig-V1-wp80"),
75 VIDNestedWPBitmap = cms.InputTag(
"bitmapVIDForPho"),
79 finalPhotons = cms.EDFilter(
"PATPhotonRefSelector",
80 src = cms.InputTag(
"slimmedPhotonsWithUserData"),
81 cut = cms.string(
"pt > 5 ")
84 photonTable = cms.EDProducer(
"SimpleCandidateFlatTableProducer",
85 src = cms.InputTag(
"linkedObjects",
"photons"),
87 name= cms.string(
"Photon"),
88 doc = cms.string(
"slimmedPhotons after basic selection (" + finalPhotons.cut.value()+
")"),
89 singleton = cms.bool(
False),
90 extension = cms.bool(
False),
91 variables = cms.PSet(CandVars,
92 jetIdx =
Var(
"?hasUserCand('jet')?userCand('jet').key():-1", int, doc=
"index of the associated jet (-1 if none)"),
93 electronIdx =
Var(
"?hasUserCand('electron')?userCand('electron').key():-1", int, doc=
"index of the associated electron (-1 if none)"),
94 energyErr =
Var(
"getCorrectedEnergyError('regression2')*userFloat('eCorr')",float,doc=
"energy error of the cluster from regression",precision=6),
95 eCorr =
Var(
"userFloat('eCorr')",float,doc=
"ratio of the calibrated energy/miniaod energy"),
96 r9 =
Var(
"full5x5_r9()",float,doc=
"R9 of the supercluster, calculated with full 5x5 region",precision=10),
97 sieie =
Var(
"full5x5_sigmaIetaIeta()",float,doc=
"sigma_IetaIeta of the supercluster, calculated with full 5x5 region",precision=10),
98 cutBased =
Var(
"userInt('cutbasedID_loose')+userInt('cutbasedID_medium')+userInt('cutbasedID_tight')",int,doc=
"cut-based ID (0:fail, 1::loose, 2:medium, 3:tight)"),
99 vidNestedWPBitmap =
Var(
"userInt('VIDNestedWPBitmap')",int,doc=_bitmapVIDForPho_docstring),
100 electronVeto =
Var(
"passElectronVeto()",bool,doc=
"pass electron veto"),
101 pixelSeed =
Var(
"hasPixelSeed()",bool,doc=
"has pixel seed"),
102 mvaID =
Var(
"userFloat('mvaID')",float,doc=
"MVA ID score",precision=10),
103 mvaID_WP90 =
Var(
"userInt('mvaID_WP90')",bool,doc=
"MVA ID WP90"),
104 mvaID_WP80 =
Var(
"userInt('mvaID_WP90')",bool,doc=
"MVA ID WP80"),
105 pfRelIso03_chg =
Var(
"userFloat('PFIsoChg')/pt",float,doc=
"PF relative isolation dR=0.3, charged component (with rho*EA PU corrections)"),
106 pfRelIso03_all =
Var(
"userFloat('PFIsoAll')/pt",float,doc=
"PF relative isolation dR=0.3, total (with rho*EA PU corrections)"),
107 hoe =
Var(
"hadronicOverEm()",float,doc=
"H over E",precision=8),
108 isScEtaEB =
Var(
"abs(superCluster().eta()) < 1.4442",bool,doc=
"is supercluster eta within barrel acceptance"),
109 isScEtaEE =
Var(
"abs(superCluster().eta()) > 1.566 && abs(superCluster().eta()) < 2.5",bool,doc=
"is supercluster eta within endcap acceptance"),
112 photonTable.variables.pt =
Var(
"pt*userFloat('eCorr')", float, precision=-1)
114 photonsMCMatchForTable = cms.EDProducer(
"MCMatcher",
115 src = photonTable.src,
116 matched = cms.InputTag(
"finalGenParticles"),
117 mcPdgId = cms.vint32(11,22),
118 checkCharge = cms.bool(
False),
119 mcStatus = cms.vint32(1),
120 maxDeltaR = cms.double(0.3),
121 maxDPtRel = cms.double(0.5),
122 resolveAmbiguities = cms.bool(
True),
123 resolveByMatchQuality = cms.bool(
True),
126 photonMCTable = cms.EDProducer(
"CandMCMatchTableProducer",
127 src = photonTable.src,
128 mcMap = cms.InputTag(
"photonsMCMatchForTable"),
129 objName = photonTable.name,
130 objType = photonTable.name,
131 branchName = cms.string(
"genPart"),
132 docString = cms.string(
"MC matching to status==1 photons or electrons"),
135 photonSequence = cms.Sequence(egmPhotonIDSequence + bitmapVIDForPho + isoForPho + calibratedPatPhotons + energyCorrForPhoton + slimmedPhotonsWithUserData + finalPhotons)
136 photonTables = cms.Sequence ( photonTable)
137 photonMC = cms.Sequence(photonsMCMatchForTable + photonMCTable)
def Var(expr, valtype, compression=None, doc=None, mcOnly=False, precision=-1)
static std::string join(char **cmd)