-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Backport FastSim refiner network for NANO (DeepJet for AK4 CHS Jets) #40828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
4b674c9
64d138d
1bc1563
34f1ebe
8657ffe
42ac076
843898a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -531,6 +531,66 @@ | |
| run2_jme_2017.toModify( cjetNN,outputFormulas = cms.vstring(["at(0)*0.24718524515628815+0.9927206635475159","0.5*(at(2)-at(1))*0.24718524515628815"])) | ||
|
|
||
|
|
||
| # | ||
| # ML-based FastSim refinement | ||
| # | ||
| from Configuration.Eras.Modifier_fastSim_cff import fastSim | ||
| def nanoAOD_refineFastSim_bTagDeepFlav(process): | ||
|
|
||
|
|
||
| fastSim.toModify( process.jetTable.variables, | ||
| btagDeepFlavBunrefined = process.jetTable.variables.btagDeepFlavB.clone(), | ||
| btagDeepFlavCvBunrefined = process.jetTable.variables.btagDeepFlavCvB.clone(), | ||
| btagDeepFlavCvLunrefined = process.jetTable.variables.btagDeepFlavCvL.clone(), | ||
| btagDeepFlavQGunrefined = process.jetTable.variables.btagDeepFlavQG.clone(), | ||
| ) | ||
|
|
||
| fastSim.toModify( process.jetTable.variables, | ||
| btagDeepFlavB = None, | ||
| btagDeepFlavCvB = None, | ||
| btagDeepFlavCvL = None, | ||
| btagDeepFlavQG = None, | ||
| ) | ||
|
|
||
| fastSim.toModify( process.jetTable.externalVariables, | ||
| btagDeepFlavB = ExtVar(cms.InputTag("btagDeepFlavRefineNN:btagDeepFlavBrefined"), float, doc="DeepJet b+bb+lepb tag discriminator", precision=10), | ||
| btagDeepFlavCvB = ExtVar(cms.InputTag("btagDeepFlavRefineNN:btagDeepFlavCvBrefined"), float, doc="DeepJet c vs b+bb+lepb discriminator", precision=10), | ||
| btagDeepFlavCvL = ExtVar(cms.InputTag("btagDeepFlavRefineNN:btagDeepFlavCvLrefined"), float, doc="DeepJet c vs uds+g discriminator", precision=10), | ||
| btagDeepFlavQG = ExtVar(cms.InputTag("btagDeepFlavRefineNN:btagDeepFlavQGrefined"), float, doc="DeepJet g vs uds discriminator", precision=10), | ||
| ) | ||
|
|
||
| process.btagDeepFlavRefineNN= cms.EDProducer("JetBaseMVAValueMapProducer", | ||
| backend = cms.string("ONNX"), | ||
| batch_eval = cms.bool(True), | ||
| disableONNXGraphOpt = cms.bool(True), | ||
|
|
||
| src = cms.InputTag("linkedObjects","jets"), | ||
|
|
||
| weightFile=cms.FileInPath("PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx"),#local hack for backporting: cp /cvmfs/cms.cern.ch/slc7_amd64_gcc11/cms/data-PhysicsTools-NanoAOD/V01-03-00/PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx # cp /nfs/dust/cms/user/wolfmor/Refinement/TrainingOutput/regression_model_20221127_opset11.onnx PhysicsTools/NanoAOD/data/btagDeepFlavRefineNN_CHS.onnx | ||
|
||
| name = cms.string("btagDeepFlavRefineNN"), | ||
|
|
||
| isClassifier = cms.bool(False), | ||
| variablesOrder = cms.vstring(["GenJet_pt","GenJet_eta","Jet_hadronFlavour", | ||
| "Jet_btagDeepFlavB","Jet_btagDeepFlavCvB","Jet_btagDeepFlavCvL","Jet_btagDeepFlavQG"]), | ||
| variables = cms.PSet( | ||
| GenJet_pt = cms.string("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().pt():pt"), | ||
| GenJet_eta = cms.string("?genJetFwdRef().backRef().isNonnull()?genJetFwdRef().backRef().eta():eta"), | ||
| Jet_hadronFlavour = cms.string("hadronFlavour()"), | ||
| Jet_btagDeepFlavB = cms.string("bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')"), | ||
| Jet_btagDeepFlavCvB = cms.string("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probb')+bDiscriminator('pfDeepFlavourJetTags:probbb')+bDiscriminator('pfDeepFlavourJetTags:problepb')):-1"), | ||
| Jet_btagDeepFlavCvL = cms.string("?(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg'))>0?bDiscriminator('pfDeepFlavourJetTags:probc')/(bDiscriminator('pfDeepFlavourJetTags:probc')+bDiscriminator('pfDeepFlavourJetTags:probuds')+bDiscriminator('pfDeepFlavourJetTags:probg')):-1"), | ||
| Jet_btagDeepFlavQG = cms.string("?(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds'))>0?bDiscriminator('pfDeepFlavourJetTags:probg')/(bDiscriminator('pfDeepFlavourJetTags:probg')+bDiscriminator('pfDeepFlavourJetTags:probuds')):-1"), | ||
| ), | ||
| inputTensorName = cms.string("input"), | ||
| outputTensorName = cms.string("output"), | ||
| outputNames = cms.vstring(["btagDeepFlavBrefined","btagDeepFlavCvBrefined","btagDeepFlavCvLrefined","btagDeepFlavQGrefined"]), | ||
| outputFormulas = cms.vstring(["at(0)","at(1)","at(2)","at(3)"]), | ||
| ) | ||
|
|
||
| fastSim.toModify(process.jetTables, process.jetTables.insert(0,process.btagDeepFlavRefineNN)) | ||
|
|
||
| return process | ||
|
|
||
|
|
||
| subJetTable = cms.EDProducer("SimpleCandidateFlatTableProducer", | ||
| src = cms.InputTag("slimmedJetsAK8PFPuppiSoftDropPacked","SubJets"), | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,13 +22,18 @@ namespace cms::Ort { | |
|
|
||
| typedef std::vector<std::vector<float>> FloatArrays; | ||
|
|
||
| enum class Backend { | ||
| cpu, | ||
| }; | ||
|
|
||
| class ONNXRuntime { | ||
| public: | ||
| ONNXRuntime(const std::string& model_path, const ::Ort::SessionOptions* session_options = nullptr); | ||
| ONNXRuntime(const ONNXRuntime&) = delete; | ||
| ONNXRuntime& operator=(const ONNXRuntime&) = delete; | ||
| ~ONNXRuntime(); | ||
|
|
||
|
|
||
| static ::Ort::SessionOptions defaultSessionOptions(Backend backend = Backend::cpu); | ||
|
||
| // Run inference and get outputs | ||
| // input_names: list of the names of the input nodes. | ||
| // input_values: list of input arrays for each input node. The order of `input_values` must match `input_names`. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.