#include #include #include #include "km3net-dataformat/offline/Head.hh" #include "km3net-dataformat/offline/Evt.hh" #include "km3net-dataformat/offline/Hit.hh" #include "JDAQ/JDAQEventIO.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JTriggeredFileScanner.hh" #include "JSupport/JMonteCarloFileSupportkit.hh" #include "JSupport/JSupport.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to read Monte Carlo events. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JMultipleFileScanner<> inputFile; JLimit_t numberOfEvents; int debug; try { JParser<> zap("Example program to read Monte Carlo events."); zap['f'] = make_field(inputFile, "list of files"); zap['n'] = make_field(numberOfEvents, "number of events to read from file(s)") = JLimit::max(); zap['d'] = make_field(debug, "debug level") = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } { // template argument corresponds to objects which will be read from file(s) JMultipleFileScanner in(inputFile, numberOfEvents); while (in.hasNext()) { STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl); Evt* event = in.next(); // pointer to Monte Carlo event DEBUG("Monte Carlo event " << event->mc_id << endl); } STATUS(endl); } { // optional template argument(s) will be read in parallel to DAQ events JTriggeredFileScanner<> in(inputFile, numberOfEvents); while (in.hasNext()) { STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl); JTriggeredFileScanner<>::multi_pointer_type ps = in.next(); const JDAQEvent* tev = ps; // pointer to DAQ event const Evt* event = ps; // pointer to corresponding Monte Carlo event DEBUG("DAQ event " << tev->getCounter() << endl); DEBUG("Monte Carlo event " << event->mc_id << endl); } STATUS(endl); } }