#include #include #include #include "TROOT.h" #include "TFile.h" #include "TH1D.h" #include "JDB/JDB.hh" #include "JDB/JSelector.hh" #include "JDB/JSelectorSupportkit.hh" #include "JDB/JDetectorIntegration_t.hh" #include "JDB/JPBSSequence.hh" #include "JDB/JProductRouter.hh" #include "JDB/JDBToolkit.hh" #include "JDetector/JDetector.hh" #include "JDetector/JDetectorToolkit.hh" #include "JDetector/JPMTParametersMap.hh" #include "JDetector/JPMTParametersToolkit.hh" #include "JDetector/JLocationRouter.hh" #include "JROOT/JManager.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \file * * Auxiliary application to plot PMT parameters as a function of variant. * \author mdejong */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JServer server; string usr; string pwd; string cookie; string detectorFile; string inputFile; JPMTParametersMap parameters; string outputFile; int debug; try { JParser<> zap("Auxiliary application to plot PMT parameters as a function of variant."); zap['s'] = make_field(server) = getServernames(); zap['u'] = make_field(usr) = ""; zap['!'] = make_field(pwd) = ""; zap['C'] = make_field(cookie) = ""; zap['a'] = make_field(detectorFile, "detector file."); zap['f'] = make_field(inputFile, "output of JPrintDB -q \"integration\" -c \";\" -W1") = ""; zap['o'] = make_field(outputFile, "output file.") = "pmt_parameters.root"; zap['P'] = make_field(parameters, "PMT calibration data (or corresponding file name)"); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } JDetector detector; try { load(detectorFile, detector); } catch(const JException& error) { FATAL(error); } const JLocationRouter router(detector); JDetectorIntegration_t integration; string detid = ""; try { JDB::reset(usr, pwd, cookie); detid = getDetector(detector.getID()); } catch(const exception& error) { FATAL(error.what() << endl); } if (inputFile != "") { integration.load(inputFile.c_str()); } else { DEBUG("Reading database table " << getTable() << endl); try { ResultSet& rs = getResultSet(getTable()); if (! (rs >> integration)) { THROW(JDatabaseException, "Error reading " << getTable()); } } catch(const exception& error) { FATAL(error.what() << endl); } } integration.configure(detid); const JProductRouter product(integration, getPBSSequences(PBS::PMT)); JDetectorIntegration_t::range_type range = integration.find(PBS::PMT); JManager H1(new TH1D("TTS_ns[%]", NULL, 100, 0.0, 4.0)); JManager H2(new TH1D("QE[%]", NULL, 100, 0.0, 2.0)); JManager H3(new TH1D("gain[%]", NULL, 100, 0.0, 2.0)); JManager H4(new TH1D("gainSpread[%]", NULL, 100, 0.0, 1.0)); for (JDetectorIntegration_t::range_const_iterator i = range.first; i != range.second; ++i) { const JUPI_t upi = integration[i->second].content.getUPI(); const JLocation_t location = product.getLocation(upi); DEBUG("PMT " << left << setw(24) << upi.getVariant() << right << ' ' << location << endl); if (location.is_valid()) { const JModule& module = router.getModule(JLocation(location.string, location.floor)); const JPMTParameters& buffer = parameters.getPMTParameters(JPMTIdentifier(module.getID(), location.position)); H1[upi.getVariant()]->Fill(buffer.TTS_ns); H2[upi.getVariant()]->Fill(buffer.QE); H3[upi.getVariant()]->Fill(buffer.gain); H4[upi.getVariant()]->Fill(buffer.gainSpread); } } TFile out(outputFile.c_str(), "recreate"); out << H1 << H2 << H3 << H4; out.Write(); out.Close(); }