#include #include #include #include #include "JDetector/JDetector.hh" #include "JDetector/JDetectorCalibration.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JDetectorSupportkit.hh" #include "JSon/JSon.hh" #include "Jeep/JeepToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to create module map of PMT addresses. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; string detectorFile; string outputFile; int debug; try { JParser<> zap("Auxiliary program to create module map of PMT addresses."); zap['a'] = make_field(detectorFile, "detector file"); zap['o'] = make_field(outputFile, "JSon formatted output file"); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } if (!hasDetectorAddressMap(detector.getID())) { FATAL("No detector address map for detector identier " << detector.getID() << endl); } const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID()); const json error = { {Message_t, "" }, {Code_t, OK_t }, {Arguments_t, json::array() } }; json js; JModuleMap data; for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) { const JModuleAddressMap& memo = demo.get(module->getID()); JModuleMap_t buffer(module->getID()); for (size_t i = 0; i != module->size(); ++i) { buffer[memo.getPMTPhysicalAddress(i).toString()] = (*module)[i].getID(); } data.push_back(buffer); } js[Comment_t] = json(detector.comment); js[Data_t][0][DetID_t] = json(detector.getID()); js[Data_t][0][DOMMap_t] = json(data); js[Error_t] = json(error); store(outputFile.c_str(), js); return 0; }