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"
29
29
#include "src/common_cpp/DataStructure/SciFiEvent.hh"
37
37
bool ReduceCppPatternRecognition::birth(std::string aJsonConfigDocument) {
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
49
50
configJSON = JsonWrapper::StringToJson(aJsonConfigDocument);
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);
59
60
std::string ReduceCppPatternRecognition::process(std::string aDocument) {
60
std::cout << "Starting Pattern Recognition Reducer" << std::endl;
62
61
bool read_success = read_in_json(aDocument);
64
62
if (read_success) {
66
64
if ( mSpill->GetReconEvents() ) {
67
65
mDataManager.process(mSpill);
68
66
mDataManager.draw(mPlotters);
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);
77
75
mDataManager.clear_spill();
79
std::cerr << "Failed to import json to spill\n";
77
std::cerr << mClassname << ": Failed to import json to spill\n";
81
79
return JsonWrapper::JsonToString(mRoot);
93
91
SpillProcessor spill_proc;
94
92
mSpill = spill_proc.JsonToCpp(mRoot);
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);