#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "km3net-dataformat/online/JDAQ.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JROOT/JROOTClassSelector.hh" #include "JLang/JObjectMultiplexer.hh" #include "JTrigger/JSuperFrame2D.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "JROOT/JManager.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Example program to process L0 hits. * \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; JROOTClassSelector selector; int debug; try { JParser<> zap("Example program to process L0 hits."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "hitL0.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['C'] = make_field(selector) = getROOTClassSelection(); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JModuleRouter router(detector); JManager h0(new TH1D("h0[%]", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5)); typedef double hit_type; typedef JSuperFrame2D JSuperFrame2D_t; JObjectMultiplexer in(inputFile, selector); for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) { STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl); const JDAQTimeslice* timeslice = in.next(); for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) { TH1D* h1 = h0[super_frame->getModuleID()]; if (router.hasModule(super_frame->getModuleID())) { const JModule& module = router.getModule(super_frame->getModuleID()); JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module); for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { if (buffer[pmt].size() > 1) { h1->Fill((Double_t) pmt); } } } } } STATUS(endl); h0.Write(outputFile.c_str()); }