23
EMRChannelKey::EMRChannelKey()
24
: _plane(-999), _orientation(-999), _bar(-999), _detector("unknown") {
27
EMRChannelKey::EMRChannelKey(int pl, int o, int b, string d)
28
: _plane(pl), _orientation(o), _bar(b), _detector(d) {
31
EMRChannelKey::~EMRChannelKey() {
34
EMRChannelKey::EMRChannelKey(string keyStr) throw(Exception) {
36
std::stringstream xConv;
40
} catch (Exception e) {
41
throw(Exception(Exception::recoverable,
42
std::string("corrupted EMR Channel Key"),
43
"EMRChannelKey::EMRChannelKey(std::string)"));
47
bool EMRChannelKey::operator==( EMRChannelKey const key ) const {
49
if ( _orientation == key._orientation &&
50
_plane == key._plane &&
52
_detector == key._detector ) {
59
bool EMRChannelKey::operator!=( EMRChannelKey const key ) const {
61
if ( _orientation == key._orientation &&
62
_plane == key._plane &&
64
_detector == key._detector ) {
71
ostream& operator<<( ostream& stream, EMRChannelKey key ) {
73
stream << "EMRChannelKey " << key._plane;
74
stream << " " << key._orientation;
75
stream << " " << key._bar;
76
stream << " " << key._detector;
80
istream& operator>>( istream& stream, EMRChannelKey &key ) throw(Exception) {
83
stream >> xLabel >> key._plane >> key._orientation >> key._bar >> key._detector;
85
if (xLabel != "EMRChannelKey") {
86
throw(Exception(Exception::recoverable,
87
std::string("corrupted EMR Channel Key"),
88
"istream& operator>>(istream& stream, EMRChannelKey)"));
94
string EMRChannelKey::str() {
103
EMRChannelMap::EMRChannelMap() {
23
106
EMRChannelMap::~EMRChannelMap() {
24
for (unsigned int i = 0;i < _emrKey.size();i++) {
107
for (size_t i = 0;i < _emrKey.size();i++) {
25
109
delete _emrKey[i];
29
113
_emrKey.resize(0);
32
bool EMRChannelMap::InitFromFile(string filename) {
116
bool EMRChannelMap::InitializeFromFile(string filename) {
33
118
ifstream stream(filename.c_str());
35
120
Squeak::mout(Squeak::error)
36
<< "Error in EMRChannelMap::InitFromFile : Can't open EMR cabling file "
121
<< "Error in EMRChannelMap::InitializeFromFile : Can't open EMR cabling file "
37
122
<< filename << std::endl;
41
126
EMRChannelKey* emrkey;
42
DAQChannelKey* dbbkey;
127
DAQChannelKey* daqKey;
44
129
while (!stream.eof()) {
45
130
emrkey = new EMRChannelKey();
46
dbbkey = new DAQChannelKey();
47
stream >> *emrkey >> *dbbkey;
131
daqKey = new DAQChannelKey();
132
stream >> *emrkey >> *daqKey;
49
134
_emrKey.push_back(emrkey);
50
_dbbKey.push_back(dbbkey);
135
_daqKey.push_back(daqKey);
52
137
} catch (Exception e) {
53
138
Squeak::mout(Squeak::error)
54
<< "Error in EMRChannelMap::InitFromFile : Error during loading." << std::endl
139
<< "Error in EMRChannelMap::InitializeFromFile : Error during loading." << std::endl
55
140
<< e.GetMessage() << std::endl;
59
144
if (_emrKey.size() == 0) {
60
145
Squeak::mout(Squeak::error)
61
<< "Error in EMRChannelMap::InitFromFile : Nothing is loaded. " << std::endl;
146
<< "Error in EMRChannelMap::InitializeFromFile : Nothing is loaded. " << std::endl;
67
void EMRChannelMap::InitFromCDB() {}
69
EMRChannelKey* EMRChannelMap::find(DAQChannelKey *daqKey) const {
70
for (unsigned int i = 0;i < _emrKey.size();i++) {
71
if ( _dbbKey[i]->eqType() == daqKey->eqType() &&
72
_dbbKey[i]->ldc() == daqKey->ldc() &&
73
_dbbKey[i]->geo() == daqKey->geo() &&
74
_dbbKey[i]->channel() == daqKey->channel() ) {
152
void EMRChannelMap::InitializeFromCDB() {}
154
EMRChannelKey* EMRChannelMap::Find(DAQChannelKey *daqKey) const {
156
for (size_t i = 0;i < _emrKey.size();i++) {
157
if ( _daqKey[i]->eqType() == daqKey->eqType() &&
158
_daqKey[i]->ldc() == daqKey->ldc() &&
159
_daqKey[i]->geo() == daqKey->geo() &&
160
_daqKey[i]->channel() == daqKey->channel() ) {
75
161
return _emrKey[i];
81
EMRChannelKey* EMRChannelMap::find(std::string daqKeyStr) {
167
EMRChannelKey* EMRChannelMap::Find(std::string daqKeyStr) {
82
169
DAQChannelKey xDaqKey;
83
170
stringstream xConv;
89
176
std::string("corrupted DAQ Channel Key"),
90
177
"EMRChannelMap::find(std::string)"));
92
EMRChannelKey* xKlKey = find(&xDaqKey);
179
EMRChannelKey* xKlKey = Find(&xDaqKey);
96
int EMRChannelMap::getOrientation(int plane) {
97
for (unsigned int i = 0;i < _emrKey.size();i++) {
98
if ( _emrKey[i]->plane() == plane )
99
return _emrKey[i]->orientation();
183
int EMRChannelMap::GetOrientation(int plane) {
185
for (size_t i = 0;i < _emrKey.size();i++) {
186
if ( _emrKey[i]->GetPlane() == plane )
187
return _emrKey[i]->GetOrientation();
104
//////////////////////////////////////////////////////////////////////////
106
EMRChannelKey::EMRChannelKey(string keyStr) throw(Exception) {
107
std::stringstream xConv;
111
}catch(Exception e) {
112
throw(Exception(Exception::recoverable,
113
std::string("corrupted EMR Channel Key"),
114
"EMRChannelKey::EMRChannelKey(std::string)"));
118
bool EMRChannelKey::operator==( EMRChannelKey const key ) const {
119
if ( _orientation == key._orientation &&
120
_plane == key._plane &&
122
_detector == key._detector) {
129
bool EMRChannelKey::operator!=( EMRChannelKey const key ) const {
130
if ( _orientation == key._orientation &&
131
_plane == key._plane &&
133
_detector == key._detector) {
140
ostream& operator<<( ostream& stream, EMRChannelKey key ) {
141
stream << "EMRChannelKey " << key._plane;
142
stream << " " << key._orientation;
143
stream << " " << key._bar;
144
stream << " " << key._detector;
148
istream& operator>>( istream& stream, EMRChannelKey &key ) throw(Exception) {
150
stream >> xLabel >> key._plane >> key._orientation >> key._bar >> key._detector;
152
if (xLabel != "EMRChannelKey") {
153
throw(Exception(Exception::recoverable,
154
std::string("corrupted EMR Channel Key"),
155
"istream& operator>>(istream& stream, EMRChannelKey)"));
161
string EMRChannelKey::str() {
193
void EMRChannelMap::Print() {
195
for (size_t i = 0; i < _emrKey.size(); i++)
196
std::cerr << *(_emrKey[i]) << " " << *(_daqKey[i]) << std::endl;