File indexing completed on 2024-04-06 12:05:14
0001
0002 #include "DataFormats/SiStripCommon/interface/SiStripEventSummary.h"
0003 #include "DataFormats/SiStripCommon/interface/SiStripEnumsAndStrings.h"
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 #include <iostream>
0006 #include <iomanip>
0007
0008 using namespace sistrip;
0009
0010
0011
0012 SiStripEventSummary::SiStripEventSummary()
0013 : valid_(true),
0014 triggerFed_(0),
0015 runType_(sistrip::UNDEFINED_RUN_TYPE),
0016 event_(0),
0017 bx_(0),
0018 spillNumber_(0),
0019 nDataSenders_(0),
0020 fedReadoutMode_(sistrip::UNDEFINED_FED_READOUT_MODE),
0021 apvReadoutMode_(sistrip::UNDEFINED_APV_READOUT_MODE),
0022 apveAddress_(0),
0023 nApvsInSync_(0),
0024 nApvsOutOfSync_(0),
0025 nApvsErrors_(0),
0026 params_(5, 0) {
0027 ;
0028 }
0029
0030
0031
0032 void SiStripEventSummary::commissioningInfo(const uint32_t* const buffer, const uint32_t& event) {
0033
0034 uint16_t run = static_cast<uint16_t>(buffer[10] & 0xFFFF);
0035 runType_ = SiStripEnumsAndStrings::runType(run);
0036
0037
0038 spillNumber_ = buffer[0];
0039
0040
0041 nDataSenders_ = buffer[20];
0042
0043
0044 if (buffer[15] == 0) {
0045 fedReadoutMode_ = sistrip::FED_SCOPE_MODE;
0046 } else if (buffer[15] == 1) {
0047 fedReadoutMode_ = sistrip::FED_VIRGIN_RAW;
0048 } else if (buffer[15] == 2) {
0049 fedReadoutMode_ = sistrip::FED_PROC_RAW;
0050 } else if (buffer[15] == 3) {
0051 fedReadoutMode_ = sistrip::FED_ZERO_SUPPR;
0052 } else if (buffer[15] == 4) {
0053 fedReadoutMode_ = sistrip::FED_ZERO_SUPPR_LITE;
0054 } else {
0055 fedReadoutMode_ = sistrip::UNKNOWN_FED_READOUT_MODE;
0056 }
0057
0058
0059 if (runType_ == sistrip::CALIBRATION || runType_ == sistrip::CALIBRATION_DECO ||
0060 runType_ == sistrip::CALIBRATION_SCAN || runType_ == sistrip::CALIBRATION_SCAN_DECO ||
0061 runType_ == sistrip::APV_LATENCY) {
0062 params_[0] = buffer[11];
0063 params_[1] = buffer[12];
0064 params_[2] = buffer[13];
0065 params_[3] = buffer[15];
0066 params_[4] = buffer[16];
0067
0068 } else if (runType_ == sistrip::OPTO_SCAN) {
0069 params_[0] = buffer[11];
0070 params_[1] = buffer[12];
0071
0072 } else if (runType_ == sistrip::APV_TIMING || runType_ == sistrip::FED_TIMING) {
0073 params_[0] = buffer[11];
0074 params_[1] = buffer[12];
0075 params_[2] = buffer[13];
0076 } else if (runType_ == sistrip::FINE_DELAY ||
0077 runType_ == sistrip::FINE_DELAY_PLL || runType_ == sistrip::FINE_DELAY_TTC) {
0078 params_[0] = buffer[11];
0079 params_[1] = buffer[12];
0080 params_[2] = buffer[13];
0081 params_[3] = buffer[14];
0082
0083 } else if (runType_ == sistrip::FAST_CABLING) {
0084 params_[0] = buffer[11];
0085 params_[1] = buffer[12];
0086 params_[2] = buffer[13];
0087 params_[3] = buffer[14];
0088
0089 } else if (runType_ == sistrip::FED_CABLING || runType_ == sistrip::QUITE_FAST_CABLING) {
0090 if (runType_ == sistrip::QUITE_FAST_CABLING) {
0091 uint16_t ii = 0;
0092 bool found = false;
0093 while (!found && ii < 20) {
0094 uint32_t dcu = buffer[21 + 3 * ii];
0095 uint32_t key = buffer[21 + 3 * ii + 1];
0096 uint32_t evt = buffer[21 + 3 * ii + 2];
0097 if (evt == event) {
0098 params_[0] = key;
0099 params_[1] = 0;
0100 params_[2] = 0;
0101 params_[3] = dcu;
0102 found = true;
0103 }
0104 ii++;
0105 }
0106 if (!found) {
0107 if (edm::isDebugEnabled()) {
0108 std::stringstream ss;
0109 ss << "[SiStripEventSummary::" << __func__ << "]"
0110 << " Did not find DeviceId/DCUid for event " << event << "!";
0111 edm::LogWarning(mlDigis_) << ss.str();
0112 }
0113 params_[0] = 0;
0114 params_[1] = 0;
0115 params_[2] = 0;
0116 params_[3] = 0;
0117 } else {
0118 if (edm::isDebugEnabled()) {
0119 std::stringstream ss;
0120 ss << "[SiStripEventSummary::" << __func__ << "]"
0121 << " Found DeviceId/DCUid for event " << event << ": 0x" << std::hex << std::setw(8) << std::setfill('0')
0122 << params_[0] << std::dec << "/0x" << std::hex << std::setw(8) << std::setfill('0') << params_[3]
0123 << std::dec;
0124 LogTrace(mlDigis_) << ss.str();
0125 }
0126 }
0127
0128 } else {
0129 params_[0] = buffer[11];
0130 params_[1] = buffer[12];
0131 params_[2] = buffer[13];
0132 params_[3] = buffer[14];
0133 }
0134
0135 } else if (runType_ == sistrip::VPSP_SCAN) {
0136 params_[0] = buffer[11];
0137 params_[1] = buffer[12];
0138
0139 } else if (runType_ == sistrip::DAQ_SCOPE_MODE) {
0140
0141
0142 } else if (runType_ == sistrip::PHYSICS || runType_ == sistrip::PHYSICS_ZS || runType_ == sistrip::PEDESTALS) {
0143
0144
0145 } else {
0146 if (edm::isDebugEnabled()) {
0147 edm::LogWarning(mlDigis_) << "[SiStripEventSummary::" << __func__ << "]"
0148 << " Unexpected commissioning task: " << runType_;
0149 }
0150 }
0151 }
0152
0153
0154
0155
0156
0157
0158 void SiStripEventSummary::commissioningInfo(const uint32_t& daq1, const uint32_t& daq2) {
0159
0160 uint16_t temp = static_cast<uint16_t>((daq1 >> 8) & 0x3);
0161 if (temp == uint16_t(1)) {
0162 valid_ = true;
0163 } else if (temp == uint16_t(2)) {
0164 valid_ = false;
0165 } else if (temp == uint16_t(3) && daq1 == sistrip::invalid32_) {
0166 if (edm::isDebugEnabled()) {
0167 edm::LogWarning(mlDigis_) << "[SiStripEventSummary::" << __func__ << "]"
0168 << " DAQ register contents set to invalid: 0x" << std::hex << std::setw(8)
0169 << std::setfill('0') << daq1 << std::dec;
0170 }
0171 valid_ = false;
0172 } else {
0173 if (edm::isDebugEnabled()) {
0174 edm::LogWarning(mlDigis_) << "[SiStripEventSummary::" << __func__ << "]"
0175 << " Unexpected bit pattern set in DAQ1: 0x" << std::hex << std::setw(8)
0176 << std::setfill('0') << daq1 << std::dec;
0177 }
0178 valid_ = false;
0179 }
0180
0181
0182 uint16_t run = static_cast<uint16_t>(daq1 & 0xFF);
0183 runType_ = SiStripEnumsAndStrings::runType(run);
0184
0185
0186 if (runType_ == sistrip::PHYSICS) {
0187 } else if (runType_ == sistrip::PHYSICS_ZS) {
0188 } else if (runType_ == sistrip::PEDESTALS) {
0189 } else if (runType_ == sistrip::DAQ_SCOPE_MODE) {
0190 } else if (runType_ == sistrip::CALIBRATION or runType_ == sistrip::CALIBRATION_DECO) {
0191 params_[0] = (daq2 >> 8) & 0xFF;
0192 params_[1] = (daq2 >> 4) & 0x0F;
0193 params_[2] = (daq2 >> 0) & 0x0F;
0194 } else if (runType_ == sistrip::CALIBRATION_SCAN or runType_ == sistrip::CALIBRATION_SCAN_DECO) {
0195 params_[0] = (daq2 >> 8) & 0xFF;
0196 params_[1] = (daq2 >> 4) & 0x0F;
0197 params_[2] = (daq2 >> 0) & 0x0F;
0198 params_[3] = (daq2 >> 16) & 0xFF;
0199 params_[4] = (daq2 >> 24);
0200 } else if (runType_ == sistrip::OPTO_SCAN) {
0201 params_[0] = (daq2 >> 8) & 0xFF;
0202 params_[1] = (daq2 >> 0) & 0xFF;
0203 } else if (runType_ == sistrip::APV_TIMING) {
0204 params_[1] = (daq2 >> 0) & 0xFF;
0205 } else if (runType_ == sistrip::APV_LATENCY) {
0206 params_[0] = (daq2 >> 0) & 0xFF;
0207 } else if (runType_ == sistrip::FINE_DELAY_PLL) {
0208 } else if (runType_ == sistrip::FINE_DELAY_TTC) {
0209 } else if (runType_ == sistrip::FINE_DELAY) {
0210 params_[2] = (daq2 >> 0) & 0xFFFF;
0211 params_[0] = params_[2] / 25;
0212 params_[1] = uint32_t((params_[2] % 25) * 24. / 25.);
0213 params_[3] = (daq2 >> 0) & 0xFFFF0000;
0214 } else if (runType_ == sistrip::FED_TIMING) {
0215 params_[1] = (daq2 >> 0) & 0xFF;
0216 } else if (runType_ == sistrip::VPSP_SCAN) {
0217 params_[0] = (daq2 >> 8) & 0xFF;
0218 params_[1] = (daq2 >> 0) & 0xFF;
0219 } else if (runType_ == sistrip::FED_CABLING) {
0220 } else if (runType_ == sistrip::QUITE_FAST_CABLING) {
0221 } else if (runType_ == sistrip::FAST_CABLING) {
0222 params_[0] = (daq2 >> 0) & 0xFF;
0223 } else {
0224 if (edm::isDebugEnabled()) {
0225 edm::LogWarning(mlDigis_) << "[SiStripEventSummary::" << __func__ << "]"
0226 << " Unexpected commissioning task: " << runType_;
0227 }
0228 }
0229 }
0230
0231
0232
0233 void SiStripEventSummary::fedReadoutMode(const uint16_t& mode) {
0234 if (mode == 1) {
0235 fedReadoutMode_ = sistrip::FED_SCOPE_MODE;
0236 } else if (mode == 2) {
0237 fedReadoutMode_ = sistrip::FED_VIRGIN_RAW;
0238 } else if (mode == 6) {
0239 fedReadoutMode_ = sistrip::FED_PROC_RAW;
0240 } else if (mode == 10) {
0241 fedReadoutMode_ = sistrip::FED_ZERO_SUPPR;
0242 } else if (mode == 12) {
0243 fedReadoutMode_ = sistrip::FED_ZERO_SUPPR_LITE;
0244 } else {
0245 fedReadoutMode_ = sistrip::UNKNOWN_FED_READOUT_MODE;
0246 }
0247 }
0248
0249
0250
0251 std::ostream& operator<<(std::ostream& os, const SiStripEventSummary& input) {
0252 return os << "[SiStripEventSummary::" << __func__ << "]" << std::endl
0253 << " isSet : " << std::boolalpha << input.isSet() << std::noboolalpha << std::endl
0254 << " Trigger FED id : " << input.triggerFed() << std::endl
0255 << " isValid : " << std::boolalpha << input.valid() << std::noboolalpha << std::endl
0256 << " Run type : " << SiStripEnumsAndStrings::runType(input.runType()) << std::endl
0257 << " Event number : " << input.event() << std::endl
0258 << " Bunch crossing : " << input.bx() << std::endl
0259 << " FED readout mode : " << SiStripEnumsAndStrings::fedReadoutMode(input.fedReadoutMode()) << std::endl
0260 << " APV readout mode : " << SiStripEnumsAndStrings::apvReadoutMode(input.apvReadoutMode()) << std::endl
0261 << " Commissioning params : " << input.params()[0] << ", " << input.params()[1] << ", " << input.params()[2]
0262 << ", " << input.params()[3] << std::endl;
0263 }