#include #include #include #include #include #include "TRandom3.h" #include "JMath/JRandom.hh" #include "JTrigger/JTriggerParameters.hh" #include "JTrigger/JTriggerTestkit.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 JTRIGGER::JTriggerParameters 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 trigger parameters with random data."); zap['o'] = make_field(outputFile) = "trigger_parameters.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); if (debug >= JEEP::debug_t) { setLongprint(cout); } 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) { JTriggerParameters* parameters = inputFile.next(); DEBUG(*parameters << endl); ASSERT(buffer[number_of_events] == *parameters, "Test of file I/O."); } ASSERT(buffer.size() == number_of_events); for (vector::const_iterator i = buffer.begin(); i != buffer.end(); ++i) { stringstream ios; ios << *i; JTriggerParameters parameters; ios >> parameters; ASSERT(parameters == *i, "Test of ASCII I/O"); } return 0; }