1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
|
//
// This class keeps the possible non-standard
// status a ROC can have.
//
//
//
#include <cstdint>
#include <set>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include "CalibFormats/SiPixelObjects/interface/PixelROCStatus.h"
using namespace std;
using namespace pos;
//======================================================================================
PixelROCStatus::PixelROCStatus() : bits_(0) {}
//======================================================================================
PixelROCStatus::PixelROCStatus(const std::set<ROCstatus>& stat) {
std::set<ROCstatus>::const_iterator i = stat.begin();
for (; i != stat.end(); ++i) {
set(*i);
}
}
//======================================================================================
PixelROCStatus::~PixelROCStatus() {}
//======================================================================================
void PixelROCStatus::set(ROCstatus stat) {
reset();
bits_ = bits_ | (1 << stat);
}
//======================================================================================
void PixelROCStatus::clear(ROCstatus stat) { bits_ = bits_ & (0 << stat); }
//======================================================================================
// Added by Dario (March 4th 2008)
void PixelROCStatus::reset(void) { bits_ = 0; }
//======================================================================================
void PixelROCStatus::set(ROCstatus stat, bool mode) {
reset();
if (mode) {
set(stat);
} else {
clear(stat);
}
}
//======================================================================================
bool PixelROCStatus::get(ROCstatus stat) const { return bits_ & (1 << stat); }
//======================================================================================
string PixelROCStatus::statusName(ROCstatus stat) const {
if (stat == off)
return "off";
if (stat == noHits)
return "noHits";
if (stat == noInit)
return "noInit";
if (stat == noAnalogSignal)
return "noAnalogSignal";
assert(0);
return "";
}
//======================================================================================
// modified by MR on 11-01-2008 15:06:28
string PixelROCStatus::statusName() const {
string result = "";
for (ROCstatus istat = off; istat != nStatus; istat = ROCstatus(istat + 1)) {
if (get(istat)) {
result += statusName(istat);
}
}
return result;
}
//======================================================================================
void PixelROCStatus::set(const string& statName) {
if (!statName.empty()) {
for (ROCstatus istat = off; istat != nStatus; istat = ROCstatus(istat + 1)) {
if (statName == statusName(istat)) {
set(istat);
return;
}
}
cout << "[PixelROCStatus::set()] statName |" << statName << "| is an invalid keyword" << endl;
::abort();
} else {
reset();
}
}
|