#include #include #include #include #include "JDB/JSupport.hh" #include "JDB/JAHRS.hh" #include "JDB/JAHRSCalibration_t.hh" #include "JDB/JAHRSToolkit.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSystem/JStat.hh" #include "JTools/JQuantile.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Program to monitor AHRS data. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JMultipleFileScanner inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string detectorFile; string ahrsFile; vector Q; int qaqc; int debug; try { JParser<> zap("Program to monitor AHRS data."); zap['f'] = make_field(inputFile, "output of JConvertDB -q ahrs"); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['a'] = make_field(detectorFile); zap['c'] = make_field(ahrsFile, "output of JAHRSCalibration"); zap['q'] = make_field(Q, "quantile"); zap['Q'] = make_field(qaqc) = 0; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JModuleRouter router(detector); const JAHRSCalibration_t calibration(ahrsFile.c_str()); const JAHRSValidity is_valid; map data; for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) { if (module->getFloor() != 0) { data[module->getID()] = 0; } } while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); const JAHRS* parameters = inputFile.next(); if (is_valid(*parameters) && router.hasModule(parameters->DOMID)) { if (router.getModule(parameters->DOMID).getFloor() != 0) { data[parameters->DOMID] += 1; } } } STATUS(endl); JQuantile q1("", true); for (map::const_iterator i = data.begin(); i != data.end(); ++i) { q1.put(i->second); } for (vector::const_iterator i = Q.begin(); i != Q.end(); ++i) { QAQC(' ' << FIXED(8,3) << q1.getQuantile(*i)); } QAQC(endl); return 0; }