#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 "JROOT/JROOTClassSelector.hh" #include "JDAQ/JDAQTimesliceIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JDetector/JStringRouter.hh" #include "JLang/JObjectMultiplexer.hh" #include "JTrigger/JChecksum.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; JROOTClassSelector selector; int debug; try { JParser<> zap("Example program to histogram string and floor hits."); zap['f'] = make_field(inputFile); zap['o'] = make_field(outputFile) = "checksum.root"; zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['C'] = make_field(selector) = getROOTClassSelection(); 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 JModuleRouter router(detector); const JStringRouter string(detector); 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)); } JObjectMultiplexer in(inputFile, selector); for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) { STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl); const JDAQTimeslice* timeslice = in.next(); for (JDAQTimeslice::const_iterator frame = timeslice->begin(); frame != timeslice->end(); ++frame) { const JModule module = router.getModule(frame->getModuleID()); const JChecksum::result_type result = checksum.get(*frame); for (JChecksum::const_iterator error = result.begin(); error != result.end(); ++error) { H2[error->type]->Fill((double) string.getIndex(module.getString()), (double) module.getFloor()); } } } STATUS(endl); TFile out(outputFile.c_str(), "recreate"); out << H2; out.Write(); out.Close(); }