#include #include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDBToolkit.hh" #include "JDB/JPMTThreshold.hh" #include "JDB/JDetectorIntegration.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using JDATABASE::JDetectorIntegration; /** * Compare detector integration by string number, floor and PMT position. * * \param first detector integration * \param second detector integration * \return true if first detector integration before second; else false */ inline bool compare(const JDetectorIntegration& first, const JDetectorIntegration& second) { if (first.DUID == second.DUID) { if (first.FLOORID == second.FLOORID) return first.CABLEPOS < second.CABLEPOS; else return first.FLOORID < second.FLOORID; } else { return first.DUID < second.DUID; } } } /** * \file * Auxiliary program to print run setup parameters from the database. * \author mdejong */ int main(const int argc, const char * const argv[]) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; string detid; int run; int debug; try { JParser<> zap("Auxiliary program to print run setup parameters from the 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(detid); zap['r'] = make_field(run); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } typedef vector detector_type; JPMTThreshold getPMTThreshold; detector_type detector; try { JDB::reset(usr, pwd, cookie); const int id = getDetector(detid); getPMTThreshold.configure(id, run); DEBUG(getPMTThreshold); ResultSet& rs = getResultSet(getTable(), getSelector(id)); for (JDetectorIntegration parameters; rs >> parameters; ) { detector.push_back(parameters); } rs.Close(); } catch(const exception& error) { FATAL(error.what() << endl); } sort(detector.begin(), detector.end(), compare); for (detector_type::const_iterator i = detector.begin(); i != detector.end(); ++i) { if (i->PMTID != -1) { try { const JPMTThreshold::result_type threshold = getPMTThreshold(i->PMTUPI); if (debug >= debug_t || !threshold.is_default) { cout << setw(4) << i->DUID << ' ' << setw(2) << i->FLOORID << ' ' << setw(2) << i->CABLEPOS << ' ' << setw(3) << threshold.value << ' ' << (threshold.is_default ? "" : "*") << endl; } } catch(const exception& error) { ERROR(error.what() << endl); } } } }