File indexing completed on 2024-04-06 12:04:39
0001 #include "DataFormats/L1Trigger/interface/L1DataEmulDigi.h"
0002 #include <iomanip>
0003
0004 bool L1DataEmulDigi::empty() const {
0005 if (m_sid == m_null || m_cid == m_null)
0006 return true;
0007 bool val = true;
0008 for (int i = 0; i < 2; i++)
0009 val &= (m_location[i] == m_null);
0010 return val;
0011 }
0012
0013 int L1DataEmulDigi::reset() {
0014 m_null = -99;
0015 m_sid = m_null;
0016 m_cid = m_null;
0017 for (int i = 0; i < 3; i++)
0018 m_location[i] = m_null;
0019 m_type = m_null;
0020 std::fill(m_data, m_data + sizeof(m_data) / sizeof(m_data[0]), 0);
0021 std::fill(m_rank, m_rank + sizeof(m_rank) / sizeof(m_rank[0]), m_null);
0022 L1MonitorDigi def;
0023 m_DEpair[0] = def;
0024 m_DEpair[1] = def;
0025 return m_null;
0026 }
0027
0028 L1DataEmulDigi::L1DataEmulDigi() { reset(); }
0029
0030 L1DataEmulDigi::L1DataEmulDigi(int sid, int cid, double x1, double x2, double x3, int n) {
0031 reset();
0032 m_sid = sid;
0033 m_cid = cid;
0034 m_location[0] = x1;
0035 m_location[1] = x2;
0036 m_location[2] = x3;
0037 m_type = n;
0038 }
0039
0040 L1DataEmulDigi::L1DataEmulDigi(int sid,
0041 int cid,
0042 double x1,
0043 double x2,
0044 double x3,
0045 int n,
0046 unsigned int dw,
0047 unsigned int ew,
0048 float dr,
0049 float er,
0050 const L1MonitorDigi& dm,
0051 const L1MonitorDigi& em) {
0052 reset();
0053 m_sid = sid;
0054 m_cid = cid;
0055 m_location[0] = x1;
0056 m_location[1] = x2;
0057 m_location[2] = x3;
0058 m_type = n;
0059 m_data[0] = dw;
0060 m_data[1] = ew;
0061 m_rank[0] = dr;
0062 m_rank[1] = er;
0063 m_DEpair[0] = dm;
0064 m_DEpair[1] = em;
0065 }
0066
0067 L1DataEmulDigi::~L1DataEmulDigi() {}
0068
0069 std::ostream& operator<<(std::ostream& s, const L1DataEmulDigi& de) {
0070 unsigned word[2];
0071 float rankarr[2];
0072 de.data(word);
0073 de.rank(rankarr);
0074 s << "DEdigi"
0075 << " subsystem: " << std::setw(2) << de.sid() << " (cid." << std::setw(2) << de.cid() << ")"
0076 << " location: "
0077 << "(" << std::setw(5) << std::setprecision(2) << de.x1() << "," << std::setw(5) << std::setprecision(2) << de.x2()
0078 << "," << std::setw(5) << std::setprecision(2) << de.x3() << ")"
0079 << " type: " << de.type() << std::hex << std::setfill('0') << " dword:0x" << std::setw(8) << word[0] << " eword:0x"
0080 << std::setw(8) << word[1] << std::dec << std::setfill(' ') << " rank:"
0081 << "(" << std::setw(5) << std::setprecision(2) << rankarr[0] << "," << std::setw(5) << std::setprecision(2)
0082 << rankarr[1] << ")";
0083 return s;
0084 }
0085
0086 GltDEDigi::GltDEDigi() { this->reset(); }
0087
0088 void GltDEDigi::reset() {
0089 const int w64 = 64;
0090 for (int j = 0; j < 2; j++) {
0091 globalDBit[j] = false;
0092 gltDecBits[j].reserve(w64 * 2);
0093 gltTchBits[j].reserve(w64);
0094 for (int i = 0; i < w64; i++) {
0095 gltDecBits[j][i] = false;
0096 gltDecBits[j][i + w64] = false;
0097 gltTchBits[j][i] = false;
0098 }
0099 }
0100 }
0101
0102 GltDEDigi::GltDEDigi(bool glbit[], GltBits dbits[], GltBits tbits[]) { this->set(glbit, dbits, tbits); }
0103
0104 void GltDEDigi::set(bool glbit[], GltBits dbits[], GltBits tbits[]) {
0105 for (int i = 0; i < 2; i++) {
0106 globalDBit[i] = glbit[i];
0107 gltDecBits[i] = dbits[i];
0108 gltTchBits[i] = tbits[i];
0109 }
0110 }
0111
0112 std::ostream& operator<<(std::ostream& s, const GltDEDigi& glt) {
0113 GltDEDigi::GltBits dbits[2], tbits[2];
0114 bool glbit[2];
0115 for (int i = 0; i < 2; i++) {
0116 glbit[i] = glt.globalDBit[i];
0117 dbits[i] = glt.gltDecBits[i];
0118 tbits[i] = glt.gltTchBits[i];
0119 }
0120 s << "GT DEdigi"
0121 << " decision: " << glbit[0];
0122 if (glbit[0] != glbit[1])
0123 s << "(data), " << glbit[1] << "(emul)";
0124 s << "\n data dec-word: ";
0125 for (GltDEDigi::GltBits::const_iterator i = dbits[0].begin(); i != dbits[0].end(); i++)
0126 s << *i;
0127 s << "\n emul dec-word: ";
0128 for (GltDEDigi::GltBits::const_iterator i = dbits[1].begin(); i != dbits[1].end(); i++)
0129 s << *i;
0130 s << "\n data techical: ";
0131 for (GltDEDigi::GltBits::const_iterator i = tbits[0].begin(); i != tbits[0].end(); i++)
0132 s << *i;
0133 s << "\n emul technical: ";
0134 for (GltDEDigi::GltBits::const_iterator i = tbits[1].begin(); i != tbits[1].end(); i++)
0135 s << *i;
0136 return s;
0137 }