~c-e-pidcott/maus/devel

« back to all changes in this revision

Viewing changes to src/input/InputCppDAQData/InputCppDAQData.hh

  • Committer: Chris Rogers
  • Date: 2011-11-04 16:46:18 UTC
  • mfrom: (656.1.27 maus-trunk3)
  • Revision ID: chris.rogers@stfc.ac.uk-20111104164618-4gaisprgsgivebix
Changes for release 0.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
 *
16
16
 */
17
17
 
18
 
#ifndef _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
19
 
#define _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
20
 
 
21
 
#include <json/json.h>
22
 
#include <unpacking/event.h>
23
 
#include <unpacking/MDdateFile.h>
24
 
#include <unpacking/MDevent.h>
25
 
#include <unpacking/MDfileManager.h>
26
 
#include <unpacking/MDprocessManager.h>
 
18
#ifndef _MAUS_SRC_INPUT_INPUTCPPDAQDATA_INPUTCPPDAQDATA_H__
 
19
#define _MAUS_SRC_INPUT_INPUTCPPDAQDATA_INPUTCPPDAQDATA_H__
27
20
 
28
21
#include <string>
29
22
#include <iostream>
30
23
 
 
24
#include "json/json.h"
 
25
 
 
26
#include "unpacking/event.h"
 
27
#include "unpacking/MDdateFile.h"
 
28
#include "unpacking/MDevent.h"
 
29
#include "unpacking/MDfileManager.h"
 
30
#include "unpacking/MDprocessManager.h"
 
31
 
31
32
#include "src/input/InputCppDAQData/UnpackEventLib.hh"
32
33
#include "Utils/DAQChannelMap.hh"
33
34
#include "Interface/Squeak.hh"
34
35
 
35
 
 /** \class InputCppDAQData
36
 
  * Load MICE raw data and unpack it into a JSON stream.
37
 
  *
38
 
  * This module reads data in the format of the MICE DAQ.  It drives the
39
 
  * 'unpacker' library to do this conversion.  The end result is the MICE data
40
 
  * in JSON format.  The data includes TDC and flash ADC values, so this
41
 
  * information is low-level.
42
 
  *
43
 
  */
 
36
/** \class InputCppDAQData
 
37
* Load MICE raw data and unpack it into a JSON stream.
 
38
*
 
39
* This module reads data in the format of the MICE DAQ.  It drives the
 
40
* 'unpacker' library to do this conversion.  The end result is the MICE data
 
41
* in JSON format.  The data includes TDC and flash ADC values, so this
 
42
* information is low-level.
 
43
*
 
44
*/
44
45
 
45
46
class InputCppDAQData {
46
47
 
47
48
 public:
48
49
 
49
 
 /** Create an instance of InputCppDAQData.
 
50
  /** Create an instance of InputCppDAQData.
50
51
  * 
51
52
  * This is the constructor for InputCppDAQData.
52
53
  *
55
56
  */
56
57
  InputCppDAQData(std::string pDataPath = "", std::string pFilename = "");
57
58
 
58
 
 /** Initialise the Unpacker.
 
59
  /** Initialise the Unpacker.
59
60
  *
60
61
  * This prepares the unpacker to read the files given in the constructor.
61
62
  *
63
64
  */
64
65
  bool birth(std::string pJSONConfig);
65
66
 
66
 
 /** Read the next event from the file into memory.
 
67
  /** Read the next event from the file into memory.
67
68
  *
68
69
  * This function simply reads an event into memory,
69
70
  * it doesn't unpack the event anymore than required to read it.
72
73
  */
73
74
  bool readNextEvent();
74
75
 
75
 
 /** Unpack the current event into JSON.
76
 
  *
77
 
  * This unpacks the current event and returns the JSON data for it.
78
 
  * Don't call this until readNextEvent() has been called and returned
79
 
  * true at least once!
80
 
  *
81
 
  * \return The current event data in JSON format.
82
 
  */
83
 
  std::string getCurEvent();
84
 
 
85
 
 /** Disable one equipment type.
 
76
  /** Unpack the current event into JSON.
 
77
  *
 
78
  * This unpacks the current event into _next_event and returns true on success.
 
79
  * Don't call this until readNextEvent() has been called and returned true at
 
80
  * least once!
 
81
  *
 
82
  * \return Bool indicating that the get was successful.
 
83
  */
 
84
  bool getCurEvent();
 
85
 
 
86
  /** Read the next event from the buffer and put it into _next_event
 
87
   *
 
88
   *  \return string containing the next event; or "" if unsuccessful
 
89
   */
 
90
  std::string getNextEvent();
 
91
 
 
92
  /** Return the spill number for some daq event
 
93
  */
 
94
  int getSpillNumber(Json::Value daq_event);
 
95
 
 
96
  /** Get a string containing the information for the next spill
 
97
  *
 
98
  * Unpacks all daq events in the spill and puts them into a json array. Writes
 
99
  * to string.
 
100
  *
 
101
  * \return string representing a json array containing daq data for all events
 
102
  *         in the spill
 
103
  */
 
104
  std::string getNextSpill();
 
105
 
 
106
  /** Disable one equipment type.
86
107
  * This disables the unpacking of the data produced by all equipment
87
108
        * with the specified type.
88
109
        */
90
111
    _dataProcessManager.Disable(pEquipType);
91
112
  }
92
113
 
93
 
 /** Close the file and free memory.
 
114
  /** Close the file and free memory.
94
115
  *
95
116
  * This function frees all resources allocated by Birth().
96
117
  * It is unlikely this will ever fail!
104
125
   * can use pure python code in the python bindings!
105
126
   */
106
127
 
107
 
 /** Internal emitter function.
 
128
  /** Internal emitter function.
108
129
  *
109
130
  * When called from C++, this function does nothing.
110
131
  * From python (where it is overriden by the bindings,
118
139
 
119
140
 private:
120
141
 
121
 
  std::string _classname;
122
 
 
123
 
 /** Process manager object.
124
 
  */
 
142
  /** Process manager object. */
125
143
  MDprocessManager _dataProcessManager;
126
144
 
127
 
 /** File manager object.
128
 
  */
 
145
  /** File manager object. */
129
146
  MDfileManager _dataFileManager;
130
147
 
131
 
 /** The DAQ channel map object.
132
 
  * It is used to group all measurements belonging to a given detector.
133
 
  */
 
148
  /** The DAQ channel map object.
 
149
  * It is used to group all measurements belonging to a given detector.*/
134
150
  DAQChannelMap _map;
135
151
 
136
 
 /** Processor for TDC particle event data.
137
 
  */
 
152
  /** Processor for TDC particle event data. */
138
153
  V1290DataProcessor*  _v1290PartEventProc;
139
154
 
140
 
 /** Processor for fADC V1724 particle event data.
141
 
  */
 
155
  /** Processor for fADC V1724 particle event data. */
142
156
  V1724DataProcessor*  _v1724PartEventProc;
143
157
 
144
 
 /** Processor for fADC V1731 particle event data.
145
 
  */
 
158
  /** Processor for fADC V1731 particle event data. */
146
159
  V1731DataProcessor*  _v1731PartEventProc;
147
160
 
148
 
 /** Processor for scaler data.
149
 
  */
 
161
  /** Processor for scaler data. */
150
162
  V830DataProcessor*  _v830FragmentProc;
151
163
 
152
 
 /** Processor for VLSB data.
153
 
  */
 
164
  /** Processor for VLSB data. */
154
165
  VLSBDataProcessor* _vLSBFragmentProc;
155
166
 
156
 
 /** Processor for DBB data.
157
 
  */
 
167
  /** Processor for DBB data. */
158
168
  DBBDataProcessor* _DBBFragmentProc;
159
169
 
160
 
 /** Pointer to the start of the current event.
161
 
  */
 
170
  /** Pointer to the start of the current event. */
162
171
  unsigned char *_eventPtr;
163
172
 
164
 
 /** Paths to the data.
 
173
  /** Paths to the data.
165
174
  * This string has to contain one or more space separated paths.
166
175
  */
167
176
  std::string _dataPaths;
168
177
 
169
 
 /** File and run names within _dataPaths.
 
178
  /** File and run names within _dataPaths.
170
179
  * This string has to contain one or more space separated
171
180
  * file names or run numbers.
172
181
  */
173
182
  std::string _datafiles;
174
183
 
175
 
 /** Max number of DAQ events to be processed.
176
 
  */ 
177
 
  int _maxNumDaqEvents;
178
 
 
179
 
 /** Counter of the DAQ events.
180
 
  */
181
 
  int _daqEventsCount;
182
 
 
183
 
 /** Enum of event types
184
 
  */
 
184
  /** Enum of event types */
185
185
  enum {
186
186
    VmeTdc = 102,
187
187
    VmefAdc1724 = 120,
191
191
    VLSB_C = 80
192
192
  };
193
193
 
194
 
 /** Convert the DAQ event type (as coded in DATE) into string.
 
194
  /** Convert the DAQ event type (as coded in DATE) into string.
195
195
  * \param[in] pType The type of the event to be converted.
196
196
  * \return The type of the event as string.
197
197
  */
198
198
  std::string event_type_to_str(int pType);
 
199
 
 
200
  Json::Value _next_event;
199
201
};
200
202
 
201
 
#endif  // _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
 
203
#endif  // _MAUS_INPUTCPPDAQDATA_INPUTCPPDAQDATA_H__