1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
3
* MAUS is free software: you can redistribute it and/or modify
4
* it under the terms of the GNU General Public License as published by
5
* the Free Software Foundation, either version 3 of the License, or
6
* (at your option) any later version.
8
* MAUS is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License
14
* along with MAUS. If not, see <http://www.gnu.org/licenses/>.
18
#include "EMRChannelMap.hh"
21
EMRChannelMap::~EMRChannelMap() {
22
for (unsigned int i = 0;i < _emrKey.size();i++) {
30
bool EMRChannelMap::InitFromFile(string filename) {
31
ifstream stream(filename.c_str());
33
Squeak::mout(Squeak::error)
34
<< "Error in EMRChannelMap::InitFromFile : Can't open EMR cabling file "
35
<< filename << std::endl;
39
EMRChannelKey* emrkey;
40
DAQChannelKey* dbbkey;
42
while (!stream.eof()) {
43
emrkey = new EMRChannelKey();
44
dbbkey = new DAQChannelKey();
45
stream >> *emrkey >> *dbbkey;
46
_emrKey.push_back(emrkey);
47
_dbbKey.push_back(dbbkey);
50
Squeak::mout(Squeak::error)
51
<< "Error in EMRChannelMap::InitFromFile : Error during loading." << std::endl
52
<< e.GetMessage() << std::endl;
56
if (_emrKey.size() == 0) {
57
Squeak::mout(Squeak::error)
58
<< "Error in EMRChannelMap::InitFromFile : Nothing is loaded. " << std::endl;
64
void EMRChannelMap::InitFromCDB() {}
66
EMRChannelKey* EMRChannelMap::find(DAQChannelKey *daqKey) {
67
if (daqKey->eqType() == 141) {
68
for (unsigned int i = 0;i < _emrKey.size();i++) {
69
if ( _dbbKey[i]->ldc() == daqKey->ldc() &&
70
_dbbKey[i]->geo() == daqKey->geo() &&
71
_dbbKey[i]->channel() == daqKey->channel() ) {
79
EMRChannelKey* EMRChannelMap::find(std::string daqKeyStr) {
80
DAQChannelKey xDaqKey;
86
throw(Squeal(Squeal::recoverable,
87
std::string("corrupted DAQ Channel Key"),
88
"EMRChannelMap::find(std::string)"));
90
EMRChannelKey* xKlKey = find(&xDaqKey);
95
//////////////////////////////////////////////////////////////////////////
97
EMRChannelKey::EMRChannelKey(string keyStr) throw(Squeal) {
98
std::stringstream xConv;
103
throw(Squeal(Squeal::recoverable,
104
std::string("corrupted EMR Channel Key"),
105
"EMRChannelKey::EMRChannelKey(std::string)"));
109
bool EMRChannelKey::operator==( EMRChannelKey const key ) {
110
if ( _module == key._module &&
111
_plane == key._plane &&
113
_detector == key._detector) {
120
bool EMRChannelKey::operator!=( EMRChannelKey const key ) {
121
if ( _module == key._module &&
122
_plane == key._plane &&
124
_detector == key._detector) {
131
ostream& operator<<( ostream& stream, EMRChannelKey key ) {
132
stream << "EMRChannelKey " << key._module;
133
stream << " " << key._plane;
134
stream << " " << key._bar;
135
stream << " " << key._detector;
139
istream& operator>>( istream& stream, EMRChannelKey &key ) throw(Squeal) {
141
stream >> xLabel >> key._module >> key._plane >> key._bar >> key._detector;
142
if (xLabel != "EMRChannelKey") {
143
throw(Squeal(Squeal::recoverable,
144
std::string("corrupted EMR Channel Key"),
145
"istream& operator>>(istream& stream, EMRChannelKey)"));
151
string EMRChannelKey::str() {