18
#ifndef _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
19
#define _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
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__
29
22
#include <iostream>
24
#include "json/json.h"
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
32
#include "src/input/InputCppDAQData/UnpackEventLib.hh"
32
33
#include "Utils/DAQChannelMap.hh"
33
34
#include "Interface/Squeak.hh"
35
/** \class InputCppDAQData
36
* Load MICE raw data and unpack it into a JSON stream.
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.
36
/** \class InputCppDAQData
37
* Load MICE raw data and unpack it into a JSON stream.
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.
45
46
class InputCppDAQData {
49
/** Create an instance of InputCppDAQData.
50
/** Create an instance of InputCppDAQData.
51
52
* This is the constructor for InputCppDAQData.
56
57
InputCppDAQData(std::string pDataPath = "", std::string pFilename = "");
58
/** Initialise the Unpacker.
59
/** Initialise the Unpacker.
60
61
* This prepares the unpacker to read the files given in the constructor.
64
65
bool birth(std::string pJSONConfig);
66
/** Read the next event from the file into memory.
67
/** Read the next event from the file into memory.
68
69
* This function simply reads an event into memory,
69
70
* it doesn't unpack the event anymore than required to read it.
73
74
bool readNextEvent();
75
/** Unpack the current event into JSON.
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
81
* \return The current event data in JSON format.
83
std::string getCurEvent();
85
/** Disable one equipment type.
76
/** Unpack the current event into JSON.
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
82
* \return Bool indicating that the get was successful.
86
/** Read the next event from the buffer and put it into _next_event
88
* \return string containing the next event; or "" if unsuccessful
90
std::string getNextEvent();
92
/** Return the spill number for some daq event
94
int getSpillNumber(Json::Value daq_event);
96
/** Get a string containing the information for the next spill
98
* Unpacks all daq events in the spill and puts them into a json array. Writes
101
* \return string representing a json array containing daq data for all events
104
std::string getNextSpill();
106
/** Disable one equipment type.
86
107
* This disables the unpacking of the data produced by all equipment
87
108
* with the specified type.
90
111
_dataProcessManager.Disable(pEquipType);
93
/** Close the file and free memory.
114
/** Close the file and free memory.
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!
107
/** Internal emitter function.
128
/** Internal emitter function.
109
130
* When called from C++, this function does nothing.
110
131
* From python (where it is overriden by the bindings,
121
std::string _classname;
123
/** Process manager object.
142
/** Process manager object. */
125
143
MDprocessManager _dataProcessManager;
127
/** File manager object.
145
/** File manager object. */
129
146
MDfileManager _dataFileManager;
131
/** The DAQ channel map object.
132
* It is used to group all measurements belonging to a given detector.
148
/** The DAQ channel map object.
149
* It is used to group all measurements belonging to a given detector.*/
134
150
DAQChannelMap _map;
136
/** Processor for TDC particle event data.
152
/** Processor for TDC particle event data. */
138
153
V1290DataProcessor* _v1290PartEventProc;
140
/** Processor for fADC V1724 particle event data.
155
/** Processor for fADC V1724 particle event data. */
142
156
V1724DataProcessor* _v1724PartEventProc;
144
/** Processor for fADC V1731 particle event data.
158
/** Processor for fADC V1731 particle event data. */
146
159
V1731DataProcessor* _v1731PartEventProc;
148
/** Processor for scaler data.
161
/** Processor for scaler data. */
150
162
V830DataProcessor* _v830FragmentProc;
152
/** Processor for VLSB data.
164
/** Processor for VLSB data. */
154
165
VLSBDataProcessor* _vLSBFragmentProc;
156
/** Processor for DBB data.
167
/** Processor for DBB data. */
158
168
DBBDataProcessor* _DBBFragmentProc;
160
/** Pointer to the start of the current event.
170
/** Pointer to the start of the current event. */
162
171
unsigned char *_eventPtr;
164
/** Paths to the data.
173
/** Paths to the data.
165
174
* This string has to contain one or more space separated paths.
167
176
std::string _dataPaths;
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.
173
182
std::string _datafiles;
175
/** Max number of DAQ events to be processed.
177
int _maxNumDaqEvents;
179
/** Counter of the DAQ events.
183
/** Enum of event types
184
/** Enum of event types */
187
187
VmefAdc1724 = 120,
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.
198
198
std::string event_type_to_str(int pType);
200
Json::Value _next_event;
201
#endif // _MAUS_INPUTCPPDATA_INPUTCPPDATA_H__
203
#endif // _MAUS_INPUTCPPDAQDATA_INPUTCPPDAQDATA_H__