#include #include #include #include #include #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDBToolkit.hh" #include "JDB/JDetectorIntegration.hh" #include "JDetector/JPMTParametersMap.hh" #include "JSystem/JStat.hh" #include "JSupport/JMeta.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to set TTS function identifier in PMT parameters file according PMT variant. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; const std::string WILDCARD = "%"; //!< wild card JServer server; string usr; string pwd; string cookie; string detid; map TTS; string pmtFile; int debug; TTS["HAMA-R12199"] = 1; TTS["HAMA-R14374"] = 67; TTS["HAMA-R14374-02"] = 67; TTS[WILDCARD] = 1; try { JParser<> zap("Auxiliary program to set TTS function identifier in PMT parameters file according PMT variant."); 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['P'] = make_field(pmtFile, "PMT parameters file") = ""; zap['!'] = make_field(TTS, "map PMT variant to TTS function identifier") = JPARSER::initialised(); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JPMTParametersMap parameters; if (pmtFile != "" && getFileStatus(pmtFile.c_str())) { parameters.load(pmtFile.c_str()); } try { JDB::reset(usr, pwd, cookie); ResultSet& rs = getResultSet(getTable(), getSelector(getDetector(detid))); for (JDetectorIntegration component; rs >> component; ) { if (component.PMTUPI.getPBS() == PBS::PMT) { map::const_iterator p = TTS.end(); if ((p = TTS.find(component.PMTUPI.getVariant())) != TTS.end()) ; else if ((p = TTS.find(WILDCARD)) != TTS.end()) ; else FATAL("Invalid variant " << component.PMTUPI << "."); const JPMTIdentifier id(component.DOMID, component.CABLEPOS); parameters[id].TTS_ns = -(p->second); } } rs.Close(); } catch(const exception& error) { FATAL(error.what() << endl); } if (pmtFile != "") { parameters.comment.add(JMeta(argc, argv)); parameters.store(pmtFile.c_str()); } else { cout << parameters << endl; } }