#include #include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDetCalibrations.hh" #include "JDB/JDBToolkit.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JSon/JSupport.hh" #include "JSupport/JMeta.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to download default detector from database. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; string id; string outputFile; string variant; int debug; try { JParser<> zap("Auxiliary program to download default detector from database."); zap['s'] = make_field(server) = getServernames(); zap['u'] = make_field(usr) = ""; zap['!'] = make_field(pwd) = ""; zap['C'] = make_field(cookie) = ""; zap['D'] = make_field(id, "detector identifier"); zap['o'] = make_field(outputFile); zap['V'] = make_field(variant, "detector version") = getDetectorVersions(); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } try { JDB::reset(usr, pwd, cookie); id = getDetector(id); ResultSet& rs = getResultSet(getTable(), getSelector(id)); map calibration; for (JDetCalibrations buffer; rs >> buffer; ) { const string type = getCalibrationType.getNickname(buffer.OPTYPE); if (calibration.count(type) == 0 || calibration[type].STARTTIME < buffer.STARTTIME) { calibration[type] = buffer; } } rs.Close(); JDetector detector; detector.comment.add(JMeta(argc,argv)); for (const auto& key : { TCAL, PCAL, RCAL, ACAL, CCAL, SCAL }) { if (calibration.count(key) == 0) { FATAL("Missing " << key << " calibration." << endl); } detector.comment.add(MAKE_STRING(key << " = " << calibration[key].OPERATIONID)); } *(JDB::get()->DetX)(id.c_str(), calibration[TCAL].OPERATIONID.c_str(), calibration[PCAL].OPERATIONID.c_str(), calibration[RCAL].OPERATIONID.c_str(), calibration[ACAL].OPERATIONID.c_str(), calibration[CCAL].OPERATIONID.c_str(), calibration[SCAL].OPERATIONID.c_str(), getDetectorVersion(variant)) >> detector; store(outputFile.c_str(), detector); } catch(const exception& error) { FATAL(error.what() << endl); } }