#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 "JDetector/JModuleRouter.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDynamics/JDynamics.hh" #include "JSupport/JParallelFileScanner.hh" #include "JSupport/JSupport.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JMeta.hh" #include "JSupport/JTreeScanner.hh" #include "JSupport/JSummaryFileRouter.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" #include "JReconstruction/JEvt.hh" #include "JReconstruction/JShowerEnergyCorrection.hh" #include "JReconstruction/JShowerParameters.hh" #include "JReconstruction/JShowerFitParameters_t.hh" #include "JReconstruction/JShowerFit.hh" #include "JReconstruction/JMultiThreadedReconstruction.hh" #include "JLang/JSharedPointer.hh" /** * \file * * Program to perform EM Shower Fit for ORCA with I/O of JFIT::JEvt data. * The reconstruction is made at the PMT level. * \author adomi */ int main(int argc, char** argv){ using namespace std; using namespace JPP; using namespace KM3NETDAQ; typedef JTYPELIST::typelist typelist; typedef JParallelFileScanner< JTypeList > JParallelFileScanner_t; typedef JParallelFileScanner_t::multi_pointer_type multi_pointer_type; typedef JTYPELIST::typelist calibration_types; typedef JMultipleFileScanner JCalibration_t; JParallelFileScanner_t inputFile; JFileRecorder outputFile; JShowerFitParameters_t parameters; JLimit_t& numberOfEvents = inputFile.getLimit(); string detectorFile; JCalibration_t calibrationFile; double Tmax_s; string pdfFile; JShowerEnergyCorrection correct; size_t threads; // number of parallel threads int debug; try { JParser<> zap; zap['f'] = make_field(inputFile) ; zap['o'] = make_field(outputFile) = "JORCAShowerFit_Output.root"; zap['a'] = make_field(detectorFile) ; zap['+'] = make_field(calibrationFile) = JPARSER::initialised(); zap['T'] = make_field(Tmax_s) = 100.0; zap['P'] = make_field(pdfFile) ; zap['E'] = make_field(correct) = JShowerEnergyCorrection(); // off zap['@'] = make_field(parameters) = JPARSER::initialised(); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['N'] = make_field(threads) = 0; zap['d'] = make_field(debug) = 2; 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); JSummaryFileRouter summary(inputFile, parameters.R_Hz); outputFile.open(); outputFile.put(JMeta(argc, argv)); { const JShowerFit::storage_type storage(pdfFile); JShowerFit fit(parameters, storage, correct, debug); JMultiThreadedReconstruction fits(fit, outputFile, threads, 2 * threads); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); multi_pointer_type ps = inputFile.next(); JDAQEvent* tev = ps; JFIT::JEvt* in = ps; summary.update(*tev); if (dynamics) { dynamics->update(*tev); } auto input = fit.getInput(router, summary, *tev, *in, dynamics ? dynamics->getCoverage() : coverage_type()); if (threads > 0) fits.enqueue(input); else outputFile.put(fit(input)); } STATUS(endl); } JSingleFileScanner::typelist> io(inputFile); io >> outputFile; outputFile.close(); }