~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to src/common_cpp/Utils/EMRChannelMap.hh

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of MAUS: http://micewww.pp.rl.ac.uk:8080/projects/maus
 
2
 *
 
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.
 
7
 *
 
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.
 
12
 *
 
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/>.
 
15
 *
 
16
 */
 
17
 
 
18
#ifndef _MAUS_INPUTCPPREALDATA_CABLINGTOOLS_EMR_HH_
 
19
#define _MAUS_INPUTCPPREALDATA_CABLINGTOOLS_EMR_HH_
 
20
 
 
21
#include <stdint.h>
 
22
#include <stdlib.h>
 
23
#include <limits.h>
 
24
#include <string>
 
25
#include <vector>
 
26
#include <iostream>
 
27
#include <sstream>
 
28
#include <algorithm>
 
29
#include <fstream>
 
30
 
 
31
#include "Utils/DAQChannelMap.hh"
 
32
#include "Utils/Exception.hh"
 
33
#include "Interface/Squeak.hh"
 
34
 
 
35
using std::string;
 
36
using std::ostream;
 
37
using std::istream;
 
38
using std::ifstream;
 
39
using std::stringstream;
 
40
 
 
41
namespace MAUS {
 
42
 
 
43
//////////////////////////////////////////////////////////////////////////////////////////////
 
44
/** Identifier for a single EMR channel.
 
45
 * This class is used to hold and manage all the information needed
 
46
 * to identifiy one channel in the EMR detectors.
 
47
 */
 
48
class EMRChannelKey {
 
49
 public:
 
50
 
 
51
  EMRChannelKey()
 
52
  :_plane(-999), _orientation(-999), _bar(-999), _detector("unknown") {}
 
53
 
 
54
  EMRChannelKey(int pl, int o, int b, string d)
 
55
  : _plane(pl), _orientation(o), _bar(b), _detector(d) {}
 
56
 
 
57
  explicit EMRChannelKey(string keyStr) throw(Exception);
 
58
  virtual ~EMRChannelKey() {}
 
59
 
 
60
  bool operator==( EMRChannelKey key );
 
61
  bool operator!=( EMRChannelKey key );
 
62
 
 
63
  friend ostream& operator<<( ostream& stream, EMRChannelKey key );
 
64
  friend istream& operator>>( istream& stream, EMRChannelKey &key ) throw(Exception);
 
65
 
 
66
  /** This function converts the DAQChannelKey into string.
 
67
  * \return String identifier.
 
68
  */
 
69
  string str();
 
70
 
 
71
  int plane()  const {return _plane;}
 
72
  int orientation() const {return _orientation;}
 
73
  int bar()    const {return _bar;}
 
74
  string detector() const {return _detector;}
 
75
 
 
76
  void SetPlane(int xPlane)   {_plane = xPlane;}
 
77
  void SetOrientation(int xOrientation) {_orientation = xOrientation;}
 
78
  void SetBar(int xBar)       {_bar = xBar;}
 
79
  void SetDetector(string xDetector) {_detector = xDetector;}
 
80
 
 
81
 private:
 
82
 
 
83
  /// Plane number.
 
84
  int _plane;
 
85
 
 
86
  /// Bar orientation.
 
87
  int _orientation;
 
88
 
 
89
  /// Bar number.
 
90
  int _bar;
 
91
 
 
92
  /// Name of the detector.
 
93
  string _detector;
 
94
};
 
95
 
 
96
//////////////////////////////////////////////////////////////////////////////////////////////
 
97
/** Complete map of all EMR channels.
 
98
 * This class is used to hold and manage the informatin for all EMR Channel.
 
99
 */
 
100
class EMRChannelMap {
 
101
 public:
 
102
 
 
103
  EMRChannelMap() {}
 
104
  virtual ~EMRChannelMap();
 
105
 
 
106
  /// Initialize the map from text file.
 
107
  bool InitFromFile(string filename);
 
108
 
 
109
  /// Not implemented.
 
110
  void InitFromCDB();
 
111
 
 
112
 /** Return pointer to the EMR key.
 
113
 * This function returns pointer to the EMR channel key for the required DAQ channel.
 
114
 * \param[in] daqch DAQ channel to search for.
 
115
 * \return The key of the EMR channel connected to the given DAQ channel.
 
116
 */
 
117
  EMRChannelKey* find(DAQChannelKey* daqKey);
 
118
 
 
119
 /** Return pointer to the EMR key.
 
120
 * This function returns pointer to the EMR channel key for the required DAQ channel.
 
121
 * \param[in] daqch DAQ channel to search for, coded as string.
 
122
 * \return The key of the EMR channel connected to the given DAQ channel.
 
123
 */
 
124
  EMRChannelKey* find(string daqKeyStr);
 
125
  int getOrientation(int plane);
 
126
 
 
127
 
 
128
  void print() {
 
129
    for (unsigned int i = 0; i < _emrKey.size(); i++)
 
130
      std::cout << *(_emrKey[i]) << " " << *(_dbbKey[i]) << std::endl;
 
131
  }
 
132
 
 
133
 private:
 
134
 
 
135
  std::vector<EMRChannelKey*>   _emrKey;
 
136
  std::vector<DAQChannelKey*>   _dbbKey;
 
137
};
 
138
}
 
139
 
 
140
#endif