#include #include #include #include #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/MultiHead.hh" #include "km3net-dataformat/offline/Evt.hh" #include "km3net-dataformat/online/JDAQHeader.hh" #include "km3net-dataformat/online/JDAQUTCExtended.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JTrigger/JTriggerParameters.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "JSupport/JTriggerParametersSupportkit.hh" #include "JSupport/JMeta.hh" #include "JSupport/JSupport.hh" #include "JLang/JPipe.hh" #include "JLang/JObjectSelector.hh" #include "JROOT/JROOTClassSelector.hh" #include "JTools/JRange.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace KM3NETDAQ; using namespace JLANG; /** * Type definition for DAQ UTC time range. */ typedef JTOOLS::JRange JDAQUTCTimeRange; /** * Default implementation for selection of objects based on UTC time range. */ template::value> struct JSelector : public virtual JObjectSelector, public virtual JDAQUTCTimeRange { virtual bool accept(const T& object) const override { return true; } }; /** * Custom implementation for selection of objects based on UTC time range. */ template<> struct JSelector : public virtual JObjectSelector, public virtual JDAQUTCTimeRange { virtual bool accept(const Evt& object) const override { return (*this)(JDAQUTCExtended(object.t.GetSec(), object.t.GetNanoSec() / 16)); } }; /** * Common implementation for selection of objects based on UTC time range. */ template struct JSelector : public virtual JObjectSelector, public virtual JDAQUTCTimeRange { virtual bool accept(const T& object) const override { return (*this)(object.getTimesliceStart()); } }; /** * Implementation for multiple selection of objects based on UTC time range. */ template struct JSelector< JTypeList, false > : public virtual JObjectSelector< JTypeList >, public JSelector, public JSelector {}; /** * Terminator class of recursive JSelector class. */ template struct JSelector< JTypeList, false > : public JSelector {}; } /** * \file * Auxiliary program to convert data formats and/or to select data. * Possible file name extensions include ".evt" (ASCII), ".root" (ROOT) and ".dat" (binary).\n * The following data structures and file name extensions are supported: * * * * * * * * *
type evt root dat
KM3NETDAQ::JDAQEvent I/O I/O
KM3NETDAQ::JDAQTimeslice I/O I/O
KM3NETDAQ::JDAQSummaryslice I/O I/O
Head I I/O
Evt I I/O
* * The name of the data structure following option -C should be preceded by a '+' or '-' * to add or remove data types in the output, respectively.\n * In this, ROOT wildcards are accepted (e.g. -C -\\\.\\* will remove all data types). * * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; typedef JAllTypes_t typelist; JMultipleFileScanner inputFile; JFileRecorder outputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); JROOTClassSelection selection = getROOTClassSelection(); bool& merge = JMultipleFileScanner::merge; JSelector selector; int debug; try { JParser<> zap("Auxiliary program to convert data formats and/or to select data."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['C'] = make_field(selection, "Precede name of data structure by a '+' or '-' " "to add or remove data types in the output, respectively." "\nROOT wildcards are accepted.") = JPARSER::initialised(); zap['m'] = make_field(merge, "Allow merging of files w/o Monte Carlo headers"); zap['r'] = make_field(selector) = JPARSER::initialised(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } outputFile.open(); outputFile.put(JMeta(argc,argv)); inputFile | JValve(selection) | selector | outputFile; outputFile.close(); }