File indexing completed on 2024-04-06 12:10:47
0001 #ifndef EventFilter_L1TRawToDigi_Omtf_EleIndex_H
0002 #define EventFilter_L1TRawToDigi_Omtf_EleIndex_H
0003
0004 #include <cstdint>
0005 #include <string>
0006 #include <ostream>
0007
0008 namespace omtf {
0009 class EleIndex {
0010 public:
0011 EleIndex() : packed_(0) {}
0012 EleIndex(const std::string &board, unsigned int link) {
0013 unsigned int fed = 0;
0014 if (board.substr(4, 1) == "n")
0015 fed = 1380;
0016 else if (board.substr(4, 1) == "p")
0017 fed = 1381;
0018 unsigned int amc = std::stoi(board.substr(5, 1));
0019 packed_ = fed * 1000 + amc * 100 + link;
0020 }
0021 EleIndex(unsigned int fed, unsigned int amc, unsigned int link) { packed_ = fed * 1000 + amc * 100 + link; }
0022 unsigned int fed() const { return packed_ / 1000; }
0023 unsigned int amc() const { return ((packed_ / 100) % 10); }
0024 unsigned int link() const { return packed_ % 100; }
0025 friend std::ostream &operator<<(std::ostream &out, const EleIndex &o) {
0026 out << "OMTF";
0027 if (o.fed() == 1380)
0028 out << "n";
0029 if (o.fed() == 1381)
0030 out << "p";
0031 out << o.amc();
0032 out << " (fed: " << o.fed() << "), ln: " << o.link();
0033 return out;
0034 }
0035 inline bool operator<(const EleIndex &o) const { return this->packed_ < o.packed_; }
0036
0037 private:
0038 uint32_t packed_;
0039 };
0040
0041 }
0042 #endif