#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "km3net-dataformat/online/JDAQ.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JPMTParametersMap.hh" #include "JDetector/JPMTParametersToolkit.hh" #include "JDetector/JDetectorAddressMap.hh" #include "JDetector/JDetectorAddressMapToolkit.hh" #include "JROOT/JManager.hh" #include "JGizmo/JGizmoToolkit.hh" #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * Auxiliary application to plot PMT parameters. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; string detectorFile; JPMTParametersMap parameters; string outputFile; bool showPMTAddress; int debug; try { JParser<> zap("Auxiliary application to plot PMT parameters."); zap['a'] = make_field(detectorFile, "detector file."); zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root"; zap['P'] = make_field(parameters, "PMT calibration data (or corresponding file name)"); zap['A'] = make_field(showPMTAddress, "show PMT address on y-axis"); zap['d'] = make_field(debug, "debug") = 0; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } if (detector.empty()) { FATAL("Empty detector." << endl); } const JDetectorAddressMap& demo = getDetectorAddressMap(detector.getID()); JManager manager(new TH1D("%", NULL, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5)); for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) { DEBUG("Module " << setw(10) << module->getID() << endl); for (int pmt = 0; pmt != NUMBER_OF_PMTS; ++pmt) { const JProperties properties = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt)).getProperties(); for (JProperties::const_iterator p = properties.begin(); p != properties.end(); ++p) { try { manager[MAKE_CSTRING(module->getID() << "." << p->first)]->SetBinContent(pmt + 1, p->second.getValue()); } catch(const exception& error) {} try { manager[MAKE_CSTRING(module->getID() << "." << p->first)]->SetBinContent(pmt + 1, p->second.getValue() ? 1.0 : 0.0); } catch(const exception& error) {} } const JPMTParameters buffer = parameters.getPMTParameters(JPMTIdentifier(module->getID(), pmt)); manager[MAKE_CSTRING(module->getID() << "." << "EFFICIENCY")]->SetBinContent(pmt + 1, getSurvivalProbability(buffer) * buffer.QE); } } if (showPMTAddress){ for (JManager::iterator i = manager.begin(); i != manager.end(); ++i) { int id; istringstream(i->first) >> id; setAxisLabels(*i->second, "X", demo.get(id)); } } manager.Write(outputFile.c_str()); }