~chris-rogers/maus/emr_mc_digitization

« back to all changes in this revision

Viewing changes to src/reduce/ReduceCppPatternRecognition/ReduceCppPatternRecognition.cc

  • Committer: Chris Rogers
  • Date: 2014-04-16 11:48:45 UTC
  • mfrom: (707 merge)
  • mto: This revision was merged to the branch mainline in revision 711.
  • Revision ID: chris.rogers@stfc.ac.uk-20140416114845-h3u3q7pdcxkxvovs
Update to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include "src/common_cpp/Utils/JsonWrapper.hh"
24
24
#include "src/common_cpp/Utils/CppErrorHandler.hh"
25
25
#include "Interface/Squeak.hh"
26
 
#include "Interface/Squeal.hh"
 
26
#include "Utils/Exception.hh"
27
27
#include "Interface/dataCards.hh"
28
28
 
29
29
#include "src/common_cpp/DataStructure/SciFiEvent.hh"
37
37
bool ReduceCppPatternRecognition::birth(std::string aJsonConfigDocument) {
38
38
 
39
39
  mClassname = "ReduceCppPatternRecognition";
 
40
  mDataManager.set_print_tracks(false);               // Do not print info about the PR tracks
40
41
  mDataManager.set_print_seeds(false);               // Do not print info about track seeds
41
42
  mXYZPlotter = new TrackerDataPlotterXYZ();         // The spacepoint and track plotter
42
43
  mInfoBoxPlotter = new TrackerDataPlotterInfoBox(); // The infobox plotter
48
49
  try {
49
50
    configJSON = JsonWrapper::StringToJson(aJsonConfigDocument);
50
51
    return true;
51
 
  } catch(Squeal squee) {
52
 
    MAUS::CppErrorHandler::getInstance()->HandleSquealNoJson(squee, mClassname);
53
 
  } catch(std::exception exc) {
 
52
  } catch (Exception exc) {
 
53
    MAUS::CppErrorHandler::getInstance()->HandleExceptionNoJson(exc, mClassname);
 
54
  } catch (std::exception exc) {
54
55
    MAUS::CppErrorHandler::getInstance()->HandleStdExcNoJson(exc, mClassname);
55
56
  }
56
57
  return false;
57
58
}
58
59
 
59
60
std::string ReduceCppPatternRecognition::process(std::string aDocument) {
60
 
  std::cout << "Starting Pattern Recognition Reducer" << std::endl;
61
 
 
62
61
  bool read_success = read_in_json(aDocument);
63
 
 
64
62
  if (read_success) {
65
63
    try {
66
64
      if ( mSpill->GetReconEvents() ) {
67
65
        mDataManager.process(mSpill);
68
66
        mDataManager.draw(mPlotters);
69
67
      }
70
 
    } catch(Squeal squee) {
71
 
      Squeak::mout(Squeak::error) << squee.GetMessage() << std::endl;
72
 
      mRoot = MAUS::CppErrorHandler::getInstance()->HandleSqueal(mRoot, squee, mClassname);
73
 
    } catch(std::exception exc) {
 
68
    } catch (Exception exc) {
 
69
      Squeak::mout(Squeak::error) << exc.GetMessage() << std::endl;
 
70
      mRoot = MAUS::CppErrorHandler::getInstance()->HandleException(mRoot, exc, mClassname);
 
71
    } catch (std::exception exc) {
74
72
      Squeak::mout(Squeak::error) << exc.what() << std::endl;
75
73
      mRoot = MAUS::CppErrorHandler::getInstance()->HandleStdExc(mRoot, exc, mClassname);
76
74
    }
77
75
    mDataManager.clear_spill();
78
76
  } else {
79
 
    std::cerr << "Failed to import json to spill\n";
 
77
    std::cerr << mClassname << ": Failed to import json to spill\n";
80
78
  }
81
79
  return JsonWrapper::JsonToString(mRoot);
82
80
}
93
91
    SpillProcessor spill_proc;
94
92
    mSpill = spill_proc.JsonToCpp(mRoot);
95
93
    return true;
96
 
  } catch(...) {
 
94
  } catch (...) {
97
95
    Json::Value errors;
98
96
    std::stringstream ss;
99
 
    ss << mClassname << " says: Failed when importing JSON to Spill";
 
97
    ss << mClassname << ": Failed when importing JSON to Spill";
100
98
    errors["bad_json_document"] = ss.str();
101
99
    mRoot["errors"] = errors;
102
100
    writer.write(mRoot);