CMS 3D CMS Logo

custom_btv_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
3 from PhysicsTools.NanoAOD.jetsAK4_Puppi_cff import jetPuppiTable, jetPuppiCorrFactorsNano, updatedJetsPuppi, updatedJetsPuppiWithUserData
4 from PhysicsTools.NanoAOD.jetsAK8_cff import fatJetTable, subJetTable
5 from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection
6 from PhysicsTools.PatAlgos.tools.helpers import addToProcessAndTask, getPatAlgosToolsTask
7 from PhysicsTools.NanoAOD.common_cff import Var, CandVars
8 from PhysicsTools.NanoAOD.simpleCandidateFlatTableProducer_cfi import simpleCandidateFlatTableProducer
9 from PhysicsTools.NanoAOD.btvMC_cff import allPFPFCandsMCSequence,ak4ak8PFCandsMCSequence,ak8onlyPFCandsMCSequence,ak4onlyPFCandsMCSequence
10 
11 
12 
13 def update_jets_AK4(process):
14  # Based on ``nanoAOD_addDeepInfo``
15  # in https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/NanoAOD/python/nano_cff.py
16  # DeepJet flav_names as found in
17  # https://github.com/cms-sw/cmssw/blob/master/RecoBTag/ONNXRuntime/plugins/DeepFlavourONNXJetTagsProducer.cc#L86
18  # and https://twiki.cern.ch/twiki/bin/view/CMS/DeepJet
19  from RecoBTag.ONNXRuntime.pfParticleTransformerAK4_cff import _pfParticleTransformerAK4JetTagsAll as pfParticleTransformerAK4JetTagsAll
20  from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll as pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll
21  from RecoBTag.ONNXRuntime.pfParticleTransformerAK4_cff import _pfNegativeParticleTransformerAK4JetTagsProbs as pfNegativeParticleTransformerAK4JetTagsProbs
22  from RecoBTag.ONNXRuntime.pfParticleNetFromMiniAODAK4_cff import _pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTagsProbs as pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTagsProbs
23 
24  _btagDiscriminators = [
25  'pfJetProbabilityBJetTags',
26  'pfJetBProbabilityBJetTags',
27  'pfNegativeOnlyJetProbabilityBJetTags',
28  'pfNegativeOnlyJetBProbabilityBJetTags',
29  'pfDeepFlavourJetTags:probb',
30  'pfDeepFlavourJetTags:probbb',
31  'pfDeepFlavourJetTags:problepb',
32  'pfDeepFlavourJetTags:probc',
33  'pfDeepFlavourJetTags:probuds',
34  'pfDeepFlavourJetTags:probg',
35  'pfNegativeDeepFlavourJetTags:probb',
36  'pfNegativeDeepFlavourJetTags:probbb',
37  'pfNegativeDeepFlavourJetTags:problepb',
38  'pfNegativeDeepFlavourJetTags:probc',
39  'pfNegativeDeepFlavourJetTags:probuds',
40  'pfNegativeDeepFlavourJetTags:probg',
41  ] + pfParticleNetFromMiniAODAK4PuppiCentralJetTagsAll + pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTagsProbs
42  # \ #+ pfParticleTransformerAK4JetTagsAll + pfNegativeParticleTransformerAK4JetTagsProbs \
43 
44  updateJetCollection(
45  process,
46  jetSource=cms.InputTag('slimmedJetsPuppi'),
47  jetCorrections=('AK4PFPuppi',
48  cms.vstring(
49  ['L1FastJet', 'L2Relative', 'L3Absolute',
50  'L2L3Residual']), 'None'),
51  btagDiscriminators=_btagDiscriminators,
52  postfix='PuppiWithDeepInfo',
53  )
54  process.load("Configuration.StandardSequences.MagneticField_cff")
55  process.jetPuppiCorrFactorsNano.src = "selectedUpdatedPatJetsPuppiWithDeepInfo"
56  process.updatedJetsPuppi.jetSource = "selectedUpdatedPatJetsPuppiWithDeepInfo"
57 
58 
59  process.updatedPatJetsTransientCorrectedPuppiWithDeepInfo.tagInfoSources.append(cms.InputTag("pfDeepFlavourTagInfosPuppiWithDeepInfo"))
60  process.updatedPatJetsTransientCorrectedPuppiWithDeepInfo.addTagInfos = cms.bool(True)
61 
62 
63 
64  return process
65 
66 def update_jets_AK8(process):
67  # Based on ``nanoAOD_addDeepInfoAK8``
68  # in https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/NanoAOD/python/nano_cff.py
69  # Care needs to be taken to make sure no discriminators from stock Nano are excluded -> would results in unfilled vars
70  _btagDiscriminators = [
71  'pfMassIndependentDeepDoubleBvLV2JetTags:probHbb',
72  'pfMassIndependentDeepDoubleCvLV2JetTags:probHcc',
73  'pfMassIndependentDeepDoubleCvBV2JetTags:probHcc',
74  ]
75  from RecoBTag.ONNXRuntime.pfParticleNet_cff import _pfParticleNetJetTagsAll as pfParticleNetJetTagsAll
76  _btagDiscriminators += pfParticleNetJetTagsAll
77  updateJetCollection(
78  process,
79  jetSource=cms.InputTag('slimmedJetsAK8'),
80  pvSource=cms.InputTag('offlineSlimmedPrimaryVertices'),
81  svSource=cms.InputTag('slimmedSecondaryVertices'),
82  rParam=0.8,
83  jetCorrections=('AK8PFPuppi',
84  cms.vstring([
85  'L1FastJet', 'L2Relative', 'L3Absolute',
86  'L2L3Residual'
87  ]), 'None'),
88  btagDiscriminators=_btagDiscriminators,
89  postfix='AK8WithDeepInfo',
90  # this should work but doesn't seem to enable the tag info with addTagInfos
91  # btagInfos=['pfDeepDoubleXTagInfos'],
92  printWarning=False)
93  process.jetCorrFactorsAK8.src = "selectedUpdatedPatJetsAK8WithDeepInfo"
94  process.updatedJetsAK8.jetSource = "selectedUpdatedPatJetsAK8WithDeepInfo"
95  # add DeepDoubleX taginfos
96  process.updatedPatJetsTransientCorrectedAK8WithDeepInfo.tagInfoSources.append(cms.InputTag("pfDeepDoubleXTagInfosAK8WithDeepInfo"))
97  process.updatedPatJetsTransientCorrectedAK8WithDeepInfo.addTagInfos = cms.bool(True)
98  return process
99 
101  # Based on ``nanoAOD_addDeepInfoAK8``
102  # in https://github.com/cms-sw/cmssw/blob/master/PhysicsTools/NanoAOD/python/nano_cff.py
103  # and https://github.com/alefisico/RecoBTag-PerformanceMeasurements/blob/10_2_X_boostedCommissioning/test/runBTagAnalyzer_cfg.py
104  _btagDiscriminators = [
105  'pfJetProbabilityBJetTags',
106  'pfDeepCSVJetTags:probb',
107  'pfDeepCSVJetTags:probc',
108  'pfDeepCSVJetTags:probbb',
109  'pfDeepCSVJetTags:probudsg',
110  ]
111  updateJetCollection(
112  process,
113  labelName='SoftDropSubjetsPF',
114  jetSource=cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked", "SubJets"),
115  jetCorrections=('AK4PFPuppi',
116  ['L2Relative', 'L3Absolute'], 'None'),
117  btagDiscriminators=list(_btagDiscriminators),
118  explicitJTA=True, # needed for subjet b tagging
119  svClustering=False, # needed for subjet b tagging (IMPORTANT: Needs to be set to False to disable ghost-association which does not work with slimmed jets)
120  fatJets=cms.InputTag('slimmedJetsAK8'), # needed for subjet b tagging
121  rParam=0.8, # needed for subjet b tagging
122  sortByPt=False, # Don't change order (would mess with subJetIdx for FatJets)
123  postfix='AK8SubjetsWithDeepInfo')
124 
125  process.subJetTable.src = 'selectedUpdatedPatJetsSoftDropSubjetsPFAK8SubjetsWithDeepInfo'
126 
127 
128  return process
129 
131  # retreive 27 jet-level features used in double-b and deep double-x taggers
132  # defined in arXiv:1712.07158
133  DDXVars = cms.PSet(
134  DDX_jetNTracks = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.jetNTracks", int, doc="number of tracks associated with the jet"),
135  DDX_jetNSecondaryVertices = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.jetNSecondaryVertices", int, doc="number of SVs associated with the jet"),
136  DDX_tau1_trackEtaRel_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_trackEtaRel_0", float, doc="1st smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis", precision=10),
137  DDX_tau1_trackEtaRel_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_trackEtaRel_1", float, doc="2nd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis", precision=10),
138  DDX_tau1_trackEtaRel_2 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_trackEtaRel_2", float, doc="3rd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis", precision=10),
139  DDX_tau2_trackEtaRel_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_trackEtaRel_0", float, doc="1st smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis", precision=10),
140  DDX_tau2_trackEtaRel_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_trackEtaRel_1", float, doc="2nd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis", precision=10),
141  DDX_tau2_trackEtaRel_3 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_trackEtaRel_2", float, doc="3rd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis", precision=10),
142  DDX_tau1_flightDistance2dSig = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_flightDistance2dSig", float, doc="transverse distance significance between primary and secondary vertex associated to the 1st N-subjettiness axis", precision=10),
143  DDX_tau2_flightDistance2dSig = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_flightDistance2dSig", float, doc="transverse distance significance between primary and secondary vertex associated to the 2nd N-subjettiness axis", precision=10),
144  DDX_tau1_vertexDeltaR = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_vertexDeltaR", float, doc="deltaR between the 1st N-subjettiness axis and secondary vertex direction", precision=10),
145  DDX_tau1_vertexEnergyRatio = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_vertexEnergyRatio", float, doc="ratio of energy at secondary vertex over total energy associated to the 1st N-subjettiness axis", precision=10),
146  DDX_tau2_vertexEnergyRatio = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_vertexEnergyRatio", float, doc="ratio of energy at secondary vertex over total energy associated to the 2nd N-subjettiness axis", precision=10),
147  DDX_tau1_vertexMass = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_vertexMass", float, doc="mass of track sum at secondary vertex associated to the 1st N-subjettiness axis", precision=10),
148  DDX_tau2_vertexMass = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_vertexMass", float, doc="mass of track sum at secondary vertex associated to the 2nd N-subjettiness axis", precision=10),
149  DDX_trackSip2dSigAboveBottom_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip2dSigAboveBottom_0", float, doc="track 2D signed impact parameter significance of 1st track lifting mass above bottom", precision=10),
150  DDX_trackSip2dSigAboveBottom_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip2dSigAboveBottom_1", float, doc="track 2D signed impact parameter significance of 2nd track lifting mass above bottom", precision=10),
151  DDX_trackSip2dSigAboveCharm = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip2dSigAboveCharm", float, doc="track 2D signed impact parameter significance of 1st track lifting mass above charm", precision=10),
152  DDX_trackSip3dSig_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip3dSig_0", float, doc="1st largest track 3D signed impact parameter significance", precision=10),
153  DDX_tau1_trackSip3dSig_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_trackSip3dSig_0", float, doc="1st largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis", precision=10),
154  DDX_tau1_trackSip3dSig_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau1_trackSip3dSig_1", float, doc="2nd largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis", precision=10),
155  DDX_trackSip3dSig_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip3dSig_1", float, doc="2nd largest track 3D signed impact parameter significance", precision=10),
156  DDX_tau2_trackSip3dSig_0 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_trackSip3dSig_0", float, doc="1st largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis", precision=10),
157  DDX_tau2_trackSip3dSig_1 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.tau2_trackSip3dSig_1", float, doc="2nd largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis", precision=10),
158  DDX_trackSip3dSig_2 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip3dSig_2", float, doc="3rd largest track 3D signed impact parameter significance", precision=10),
159  DDX_trackSip3dSig_3 = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.trackSip3dSig_3", float, doc="4th largest track 3D signed impact parameter significance", precision=10),
160  DDX_z_ratio = Var("tagInfo(\'pfDeepDoubleX\').features().tag_info_features.z_ratio", float, doc="z = deltaR(SV0,SV1)*pT(SV1)/m(SV0,SV1), defined in Eq. 7 of arXiv:1712.07158", precision=10)
161  )
162  return DDXVars
163 
165  DeepCSVVars = cms.PSet(
166  # Tagger inputs also include jet pt and eta
167  # Track based (keep only jet-based features for DeepCSV from Run 3 commissioning)
168  # DeepCSV_trackPtRel_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[0]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
169  # DeepCSV_trackPtRel_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[1]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
170  # DeepCSV_trackPtRel_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[2]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
171  # DeepCSV_trackPtRel_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[3]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
172  # DeepCSV_trackPtRel_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[4]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
173  # DeepCSV_trackPtRel_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRel\')[5]:-999", float, doc="track transverse momentum, relative to the jet axis", precision=10),
174  # DeepCSV_trackJetDistVal_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[0]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
175  # DeepCSV_trackJetDistVal_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[1]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
176  # DeepCSV_trackJetDistVal_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[2]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
177  # DeepCSV_trackJetDistVal_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[3]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
178  # DeepCSV_trackJetDistVal_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[4]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
179  # DeepCSV_trackJetDistVal_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackJetDistVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackJetDistVal\')[5]:-999", float, doc="minimum track approach distance to jet axis", precision=10),
180  # DeepCSV_trackDeltaR_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[0]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
181  # DeepCSV_trackDeltaR_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[1]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
182  # DeepCSV_trackDeltaR_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[2]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
183  # DeepCSV_trackDeltaR_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[3]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
184  # DeepCSV_trackDeltaR_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[4]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
185  # DeepCSV_trackDeltaR_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDeltaR\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDeltaR\')[5]:-999", float, doc="track pseudoangular distance from the jet axis", precision=10),
186  # DeepCSV_trackPtRatio_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[0]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
187  # DeepCSV_trackPtRatio_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[1]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
188  # DeepCSV_trackPtRatio_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[2]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
189  # DeepCSV_trackPtRatio_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[3]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
190  # DeepCSV_trackPtRatio_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[4]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
191  # DeepCSV_trackPtRatio_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackPtRatio\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackPtRatio\')[5]:-999", float, doc="track transverse momentum, relative to the jet axis, normalized to its energy", precision=10),
192  # DeepCSV_trackSip3dSig_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[0]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
193  # DeepCSV_trackSip3dSig_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[1]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
194  # DeepCSV_trackSip3dSig_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[2]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
195  # DeepCSV_trackSip3dSig_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[3]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
196  # DeepCSV_trackSip3dSig_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[4]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
197  # DeepCSV_trackSip3dSig_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip3dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip3dSig\')[5]:-999", float, doc="track 3D signed impact parameter significance", precision=10),
198  # DeepCSV_trackSip2dSig_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[0]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
199  # DeepCSV_trackSip2dSig_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[1]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
200  # DeepCSV_trackSip2dSig_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[2]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
201  # DeepCSV_trackSip2dSig_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[3]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
202  # DeepCSV_trackSip2dSig_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[4]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
203  # DeepCSV_trackSip2dSig_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackSip2dSig\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackSip2dSig\')[5]:-999", float, doc="track 2D signed impact parameter significance", precision=10),
204  # DeepCSV_trackDecayLenVal_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[0]:-999", float, doc="track decay length", precision=10),
205  # DeepCSV_trackDecayLenVal_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[1]:-999", float, doc="track decay length", precision=10),
206  # DeepCSV_trackDecayLenVal_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[2]:-999", float, doc="track decay length", precision=10),
207  # DeepCSV_trackDecayLenVal_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[3]:-999", float, doc="track decay length", precision=10),
208  # DeepCSV_trackDecayLenVal_4 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[4]:-999", float, doc="track decay length", precision=10),
209  # DeepCSV_trackDecayLenVal_5 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackDecayLenVal\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackDecayLenVal\')[5]:-999", float, doc="track decay length", precision=10),
210  # DeepCSV_trackEtaRel_0 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackEtaRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackEtaRel\')[0]:-999", float, doc="track pseudorapidity, relative to the jet axis", precision=10),
211  # DeepCSV_trackEtaRel_1 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackEtaRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackEtaRel\')[1]:-999", float, doc="track pseudorapidity, relative to the jet axis", precision=10),
212  # DeepCSV_trackEtaRel_2 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackEtaRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackEtaRel\')[2]:-999", float, doc="track pseudorapidity, relative to the jet axis", precision=10),
213  # DeepCSV_trackEtaRel_3 = Var("?tagInfo(\'pfDeepCSV\').taggingVariables.checkTag(\'trackEtaRel\')?tagInfo(\'pfDeepCSV\').taggingVariables.getList(\'trackEtaRel\')[3]:-999", float, doc="track pseudorapidity, relative to the jet axis", precision=10),
214  # Jet based
215  DeepCSV_trackJetPt = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackJetPt\', -999)", float, doc="track-based jet transverse momentum", precision=10),
216  DeepCSV_vertexCategory = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'vertexCategory\', -999)", float, doc="category of secondary vertex (Reco, Pseudo, No)", precision=10),
217  DeepCSV_jetNSecondaryVertices = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'jetNSecondaryVertices\', -999)", int, doc="number of reconstructed possible secondary vertices in jet"),
218  DeepCSV_jetNSelectedTracks = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'jetNSelectedTracks\', -999)", int, doc="selected tracks in the jet"),
219  DeepCSV_jetNTracksEtaRel = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'jetNTracksEtaRel\', -999)", int, doc="number of tracks for which etaRel is computed"),
220  DeepCSV_trackSumJetEtRatio = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSumJetEtRatio\', -999)", float, doc="ratio of track sum transverse energy over jet energy", precision=10),
221  DeepCSV_trackSumJetDeltaR = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSumJetDeltaR\', -999)", float, doc="pseudoangular distance between jet axis and track fourvector sum", precision=10),
222  DeepCSV_trackSip2dValAboveCharm = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSip2dValAboveCharm\', -999)", float, doc="track 2D signed impact parameter of first track lifting mass above charm", precision=10),
223  DeepCSV_trackSip2dSigAboveCharm = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSip2dSigAboveCharm\', -999)", float, doc="track 2D signed impact parameter significance of first track lifting mass above charm", precision=10),
224  DeepCSV_trackSip3dValAboveCharm = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSip3dValAboveCharm\', -999)", float, doc="track 3D signed impact parameter of first track lifting mass above charm", precision=10),
225  DeepCSV_trackSip3dSigAboveCharm = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'trackSip3dSigAboveCharm\', -999)", float, doc="track 3D signed impact parameter significance of first track lifting mass above charm", precision=10),
226  DeepCSV_vertexMass = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'vertexMass\', -999)", float, doc="mass of track sum at secondary vertex", precision=10),
227  DeepCSV_vertexNTracks = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'vertexNTracks\', -999)", int, doc="number of tracks at secondary vertex"),
228  DeepCSV_vertexEnergyRatio = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'vertexEnergyRatio\', -999)", float, doc="ratio of energy at secondary vertex over total energy", precision=10),
229  DeepCSV_vertexJetDeltaR = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'vertexJetDeltaR\', -999)", float, doc="pseudoangular distance between jet axis and secondary vertex direction", precision=10),
230  DeepCSV_flightDistance2dVal = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'flightDistance2dVal\', -999)", float, doc="transverse distance between primary and secondary vertex", precision=10),
231  DeepCSV_flightDistance2dSig = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'flightDistance2dSig\', -999)", float, doc="transverse distance significance between primary and secondary vertex", precision=10),
232  DeepCSV_flightDistance3dVal = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'flightDistance3dVal\', -999)", float, doc="distance between primary and secondary vertex", precision=10),
233  DeepCSV_flightDistance3dSig = Var("tagInfo(\'pfDeepCSV\').taggingVariables.get(\'flightDistance3dSig\', -999)", float, doc="distance significance between primary and secondary vertex", precision=10),
234  )
235  return DeepCSVVars
236 
237 
239  DeepJetOutputVars = cms.PSet(
240  btagDeepFlavB_b=Var("bDiscriminator('pfDeepFlavourJetTags:probb')",
241  float,
242  doc="DeepJet b tag probability",
243  precision=10),
244  btagDeepFlavB_bb=Var("bDiscriminator('pfDeepFlavourJetTags:probbb')",
245  float,
246  doc="DeepJet bb tag probability",
247  precision=10),
248  btagDeepFlavB_lepb=Var("bDiscriminator('pfDeepFlavourJetTags:problepb')",
249  float,
250  doc="DeepJet lepb tag probability",
251  precision=10),
252  btagDeepFlavC=Var("bDiscriminator('pfDeepFlavourJetTags:probc')",
253  float,
254  doc="DeepJet c tag probability",
255  precision=10),
256  btagDeepFlavUDS=Var("bDiscriminator('pfDeepFlavourJetTags:probuds')",
257  float,
258  doc="DeepJet uds tag probability",
259  precision=10),
260  btagDeepFlavG=Var("bDiscriminator('pfDeepFlavourJetTags:probg')",
261  float,
262  doc="DeepJet gluon tag probability",
263  precision=10),
264  # discriminators are already part of jets_cff.py from NanoAOD and therefore not added here
265 
266  # negative taggers
267  btagNegDeepFlavB = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probb')+bDiscriminator('pfNegativeDeepFlavourJetTags:probbb')+bDiscriminator('pfNegativeDeepFlavourJetTags:problepb')",
268  float,
269  doc="Negative DeepJet b+bb+lepb tag discriminator",
270  precision=10),
271  btagNegDeepFlavCvL = Var("?(bDiscriminator('pfNegativeDeepFlavourJetTags:probc')+bDiscriminator('pfNegativeDeepFlavourJetTags:probuds')+bDiscriminator('pfNegativeDeepFlavourJetTags:probg'))>0?bDiscriminator('pfNegativeDeepFlavourJetTags:probc')/(bDiscriminator('pfNegativeDeepFlavourJetTags:probc')+bDiscriminator('pfNegativeDeepFlavourJetTags:probuds')+bDiscriminator('pfNegativeDeepFlavourJetTags:probg')):-1",
272  float,
273  doc="Negative DeepJet c vs uds+g discriminator",
274  precision=10),
275  btagNegDeepFlavCvB = Var("?(bDiscriminator('pfNegativeDeepFlavourJetTags:probc')+bDiscriminator('pfNegativeDeepFlavourJetTags:probb')+bDiscriminator('pfNegativeDeepFlavourJetTags:probbb')+bDiscriminator('pfNegativeDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfNegativeDeepFlavourJetTags:probc')/(bDiscriminator('pfNegativeDeepFlavourJetTags:probc')+bDiscriminator('pfNegativeDeepFlavourJetTags:probb')+bDiscriminator('pfNegativeDeepFlavourJetTags:probbb')+bDiscriminator('pfNegativeDeepFlavourJetTags:problepb')):-1",
276  float,
277  doc="Negative DeepJet c vs b+bb+lepb discriminator",
278  precision=10),
279  btagNegDeepFlavQG = Var("?(bDiscriminator('pfNegativeDeepFlavourJetTags:probg')+bDiscriminator('pfNegativeDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfNegativeDeepFlavourJetTags:probg')/(bDiscriminator('pfNegativeDeepFlavourJetTags:probg')+bDiscriminator('pfNegativeDeepFlavourJetTags:probuds')):-1",
280  float,
281  doc="Negative DeepJet g vs uds discriminator",
282  precision=10),
283  btagNegDeepFlavB_b = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probb')",
284  float,
285  doc="Negative DeepJet b tag probability",
286  precision=10),
287  btagNegDeepFlavB_bb = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probbb')",
288  float,
289  doc="Negative DeepJet bb tag probability",
290  precision=10),
291  btagNegDeepFlavB_lepb = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:problepb')",
292  float,
293  doc="Negative DeepJet lepb tag probability",
294  precision=10),
295  btagNegDeepFlavC = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probc')",
296  float,
297  doc="Negative DeepJet c tag probability",
298  precision=10),
299  btagNegDeepFlavUDS = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probuds')",
300  float,
301  doc="Negative DeepJet uds tag probability",
302  precision=10),
303  btagNegDeepFlavG = Var("bDiscriminator('pfNegativeDeepFlavourJetTags:probg')",
304  float,
305  doc="Negative DeepJet gluon tag probability",
306  precision=10),
307  )
308  return DeepJetOutputVars
309 
311 
312  ParticleNetAK4OutputVars = cms.PSet(
313  # raw scores
314  btagPNetProbB = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probb'):-1",
315  float,
316  doc="ParticleNet b tag probability",
317  precision=10),
318  btagPNetProbC = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probc'):-1",
319  float,
320  doc="ParticleNet c tag probability",
321  precision=10),
322  btagPNetProbUDS = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds'):-1",
323  float,
324  doc="ParticleNet uds tag probability",
325  precision=10),
326  btagPNetProbG = Var("?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probg')>0?bDiscriminator('pfParticleNetFromMiniAODAK4PuppiCentralJetTags:probg'):-1",
327  float,
328  doc="ParticleNet gluon tag probability",
329  precision=10),
330 
331  # negative taggers
332  btagNegPNetB = Var("?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg'))>0?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb'))/(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg')):-1",
333  float,
334  doc="Negative ParticleNet b vs. udscg",
335  precision=10),
336  btagNegPNetCvL = Var("?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg'))>0?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc'))/(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg')):-1",
337  float,
338  doc="Negative ParticleNet c vs. udsg",
339  precision=10),
340  btagNegPNetCvB = Var("?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb'))>0?(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc'))/(bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')+bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')):-1",
341  float,
342  doc="Negative ParticleNet c vs. b",
343  precision=10),
344  btagNegPNetProbB = Var("?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb')>0?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probb'):-1",
345  float,
346  doc="Negative ParticleNet b tag probability",
347  precision=10),
348  btagNegPNetProbC = Var("?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc')>0?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probc'):-1",
349  float,
350  doc="Negative ParticleNet c tag probability",
351  precision=10),
352  btagNegPNetProbUDS = Var("?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds')>0?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probuds'):-1",
353  float,
354  doc="Negative ParticleNet uds tag probability",
355  precision=10),
356  btagNegPNetProbG = Var("?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg')>0?bDiscriminator('pfNegativeParticleNetFromMiniAODAK4PuppiCentralJetTags:probg'):-1",
357  float,
358  doc="Negative ParticleNet gluon tag probability",
359  precision=10),
360  )
361 
362  return ParticleNetAK4OutputVars
363 
365  ParticleTransformerAK4OutputVars = cms.PSet(
366  btagRobustParTAK4B_b=Var("bDiscriminator('pfParticleTransformerAK4JetTags:probb')",
367  float,
368  doc="RobustParTAK4 b tag probability",
369  precision=10),
370  btagRobustParTAK4B_bb=Var("bDiscriminator('pfParticleTransformerAK4JetTags:probbb')",
371  float,
372  doc="RobustParTAK4 bb tag probability",
373  precision=10),
374  btagRobustParTAK4B_lepb=Var("bDiscriminator('pfParticleTransformerAK4JetTags:problepb')",
375  float,
376  doc="RobustParTAK4 lepb tag probability",
377  precision=10),
378  btagRobustParTAK4C=Var("bDiscriminator('pfParticleTransformerAK4JetTags:probc')",
379  float,
380  doc="RobustParTAK4 c tag probability",
381  precision=10),
382  btagRobustParTAK4UDS=Var("bDiscriminator('pfParticleTransformerAK4JetTags:probuds')",
383  float,
384  doc="RobustParTAK4 uds tag probability",
385  precision=10),
386  btagRobustParTAK4G=Var("bDiscriminator('pfParticleTransformerAK4JetTags:probg')",
387  float,
388  doc="RobustParTAK4 gluon tag probability",
389  precision=10),
390 
391  # negative taggers
392  btagNegRobustParTAK4B = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:problepb')",
393  float,
394  doc="Negative RobustParTAK4 b+bb+lepb tag discriminator",
395  precision=10),
396  btagNegRobustParTAK4CvL = Var("?(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg'))>0?bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probuds')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg')):-1",
397  float,
398  doc="Negative RobustParTAK4 c vs uds+g discriminator",
399  precision=10),
400  btagNegRobustParTAK4CvB = Var("?(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:problepb'))>0?bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')/(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probbb')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:problepb')):-1",
401  float,
402  doc="Negative RobustParTAK4 c vs b+bb+lepb discriminator",
403  precision=10),
404  btagNegRobustParTAK4QG = Var("?(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probuds'))>0?bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg')/(bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg')+bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probuds')):-1",
405  float,
406  doc="Negative RobustParTAK4 g vs uds discriminator",
407  precision=10),
408  btagNegRobustParTAK4B_b = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probb')",
409  float,
410  doc="Negative RobustParTAK4 b tag probability",
411  precision=10),
412  btagNegRobustParTAK4B_bb = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probbb')",
413  float,
414  doc="Negative RobustParTAK4 bb tag probability",
415  precision=10),
416  btagNegRobustParTAK4B_lepb = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:problepb')",
417  float,
418  doc="Negative RobustParTAK4 lepb tag probability",
419  precision=10),
420  btagNegRobustParTAK4C = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probc')",
421  float,
422  doc="Negative RobustParTAK4 c tag probability",
423  precision=10),
424  btagNegRobustParTAK4UDS = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probuds')",
425  float,
426  doc="Negative RobustParTAK4 uds tag probability",
427  precision=10),
428  btagNegRobustParTAK4G = Var("bDiscriminator('pfNegativeParticleTransformerAK4JetTags:probg')",
429  float,
430  doc="Negative RobustParTAK4 gluon tag probability",
431  precision=10),
432  )
433 
434  return ParticleTransformerAK4OutputVars
435 
436 def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF"):
437  process.customizeJetTask = cms.Task()
438  process.schedule.associate(process.customizeJetTask)
439 
440  CommonVars = cms.PSet(
441  Proba=Var("bDiscriminator('pfJetProbabilityBJetTags')",
442  float,
443  doc="Jet Probability (Usage:BTV)",
444  precision=10),
445  ProbaN=Var("bDiscriminator('pfNegativeOnlyJetProbabilityBJetTags')",
446  float,
447  doc="Negative-only Jet Probability (Usage:BTV)",
448  precision=10),
449  Bprob=Var("bDiscriminator('pfJetBProbabilityBJetTags')",
450  float,
451  doc="Jet B Probability (Usage:BTV)",
452  precision=10),
453  BprobN=Var("bDiscriminator('pfNegativeOnlyJetBProbabilityBJetTags')",
454  float,
455  doc="Negative-only Jet B Probability (Usage:BTV)",
456  precision=10),
457  )
458 
459  # decouple these from CommonVars, not relevant for data
460  HadronCountingVars = cms.PSet(
461  nBHadrons=Var("jetFlavourInfo().getbHadrons().size()",
462  int,
463  doc="number of b-hadrons"),
464  nCHadrons=Var("jetFlavourInfo().getcHadrons().size()",
465  int,
466  doc="number of c-hadrons")
467  )
468 
469  # AK4
470  if addAK4:
471  if scheme == "btvSF":
472  _n_cpf = 3
473  _n_npf = 3
474  _n_sv = 4
475  elif scheme == "DeepJet":
476  _n_cpf = 25
477  _n_npf = 25
478  _n_sv = 4
479  elif scheme == "RobustParTAK4":
480  _n_cpf = 25
481  _n_npf = 25
482  _n_sv = 12
483  process = update_jets_AK4(process)
484 
485  process.customJetExtTable = cms.EDProducer(
486  "SimplePATJetFlatTableProducer",
487  src=jetPuppiTable.src,
488  cut=jetPuppiTable.cut,
489  name=jetPuppiTable.name,
490  doc=jetPuppiTable.doc,
491  singleton=cms.bool(False), # the number of entries is variable
492  extension=cms.bool(True), # this is the extension table for Jets
493  variables=cms.PSet(
494  CommonVars,
496  get_DeepJet_outputs(), # outputs are added in any case, inputs only if requested
498  #get_ParticleTransformerAK4_outputs(),# removed in 2024
499  ))
500 
501  # disable the ParT branches in default jetPuppi table
502  from PhysicsTools.NanoAOD.nano_eras_cff import run3_nanoAOD_122, run3_nanoAOD_124
503  (run3_nanoAOD_122 | run3_nanoAOD_124).toModify(
504  process.jetPuppiTable.variables,
505  btagRobustParTAK4B = None,
506  btagRobustParTAK4CvL = None,
507  btagRobustParTAK4CvB = None,
508  btagRobustParTAK4QG = None,
509  )
510 
511 
512  # from Run3 onwards, always set storeAK4Truth to True for MC
513  process.customAK4ConstituentsForDeepJetTable = cms.EDProducer("PatJetDeepJetTableProducer",
514  jets = cms.InputTag("linkedObjects","jets"),
515  n_cpf=cms.uint32(_n_cpf),
516  n_npf=cms.uint32(_n_npf),
517  n_sv=cms.uint32(_n_sv)
518  )
519  process.customizeJetTask.add(process.customJetExtTable)
520  process.customizeJetTask.add(process.customAK4ConstituentsForDeepJetTable)
521  # AK8
522  if addAK8:
523  process = update_jets_AK8(process)
524  process = update_jets_AK8_subjet(process)
525  process.customFatJetExtTable = cms.EDProducer(
526  "SimplePATJetFlatTableProducer",
527  src=fatJetTable.src,
528  cut=fatJetTable.cut,
529  name=fatJetTable.name,
530  doc=fatJetTable.doc,
531  singleton=cms.bool(False), # the number of entries is variable
532  extension=cms.bool(True), # this is the extension table for FatJets
533  variables=cms.PSet(
534  CommonVars,
535  #HadronCountingVars if runOnMC else cms.PSet(), # only necessary before 106x
536  get_DDX_vars() ,
537  ))
538 
539 
540  # Subjets
541  process.customSubJetExtTable = cms.EDProducer(
542  "SimplePATJetFlatTableProducer",
543  src=subJetTable.src,
544  cut=subJetTable.cut,
545  name=subJetTable.name,
546  doc=subJetTable.doc,
547  singleton=cms.bool(False), # the number of entries is variable
548  extension=cms.bool(True), # this is the extension table for FatJets
549  variables=cms.PSet(
550  CommonVars,
551  #HadronCountingVars if runOnMC else cms.PSet(), # only necessary before 106x
552  ))
553 
554  process.customizeJetTask.add(process.customFatJetExtTable)
555  process.customizeJetTask.add(process.customSubJetExtTable)
556 
557 
558 
559 # From https://github.com/cms-jet/PFNano/blob/13_0_7_from124MiniAOD/python/addPFCands_cff.py
560 def addPFCands(process, allPF = False, addAK4=False, addAK8=False):
561  process.customizedPFCandsTask = cms.Task()
562  process.schedule.associate(process.customizedPFCandsTask)
563 
564  process.finalJetsAK8Constituents = cms.EDProducer("PatJetConstituentPtrSelector",
565  src = cms.InputTag("finalJetsAK8"),
566  cut = cms.string("")
567  )
568  process.finalJetsAK4Constituents = cms.EDProducer("PatJetConstituentPtrSelector",
569  src = cms.InputTag("finalJetsPuppi"),
570  cut = cms.string("")
571  )
572  if allPF:
573  candInput = cms.InputTag("packedPFCandidates")
574  elif not addAK8:
575  candList = cms.VInputTag(cms.InputTag("finalJetsAK4Constituents", "constituents"))
576  process.customizedPFCandsTask.add(process.finalJetsAK4Constituents)
577  process.finalJetsConstituentsTable = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
578  candInput = cms.InputTag("finalJetsConstituentsTable")
579  elif not addAK4:
580  candList = cms.VInputTag(cms.InputTag("finalJetsAK8Constituents", "constituents"))
581  process.customizedPFCandsTask.add(process.finalJetsAK8Constituents)
582  process.finalJetsConstituentsTable = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
583  candInput = cms.InputTag("finalJetsConstituentsTable")
584  else:
585  candList = cms.VInputTag(cms.InputTag("finalJetsAK4Constituents", "constituents"), cms.InputTag("finalJetsAK8Constituents", "constituents"))
586  process.customizedPFCandsTask.add(process.finalJetsAK4Constituents)
587  process.customizedPFCandsTask.add(process.finalJetsAK8Constituents)
588  process.finalJetsConstituentsTable = cms.EDProducer("PackedCandidatePtrMerger", src = candList, skipNulls = cms.bool(True), warnOnSkip = cms.bool(True))
589  candInput = cms.InputTag("finalJetsConstituentsTable")
590 
591  process.customConstituentsExtTable = cms.EDProducer("SimplePATCandidateFlatTableProducer",
592  src = candInput,
593  cut = cms.string(""), #we should not filter after pruning
594  name = cms.string("PFCands"),
595  doc = cms.string("interesting particles from AK4 and AK8 jets"),
596  singleton = cms.bool(False), # the number of entries is variable
597  extension = cms.bool(False), # this is the extension table for the AK8 constituents
598  variables = cms.PSet(CandVars,
599  puppiWeight = Var("puppiWeight()", float, doc="Puppi weight",precision=10),
600  puppiWeightNoLep = Var("puppiWeightNoLep()", float, doc="Puppi weight removing leptons",precision=10),
601  vtxChi2 = Var("?hasTrackDetails()?vertexChi2():-1", float, doc="vertex chi2",precision=10),
602  trkChi2 = Var("?hasTrackDetails()?pseudoTrack().normalizedChi2():-1", float, doc="normalized trk chi2", precision=10),
603  dz = Var("?hasTrackDetails()?dz():-1", float, doc="pf dz", precision=10),
604  dzErr = Var("?hasTrackDetails()?dzError():-1", float, doc="pf dz err", precision=10),
605  d0 = Var("?hasTrackDetails()?dxy():-1", float, doc="pf d0", precision=10),
606  d0Err = Var("?hasTrackDetails()?dxyError():-1", float, doc="pf d0 err", precision=10),
607  pvAssocQuality = Var("pvAssociationQuality()", int, doc="primary vertex association quality. 0: NotReconstructedPrimary, 1: OtherDeltaZ, 4: CompatibilityBTag, 5: CompatibilityDz, 6: UsedInFitLoose, 7: UsedInFitTight"),
608  lostInnerHits = Var("lostInnerHits()", int, doc="lost inner hits. -1: validHitInFirstPixelBarrelLayer, 0: noLostInnerHits, 1: oneLostInnerHit, 2: moreLostInnerHits"),
609  lostOuterHits = Var("?hasTrackDetails()?pseudoTrack().hitPattern().numberOfLostHits('MISSING_OUTER_HITS'):0", int, doc="lost outer hits"),
610  numberOfHits = Var("numberOfHits()", int, doc="number of hits"),
611  numberOfPixelHits = Var("numberOfPixelHits()", int, doc="number of pixel hits"),
612  trkQuality = Var("?hasTrackDetails()?pseudoTrack().qualityMask():0", int, doc="track quality mask"),
613  trkHighPurity = Var("?hasTrackDetails()?pseudoTrack().quality('highPurity'):0", bool, doc="track is high purity"),
614  trkAlgo = Var("?hasTrackDetails()?pseudoTrack().algo():-1", int, doc="track algorithm"),
615  trkP = Var("?hasTrackDetails()?pseudoTrack().p():-1", float, doc="track momemtum", precision=-1),
616  trkPt = Var("?hasTrackDetails()?pseudoTrack().pt():-1", float, doc="track pt", precision=-1),
617  trkEta = Var("?hasTrackDetails()?pseudoTrack().eta():-1", float, doc="track pt", precision=12),
618  trkPhi = Var("?hasTrackDetails()?pseudoTrack().phi():-1", float, doc="track phi", precision=12),
619  )
620  )
621  process.customAK8ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer",
622  candidates = candInput,
623  jets = cms.InputTag("finalJetsAK8"),
624  jet_radius = cms.double(0.8),
625  name = cms.string("FatJetPFCands"),
626  idx_name = cms.string("pFCandsIdx"),
627  nameSV = cms.string("FatJetSVs"),
628  idx_nameSV = cms.string("sVIdx"),
629  )
630  process.customAK4ConstituentsTable = cms.EDProducer("PatJetConstituentTableProducer",
631  candidates = candInput,
632  jets = cms.InputTag("finalJetsPuppi"), # was finalJets before
633  jet_radius = cms.double(0.4),
634  name = cms.string("JetPFCands"),
635  idx_name = cms.string("pFCandsIdx"),
636  nameSV = cms.string("JetSVs"),
637  idx_nameSV = cms.string("sVIdx"),
638  )
639  process.customizedPFCandsTask.add(process.customConstituentsExtTable)
640 
641  if not allPF:
642  process.customizedPFCandsTask.add(process.finalJetsConstituentsTable)
643  # linkedObjects are WIP for Run3
644  if addAK8:
645  process.customizedPFCandsTask.add(process.customAK8ConstituentsTable)
646  if addAK4:
647  process.customizedPFCandsTask.add(process.customAK4ConstituentsTable)
648 
649 
650  return process
651 
652 
655 
656 btvNano_switch = cms.PSet(
657  btvNano_addAK4_switch = cms.untracked.bool(True),
658  btvNano_addAK8_switch = cms.untracked.bool(False),
659  btvNano_addallPF_switch = cms.untracked.bool(False),
660  TaggerInput = cms.string("btvSF")
661  )
662 
663 def BTVCustomNanoAOD(process):
664  addPFCands(process,btvNano_switch.btvNano_addallPF_switch,btvNano_switch.btvNano_addAK4_switch,btvNano_switch.btvNano_addAK8_switch)
665  add_BTV(process, btvNano_switch.btvNano_addAK4_switch,btvNano_switch.btvNano_addAK8_switch,btvNano_switch.TaggerInput)
666  process.load("PhysicsTools.NanoAOD.btvMC_cff")
667 
668  if btvNano_switch.btvNano_addallPF_switch:
669  process.nanoSequenceMC+=allPFPFCandsMCSequence
670  else:
671  if btvNano_switch.btvNano_addAK4_switch and btvNano_switch.btvNano_addAK8_switch :
672  process.nanoSequenceMC+=ak4ak8PFCandsMCSequence
673  elif btvNano_switch.btvNano_addAK4_switch and not btvNano_switch.btvNano_addAK8_switch :
674  process.nanoSequenceMC+=ak4onlyPFCandsMCSequence
675  elif not btvNano_switch.btvNano_addAK4_switch and btvNano_switch.btvNano_addAK8_switch:
676  process.nanoSequenceMC+=ak8onlyPFCandsMCSequence
677 
678  return process
def Var(expr, valtype, doc=None, precision=-1, lazyEval=False)
Definition: common_cff.py:17
def get_ParticleTransformerAK4_outputs()
def BTVCustomNanoAOD(process)
def update_jets_AK4(process)
Move PFNano (https://github.com/cms-jet/PFNano/) to NanoAOD.
def add_BTV(process, addAK4=False, addAK8=False, scheme="btvSF")
def update_jets_AK8_subjet(process)
def addPFCands(process, allPF=False, addAK4=False, addAK8=False)
def update_jets_AK8(process)
def get_ParticleNetAK4_outputs()
def get_DeepJet_outputs()
Store all output nodes, negative tagger for SF.