#include #include #include #include "JDAQ/JDAQSummarysliceIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JTrigger/JTriggerParameters.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JTriggerParametersSupportkit.hh" #include "JSupport/JSupport.hh" #include "JSupport/JMeta.hh" #include "JSummaryslice/JSummaryslice.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to blend and write summary data. * * This application can be used to convert measured rates of any detector * to a consistent set of rates for a simulated complete detector.\n * The rates as well as the high-rate veto and FIFO (almost) full will then be included * in the run-by-run simulations using JTriggerEfficiency.cc. * * The option -f \ corresponds to a list of input files * containing summary data (commonly referred to as "measured rates").\n * These data can originate from any detector. * * The option -a \ corresponds to the detector to be used in simulations.\n * This could be a complete detector. * * The option -@ \ corresponds to the trigger parameters.\n * This is needed here because in the run-by-run simulations, * the trigger parameters are taken from the input file. * * The application JSummaryWriter.cc can be used to write summary data according user defined input rates. * * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JMultipleFileScanner inputFile; JFileRecorder ::typelist> outputFile; int numberOfEvents; string detectorFile; JTriggerParameters parameters; int run_number; int debug; try { JParser<> zap("Auxiliary program to blend and write summary data."); zap['f'] = make_field(inputFile); zap['n'] = make_field(numberOfEvents); zap['o'] = make_field(outputFile); zap['a'] = make_field(detectorFile); zap['@'] = make_field(parameters) = JPARSER::initialised(); zap['R'] = make_field(run_number) = 1; zap['d'] = make_field(debug) = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } // check availability of sufficient summary data unsigned int number_of_modules = 0; while (inputFile.hasNext() && number_of_modules < detector.size()) { number_of_modules += inputFile.next()->size(); } if (number_of_modules < detector.size()) { FATAL("Input summary data insufficient: " << number_of_modules << " < " << detector.size() << endl); } inputFile.rewind(); outputFile.open(); outputFile.put(JMeta(argc, argv)); outputFile.put(parameters); for (int frame_index = 1; frame_index <= numberOfEvents; ) { NOTICE("event: " << setw(10) << frame_index << '\r'); DEBUG(endl); JSummaryslice summary(JDAQChronometer(detector.getID(), run_number, frame_index, getTimeOfFrame(frame_index)), inputFile, detector); if (summary.size() == detector.size()) { outputFile.put(summary); ++frame_index; } else { inputFile.rewind(); } } NOTICE(endl); outputFile.close(); }