#include #include #include #include #include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JRunQuality.hh" #include "JDB/JRunsetups.hh" #include "JDB/JDBToolkit.hh" #include "JLang/JLangToolkit.hh" #include "JTools/JRange.hh" #include "JROOT/JRootPrinter.hh" #include "JROOT/JRootToolkit.hh" #include "JDataQuality/JGITTags.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Main program to print quality data from data base. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JRange JRange_t; JServer server; string usr; string pwd; string cookie; string inputFile; string outputFile; string detid; JRange_t runs; vector source; TRegexp regexp("."); JSelector selection; vector format; int debug; try { JParser<> zap("Main program to print quality data from data base."); 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(runs, "Run range") = JRange_t(1, JRange_t::getMaximum()); zap['S'] = make_field(source, "GIT versions") = getGITTags(TRegexp("v[0-9]*\\.[0-9]*\\.[0-9]*$"), JGITTags_t::key_type("2019-04-12")); zap['r'] = make_field(regexp, "TRegexp for selection of run setup names.") = JPARSER::initialised(); zap['F'] = make_field(format, "column names: " << JEEPZ() << getColumns()) = JPARSER::initialised(); zap['@'] = make_field(selection) = JPARSER::initialised(); zap['d'] = make_field(debug, "Debug level") = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JRunsetups setups; // run -> value set buffer; // storage try { JDB::reset(usr, pwd, cookie); const int ID = getDetector (detid); detid = getDetector(detid); // run setups selection += getSelector(ID, runs.getLowerLimit(), runs.getUpperLimit()); ResultSet& rs = getResultSet(getTable(), selection); for (JRuns parameters; rs >> parameters; ) { if (TString(parameters.RUNSETUPNAME.c_str()).Contains(regexp)) { setups.put(parameters); } } rs.Close(); // run summary data for (vector::const_iterator git = source.begin(); git != source.end() && buffer.size() < setups.size(); ++git) { typedef map data_type; typedef map map_type; map_type zmap; JSelector selector = getSelector(detid, runs.getLowerLimit(), runs.getUpperLimit()); selector.add(&JRunSummaryNumbers::SOURCE_NAME, *git); try { ResultSet& rs = getResultSet(getTable(), selector); for (JRunSummaryNumbers parameters; rs >> parameters; ) { if (setups.count(parameters.RUN) != 0) { zmap[parameters.RUN].insert(make_pair(parameters.PARAMETER_NAME, parameters.DATA_VALUE)); } } rs.Close(); } catch(const exception& error) {} for (map_type::const_iterator run = zmap.begin(); run != zmap.end(); ++run) { JRunQuality quality; quality.GIT = *git; quality.detector = ID; quality.run = run->first; quality.name = setups[run->first].name; quality.value = setups[run->first].value; for (data_type::const_iterator i = run->second.begin(); i != run->second.end(); ++i) { quality.put(i->first, i->second); } buffer.insert(quality); // only insert if absent } } } catch(const exception& error) { FATAL(error.what() << endl); } for (set::const_iterator quality = buffer.begin(); quality != buffer.end(); ++quality) { for (vector::const_iterator i = format.begin(); i != format.end(); ++i) { JRootPrinter::print(cout, *quality, *i); } cout << endl; } return 0; }