#include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDetectorIntegration_t.hh" #include "JDB/JProductRouter.hh" #include "JDB/JCLBID.hh" #include "JDB/JDBToolkit.hh" #include "JLang/JComparator.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program for module identification. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; string detectorFile; int debug; try { JParser<> zap("Example program for module identification."); zap['s'] = make_field(server) = getServernames(); zap['u'] = make_field(usr) = ""; zap['!'] = make_field(pwd) = ""; zap['C'] = make_field(cookie) = ""; zap['a'] = make_field(detectorFile); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetectorIntegration_t detector; DEBUG("Reading database table " << getTable() << endl); try { JDB::reset(usr, pwd, cookie); ResultSet& rs = getResultSet(getTable()); if (! (rs >> detector)) { THROW(JDatabaseException, "Error reading " << getTable()); } } catch(const exception& error) { FATAL(error.what() << endl); } JDetector detx; try { load(detectorFile, detx); } catch(const JException& error) { FATAL(error); } detector.configure(getDetector(detx.getID())); const JProductRouter router(detector, PBS::CLB_SEQUENCES); const JDetectorIntegration_t::range_type range = detector.find(PBS::CLB); for (JDetectorIntegration_t::range_const_iterator i = range.first; i != range.second; ++i) { const JUPI_t upi = detector[i->second].content.getUPI(); const JLocation_t location = router.getLocation(upi); cout << setw(24) << left << upi << right << ' ' << setw(4) << location.string << ' ' << setw(2) << location.floor << ' ' << setw(10) << getCLBID(upi) << ' '; for (JDetector::const_iterator module = detx.begin(); module != detx.end(); ++module) { if (module->getString() == location.string && module->getFloor() == location.floor) { cout << setw(10) << module->getID(); break; } } cout << endl; } return 0; }