File indexing completed on 2024-04-06 11:58:17
0001
0002
0003
0004
0005
0006
0007
0008 #include <cstdint>
0009 #include <set>
0010 #include <iostream>
0011 #include <cassert>
0012 #include <cstdlib>
0013 #include "CalibFormats/SiPixelObjects/interface/PixelROCStatus.h"
0014
0015 using namespace std;
0016 using namespace pos;
0017
0018
0019 PixelROCStatus::PixelROCStatus() : bits_(0) {}
0020
0021
0022 PixelROCStatus::PixelROCStatus(const std::set<ROCstatus>& stat) {
0023 std::set<ROCstatus>::const_iterator i = stat.begin();
0024
0025 for (; i != stat.end(); ++i) {
0026 set(*i);
0027 }
0028 }
0029
0030
0031 PixelROCStatus::~PixelROCStatus() {}
0032
0033
0034 void PixelROCStatus::set(ROCstatus stat) {
0035 reset();
0036 bits_ = bits_ | (1 << stat);
0037 }
0038
0039
0040 void PixelROCStatus::clear(ROCstatus stat) { bits_ = bits_ & (0 << stat); }
0041
0042
0043
0044 void PixelROCStatus::reset(void) { bits_ = 0; }
0045
0046
0047 void PixelROCStatus::set(ROCstatus stat, bool mode) {
0048 reset();
0049 if (mode) {
0050 set(stat);
0051 } else {
0052 clear(stat);
0053 }
0054 }
0055
0056
0057 bool PixelROCStatus::get(ROCstatus stat) const { return bits_ & (1 << stat); }
0058
0059
0060 string PixelROCStatus::statusName(ROCstatus stat) const {
0061 if (stat == off)
0062 return "off";
0063 if (stat == noHits)
0064 return "noHits";
0065 if (stat == noInit)
0066 return "noInit";
0067 if (stat == noAnalogSignal)
0068 return "noAnalogSignal";
0069 assert(0);
0070 return "";
0071 }
0072
0073
0074
0075 string PixelROCStatus::statusName() const {
0076 string result = "";
0077 for (ROCstatus istat = off; istat != nStatus; istat = ROCstatus(istat + 1)) {
0078 if (get(istat)) {
0079 result += statusName(istat);
0080 }
0081 }
0082 return result;
0083 }
0084
0085
0086 void PixelROCStatus::set(const string& statName) {
0087 if (!statName.empty()) {
0088 for (ROCstatus istat = off; istat != nStatus; istat = ROCstatus(istat + 1)) {
0089 if (statName == statusName(istat)) {
0090 set(istat);
0091 return;
0092 }
0093 }
0094 cout << "[PixelROCStatus::set()] statName |" << statName << "| is an invalid keyword" << endl;
0095 ::abort();
0096 } else {
0097 reset();
0098 }
0099 }