#include #include #include #include "TRandom3.h" #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQTestkit.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to test I/O of KM3NETDAQ::JDAQEvent with random data. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JFileRecorder outputFile; Long64_t numberOfEvents; UInt_t seed; int debug; try { JParser<> zap("Auxiliary program to test I/O of DAQ events with random data."); zap['o'] = make_field(outputFile) = "event.root"; zap['n'] = make_field(numberOfEvents) = 10; zap['S'] = make_field(seed) = 0; zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } gRandom->SetSeed(seed); setDAQLongprint(debug >= JEEP::debug_t); ASSERT(numberOfEvents > 0); outputFile.open(); if (!outputFile.is_open()) { FATAL("Error opening file " << outputFile << endl); } // create data vector buffer; for (int event = 1; event <= numberOfEvents; ++event) { buffer.push_back(getRandom()); outputFile.put(*buffer.rbegin()); } outputFile.close(); ASSERT((Long64_t) buffer.size() == numberOfEvents); // test JSingleFileScanner inputFile(outputFile.getFilename()); size_t number_of_events = 0; for ( ; inputFile.hasNext(); ++number_of_events) { JDAQEvent* event = inputFile.next(); DEBUG(*event << endl); ASSERT(buffer[number_of_events] == *event); } ASSERT(buffer.size() == number_of_events); return 0; }