#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TH2D.h" #include "TProfile2D.h" #include "JTools/JHashCollection.hh" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram string and floor rates. * \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; int debug; try { JParser<> zap("Example program to histogram string and floor rates."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "router.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } cout.tie(&cerr); JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JModuleRouter router(detector); typedef JTOOLS::JHashCollection JHashCollection_t; const JHashCollection_t string(make_array(detector.begin(), detector.end(), &JModule::getString)); const JHashCollection_t floor (make_array(detector.begin(), detector.end(), &JModule::getFloor)); TFile out(outputFile.c_str(), "recreate"); TProfile2D h2("h2", NULL, string.size(), -0.5, string.size() - 0.5, floor .size(), -0.5, floor .size() - 0.5); for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) { h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1))); } for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) { h2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(floor .at(i-1))); } while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); const JDAQSummaryslice* summary = inputFile.next(); for (JDAQSummaryslice::const_iterator frame = summary->begin(); frame != summary->end(); ++frame) { if (router.hasModule(frame->getModuleID())) { const JModule& module = router.getModule(frame->getModuleID()); for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { if (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt)) { h2.Fill((double) string.getIndex(module.getString()), (double) floor .getIndex(module.getFloor()), frame->getRate(pmt) * 1.0e-3); // [kHz] } } } else { FATAL("JModuleRouter trying to access non existing identifier: " << frame->getModuleID()); } } } STATUS(endl); out.Write(); out.Close(); }