#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TH2D.h" #include "JTools/JRange.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JDAQHitRouter.hh" #include "JDetector/JStringRouter.hh" #include "JSupport/JMultipleFileScanner.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Example program to histogram string and floor 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; int debug; try { JParser<> zap("Example program to histogram string and floor hits."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "router.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['d'] = make_field(debug) = 2; zap(argc, argv); } catch(const exception& error) { FATAL(error.what() << endl); } cout.tie(&cerr); JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JDAQHitRouter router(detector); const JStringRouter string(detector); TFile out(outputFile.c_str(), "recreate"); TH1D h1("h1", NULL, 100, 0.0, 1.0e1); TH2D h2("h2", NULL, getNumberOfStrings(detector), -0.5, getNumberOfStrings(detector) - 0.5, getNumberOfFloors (detector), +0.5, getNumberOfFloors (detector) + 0.5); for (Int_t i = 1; i <= h2.GetXaxis()->GetNbins(); ++i) { h2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1))); } for (Int_t i = 1; i <= h2.GetYaxis()->GetNbins(); ++i) { h2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i)); } TH2D* h3 = (TH2D*) h2.Clone("h3"); while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = inputFile.next(); JTimeRange tx = JTimeRange::DEFAULT_RANGE; { typedef JDAQTriggeredHit JHit_t; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { const JPMTChannel& channel = router.getPMTChannel(*hit); h2.Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor()); tx.include(getTime(*hit, router.getPMT(*hit))); } } h1.Fill(tx.getLength() * 1.0e-3); { typedef JDAQSnapshotHit JHit_t; for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { const JPMTChannel& channel = router.getPMTChannel(*hit); h3->Fill((double) string.getIndex(channel.getString()), (double) channel.getFloor()); } } } STATUS(endl); out.Write(); out.Close(); }