#include #include #include #include #include "JLang/JVectorize.hh" #include "JDetector/JPMTParameters.hh" #include "JDetector/JPMTParametersMap.hh" #include "JDetector/JPMTIdentifier.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" namespace { using namespace JPP; static const int WILDCARD = -1; // inline void print(std::ostream& out, const std::string& id, const JPMTParameters& parameters, T __begin, T __end) { using namespace std; using namespace JPP; out << LEFT(12) << id; for (T i = __begin; i != __end; ++i) { out << ' ' << FIXED(7,3); parameters.getProperties()[*i]->write(out); } out << endl; } } /** * \file * * Auxiliary program to print PMT parameters. * * NOTE: PMT identifiers need to be specified as \.\ or as "%" in case the default PMT parameters need to be printed. * \author mdejong, bjung */ int main(int argc, char **argv) { using namespace std; using namespace JPP; JPMTParametersMap parameters; vector pmts; vector keys; int debug; try { const JPMTParameters& buffer = parameters.getDefaultPMTParameters(); const JProperties properties = buffer.getProperties(); JParser<> zap("Auxiliary program to print PMT parameters."); zap['P'] = make_field(parameters, "PMT simulation data (or corresponding file name)") = JPMTParametersMap(); zap['p'] = make_field(pmts, "PMT identifier, e.g. . or \"%\"") = JPARSER::initialised(); zap['k'] = make_field(keys, "parameters:" << endl << get_keys(properties)) = JPARSER::initialised(); zap['d'] = make_field(debug) = 3; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } for (vector::const_iterator i = pmts.cbegin(); i != pmts.cend(); ++i) { if ((*i) != DEFAULT_ID) { // Print PMT-specific parameters const size_t pos = i->find(SEPARATOR); if (pos == string::npos) { FATAL("Invalid PMT specifier " << *i << endl); } const JPMTIdentifier id(stoi(i->substr(0, pos)), stoi(i->substr(pos + 1))); for (JPMTParametersMap::const_iterator ps = parameters.cbegin(); ps != parameters.cend(); ++ps) { if (compare(ps->first, id)) { print(cout, *i, ps->second, keys.cbegin(), keys.cend()); } } } else { // Print default PMT parameters print(cout, *i, parameters.getDefaultPMTParameters(), keys.cbegin(), keys.cend()); } } return 0; }