#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "JTools/JRange.hh" #include "JROOT/JRootToolkit.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JDAQHitRouter.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to monitor event duration. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JMultipleFileScanner inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string outputFile; string detectorFile; double T_ns; int qaqc; int debug; try { JParser<> zap("Example program to monitor event duration."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "mermaid.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['T'] = make_field(T_ns, "Time limit for event duration [ns]") = 10.0e3; zap['Q'] = make_field(qaqc) = 0; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JDAQHitRouter router(detector); TH1D h1("h1", NULL, 100, 0.0, 10.0e3); size_t N = 0; while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = inputFile.next(); JTimeRange tx = JTimeRange::DEFAULT_RANGE(); for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { tx.include(getTime(*hit, router.getPMT(*hit))); } h1.Fill(tx.getLength()); if (tx.getLength() >= T_ns) { N += 1; } } STATUS(endl); TFile out(outputFile.c_str(), "recreate"); out << h1; out.Write(); out.Close(); NOTICE("Number of event with duration beyond " << FIXED(9,0) << T_ns << " [ns] " << N << endl); QAQC(N << endl); return 0; }