#include #include #include #include #include #include "km3net-dataformat/online/JDAQ.hh" #include "JDAQ/JDAQEventIO.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JModuleRouter.hh" #include "JDetector/JPMTParametersMap.hh" #include "JTools/JQuantile.hh" #include "JSupport/JSingleFileScanner.hh" #include "JSupport/JTreeScanner.hh" #include "JSupport/JSupport.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary program to monitor optical module response. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; JSingleFileScanner inputFile; JLimit_t& numberOfEvents = inputFile.getLimit(); string outputFile; string detectorFile; string pmtFile; double factor; int debug; try { JParser<> zap("Auxiliary program to monitor optical module response."); zap['f'] = make_field(inputFile); zap['a'] = make_field(detectorFile); zap['n'] = make_field(numberOfEvents) = JLimit::max(); zap['P'] = make_field(pmtFile) = ""; zap['s'] = make_field(factor) = 5.0e-2; 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); } map zmap; for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) { zmap[i->getID()] = 0; } while (inputFile.hasNext()) { STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl); JDAQEvent* event = inputFile.next(); for (JDAQEvent::const_iterator hit = event->begin(); hit != event->end(); ++hit) { zmap[hit->getModuleID()] += 1; } } STATUS(endl); JQuantile Q("DOM", true); for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) { Q.put(zmap[i->getID()]); } const double Rmin = factor * Q.getQuantile(0.5); NOTICE("Minimal DOM count " << Rmin << endl); for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) { NOTICE("module " << setw(3) << i->getString() << ' ' << setw(2) << i->getFloor() << ' ' << setw(8) << i->getID() << ' ' << setw(6) << zmap[i->getID()] << ' ' << (zmap[i->getID()] < Rmin ? "***" : "") << endl); } if (pmtFile != "") { JPMTParametersMap parameters; try { parameters.load(pmtFile.c_str()); } catch(const JException& error) {} for (JDetector::const_iterator i = detector.begin(); i != detector.end(); ++i) { if (zmap[i->getID()] < Rmin) { for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { parameters[JPMTIdentifier(i->getID(), pmt)].QE = 0.0; } } } parameters.store(pmtFile.c_str()); } }