CMS 3D CMS Logo

pfParticleNet_cff.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 from RecoBTag.FeatureTools.pfDeepBoostedJetTagInfos_cfi import pfDeepBoostedJetTagInfos
4 from RecoBTag.ONNXRuntime.boostedJetONNXJetTagsProducer_cfi import boostedJetONNXJetTagsProducer
5 from RecoBTag.ONNXRuntime.particleNetSonicJetTagsProducer_cfi import particleNetSonicJetTagsProducer as _particleNetSonicJetTagsProducer
6 from RecoBTag.ONNXRuntime.pfParticleNetDiscriminatorsJetTags_cfi import pfParticleNetDiscriminatorsJetTags
7 from RecoBTag.ONNXRuntime.pfMassDecorrelatedParticleNetDiscriminatorsJetTags_cfi import pfMassDecorrelatedParticleNetDiscriminatorsJetTags
8 from Configuration.ProcessModifiers.particleNetSonicTriton_cff import particleNetSonicTriton
9 from Configuration.ProcessModifiers.particleNetPTSonicTriton_cff import particleNetPTSonicTriton
10 
11 pfParticleNetTagInfos = pfDeepBoostedJetTagInfos.clone(
12  use_puppiP4 = False
13 )
14 
15 pfParticleNetJetTags = boostedJetONNXJetTagsProducer.clone(
16  src = 'pfParticleNetTagInfos',
17  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/General/V01/preprocess.json',
18  model_path = 'RecoBTag/Combined/data/ParticleNetAK8/General/V01/modelfile/model.onnx',
19  flav_names = ["probTbcq", "probTbqq", "probTbc", "probTbq", "probTbel", "probTbmu", "probTbta",
20  "probWcq", "probWqq", "probZbb", "probZcc", "probZqq", "probHbb", "probHcc",
21  "probHqqqq", "probQCDbb", "probQCDcc", "probQCDb", "probQCDc", "probQCDothers"],
22 )
23 
24 particleNetSonicTriton.toReplaceWith(pfParticleNetJetTags, _particleNetSonicJetTagsProducer.clone(
25  src = 'pfParticleNetTagInfos',
26  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/General/V01/preprocess.json',
27  Client = cms.PSet(
28  timeout = cms.untracked.uint32(300),
29  mode = cms.string("Async"),
30  modelName = cms.string("particlenet"),
31  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet/config.pbtxt"),
32  modelVersion = cms.string(""),
33  verbose = cms.untracked.bool(False),
34  allowedTries = cms.untracked.uint32(0),
35  useSharedMemory = cms.untracked.bool(True),
36  compression = cms.untracked.string(""),
37  ),
38  flav_names = pfParticleNetJetTags.flav_names,
39 ))
40 
41 (particleNetSonicTriton & particleNetPTSonicTriton).toModify(pfParticleNetJetTags,
42  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/General/V01/preprocess_PT.json',
43  Client = dict(
44  modelName = "particlenet_PT",
45  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet_PT/config.pbtxt"),
46  )
47 )
48 
49 pfMassDecorrelatedParticleNetJetTags = boostedJetONNXJetTagsProducer.clone(
50  src = 'pfParticleNetTagInfos',
51  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MD-2prong/V01/preprocess.json',
52  model_path = 'RecoBTag/Combined/data/ParticleNetAK8/MD-2prong/V01/modelfile/model.onnx',
53  flav_names = ["probXbb", "probXcc", "probXqq", "probQCDbb", "probQCDcc",
54  "probQCDb", "probQCDc", "probQCDothers"],
55 )
56 
57 particleNetSonicTriton.toReplaceWith(pfMassDecorrelatedParticleNetJetTags, _particleNetSonicJetTagsProducer.clone(
58  src = 'pfParticleNetTagInfos',
59  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MD-2prong/V01/preprocess.json',
60  Client = cms.PSet(
61  timeout = cms.untracked.uint32(300),
62  modelName = cms.string("particlenet_AK8_MD-2prong"),
63  mode = cms.string("Async"),
64  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet_AK8_MD-2prong/config.pbtxt"),
65  modelVersion = cms.string(""),
66  verbose = cms.untracked.bool(False),
67  allowedTries = cms.untracked.uint32(0),
68  ),
69  flav_names = pfMassDecorrelatedParticleNetJetTags.flav_names,
70 ))
71 
72 (particleNetSonicTriton & particleNetPTSonicTriton).toModify(pfMassDecorrelatedParticleNetJetTags,
73  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MD-2prong/V01/preprocess_PT.json',
74  Client = dict(
75  modelName = "particlenet_AK8_MD-2prong_PT",
76  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet_AK8_MD-2prong_PT/config.pbtxt"),
77  )
78 )
79 
80 pfParticleNetMassRegressionJetTags = boostedJetONNXJetTagsProducer.clone(
81  src = 'pfParticleNetTagInfos',
82  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MassRegression/V01/preprocess.json',
83  model_path = 'RecoBTag/Combined/data/ParticleNetAK8/MassRegression/V01/modelfile/model.onnx',
84  flav_names = ["mass"],
85 )
86 
87 particleNetSonicTriton.toReplaceWith(pfParticleNetMassRegressionJetTags, _particleNetSonicJetTagsProducer.clone(
88  src = 'pfParticleNetTagInfos',
89  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MassRegression/V01/preprocess.json',
90  Client = cms.PSet(
91  timeout = cms.untracked.uint32(300),
92  modelName = cms.string("particlenet_AK8_MassRegression"),
93  mode = cms.string("Async"),
94  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet_AK8_MassRegression/config.pbtxt"),
95  modelVersion = cms.string(""),
96  verbose = cms.untracked.bool(False),
97  allowedTries = cms.untracked.uint32(0),
98  ),
99  flav_names = pfParticleNetMassRegressionJetTags.flav_names,
100 ))
101 
102 (particleNetSonicTriton & particleNetPTSonicTriton).toModify(pfParticleNetMassRegressionJetTags,
103  preprocess_json = 'RecoBTag/Combined/data/ParticleNetAK8/MassRegression/V01/preprocess_PT.json',
104  Client = dict(
105  modelName = "particlenet_AK8_MassRegression_PT",
106  modelConfigPath = cms.FileInPath("RecoBTag/Combined/data/models/particlenet_AK8_MassRegression_PT/config.pbtxt"),
107  )
108 )
109 
110 from CommonTools.PileupAlgos.Puppi_cff import puppi
111 from CommonTools.RecoAlgos.primaryVertexAssociation_cfi import primaryVertexAssociation
112 
113 # This task is not used, useful only if we run it from RECO jets (RECO/AOD)
114 pfParticleNetTask = cms.Task(puppi, primaryVertexAssociation, pfParticleNetTagInfos,
115  pfParticleNetJetTags, pfMassDecorrelatedParticleNetJetTags, pfParticleNetMassRegressionJetTags,
116  pfParticleNetDiscriminatorsJetTags, pfMassDecorrelatedParticleNetDiscriminatorsJetTags)
117 
118 # declare all the discriminators
119 # nominal: probs
120 _pfParticleNetJetTagsProbs = ['pfParticleNetJetTags:' + flav_name
121  for flav_name in pfParticleNetJetTags.flav_names]
122 
123 # nominal: meta-taggers
124 _pfParticleNetJetTagsMetaDiscrs = ['pfParticleNetDiscriminatorsJetTags:' + disc.name.value()
125  for disc in pfParticleNetDiscriminatorsJetTags.discriminators]
126 # mass-decorrelated: probs
127 _pfMassDecorrelatedParticleNetJetTagsProbs = ['pfMassDecorrelatedParticleNetJetTags:' + flav_name
128  for flav_name in pfMassDecorrelatedParticleNetJetTags.flav_names]
129 
130 # mass-decorrelated: meta-taggers
131 _pfMassDecorrelatedParticleNetJetTagsMetaDiscrs = ['pfMassDecorrelatedParticleNetDiscriminatorsJetTags:' + disc.name.value()
132  for disc in pfMassDecorrelatedParticleNetDiscriminatorsJetTags.discriminators]
133 
134 _pfParticleNetMassRegressionOutputs = ['pfParticleNetMassRegressionJetTags:' + flav_name
135  for flav_name in pfParticleNetMassRegressionJetTags.flav_names]
136 
137 _pfParticleNetJetTagsAll = _pfParticleNetJetTagsProbs + _pfParticleNetJetTagsMetaDiscrs + \
138  _pfMassDecorrelatedParticleNetJetTagsProbs + _pfMassDecorrelatedParticleNetJetTagsMetaDiscrs
139 
140 _pfParticleNetMassCorrelatedJetTagsAll = _pfParticleNetJetTagsProbs + _pfParticleNetJetTagsMetaDiscrs