~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

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

  • Committer: Durga Rajaram
  • Date: 2014-07-16 15:13:05 UTC
  • mfrom: (659.1.92 cand)
  • Revision ID: durga@fnal.gov-20140716151305-q27rv1y9p03v9lks
Tags: MAUS-v0.9, MAUS-v0.9.0
MAUS-v0.9.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
#include "unpacking/MDequipMap.h"
33
33
#include "unpacking/MDfragment.h"
34
34
 
 
35
#include "src/common_cpp/API/InputBase.hh"
 
36
 
35
37
#include "src/input/InputCppDAQData/UnpackEventLib.hh"
36
38
#include "DataStructure/Data.hh"
37
39
#include "DataStructure/Spill.hh"
53
55
* information is low-level.
54
56
*/
55
57
 
56
 
class InputCppDAQData {
 
58
class InputCppDAQData : public InputBase<std::string> {
57
59
 
58
60
 public:
59
61
 
63
65
  */
64
66
  InputCppDAQData();
65
67
 
66
 
  /** Initialise the Unpacker.
67
 
  *
68
 
  * This prepares the unpacker to read the data according to the configuration.
69
 
  *
70
 
  * \return True if the configuration is loaded and the processors are
71
 
  * initialised sucessfully.
72
 
  */
73
 
  bool birth(std::string pJSONConfig);
74
 
 
75
68
  /** Dummy function.
76
69
  * The access to the data is provided by the two daughter classes
77
70
  * InputCppDAQOfflineData and InputCppDAQOnlineData.
78
71
  *
79
72
  * \return false after printing an error message.
80
73
  */
81
 
  bool readNextEvent();
 
74
  virtual bool readNextEvent();
82
75
 
83
76
  /** Unpack the current event into JSON.
84
77
  *
108
101
    _dataProcessManager.Disable(pEquipType);
109
102
  }
110
103
 
111
 
  /** Close the file and free memory.
112
 
  *
113
 
  * This function frees all resources allocated by Birth().
114
 
  * It is unlikely this will ever fail!
115
 
  *
116
 
  * \return True if successful.
117
 
  */
118
 
  bool death();
119
 
 
120
104
  /* Functions for python use only!
121
105
   * They are written in InputCppDAQData.i so that they
122
106
   * can use pure python code in the python bindings!
123
107
   */
124
108
 
 
109
 protected:
 
110
 
125
111
  /** Internal emitter function.
126
112
  *
127
 
  * When called from C++, this function does nothing.
128
 
  * From python (where it is overriden by the bindings,
129
 
  * it returns an iterable result which allows access to all events.
130
 
  *
131
 
  * \return An empty string from C++.
 
113
  * \return An event string.
132
114
  */
133
 
  std::string emitter() {
134
 
     return "";
 
115
  std::string _emit_cpp() {
 
116
     if (this->readNextEvent())
 
117
        return this->getCurEvent();
 
118
     else
 
119
        throw(MAUS::Exception(Exception::recoverable,
 
120
                              "Failed to read next event",
 
121
                              "InputCppDAQData::_emit_cpp()"));
135
122
  };
136
123
 
137
 
 protected:
138
 
 
139
 
  std::string _classname;
140
 
 
141
124
  /** Counter of the DAQ events. */
142
125
  int _eventsCount;
143
126
 
147
130
  /** Pointer to the start of the current event. */
148
131
  unsigned char *_eventPtr;
149
132
 
 
133
  /** Initialise the Unpacker.
 
134
  *
 
135
  * This protected birth is intended to be called from children
 
136
  *
 
137
  * This prepares the unpacker to read the data according to the configuration.
 
138
  */
 
139
  void _childbirth(const std::string& pJSONConfig);
 
140
 
150
141
 private:
151
142
 
 
143
  void _birth(const std::string& pJSONConfig) {
 
144
    _childbirth(pJSONConfig);
 
145
  }
 
146
 
 
147
  /** Close the file and free memory.
 
148
  *
 
149
  * This function frees all resources allocated by Birth().
 
150
  * It is unlikely this will ever fail!
 
151
  */
 
152
  void _death();
 
153
 
152
154
  /** Initialise the processor.
153
155
  * Template function used to initialise a processor
154
156
  * according to the configuration.