Skip to content

Commit

Permalink
Merge pull request cms-sw#621 from arizzi/btagDeep2
Browse files Browse the repository at this point in the history
minimal version of deep CSV implementation
  • Loading branch information
arizzi committed Jan 13, 2017
2 parents a22422f + 0ac20cd commit b6fc246
Show file tree
Hide file tree
Showing 59 changed files with 80,143 additions and 36 deletions.
41 changes: 41 additions & 0 deletions DataFormats/BTauReco/interface/ShallowTagInfo.h
@@ -0,0 +1,41 @@
#ifndef DataFormats_BTauReco_ShallowTagInfo_h
#define DataFormats_BTauReco_ShallowTagInfo_h

#include "DataFormats/BTauReco/interface/RefMacros.h"
#include "DataFormats/BTauReco/interface/BaseTagInfo.h"
#include "DataFormats/BTauReco/interface/CandIPTagInfo.h"
#include "DataFormats/BTauReco/interface/CandSecondaryVertexTagInfo.h"
#include "DataFormats/BTauReco/interface/TaggingVariable.h"

namespace reco {

class ShallowTagInfo : public BaseTagInfo {
public:
ShallowTagInfo(void) { }

ShallowTagInfo(
const TaggingVariableList & list,
const edm::RefToBase<Jet> & jetref) :
list_(list),
jetRef_(jetref) { }

virtual ~ShallowTagInfo(void) { }

virtual ShallowTagInfo* clone(void) const { return new ShallowTagInfo(*this); }

virtual edm::RefToBase<Jet> jet(void) const { return jetRef_; }

virtual TaggingVariableList taggingVariables(void) const { return list_; }

// Used by ROOT storage
CMS_CLASS_VERSION(3)
protected:
const TaggingVariableList list_;
const edm::RefToBase<Jet> jetRef_;
};

DECLARE_EDM_REFS( ShallowTagInfo )

}

#endif // DataFormats_BTauReco_ShallowTagInfo_h
8 changes: 8 additions & 0 deletions DataFormats/BTauReco/interface/TaggingVariable.h
Expand Up @@ -35,8 +35,11 @@ namespace reco {
jetPt, // jet transverse momentum
trackJetPt, // track-based jet transverse momentum
jetEta, // jet pseudorapidity
jetAbsEta, // jet pseudorapidity
jetPhi, // jet polar angle
jetNTracks, // tracks associated to jet
jetNSelectedTracks, // tracks associated to jet
jetNTracksEtaRel, // number of tracks for which etaRel is computed

trackMomentum, // track momentum
trackEta, // track pseudorapidity
Expand Down Expand Up @@ -151,6 +154,11 @@ namespace reco {
tau2_flightDistance2dSig, // transverse distance significance between primary and secondary vertex associated to the 2nd N-subjettiness axis
tau2_vertexDeltaR, // pseudoangular distance between the 2nd N-subjettiness axis and secondary vertex direction
z_ratio, // z ratio

Jet_SoftMu, // discriminator output of SoftMuon Tagger, used as input to (Deep)CMVA
Jet_SoftEl, // discriminator output of SoftElectron Tagger, used as input to (Deep)CMVA
Jet_JBP, // discriminator output of JPB Tagger, used as input to (Deep)CMVA
Jet_JP, // discriminator output of JP Tagger, used as input to (Deep)CMVA
// #################################################################################

algoDiscriminator, // discriminator output of an algorithm
Expand Down
10 changes: 10 additions & 0 deletions DataFormats/BTauReco/src/TaggingVariable.cc
Expand Up @@ -13,8 +13,11 @@ const char* const TaggingVariableDescription[] = {
/* [jetPt] = */ "jet transverse momentum",
/* [trackJetPt] = */ "track-based jet transverse momentum",
/* [jetEta] = */ "jet pseudorapidity",
/* [jetAbsEta] = */ "jet absolute pseudorapidity",
/* [jetPhi] = */ "jet polar angle",
/* [jetNTracks] = */ "tracks associated to jet",
/* [jetNSelectedTracks] = */ "selected tracks in the jet",
/* [jetNTracksEtaRel] = */ "number of tracks for which etaRel is computed",

/* [trackMomentum] = */ "track momentum",
/* [trackEta] = */ "track pseudorapidity",
Expand Down Expand Up @@ -139,8 +142,11 @@ const char* const TaggingVariableTokens[] = {
/* [jetPt] = */ "jetPt",
/* [trackJetPt] = */ "trackJetPt",
/* [jetEta] = */ "jetEta",
/* [jetAbsEta] = */ "jetAbsEta",
/* [jetPhi] = */ "jetPhi",
/* [jetNTracks] = */ "jetNTracks",
/* [jetNSelectedTracks] = */ "jetNSelectedTracks",
/* [jetNTracksEtaRel] = */ "jetNTracksEtaRel",

/* [trackMomentum] = */ "trackMomentum",
/* [trackEta] = */ "trackEta",
Expand Down Expand Up @@ -255,6 +261,10 @@ const char* const TaggingVariableTokens[] = {
/* [tau2_flightDistance2dSig] = */ "tau2_flightDistance2dSig",
/* [tau2_vertexDeltaR] = */ "tau2_vertexDeltaR",
/* [z_ratio] = */ "z_ratio",
/* [Jet_SoftMu] = */ "Jet_SoftMu",
/* [Jet_SoftEl] = */ "Jet_SoftEl",
/* [Jet_JBP] = */ "Jet_JBP",
/* [Jet_JP] = */ "Jet_JP",

/* [algoDiscriminator] = */ "algoDiscriminator",

Expand Down
13 changes: 13 additions & 0 deletions DataFormats/BTauReco/src/classes.h
Expand Up @@ -33,6 +33,7 @@
#include "DataFormats/BTauReco/interface/SecondaryVertexTagInfo.h"
#include "DataFormats/BTauReco/interface/CandSecondaryVertexTagInfo.h"
#include "DataFormats/BTauReco/interface/BoostedDoubleSVTagInfo.h"
#include "DataFormats/BTauReco/interface/ShallowTagInfo.h"
#include "DataFormats/BTauReco/interface/SoftLeptonTagInfo.h"
#include "DataFormats/BTauReco/interface/CandSoftLeptonTagInfo.h"
#include "DataFormats/BTauReco/interface/TauImpactParameterInfo.h"
Expand Down Expand Up @@ -87,6 +88,14 @@ namespace DataFormats_BTauReco {
reco::BoostedDoubleSVTagInfoRefVector bdsv_rv;
edm::Wrapper<reco::BoostedDoubleSVTagInfoCollection> bdsv_wc;

reco::ShallowTagInfo dnn;
reco::ShallowTagInfoCollection dnn_c;
reco::ShallowTagInfoRef dnn_r;
reco::ShallowTagInfoFwdRef dnn_fr;
reco::ShallowTagInfoRefProd dnn_rp;
reco::ShallowTagInfoRefVector dnn_rv;
edm::Wrapper<reco::ShallowTagInfoCollection> dnn_wc;

reco::CombinedTauTagInfo ct;
reco::CombinedTauTagInfoCollection ct_c;
reco::CombinedTauTagInfoRef ct_r;
Expand Down Expand Up @@ -283,6 +292,8 @@ namespace DataFormats_BTauReco {
edm::reftobase::RefHolder<reco::CandSecondaryVertexTagInfoRef> rbh_casv;
edm::reftobase::Holder<reco::BaseTagInfo, reco::BoostedDoubleSVTagInfoRef> rb_bdsv;
edm::reftobase::RefHolder<reco::BoostedDoubleSVTagInfoRef> rbh_bdsv;
edm::reftobase::Holder<reco::BaseTagInfo, reco::ShallowTagInfoRef> rb_dnn;
edm::reftobase::RefHolder<reco::ShallowTagInfoRef> rbh_dnn;
edm::reftobase::Holder<reco::BaseTagInfo, reco::CombinedTauTagInfoRef> rb_ct;
edm::reftobase::RefHolder<reco::CombinedTauTagInfoRef> rbh_ct;
edm::reftobase::Holder<reco::BaseTagInfo, reco::IsolatedTauTagInfoRef> rb_it;
Expand Down Expand Up @@ -314,6 +325,8 @@ namespace DataFormats_BTauReco {
edm::reftobase::RefHolder<reco::CandSecondaryVertexTagInfoFwdRef> rbh_casvf;
edm::reftobase::Holder<reco::BaseTagInfo, reco::BoostedDoubleSVTagInfoFwdRef> rb_bdsvf;
edm::reftobase::RefHolder<reco::BoostedDoubleSVTagInfoFwdRef> rbh_bdsvf;
edm::reftobase::Holder<reco::BaseTagInfo, reco::ShallowTagInfoFwdRef> rb_dnnf;
edm::reftobase::RefHolder<reco::ShallowTagInfoFwdRef> rbh_dnnf;
edm::reftobase::Holder<reco::BaseTagInfo, reco::CombinedTauTagInfoFwdRef> rb_ctf;
edm::reftobase::RefHolder<reco::CombinedTauTagInfoFwdRef> rbh_ctf;
edm::reftobase::Holder<reco::BaseTagInfo, reco::IsolatedTauTagInfoFwdRef> rb_itf;
Expand Down
14 changes: 14 additions & 0 deletions DataFormats/BTauReco/src/classes_def.xml
Expand Up @@ -71,6 +71,16 @@
<class name="reco::BoostedDoubleSVTagInfoRefVector"/>
<class name="edm::Wrapper<reco::BoostedDoubleSVTagInfoCollection>"/>

<class name="reco::ShallowTagInfo" ClassVersion="3">
<version ClassVersion="3" checksum="3123030258"/>
</class>
<class name="reco::ShallowTagInfoCollection"/>
<class name="reco::ShallowTagInfoRef"/>
<class name="reco::ShallowTagInfoFwdRef"/>
<class name="reco::ShallowTagInfoRefProd"/>
<class name="reco::ShallowTagInfoRefVector"/>
<class name="edm::Wrapper<reco::ShallowTagInfoCollection>"/>

<class name="reco::CombinedTauTagInfo" ClassVersion="11">
<version ClassVersion="11" checksum="224969361"/>
<version ClassVersion="10" checksum="3920242404"/>
Expand Down Expand Up @@ -318,6 +328,8 @@
<class name="edm::reftobase::RefHolder<reco::CandSecondaryVertexTagInfoRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::BoostedDoubleSVTagInfoRef>" />
<class name="edm::reftobase::RefHolder<reco::BoostedDoubleSVTagInfoRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::ShallowTagInfoRef>" />
<class name="edm::reftobase::RefHolder<reco::ShallowTagInfoRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::CombinedTauTagInfoRef>" />
<class name="edm::reftobase::RefHolder<reco::CombinedTauTagInfoRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::IsolatedTauTagInfoRef>" />
Expand Down Expand Up @@ -349,6 +361,8 @@
<class name="edm::reftobase::RefHolder<reco::CandSecondaryVertexTagInfoFwdRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::BoostedDoubleSVTagInfoFwdRef>" />
<class name="edm::reftobase::RefHolder<reco::BoostedDoubleSVTagInfoFwdRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::ShallowTagInfoFwdRef>" />
<class name="edm::reftobase::RefHolder<reco::ShallowTagInfoFwdRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::CombinedTauTagInfoFwdRef>" />
<class name="edm::reftobase::RefHolder<reco::CombinedTauTagInfoFwdRef>" />
<class name="edm::reftobase::Holder<reco::BaseTagInfo, reco::IsolatedTauTagInfoFwdRef>" />
Expand Down
7 changes: 6 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATJetProducer.cc
Expand Up @@ -35,7 +35,7 @@
#include <vector>
#include <memory>
#include <algorithm>

#include <sstream>

using namespace pat;

Expand Down Expand Up @@ -100,6 +100,11 @@ PATJetProducer::PATJetProducer(const edm::ParameterSet& iConfig) :
if ((pos != std::string::npos) && (pos != label.length() - 7)) {
label.erase(pos+7); // trim a tail after "JetTags"
}
if(it->instance().size()) {
std::stringstream name;
name << label << ":" << it->instance();
label = name.str();
}
discriminatorLabels_.push_back(label);
}
}
Expand Down
7 changes: 6 additions & 1 deletion PhysicsTools/PatAlgos/plugins/PATJetUpdater.cc
Expand Up @@ -20,7 +20,7 @@
#include <vector>
#include <memory>
#include <algorithm>

#include <sstream>

using namespace pat;

Expand Down Expand Up @@ -51,6 +51,11 @@ PATJetUpdater::PATJetUpdater(const edm::ParameterSet& iConfig) :
if ((pos != std::string::npos) && (pos != label.length() - 7)) {
label.erase(pos+7); // trim a tail after "JetTags"
}
if(it->instance().size()) {
std::stringstream name;
name << label << ":" << it->instance();
label = name.str();
}
discriminatorLabels_.push_back(label);
}
}
Expand Down
14 changes: 13 additions & 1 deletion PhysicsTools/PatAlgos/python/producersLayer1/jetProducer_cfi.py
Expand Up @@ -48,7 +48,19 @@
cms.InputTag("pfCombinedMVAV2BJetTags"),
# CTagging
cms.InputTag('pfCombinedCvsLJetTags'),
cms.InputTag('pfCombinedCvsBJetTags')
cms.InputTag('pfCombinedCvsBJetTags'),
# DeepFlavour
cms.InputTag('deepFlavourJetTags:probb'),
cms.InputTag('deepFlavourJetTags:probc'),
cms.InputTag('deepFlavourJetTags:probudsg'),
cms.InputTag('deepFlavourJetTags:probbb'),
cms.InputTag('deepFlavourJetTags:probcc'),
# DeepCMVA
cms.InputTag('deepFlavourCMVAJetTags:probb'),
cms.InputTag('deepFlavourCMVAJetTags:probc'),
cms.InputTag('deepFlavourCMVAJetTags:probudsg'),
cms.InputTag('deepFlavourCMVAJetTags:probbb'),
cms.InputTag('deepFlavourCMVAJetTags:probcc'),
),
# clone tag infos ATTENTION: these take lots of space!
# usually the discriminators from the default algos
Expand Down
40 changes: 40 additions & 0 deletions PhysicsTools/PatAlgos/python/recoLayer0/bTagging_cff.py
Expand Up @@ -27,6 +27,14 @@
# C-Tagging tag infos
, 'pfInclusiveSecondaryVertexFinderCvsLTagInfos'
, 'pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos'
# DeepFlavour
, 'deepNNTagInfos'
, 'deepNNNegativeTagInfos'
, 'deepNNPositiveTagInfos'
# DeepCMVA
, 'deepCMVATagInfos'
, 'deepCMVANegativeTagInfos'
, 'deepCMVAPositiveTagInfos'
# TopTagInfos (unrelated to b tagging)
, 'caTopTagInfos'
]
Expand Down Expand Up @@ -126,6 +134,38 @@
, 'pfCombinedCvsBJetTags' : [["pfImpactParameterTagInfos", "pfInclusiveSecondaryVertexFinderCvsLTagInfos", "softPFMuonsTagInfos", "softPFElectronsTagInfos"]]
, 'pfNegativeCombinedCvsBJetTags' : [["pfImpactParameterTagInfos", "pfInclusiveSecondaryVertexFinderNegativeCvsLTagInfos", "softPFMuonsTagInfos", "softPFElectronsTagInfos"]]
, 'pfPositiveCombinedCvsBJetTags' : [["pfImpactParameterTagInfos", "pfInclusiveSecondaryVertexFinderCvsLTagInfos", "softPFMuonsTagInfos", "softPFElectronsTagInfos"]]
# DeepFlavour
, 'deepFlavourJetTags:probudsg' : [['deepNNTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'deepFlavourJetTags:probb' : [['deepNNTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'deepFlavourJetTags:probc' : [['deepNNTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'deepFlavourJetTags:probbb' : [['deepNNTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'deepFlavourJetTags:probcc' : [['deepNNTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'negativeDeepFlavourJetTags:probudsg' : [['deepNNNegativeTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderNegativeTagInfos']]
, 'negativeDeepFlavourJetTags:probb' : [['deepNNNegativeTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderNegativeTagInfos']]
, 'negativeDeepFlavourJetTags:probc' : [['deepNNNegativeTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderNegativeTagInfos']]
, 'negativeDeepFlavourJetTags:probbb' : [['deepNNNegativeTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderNegativeTagInfos']]
, 'negativeDeepFlavourJetTags:probcc' : [['deepNNNegativeTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderNegativeTagInfos']]
, 'positiveDeepFlavourJetTags:probudsg' : [['deepNNPositiveTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'positiveDeepFlavourJetTags:probb' : [['deepNNPositiveTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'positiveDeepFlavourJetTags:probc' : [['deepNNPositiveTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'positiveDeepFlavourJetTags:probbb' : [['deepNNPositiveTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
, 'positiveDeepFlavourJetTags:probcc' : [['deepNNPositiveTagInfos'], ["pfImpactParameterTagInfos", 'pfInclusiveSecondaryVertexFinderTagInfos']]
# DeepCMVA
, 'deepFlavourCMVAJetTags:probudsg' : [["deepCMVATagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'deepFlavourCMVAJetTags:probb' : [["deepCMVATagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'deepFlavourCMVAJetTags:probc' : [["deepCMVATagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'deepFlavourCMVAJetTags:probbb' : [["deepCMVATagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'deepFlavourCMVAJetTags:probcc' : [["deepCMVATagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'negativeDeepFlavourCMVAJetTags:probudsg' : [["deepCMVANegativeTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderNegativeTagInfos"]]
, 'negativeDeepFlavourCMVAJetTags:probb' : [["deepCMVANegativeTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderNegativeTagInfos"]]
, 'negativeDeepFlavourCMVAJetTags:probc' : [["deepCMVANegativeTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderNegativeTagInfos"]]
, 'negativeDeepFlavourCMVAJetTags:probbb' : [["deepCMVANegativeTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderNegativeTagInfos"]]
, 'negativeDeepFlavourCMVAJetTags:probcc' : [["deepCMVANegativeTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderNegativeTagInfos"]]
, 'positiveDeepFlavourCMVAJetTags:probudsg' : [["deepCMVAPositiveTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'positiveDeepFlavourCMVAJetTags:probb' : [["deepCMVAPositiveTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'positiveDeepFlavourCMVAJetTags:probc' : [["deepCMVAPositiveTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'positiveDeepFlavourCMVAJetTags:probbb' : [["deepCMVAPositiveTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
, 'positiveDeepFlavourCMVAJetTags:probcc' : [["deepCMVAPositiveTagInfos"], ["pfImpactParameterTagInfos","softPFMuonsTagInfos","softPFElectronsTagInfos","pfInclusiveSecondaryVertexFinderTagInfos"]]
# ChargeTagging
, 'pfChargeBJetTags' : [["pfImpactParameterTagInfos", "pfInclusiveSecondaryVertexFinderTagInfos", "softPFMuonsTagInfos", "softPFElectronsTagInfos"]]
}

0 comments on commit b6fc246

Please sign in to comment.