#include #include #include #include "TRandom3.h" #include "JMath/JRandom.hh" #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "JAAnet/JAAnetTestkit.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JFileRecorder.hh" #include "JSupport/JSupport.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "Jeep/JeepToolkit.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to test I/O of aanet evt with random data. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JFileRecorder outputFile; Long64_t numberOfEvents; UInt_t seed; int debug; try { JParser<> zap("Auxiliary program to test I/O of aanet events with random data."); zap['o'] = make_field(outputFile) = "evt.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); cout.tie(&cerr); if (debug >= JEEP::debug_t) { setLongprint(cout); } use_root = getFilenameExtension(outputFile.getFilename()) == ".root"; outputFile.open(); if (!outputFile.is_open()) { FATAL("Error opening file " << outputFile << endl); } Head head; head["start_run"] = "1 1"; // minimal aanet requirement outputFile.put(head); // 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) { Evt* event = inputFile.next(); DEBUG(*event << endl); ASSERT(buffer[number_of_events] == *event); } ASSERT(buffer.size() == number_of_events); return 0; }