#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "TH2D.h" #include "JTools/JRange.hh" #include "JROOT/JManager.hh" #include "JROOT/JRootToolkit.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); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const floor_range range = getRangeOfFloors(detector); const JDAQHitRouter router(detector); const JStringRouter string(detector); TH1D h1("h1", NULL, 100, 0.0, 1.0e1); JManager H2(new TH2D("h2[%]", NULL, getNumberOfStrings(detector), -0.5, getNumberOfStrings(detector) - 0.5, range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 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()); for (int i = 0; i != NUMBER_OF_TRIGGER_BITS; ++i) { if (hit->hasTriggerBit(i)) { H2[i]->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); TFile out(outputFile.c_str(), "recreate"); out << h1; out << *H2; out << H2; out << *h3; out.Write(); out.Close(); }