File indexing completed on 2024-04-06 12:03:59
0001
0002
0003
0004
0005
0006
0007 #include "DataFormats/CSCDigi/interface/CSCWireDigi.h"
0008 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0009 #include <iostream>
0010 #include <cstdint>
0011
0012
0013
0014 CSCWireDigi::CSCWireDigi(int wire, unsigned int tbinb) {
0015
0016 wire_ = wire & 0x0000FFFF;
0017 tbinb_ = tbinb;
0018
0019 wireBX_ = (wire >> 16) & 0x0000FFFF;
0020
0021 wireBXandWires_ = wire;
0022 }
0023
0024
0025 CSCWireDigi::CSCWireDigi() {
0026 wire_ = 0;
0027 tbinb_ = 0;
0028 wireBX_ = 0;
0029 wireBXandWires_ = 0;
0030 }
0031
0032
0033 int CSCWireDigi::getBeamCrossingTag() const { return getTimeBin(); }
0034
0035 int CSCWireDigi::getTimeBin() const {
0036 uint32_t tbit = 1;
0037 int tbin = -1;
0038 for (int i = 0; i < 32; i++) {
0039 if (tbit & tbinb_)
0040 tbin = i;
0041 if (tbin > -1)
0042 break;
0043 tbit = tbit << 1;
0044 }
0045 return tbin;
0046 }
0047
0048 std::vector<int> CSCWireDigi::getTimeBinsOn() const {
0049 std::vector<int> tbins;
0050 uint32_t tbit = tbinb_;
0051 uint32_t one = 1;
0052 for (int i = 0; i < 32; i++) {
0053 if (tbit & one)
0054 tbins.push_back(i);
0055 tbit = tbit >> 1;
0056 if (tbit == 0)
0057 break;
0058 }
0059 return tbins;
0060 }
0061
0062
0063
0064 void CSCWireDigi::print() const {
0065 std::ostringstream ost;
0066 ost << "CSCWireDigi | wg " << getWireGroup() << " | "
0067 << " BX # " << getWireGroupBX() << " | "
0068 << " BX + Wire " << std::hex << getBXandWireGroup() << " | " << std::dec << " First Time Bin On " << getTimeBin()
0069 << " | Time Bins On ";
0070 std::vector<int> tbins = getTimeBinsOn();
0071 std::copy(tbins.begin(), tbins.end(), std::ostream_iterator<int>(ost, " "));
0072 edm::LogVerbatim("CSCDigi") << ost.str();
0073 }
0074
0075 std::ostream& operator<<(std::ostream& o, const CSCWireDigi& digi) {
0076 o << " CSCWireDigi wg: " << digi.getWireGroup() << ", First Time Bin On: " << digi.getTimeBin() << ", Time Bins On: ";
0077 std::vector<int> tbins = digi.getTimeBinsOn();
0078 std::copy(tbins.begin(), tbins.end(), std::ostream_iterator<int>(o, " "));
0079 return o;
0080 }