Skip to content

Commit ca8ac03

Browse files
authored
Merge pull request #48020 from iarspider/print_jettagclass
Add ability to output JetTagClass to std::ostream
2 parents 133c4a6 + 686e845 commit ca8ac03

File tree

1 file changed

+10
-0
lines changed
  • DataFormats/L1TParticleFlow/interface

1 file changed

+10
-0
lines changed

DataFormats/L1TParticleFlow/interface/jets.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "DataFormats/L1TParticleFlow/interface/gt_datatypes.h"
66
#include "DataFormats/L1TParticleFlow/interface/bit_encoding.h"
77
#include <array>
8+
#include <algorithm>
89
#include <cstdint>
910
#include <vector>
1011
#include <unordered_map>
@@ -33,6 +34,15 @@ namespace l1ct {
3334
JetTagClassValue value_;
3435
static const std::unordered_map<std::string, JetTagClassValue> labels_;
3536

37+
friend std::ostream &operator<<(std::ostream &ost, const l1ct::JetTagClass &jtc) {
38+
auto it = std::find_if(
39+
std::begin(jtc.labels_), std::end(jtc.labels_), [&jtc](auto &&p) { return p.second == jtc.value_; });
40+
if (it != std::end(jtc.labels_)) {
41+
ost << it->first;
42+
}
43+
return ost;
44+
}
45+
3646
}; // JetTagClass
3747

3848
// Define a separate class/struct for jet tag handling

0 commit comments

Comments
 (0)