#include #include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "JDAQ/JDAQEventIO.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to analyse KM3NETDAQ::JDAQEvent. * \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; JDAQTriggerMask trigger_mask; int debug; try { JParser<> zap("Example program to histogram event data."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "event.root"; zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['T'] = make_field(trigger_mask) = TRIGGER_MASK_ON; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } TFile out(outputFile.c_str(), "recreate"); TH1D h0("h0", NULL, numeric_limits::max(), -0.5, numeric_limits::max() - 0.5); TH1D h1("h1", NULL, numeric_limits::max(), -0.5, numeric_limits::max() - 0.5); TH1D h2("h2", NULL, 1000, 0.0, getFrameTime()); TH1D hn("hn", NULL, 1001, -0.5, 1000.5); TH1D hs("hs", NULL, 1001, -0.5, 1000.5); TH1D ho("ho", NULL, 101, -0.5, 100.5); TH1D ha("ha", NULL, 101, -0.5, 100.5); TH1D hb("hb", NULL, 101, -0.5, 100.5); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = inputFile.next(); if (event->hasTriggerMask(trigger_mask)) { { typedef JDAQTriggeredHit JHit_t; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { h0.Fill(hit->getPMT()); h1.Fill(hit->getToT()); h2.Fill(hit->getT()); } } hn.Fill((double) event->size()); hs.Fill((double) event->size()); ho.Fill((double) event->getOverlays()); { set buffer; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { if (hit->hasTriggerMask(trigger_mask)) { buffer.insert(hit->getModuleID()); } } ha.Fill((double) buffer.size()); } { set buffer; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { buffer.insert(hit->getModuleID()); } hb.Fill((double) buffer.size()); } } } STATUS(endl); out.Write(); out.Close(); }