~christopher-hunt08/maus/maus_integrated_kalman

« back to all changes in this revision

Viewing changes to src/input/InputCppDAQOfflineData/InputCppDAQOfflineData.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:
15
15
 *
16
16
 */
17
17
 
 
18
#include "src/common_cpp/API/PyWrapInputBase.hh"
18
19
#include "src/input/InputCppDAQOfflineData/InputCppDAQOfflineData.hh"
19
20
 
20
21
namespace MAUS {
 
22
PyMODINIT_FUNC init_InputCppDAQOfflineData(void) {
 
23
    PyWrapInputBase<MAUS::InputCppDAQOfflineData>::PyWrapInputBaseModInit(
 
24
                  "InputCppDAQOfflineData", "", "", "", "");
 
25
}
21
26
 
22
 
InputCppDAQOfflineData::InputCppDAQOfflineData(std::string pDataPath, std::string pFilename)
23
 
:InputCppDAQData::InputCppDAQData(), _dataPaths(pDataPath), _datafiles(pFilename) {
 
27
InputCppDAQOfflineData::InputCppDAQOfflineData()
 
28
:InputCppDAQData::InputCppDAQData(), _dataPaths(""), _datafiles("") {
24
29
  _classname = "InputCppDAQOfflineData";
25
30
}
26
31
 
27
 
bool InputCppDAQOfflineData::birth(std::string jsonDataCards) {
28
 
 
 
32
void InputCppDAQOfflineData::_birth(const std::string& jsonDataCards) {
29
33
  if ( _dataFileManager.GetNFiles() ) {
30
 
     return false;  // Faile because files are already open.
 
34
    throw(MAUS::Exception(Exception::recoverable,
 
35
                          "Failed to get files - are they open already?",
 
36
                          "InputCppDAQOfflineData::_birth"));
31
37
  }
32
38
 
33
39
  //  JsonCpp setup
37
43
  // Check if the JSON document can be parsed, else return error only
38
44
  bool parsingSuccessful = reader.parse(jsonDataCards, configJSON);
39
45
  if (!parsingSuccessful) {
40
 
    return false;
 
46
    throw(MAUS::Exception(Exception::recoverable,
 
47
                          "Failed to parse datacards",
 
48
                          "InputCppDAQOfflineData::_birth"));
41
49
  }
42
50
 
43
51
  // Load some data.
56
64
  _dataFileManager.OpenFile();
57
65
  unsigned int nfiles = _dataFileManager.GetNFiles();
58
66
  if (!nfiles) {
59
 
    Squeak::mout(Squeak::error) << "Unable to load any data files." << std::endl;
60
 
    Squeak::mout(Squeak::error) << "Check your run number (or file name) and data path."
61
 
    << std::endl;
62
 
    return false;
 
67
    throw(MAUS::Exception(Exception::recoverable,
 
68
                        "Unable to load any data files. Check your run"+
 
69
                        std::string("number (or file name) and data path."),
 
70
                        "InputCppDAQOfflineData::_birth"));
63
71
  }
64
72
 
65
73
  // Set the number of DAQ events to be processed.
72
80
  _calib_Events_Only = configJSON["Calib_Events_Only"].asBool();
73
81
 
74
82
  if (_phys_Events_Only && _calib_Events_Only) {
75
 
    Squeak::mout(Squeak::error) << "There is a contradiction in the configuration:"
76
 
    << std::endl;
77
 
    Squeak::mout(Squeak::error) << "Phys_Events_Only and Calib_Events_Only are both true!!!"
78
 
    << std::endl;
79
 
    return false;
 
83
     throw(MAUS::Exception(Exception::recoverable,
 
84
                          "There is a contradiction in the configuration:\n"+
 
85
                          std::string("Phys_Events_Only and Calib_Events_Only ")+
 
86
                          std::string("are both true!!!"),
 
87
                          "InputCppDAQOfflineData::_birth"));
80
88
  }
81
89
 
82
 
  if (!InputCppDAQData::birth(jsonDataCards))
83
 
    return false;
 
90
  InputCppDAQData::_childbirth(jsonDataCards);
84
91
 
85
92
  // _dataProcessManager.DumpProcessors();
86
 
 
87
 
  return true;
88
93
}
89
94
 
90
95
 
95
100
    if (_eventsCount >= _maxNumEvents)
96
101
      return false;
97
102
 
 
103
 
98
104
//   cerr << "InputCppDAQData::readNextEvent   event: " << _eventsCount << endl;
99
105
 
100
106
  // Use the MDfileManager object to get the next event.