#include #include #include #include #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/MultiHead.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JDAQ/JDAQEvaluator.hh" #include "JTrigger/JTriggerParameters.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JDynamics/JDynamics.hh" #include "JSupport/JSupport.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JTreeScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JMeta.hh" #include "JReconstruction/JEvt.hh" #include "JReconstruction/JMuonPrefit.hh" #include "JReconstruction/JMuonPrefitParameters_t.hh" #include "JReconstruction/JMultiThreadedReconstruction.hh" #include "JLang/JPredicate.hh" #include "JLang/JComparison.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Program to perform linear fits JFIT::JEstimator covering the solid angle producing JFIT::JEvt data. * * \author mdejong, gmaggi, azegarelli */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; typedef JTYPELIST::typelist, JFIT::JEvt>::typelist typelist; typedef JSingleFileScanner JSingleFileScanner_t; typedef JTYPELIST::typelist calibration_types; typedef JMultipleFileScanner JCalibration_t; JSingleFileScanner_t inputFile; JFileRecorder outputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string detectorFile; JCalibration_t calibrationFile; double Tmax_s; JMuonPrefitParameters_t parameters; size_t threads; // number of parallel threads int debug; try { JParser<> zap("Program to perform pre-fit of muon trajectory to data."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "prefit.root"; zap['a'] = make_field(detectorFile); zap['+'] = make_field(calibrationFile) = JPARSER::initialised(); zap['T'] = make_field(Tmax_s) = 100.0; zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['@'] = make_field(parameters) = JPARSER::initialised(); zap['N'] = make_field(threads, "number of threads") = 0; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } getTreeParameters().setSplitLevel(0); JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } unique_ptr dynamics; if (!calibrationFile.empty()) { try { dynamics.reset(new JDynamics(detector, Tmax_s)); dynamics->load(calibrationFile); } catch(const exception& error) { FATAL(error.what()); } } const JModuleRouter router(dynamics ? dynamics->getDetector() : detector); JMuonPrefit fit(parameters, debug); outputFile.open(); outputFile.put(JMeta(argc, argv)); JTreeScanner in(inputFile, inputFile.getLimit()); { JMultiThreadedReconstruction fits(fit, outputFile, threads, 2 * threads); while (in.hasNext()) { STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl); const JDAQEvent* tev = in.next(); if (dynamics) { dynamics->update(*tev); } auto input = fit.getInput(router, *tev, dynamics ? dynamics->getCoverage() : coverage_type()); if (threads > 0) fits.enqueue(input); else outputFile.put(fit(input)); outputFile.put(*tev); } STATUS(endl); } JSingleFileScanner::typelist>::typelist> io(inputFile); io >> outputFile; outputFile.close(); }