#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "JDAQ/JDAQEventIO.hh" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JTrigger/JTriggerToolkit.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JSupport.hh" #include "JSupport/JSummaryFileRouter.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Program to plot snapshot data. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JSingleFileScanner inputFile; string outputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string detectorFile; int debug; try { JParser<> zap("Program to perform fit of muon energy to data."); zap['f'] = make_field(inputFile, "input file."); zap['o'] = make_field(outputFile, "output file.") = "snapshot.root"; zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['a'] = make_field(detectorFile, "detector file.") = ""; zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } cout.tie(&cerr); JDetector detector; if (detectorFile != "") { try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } } const JModuleRouter router(detector); JSummaryFileRouter summary(inputFile, 0.0); TFile out(outputFile.c_str(), "recreate"); TH1D h0("h0", NULL, 250, -0.5, 499.5); TH1D h1("h1", NULL, 250, -0.5, 499.5); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = inputFile.next(); summary.update(*event); int number_of_hits = 0; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { if (summary.hasSummaryFrame(hit->getModuleID())) { const JDAQSummaryFrame& frame = summary.getSummaryFrame(hit->getModuleID()); JStatus status; if (router.hasModule(frame.getModuleID())) { status = router.getModule(frame.getModuleID()).getPMT(hit->getPMT()).getStatus(); } if (getPMTStatus(frame, status, hit->getPMT()) && getDAQStatus(frame, status)) { ++number_of_hits; } } } DEBUG("Number of snapshot hits " << event->size() << ' ' << number_of_hits << endl); h0.Fill((double) event->size ()); h1.Fill((double) number_of_hits); } STATUS(endl); out.Write(); out.Close(); }