#include "JAcoustics/JToA.hh" #include #include #include "JAcoustics/JSupport.hh" #include "JDB/JDB.hh" #include "JDB/JDBToolkit.hh" #include "JDB/JDatabaseObjectIterator.hh" #include "JDB/JSelector.hh" #include "JDB/JSupport.hh" #include "JDB/JToAshort.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JMeta.hh" #include "Jeep/JMessage.hh" #include "Jeep/JParser.hh" #include "dbclient/KM3NeTDBClient.h" /** * \file * * Auxiliary program to convert acoustics data from data base into ROOT format. * * Example usage : * * JToA -@ "minrun=16514" \ * -@ "maxrun=16514" \ * -@ "detid=D1ORCA015" \ * -o KM3NeT_00000146_00016514_toa.root * * \author mdejong */ int main(int argc, char** argv) { using namespace std; using namespace JPP; JFileRecorder outputFile; JServer server; string usr; string pwd; string cookie; JSelector selection; int debug; try { JParser<> zap("Auxiliary program to convert acoustics data from data base into ROOT format."); // clang-format off zap['o'] = make_field(outputFile); zap['s'] = make_field(server) = getServernames(); zap['u'] = make_field(usr) = ""; zap['!'] = make_field(pwd) = ""; zap['C'] = make_field(cookie) = ""; zap['@'] = make_field(selection) = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; // clang-format on zap(argc, argv); } catch (const exception& error) { FATAL(error.what() << endl); } try { JDB::reset(usr, pwd, cookie); JDBToolkit::initialise(getDetector); outputFile.open(); outputFile.put(JMeta(argc, argv)); outputFile.close(); auto ofile = std::unique_ptr(TFile::Open(outputFile.getFilename().c_str(), "UPDATE")); auto toa_tree = std::unique_ptr(new TTree("TOA", "Time Of Arrival (Acoustic Data)")); toa_tree->SetAutoSave(0); JToA toa; toa_tree->Branch("RUN", &toa.RUN); toa_tree->Branch("DOMID", &toa.DOMID); toa_tree->Branch("WAVEFORMID", &toa.WAVEFORMID); toa_tree->Branch("DETID", &toa.DETID); toa_tree->Branch("TOA_NS", &toa.TOA_NS); toa_tree->Branch("SECONDS", &toa.SECONDS); toa_tree->Branch("TICKS", &toa.TICKS); toa_tree->Branch("QUALITYFACTOR", &toa.QUALITYFACTOR); toa_tree->Branch("QUALITYNORMALISATION", &toa.QUALITYNORMALISATION); for (JDatabaseObjectIterator in(JToAshort::getName(), selection); in.hasNext();) { const JToAshort* p = in.next(); toa.DETID = getDetector(p->DETID); toa.RUN = p->RUN; toa.DOMID = p->DOMID; toa.WAVEFORMID = p->EMITTERID; toa.TOA_NS = p->getAbsoluteToA_ns(); toa.SECONDS = p->getDAQFrameSeconds(); toa.TICKS = p->getDAQFrameTicks(); toa.QUALITYFACTOR = p->QUALITYFACTOR; toa.QUALITYNORMALISATION = p->QUALITYNORMALISATION; toa_tree->Fill(); } toa_tree->Write(); } catch (const exception& error) { FATAL(error.what() << endl); } }