#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TProfile.h" #include "JDAQ/JDAQSummarysliceIO.hh" #include "JDAQ/JDAQEventIO.hh" #include "km3net-dataformat/online/JDAQClock.hh" #include "JDAQ/JDAQEvaluator.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JTreeScanner.hh" #include "JSupport/JSupportToolkit.hh" #include "JSupport/JSupport.hh" #include "JROOT/JManager.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram various data profiles. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; string inputFile; JLimit_t numberOfEvents; string outputFile; Long64_t prescale; int debug; try { JParser<> zap("Example program to histogram various data profiles."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "profile.root"; zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['P'] = make_field(prescale) = 1; zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } NOTICE("Determine frame index range... " << flush); const JFrameIndexRange frame_index = getFrameIndexRange(inputFile); NOTICE("= (" << frame_index.first << "," << frame_index.second << ")" << endl); const Long64_t NX = frame_index.second - frame_index.first + 1; const Long64_t nx = (NX + prescale - 1) / prescale; const Double_t xmin = frame_index.first; const Double_t xmax = frame_index.first + nx * prescale; TFile out(outputFile.c_str(), "recreate"); typedef JManager JManager_t; JManager_t m_summary(new TH1D("Summary[%]", NULL, nx, xmin, xmax)); JManager_t m_trigger(new TH1D("Trigger[%]", NULL, nx, xmin, xmax)); JManager_t m_status (new TH1D("Status[%]", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5)); TH1D hu("#N [all]", NULL, nx, xmin, xmax); TH1D hv("#M [UDP]", NULL, nx, xmin, xmax); TH1D hw("#L [HRV]", NULL, nx, xmin, xmax); TH1D ha("L0 [all]", NULL, nx, xmin, xmax); TH1D hb("L0 [HRV]", NULL, nx, xmin, xmax); TH1D h1("WR", NULL, nx, xmin, xmax); TH1D h2("trigger", NULL, nx, xmin, xmax); TH1D h3("PMT", NULL, nx, xmin, xmax); h2.Sumw2(); for (JMultipleFileScanner in(inputFile, numberOfEvents); in.hasNext(); ) { STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl); JDAQSummaryslice* summary = in.next(); const Double_t x = summary->getFrameIndex(); Double_t U = summary->size(); Double_t V = 0.0; Double_t W = 0.0; Double_t Y[] = { 0.0, 0.0 }; Double_t Z = 0.0; for (JDAQSummaryslice::const_iterator frame = summary->begin(); frame != summary->end(); ++frame) { Double_t y = 0.0; if (frame->testDAQStatus()) { V += 1.0; for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { if (frame->testHighRateVeto(pmt) || frame->testFIFOStatus(pmt)) m_status[frame->getModuleID()]->Fill((Double_t) pmt); else W += 1.0 / NUMBER_OF_PMTS; y += frame->getRate(pmt) * 1e-3; // kHz } } m_summary[frame->getModuleID()]->Fill(x, y); for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { Y[0] += frame->getRate(pmt) * 1e-3; // kHz if (!frame->testHighRateVeto(pmt) && !frame->testFIFOStatus(pmt)) { Y[1] += frame->getRate(pmt) * 1e-3; // kHz } } if (frame->testWhiteRabbitStatus()) { Z += 1.0; } } Y[0] /= (summary->size() * NUMBER_OF_PMTS); Y[1] /= (summary->size() * NUMBER_OF_PMTS); Z /= summary->size(); hu.Fill(x, U / prescale); hv.Fill(x, V / prescale); hw.Fill(x, W / prescale); ha.Fill(x, Y[0] / prescale); hb.Fill(x, Y[1] / prescale); h1.Fill(x, Z / prescale); } STATUS(endl); for (JMultipleFileScanner in(inputFile, numberOfEvents); in.hasNext(); ) { STATUS("event: " << setw(10) << in.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = in.next(); const Double_t x = event->getFrameIndex(); const Double_t y = 1.0e9 / getFrameTime() / prescale; h2.Fill(x, y); typedef JDAQTriggeredHit JHit_t; //typedef JDAQSnapshotHit JHit_t; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { m_trigger[hit->getModuleID()]->Fill(x); } } STATUS(endl); m_summary.Write(out); m_trigger.Write(out); m_status .Write(out); out.Write(); out.Close(); }