#include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "km3net-dataformat/online/JDAQPMTIdentifier.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "JROOT/JManager.hh" #include "Jeep/JeepToolkit.hh" #include "JLang/JObjectMultiplexer.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram KM3NETDAQ::JDAQTimeslice. * \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; JDAQPMTIdentifier PMT; int debug; try { JParser<> zap("Example program to histogram timeslice data."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "timeslice.root"; zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['P'] = make_field(PMT) = JDAQPMTIdentifier(-1, -1); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } cout.tie(&cerr); const bool zoom = (PMT.getModuleID() != -1 && PMT.getPMTAddress() != -1); JManager h0(new TH1D("h0[%]", NULL, numeric_limits::max(), -0.5, numeric_limits::max() - 0.5)); JManager h1(new TH1D("h1[%]", NULL, numeric_limits::max(), -0.5, numeric_limits::max() - 0.5)); JManager h2(new TH1D("h2[%]", NULL, (zoom ? 20000000 : 1000), -0.5, getFrameTime() + 0.5)); h0->Sumw2(); h1->Sumw2(); h2->Sumw2(); JObjectMultiplexer in(inputFile); for (counter_type counter = 0; in.hasNext(); ++counter) { STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl); JDAQTimeslice* timeslice = in.next(); TH1D* p0 = h0[getClassname(timeslice->GetName())]; TH1D* p1 = h1[getClassname(timeslice->GetName())]; TH1D* p2 = h2[getClassname(timeslice->GetName())]; for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) { for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) { if (JDAQPMTIdentifier::compare(PMT, JDAQPMTIdentifier(frame->getModuleID(), hit->getPMT()))) { p0->Fill(hit->getPMT()); p1->Fill(hit->getToT()); p2->Fill(hit->getT()); } } } } STATUS(endl); TFile out(outputFile.c_str(), "recreate"); h0.Write(out); h1.Write(out); h2.Write(out); out.Write(); out.Close(); }