Skip to content

Commit

Permalink
add Higgs IN tagger
Browse files Browse the repository at this point in the history
  • Loading branch information
jmduarte committed Jun 21, 2020
1 parent a89f2b2 commit 3650105
Show file tree
Hide file tree
Showing 13 changed files with 847 additions and 1 deletion.
61 changes: 61 additions & 0 deletions DataFormats/BTauReco/interface/HiggsInteractionNetFeatures.h
@@ -0,0 +1,61 @@
#ifndef DataFormats_BTauReco_HiggsInteractionNetFeatures_h
#define DataFormats_BTauReco_HiggsInteractionNetFeatures_h

#include <string>
#include <vector>
#include <unordered_map>
#include "FWCore/Utilities/interface/Exception.h"

namespace btagbtvdeep {

class HiggsInteractionNetFeatures {
public:
bool empty() const { return is_empty_; }

void add(const std::string& name) { feature_map_[name]; }

void reserve(const std::string& name, unsigned capacity) { feature_map_[name].reserve(capacity); }

void fill(const std::string& name, float value) {
auto item = feature_map_.find(name);
if (item != feature_map_.end()) {
item->second.push_back(value);
is_empty_ = false;
} else {
throw cms::Exception("InvalidArgument")
<< "[HiggsInteractionNetFeatures::fill()] Feature " << name << " has not been registered";
}
}

void set(const std::string& name, const std::vector<float>& vec) { feature_map_[name] = vec; }

void check_consistency(const std::vector<std::string>& names) const {
if (names.empty())
return;
const auto ref_len = get(names.front()).size();
for (unsigned i = 1; i < names.size(); ++i) {
if (get(names[i]).size() != ref_len) {
throw cms::Exception("InvalidArgument")
<< "[HiggsInteractionNetFeatures::check_consistency()] Inconsistent variable length " << get(names[i]).size()
<< " for " << names[i] << ", should be " << ref_len;
}
}
}

const std::vector<float>& get(const std::string& name) const {
auto item = feature_map_.find(name);
if (item != feature_map_.end()) {
return item->second;
} else {
throw cms::Exception("InvalidArgument") << "[HiggsInteractionNetFeatures::get()] Feature " << name << " does not exist!";
}
}

private:
bool is_empty_ = true;
std::unordered_map<std::string, std::vector<float>> feature_map_;
};

} // namespace btagbtvdeep

#endif // DataFormats_BTauReco_HiggsInteractionNetFeatures_h
15 changes: 15 additions & 0 deletions DataFormats/BTauReco/interface/HiggsInteractionNetTagInfo.h
@@ -0,0 +1,15 @@
#ifndef DataFormats_BTauReco_HiggsInteractionNetTagInfo_h
#define DataFormats_BTauReco_HiggsInteractionNetTagInfo_h

#include "DataFormats/BTauReco/interface/FeaturesTagInfo.h"
#include "DataFormats/BTauReco/interface/HiggsInteractionNetFeatures.h"

namespace reco {

typedef FeaturesTagInfo<btagbtvdeep::HiggsInteractionNetFeatures> HiggsInteractionNetTagInfo;

DECLARE_EDM_REFS(HiggsInteractionNetTagInfo)

} // namespace reco

#endif // DataFormats_BTauReco_HiggsInteractionNetTagInfo_h
2 changes: 2 additions & 0 deletions DataFormats/BTauReco/src/classes.h
Expand Up @@ -63,6 +63,8 @@
#include "DataFormats/BTauReco/interface/DeepFlavourTagInfo.h"
#include "DataFormats/BTauReco/interface/DeepDoubleXFeatures.h"
#include "DataFormats/BTauReco/interface/DeepDoubleXTagInfo.h"
#include "DataFormats/BTauReco/interface/HiggsInteractionNetFeatures.h"
#include "DataFormats/BTauReco/interface/HiggsInteractionNetTagInfo.h"
#include "DataFormats/BTauReco/interface/DeepBoostedJetTagInfo.h"
#include "DataFormats/BTauReco/interface/PixelClusterTagInfo.h"

Expand Down
9 changes: 9 additions & 0 deletions DataFormats/BTauReco/src/classes_def.xml
Expand Up @@ -465,6 +465,15 @@
<class name="reco::DeepBoostedJetTagInfoRefVector"/>
<class name="edm::Wrapper<reco::DeepBoostedJetTagInfoCollection>" persistent="false"/>

<class name="btagbtvdeep::HiggsInteractionNetFeatures"/>
<class name="reco::HiggsInteractionNetTagInfo"/>
<class name="reco::HiggsInteractionNetTagInfoCollection"/>
<class name="reco::HiggsInteractionNetTagInfoRef"/>
<class name="reco::HiggsInteractionNetTagInfoFwdRef"/>
<class name="reco::HiggsInteractionNetTagInfoRefProd"/>
<class name="reco::HiggsInteractionNetTagInfoRefVector"/>
<class name="edm::Wrapper<reco::HiggsInteractionNetTagInfoCollection>" persistent="false"/>

<class name="reco::PixelClusterProperties"/>
<class name="reco::PixelClusterData" ClassVersion="3">
<version ClassVersion="3" checksum="525314740"/>
Expand Down
7 changes: 7 additions & 0 deletions PhysicsTools/PatAlgos/python/recoLayer0/bTagging_cff.py
Expand Up @@ -49,6 +49,8 @@
, 'pfParticleNetTagInfos'
# Pixel Cluster tag infos
, 'pixelClusterTagInfos'
# HiggsInteractionNet tag infos
, 'pfHiggsInteractionNetTagInfos'
]
# extend for "internal use" in PAT/MINIAOD (renaming)
supportedBtagInfos.append( 'caTopTagInfosPAT' )
Expand Down Expand Up @@ -247,3 +249,8 @@
for disc in _pfMassDecorrelatedParticleNetJetTagsMetaDiscrs:
supportedMetaDiscr[disc] = _pfMassDecorrelatedParticleNetJetTagsProbs
# -----------------------------------
# setup HiggsInteractionNet
from RecoBTag.ONNXRuntime.pfHiggsInteractionNet_cff import _pfHiggsInteractionNetTagsProbs
# update supportedBtagDiscr
for disc in _pfHiggsInteractionNetTagsProbs:
supportedBtagDiscr[disc] = [["pfHiggsInteractionNetTagInfos"]]
Expand Up @@ -43,6 +43,7 @@ def applyDeepBtagging( process, postfix="" ) :
delattr(process, 'selectedUpdatedPatJetsSlimmedDeepFlavour'+postfix)

from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import _pfDeepBoostedJetTagsAll as pfDeepBoostedJetTagsAll
from RecoBTag.ONNXRuntime.pfHiggsInteractionNet_cff import _pfHiggsInteractionNetTagsProbs as pfHiggsInteractionNetTagsProbs
from RecoBTag.MXNet.pfParticleNet_cff import _pfParticleNetJetTagsAll as pfParticleNetJetTagsAll

# update slimmed jets to include particle-based deep taggers (keep same name)
Expand All @@ -61,7 +62,7 @@ def applyDeepBtagging( process, postfix="" ) :
'pfMassIndependentDeepDoubleCvLJetTags:probHcc',
'pfMassIndependentDeepDoubleCvBJetTags:probHbb',
'pfMassIndependentDeepDoubleCvBJetTags:probHcc',
) + pfDeepBoostedJetTagsAll + pfParticleNetJetTagsAll
) + pfDeepBoostedJetTagsAll + pfParticleNetJetTagsAll + pfHiggsInteractionNetTagsProbs
)
updateJetCollection(
process,
Expand Down
10 changes: 10 additions & 0 deletions PhysicsTools/PatAlgos/python/tools/jetTools.py
Expand Up @@ -650,6 +650,16 @@ def setupBTagging(process, jetSource, pfCandidates, explicitJTA, pvSource, svSou
),
process, task)

if btagInfo == 'pfHiggsInteractionNetTagInfos':
addToProcessAndTask(btagPrefix+btagInfo+labelName+postfix,
btag.pfHiggsInteractionNetTagInfos.clone(
jets = jetSource,
vertices = pvSource,
secondary_vertices = svSource,
pf_candidates = pfCandidates,
),
process, task)

if btagInfo == 'pfDeepBoostedJetTagInfos':
if pfCandidates.value() == 'packedPFCandidates':
# case 1: running over jets whose daughters are PackedCandidates (only via updateJetCollection for now)
Expand Down
1 change: 1 addition & 0 deletions RecoBTag/Configuration/python/RecoBTag_cff.py
Expand Up @@ -10,6 +10,7 @@
from RecoBTag.ONNXRuntime.pfDeepFlavour_cff import *
from RecoBTag.ONNXRuntime.pfDeepDoubleX_cff import *
from RecoBTag.ONNXRuntime.pfDeepBoostedJet_cff import *
from RecoBTag.ONNXRuntime.pfHiggsInteractionNet_cff import *
from RecoBTag.MXNet.pfParticleNet_cff import *
from RecoVertex.AdaptiveVertexFinder.inclusiveVertexing_cff import *
from RecoBTag.PixelCluster.pixelClusterTagInfos_cfi import *
Expand Down

0 comments on commit 3650105

Please sign in to comment.