~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

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

  • 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:
21
21
#include "src/common_cpp/Converter/DataConverters/CppJsonSpillConverter.hh"
22
22
#include "src/common_cpp/Converter/DataConverters/JsonCppSpillConverter.hh"
23
23
#include "Utils/Exception.hh"
 
24
#include "src/common_cpp/API/PyWrapInputBase.hh"
24
25
 
25
26
namespace MAUS {
 
27
PyMODINIT_FUNC init_InputCppDAQData(void) {
 
28
    PyWrapInputBase<MAUS::InputCppDAQData>::PyWrapInputBaseModInit(
 
29
                  "InputCppDAQData", "", "", "", "");
 
30
}
26
31
 
27
 
InputCppDAQData::InputCppDAQData() {
28
 
  _classname = "InputCppDAQData";
 
32
InputCppDAQData::InputCppDAQData() : InputBase<std::string>("InputCppDAQData") {
29
33
  _eventPtr = NULL;
30
34
  _eventsCount = 0;
31
35
 
39
43
}
40
44
 
41
45
 
42
 
bool InputCppDAQData::birth(std::string jsonDataCards) {
 
46
void InputCppDAQData::_childbirth(const std::string& jsonDataCards) {
43
47
  if ( _dataFileManager.GetNFiles() ) {
44
 
     return false;  // Faile because files are already open
 
48
     throw(MAUS::Exception(Exception::recoverable, "STRING", "InputCppDAQData::_childbirth"));
45
49
  }
46
50
 
47
51
  //  JsonCpp setup
51
55
  // Check if the JSON document can be parsed, else return error only
52
56
  bool parsingSuccessful = reader.parse(jsonDataCards, configJSON);
53
57
  if (!parsingSuccessful) {
54
 
    return false;
 
58
    throw(MAUS::Exception(Exception::recoverable, "STRING", "InputCppDAQData::_childbirth"));
55
59
  }
56
60
 
57
61
  // Comfigure the V830 (scaler) data processor.
86
90
    Squeak::mout(Squeak::error) << "Could not find the $MAUS_ROOT_DIR environmental variable."
87
91
    << std::endl;
88
92
    Squeak::mout(Squeak::error) << "Did you try running: source env.sh ?" << std::endl;
89
 
    return false;
 
93
    throw(MAUS::Exception(Exception::recoverable, "STRING", "InputCppDAQData::_childbirth"));
90
94
  }
91
95
 
92
96
  // Initialize the map by using text file.
93
97
  bool loaded = _map.InitFromFile(std::string(pMAUS_ROOT_DIR) + map_file_name);
94
98
  if (!loaded) {
95
 
    return false;
 
99
    throw(MAUS::Exception(Exception::recoverable, "STRING", "InputCppDAQData::_childbirth"));
96
100
  }
97
101
 
98
102
  // Set the map (a static data member) of all the processors.
99
103
  MDarranger::set_DAQ_map(&_map);
100
 
 
101
 
//   _dataProcessManager.DumpProcessors();
102
 
 
103
 
  return true;
104
104
}
105
105
 
106
 
 
107
106
bool InputCppDAQData::readNextEvent() {
108
107
 
109
108
  Squeak::mout(Squeak::error)
115
114
}
116
115
 
117
116
void InputCppDAQData::getCurEvent(MAUS::Data *data) {
118
 
 
119
117
  MAUS::Spill* spill = data->GetSpill();
120
118
  try {
121
119
    // Do the loop over the binary DAQ data.
122
120
    _dataProcessManager.Process(_eventPtr);
123
 
 
124
121
    // The data is now processed and is ready to be filled.
125
122
    unsigned int event_type = _dataProcessManager.GetEventType();
126
123
    spill->SetDaqEventType(event_type_to_str(event_type));
212
209
    errors["bad_data_input"] = ss.str();
213
210
    spill->SetErrors(errors);
214
211
  }
215
 
 
216
212
  this->resetAllProcessors();
217
213
}
218
214
 
236
232
  return output;
237
233
}
238
234
 
239
 
bool InputCppDAQData::death() {
 
235
void InputCppDAQData::_death() {
240
236
  // Free the memory.
241
237
  if (_v1290PartEventProc_cpp)    delete _v1290PartEventProc_cpp;
242
238
  if (_v1724PartEventProc_cpp)    delete _v1724PartEventProc_cpp;
245
241
  if (_vLSBFragmentProc_cpp)     delete _vLSBFragmentProc_cpp;
246
242
  if (_DBBFragmentProc_cpp)       delete _DBBFragmentProc_cpp;
247
243
  if (_DBBChainFragmentProc_cpp)  delete _DBBChainFragmentProc_cpp;
248
 
 
249
 
  return true;
250
244
}
251
245
 
252
246
void InputCppDAQData::resetAllProcessors() {