-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
TensorFlow-based DeepDoubleB tagger integration #23033
Merged
Merged
Changes from 37 commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
55696f8
add double-b features
5b29ed0
rearrange files
4e89f23
update src and interface
cvernier 4f583de
define templates in .h, instantiate in .cc
kpedro88 a3c8752
update tensor shape; fix tensor filler
59d9c01
fix double-b inputs, except for slight diff in tau1_flightDistance2dS…
d5bed9e
fix packed candidate loop for AK8 jets (double loop)
jmduarte a9d5636
add ptratio to charged candidate
jmduarte b322d5c
make jet radius configurable for drmin
jmduarte 9cf3a23
fix producer for RECO/AOD
jmduarte e00f90c
testing from MINIAOD
jmduarte 5bd87bc
remove vertex_associator from deepdoubleb in jetTools
jmduarte de5426a
rm printouts and vertex associator
jmduarte 4e0dba2
testing configs
jmduarte 2c5da18
update default model file with pt cut and mass sculpting penalty
jmduarte 3c5dd9e
enable DeepDoubleB tagger in MINIAOD
jmduarte fb855f9
add class versions
jmduarte 682a77d
add comment that these variables should match the content of DataForm…
jmduarte 17f139d
factorize deep b-tagging on top of MINIAOD into applyDeepBtagging_cff.py
jmduarte 8e920d8
remove unnecessary tags in BuildFile.xml; fix indenting
jmduarte a4e89c8
fix naming conventions for converter classes, functions, and include …
jmduarte 0c08ec1
double jetR -> float jetR
jmduarte 0baa490
add comment on unused variable
jmduarte 98f4300
remove commented out code
jmduarte b825564
generalize range for different jetR
jmduarte 2d5846c
add newline for readability
jmduarte 89d8406
moved unnecessary includes for interface from .h to .cc
jmduarte a23111c
fix indentation in deep_helpers
jmduarte 95211f0
clang-format DeepDoubleBTagInfoProducer
jmduarte b9f24c6
mv RecoBTag/DeepFlavour -> RecoBTag/TensorFlow
jmduarte 63ff44b
mv RecoBTag/DeepFlavour -> RecoBTag/TensorFlow
jmduarte 05ba24f
remove pointer to reco candidate; small fix to applyDeepBtagging_cff.py
jmduarte dd2a595
reapply Puppi JECs for slimmedAK8 jets after double-b tagging
jmduarte 12e9800
add back buildfile
jmduarte 5e2cfe5
sVToFeatures -> svToFeatures
jmduarte 15d011e
move reco_cand and rename pv local variable
jmduarte 2f77331
mv sorting_modules
jmduarte a3fceea
remove multiple definition of jetToFeatures
jmduarte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
DataFormats/BTauReco/interface/BoostedDoubleSVTagInfoFeatures.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef DataFormats_BTauReco_BoostedDoubleSVTagInfoFeatures_h | ||
#define DataFormats_BTauReco_BoostedDoubleSVTagInfoFeatures_h | ||
|
||
namespace btagbtvdeep { | ||
|
||
class BoostedDoubleSVTagInfoFeatures { | ||
|
||
// Note: these variables are intended to match the variables defined in DataFormats/BTauReco/interface/TaggingVariable.h | ||
|
||
public: | ||
float jetNTracks; // tracks associated to jet | ||
float jetNSecondaryVertices; // number of reconstructed possible secondary vertices in jet | ||
float trackSip3dSig_0; // 1st largest track 3D signed impact parameter significance | ||
float trackSip3dSig_1; // 2nd largest track 3D signed impact parameter significance | ||
float trackSip3dSig_2; // 3rd largest track 3D signed impact parameter significance | ||
float trackSip3dSig_3; // 4th largest track 3D signed impact parameter significance | ||
float tau1_trackSip3dSig_0; // 1st largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis | ||
float tau1_trackSip3dSig_1; // 2nd largest track 3D signed impact parameter significance associated to the 1st N-subjettiness axis | ||
float tau2_trackSip3dSig_0; // 1st largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis | ||
float tau2_trackSip3dSig_1; // 2nd largest track 3D signed impact parameter significance associated to the 2nd N-subjettiness axis | ||
float trackSip2dSigAboveBottom_0;// track 2D signed impact parameter significance of 1st track lifting mass above bottom | ||
float trackSip2dSigAboveBottom_1;// track 2D signed impact parameter significance of 2nd track lifting mass above bottom | ||
float trackSip2dSigAboveCharm; // track 2D signed impact parameter significance of first track lifting mass above charm | ||
float tau1_trackEtaRel_0; // 1st smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis | ||
float tau1_trackEtaRel_1; // 2nd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis | ||
float tau1_trackEtaRel_2; // 3rd smallest track pseudorapidity, relative to the jet axis, associated to the 1st N-subjettiness axis | ||
float tau2_trackEtaRel_0; // 1st smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis | ||
float tau2_trackEtaRel_1; // 2nd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis | ||
float tau2_trackEtaRel_2; // 3rd smallest track pseudorapidity, relative to the jet axis, associated to the 2nd N-subjettiness axis | ||
float tau1_vertexMass; // mass of track sum at secondary vertex associated to the 1st N-subjettiness axis | ||
float tau1_vertexEnergyRatio; // ratio of energy at secondary vertex over total energy associated to the 1st N-subjettiness axis | ||
float tau1_flightDistance2dSig; // transverse distance significance between primary and secondary vertex associated to the 1st N-subjettiness axis | ||
float tau1_vertexDeltaR; // pseudoangular distance between the 1st N-subjettiness axis and secondary vertex direction | ||
float tau2_vertexMass; // mass of track sum at secondary vertex associated to the 2nd N-subjettiness axis | ||
float tau2_vertexEnergyRatio; // ratio of energy at secondary vertex over total energy associated to the 2nd N-subjettiness axis | ||
float tau2_flightDistance2dSig; // transverse distance significance between primary and secondary vertex associated to the 2nd N-subjettiness axis | ||
float tau2_vertexDeltaR; // pseudoangular distance between the 2nd N-subjettiness axis and secondary vertex direction (NOT USED!) | ||
float z_ratio; // z ratio | ||
|
||
}; | ||
|
||
} | ||
|
||
#endif //DataFormats_BTauReco_BoostedDoubleSVTagInfoFeatures_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef DataFormats_BTauReco_DeepDoubleBFeatures_h | ||
#define DataFormats_BTauReco_DeepDoubleBFeatures_h | ||
|
||
#include <vector> | ||
|
||
#include "DataFormats/BTauReco/interface/JetFeatures.h" | ||
#include "DataFormats/BTauReco/interface/SecondaryVertexFeatures.h" | ||
#include "DataFormats/BTauReco/interface/BoostedDoubleSVTagInfoFeatures.h" | ||
#include "DataFormats/BTauReco/interface/ChargedCandidateFeatures.h" | ||
|
||
namespace btagbtvdeep { | ||
|
||
class DeepDoubleBFeatures { | ||
|
||
public: | ||
JetFeatures jet_features; | ||
BoostedDoubleSVTagInfoFeatures tag_info_features; | ||
|
||
std::vector<SecondaryVertexFeatures> sv_features; | ||
|
||
std::vector<ChargedCandidateFeatures> c_pf_features; | ||
|
||
std::size_t npv; // used by deep flavour | ||
}; | ||
|
||
|
||
} | ||
|
||
#endif //DataFormats_BTauReco_DeepDoubleBFeatures_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#ifndef DataFormats_BTauReco_DeepDoubleBTagInfo_h | ||
#define DataFormats_BTauReco_DeepDoubleBTagInfo_h | ||
|
||
#include "DataFormats/Common/interface/CMS_CLASS_VERSION.h" | ||
#include "DataFormats/BTauReco/interface/BaseTagInfo.h" | ||
#include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h" | ||
#include "DataFormats/BTauReco/interface/DeepDoubleBFeatures.h" | ||
|
||
#include "DataFormats/PatCandidates/interface/Jet.h" | ||
|
||
namespace reco { | ||
|
||
typedef FeaturesTagInfo<btagbtvdeep::DeepDoubleBFeatures> DeepDoubleBTagInfo; | ||
|
||
DECLARE_EDM_REFS( DeepDoubleBTagInfo ) | ||
|
||
} | ||
|
||
#endif // DataFormats_BTauReco_DeepDoubleBTagInfo_h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,6 +70,7 @@ | |
<class name="reco::BoostedDoubleSVTagInfoRefProd"/> | ||
<class name="reco::BoostedDoubleSVTagInfoRefVector"/> | ||
<class name="edm::Wrapper<reco::BoostedDoubleSVTagInfoCollection>"/> | ||
<class name="edm::Wrapper<std::vector<reco::BoostedDoubleSVTagInfo> >"/> | ||
|
||
<class name="reco::ShallowTagInfo" ClassVersion="3"> | ||
<version ClassVersion="3" checksum="3904302444"/> | ||
|
@@ -439,12 +440,20 @@ | |
<class name="btagbtvdeep::NeutralCandidateFeatures" ClassVersion="3"> | ||
<version ClassVersion="3" checksum="938442516"/> | ||
</class> | ||
<class name="btagbtvdeep::ChargedCandidateFeatures" ClassVersion="3"> | ||
<class name="btagbtvdeep::ChargedCandidateFeatures" ClassVersion="4"> | ||
<version ClassVersion="4" checksum="2173116472"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. old version should be kept in the list. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed in 63f21e4 |
||
<version ClassVersion="3" checksum="1302021141"/> | ||
</class> | ||
<class name="btagbtvdeep::DeepFlavourFeatures" ClassVersion="3"> | ||
<version ClassVersion="3" checksum="2487956635"/> | ||
</class> | ||
<class name="btagbtvdeep::DeepDoubleBFeatures" ClassVersion="3"> | ||
<version ClassVersion="3" checksum="2060552560"/> | ||
</class> | ||
<class name="btagbtvdeep::BoostedDoubleSVTagInfoFeatures" ClassVersion="3"> | ||
<version ClassVersion="3" checksum="683471882"/> | ||
</class> | ||
|
||
|
||
<class name="reco::DeepFlavourTagInfo"/> | ||
<class name="reco::DeepFlavourTagInfoCollection"/> | ||
|
@@ -454,4 +463,12 @@ | |
<class name="reco::DeepFlavourTagInfoRefVector"/> | ||
<class name="edm::Wrapper<reco::DeepFlavourTagInfoCollection>"/> | ||
|
||
<class name="reco::DeepDoubleBTagInfo"/> | ||
<class name="reco::DeepDoubleBTagInfoCollection"/> | ||
<class name="reco::DeepDoubleBTagInfoRef"/> | ||
<class name="reco::DeepDoubleBTagInfoFwdRef"/> | ||
<class name="reco::DeepDoubleBTagInfoRefProd"/> | ||
<class name="reco::DeepDoubleBTagInfoRefVector"/> | ||
<class name="edm::Wrapper<reco::DeepDoubleBTagInfoCollection>"/> | ||
|
||
</lcgdict> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
PhysicsTools/PatAlgos/python/slimming/applyDeepBtagging_cff.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
from PhysicsTools.PatAlgos.tools.helpers import getPatAlgosToolsTask, addToProcessAndTask | ||
|
||
def applyDeepBtagging( process, postfix="" ) : | ||
|
||
task = getPatAlgosToolsTask(process) | ||
|
||
from PhysicsTools.PatAlgos.tools.jetTools import updateJetCollection | ||
|
||
process.load('PhysicsTools.PatAlgos.slimming.slimmedJets_cfi') | ||
|
||
# update slimmed jets to include DeepFlavour (keep same name) | ||
# make clone for DeepFlavour-less slimmed jets, so output name is preserved | ||
addToProcessAndTask('slimmedJetsNoDeepFlavour', process.slimmedJets.clone(), process, task) | ||
updateJetCollection( | ||
process, | ||
jetSource = cms.InputTag('slimmedJetsNoDeepFlavour'), | ||
# updateJetCollection defaults to MiniAOD inputs but | ||
# here it is made explicit (as in training or MINIAOD redoing) | ||
pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), | ||
pfCandidates = cms.InputTag('packedPFCandidates'), | ||
svSource = cms.InputTag('slimmedSecondaryVertices'), | ||
muSource = cms.InputTag('slimmedMuons'), | ||
elSource = cms.InputTag('slimmedElectrons'), | ||
jetCorrections = ('AK4PFchs', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), | ||
btagDiscriminators = [ | ||
'pfDeepFlavourJetTags:probb', | ||
'pfDeepFlavourJetTags:probbb', | ||
'pfDeepFlavourJetTags:problepb', | ||
'pfDeepFlavourJetTags:probc', | ||
'pfDeepFlavourJetTags:probuds', | ||
'pfDeepFlavourJetTags:probg', | ||
], | ||
postfix = 'SlimmedDeepFlavour'+postfix, | ||
printWarning = False | ||
) | ||
|
||
# slimmedJets with DeepFlavour (remove DeepFlavour-less) | ||
delattr(process, 'slimmedJets') | ||
addToProcessAndTask('slimmedJets', getattr(process,'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix).clone(), process, task) | ||
# delete module not used anymore (slimmedJets substitutes) | ||
delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix) | ||
|
||
|
||
|
||
# update slimmed jets to include DeepFlavour (keep same name) | ||
# make clone for DeepDoubleB-less slimmed AK8 jets, so output name is preserved | ||
addToProcessAndTask('slimmedJetsAK8NoDeepDoubleB', process.slimmedJetsAK8.clone(), process, task) | ||
updateJetCollection( | ||
process, | ||
jetSource = cms.InputTag('slimmedJetsAK8NoDeepDoubleB'), | ||
# updateJetCollection defaults to MiniAOD inputs but | ||
# here it is made explicit (as in training or MINIAOD redoing) | ||
pvSource = cms.InputTag('offlineSlimmedPrimaryVertices'), | ||
pfCandidates = cms.InputTag('packedPFCandidates'), | ||
svSource = cms.InputTag('slimmedSecondaryVertices'), | ||
muSource = cms.InputTag('slimmedMuons'), | ||
elSource = cms.InputTag('slimmedElectrons'), | ||
rParam = 0.8, | ||
jetCorrections = ('AK8PFPuppi', cms.vstring(['L1FastJet', 'L2Relative', 'L3Absolute']), 'None'), | ||
btagDiscriminators = [ | ||
'pfDeepDoubleBJetTags:probQ', | ||
'pfDeepDoubleBJetTags:probH', | ||
], | ||
postfix = 'SlimmedAK8DeepDoubleB'+postfix, | ||
printWarning = False | ||
) | ||
|
||
# slimmedJetsAK8 with DeepDoubleB (remove DeepDoubleB-less) | ||
delattr(process, 'slimmedJetsAK8') | ||
addToProcessAndTask('slimmedJetsAK8', getattr(process,'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB'+postfix).clone(), process, task) | ||
# delete module not used anymore (slimmedJetsAK8 substitutes) | ||
delattr(process, 'selectedUpdatedPatJetsSlimmedAK8DeepDoubleB'+postfix) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth to add a comment that these variables are (supposed to be) matching the content of DataFormats/BTauReco/interface/TaggingVariable.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in 7932110