Skip to content

Commit 6fc2f50

Browse files
committed
Add ability to output JetTagClass to std::ostream
1 parent 090d315 commit 6fc2f50

File tree

1 file changed

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

1 file changed

+13
-0
lines changed

DataFormats/L1TParticleFlow/interface/jets.h

Lines changed: 13 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,18 @@ 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+
std::string res = "";
39+
auto it = std::find_if(
40+
std::begin(jtc.labels_), std::end(jtc.labels_), [&jtc](auto &&p) { return p.second == jtc.value_; });
41+
if (it != std::end(jtc.labels_)) {
42+
res = it->first;
43+
}
44+
45+
ost << res;
46+
return ost;
47+
}
48+
3649
}; // JetTagClass
3750

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

0 commit comments

Comments
 (0)