#include #include #include #include #include "TROOT.h" #include "TFile.h" #include "TH2D.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, rgruiz */ int main(int argc, char **argv) { using namespace std; using namespace JPP; using namespace KM3NETDAQ; string detectorFile; vector inputFile; string outputFile; string regexp; int labelInterval; bool showPMTAddress; int debug; try { JParser<> zap("Auxiliary application to plot PMT parameters."); zap['a'] = make_field(detectorFile, "detector file."); zap['P'] = make_field(inputFile, "PMT calibration data file(s)"); zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root"; zap['r'] = make_field(regexp, "regular expresion to extract bin labels for the x-axis") = " "; zap['A'] = make_field(showPMTAddress, "show PMT address on y-axis"); zap['L'] = make_field(labelInterval, "interval between x-axis bins for which labels are shown") = 1; 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()); vector parameters; for (vector::const_iterator i = inputFile.begin(); i != inputFile.end(); ++i) { parameters.push_back(JPMTParametersMap(i->c_str())); } const int NUMBER_OF_FILES = parameters.size(); JManager manager(new TH2D("%", NULL, NUMBER_OF_FILES, -0.5, NUMBER_OF_FILES - 0.5, NUMBER_OF_PMTS, -0.5, NUMBER_OF_PMTS - 0.5)); manager->Sumw2(kFALSE); if (regexp != " ") { const int n = (NUMBER_OF_FILES < labelInterval) ? 1 : labelInterval; const TPRegexp buffer(regexp); for (int i = 0; i != NUMBER_OF_FILES; ++i) { if(i%n == 0) manager->GetXaxis()->SetBinLabel(i+1 , parse(buffer, TString(inputFile[i].c_str()))); else manager->GetXaxis()->SetBinLabel(i+1 , " "); } } 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) { for (int i = 0; i != NUMBER_OF_FILES; ++i) { const JProperties properties = parameters[i].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(i + 1, pmt + 1, p->second.getValue()); } catch(const exception& error) {} try { manager[MAKE_CSTRING(module->getID() << "." << p->first)]->SetBinContent(i + 1, pmt + 1, p->second.getValue() ? 1.0 : 0.0); } catch(const exception& error) {} } const JPMTParameters buffer = parameters[i].getPMTParameters(JPMTIdentifier(module->getID(), pmt)); manager[MAKE_CSTRING(module->getID() << "." << "EFFICIENCY")]->SetBinContent(i + 1, pmt + 1, getSurvivalProbability(buffer) * buffer.QE); } } } for (JManager::iterator i = manager.begin(); i != manager.end(); ++i) { i->second->Sumw2(kFALSE); } if (showPMTAddress){ for (JManager::iterator i = manager.begin(); i != manager.end(); ++i) { int id; istringstream(i->first) >> id; setAxisLabels(*i->second, "Y", demo.get(id)); } } manager.Write(outputFile.c_str()); }