#include #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 "JDB/JLocation_t.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to check HV. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; string detectorFile; string outputFile; int debug; try { JParser<> zap("Auxiliary program to check HV."); 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['o'] = make_field(outputFile) = ""; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detectorA; try { load(detectorFile, detectorA); } catch(const JException& error) { FATAL(error); } try { JDB::reset(usr, pwd, cookie); const string detid = getDetector(detectorA.getID()); typedef map detector_type; detector_type detectorB; { ResultSet& rs = getResultSet(getTable(), getSelector(detectorA.getID())); for (JDetectorIntegration parameters; rs >> parameters; ) { if (parameters.PMTUPI.getPBS() == PBS::PMT) { detectorB[parameters.PMTSER] = parameters; } } rs.Close(); } for (JDetector::iterator module = detectorA.begin(); module != detectorA.end(); ++module) { vector buffer(module->begin(), module->end()); for (size_t i = 0; i != module->size(); ++i) { const int pmt = (*module)[i].getID(); if (detectorB.count(pmt) == 1) { const JDetectorIntegration& parameters = detectorB[pmt]; const JLocation location(parameters.DUID, parameters.FLOORID); if (module->getLocation() != location) { FATAL("Wrong location " << left << setw(5) << pmt << " " << module->getLocation() << " != " << location << endl); } if (parameters.PMTID != parameters.CABLEPOS) { NOTICE("Swap PMT " << right << setw(10) << module->getID() << ' ' << JLocation_t(parameters.DUID, parameters.FLOORID, parameters.CABLEPOS) << " <- " << JLocation_t(parameters.DUID, parameters.FLOORID, parameters.PMTID) << endl); buffer[parameters.CABLEPOS] = (*module)[parameters.PMTID]; } } else { ERROR("Missing PMT " << left << setw(5) << pmt << right << setw(10) << module->getID() << "." << FILL(2,'0') << i << FILL() << endl); } } module->swap(buffer); } } catch(const exception& error) { FATAL(error.what() << endl); } if (outputFile != "") { try { store(outputFile, detectorA); } catch(const JException& error) { FATAL(error); } } }