Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
847 additions
and
1 deletion.
There are no files selected for viewing
61 changes: 61 additions & 0 deletions
61
DataFormats/BTauReco/interface/HiggsInteractionNetFeatures.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,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
15
DataFormats/BTauReco/interface/HiggsInteractionNetTagInfo.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,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 |
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
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.