#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); } 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)); JManager H3(new TH1D("h3[%]", NULL, 100, 0.0, 7.0)); 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* h0 = H0[getClassname(timeslice->GetName())]; TH1D* h1 = H1[getClassname(timeslice->GetName())]; TH1D* h2 = H2[getClassname(timeslice->GetName())]; TH1D* h3 = H3[getClassname(timeslice->GetName())]; for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) { h3->Fill(log10((double) frame->size())); for (JDAQSuperFrame::const_iterator hit = frame->begin(); hit != frame->end(); ++hit) { if (JDAQPMTIdentifier::compare(PMT, JDAQPMTIdentifier(frame->getModuleID(), hit->getPMT()))) { h0->Fill(hit->getPMT()); h1->Fill(hit->getToT()); h2->Fill(hit->getT()); } } } } STATUS(endl); TFile out(outputFile.c_str(), "recreate"); out << H0 << H1 << H2 << H3; out.Write(); out.Close(); }