#include #include #include #include #include #include "Jeep/JPrint.hh" #include "Jeep/JParser.hh" #include "Jeep/JMessage.hh" /** * \author mdejong */ /** * Auxiliary program to convert PMT QE(angle) data. */ int main(int argc, char **argv) { using namespace std; string inputFile; int debug; try { JParser<> zap("Auxiliary program to convert PMT QE(angle) data."); zap['f'] = make_field(inputFile); zap['d'] = make_field(debug) = 1; zap(argc, argv); } catch(const exception &error) { FATAL(error.what() << endl); } const string DEG("deg"); if (inputFile != "") { ifstream in(inputFile.c_str()); while (in.peek() == '#') { in.ignore(numeric_limits::max(), '\n'); } // header vector energy; vector wavelength; string buffer, key; if (getline(in,buffer)) { istringstream is(buffer); is >> key; for (double x; is >> x; ) { energy.push_back(x); } } if (getline(in,buffer)) { istringstream is(buffer); is >> key; for (double x; is >> x; ) { wavelength.push_back(x); } } //in.ignore(numeric_limits::max(), '\n'); // data while (getline(in,buffer)) { istringstream is(buffer); // first column /* is >> key; const size_t pos = key.find(DEG); if (pos != string::npos) { key.replace(pos, DEG.size(), ""); } double angle; istringstream(key) >> angle; */ double ct; is >> ct; // following columns size_t i = 0; for (double y ; is >> y; ++i) { if (i != energy.size()) { cout << " (*this)" << noshowpos //<< "[" << FIXED(5,1) << angle << "]" //<< "[" << FIXED(3,1) << energy[i] << "]" << "[" << FIXED(5,2) << -ct << "]" << "[" << FIXED(3,1) << wavelength[i] << "]" << " = " << showpos << FIXED(9,5) << y << ";" << endl; } else { //FATAL("Inconsistent data " << i << " != " << energy.size() << endl); FATAL("Inconsistent data " << i << " != " << wavelength.size() << endl); } } if (i != energy.size()) { //FATAL("Inconsistent data " << i << " != " << energy.size() << endl); FATAL("Inconsistent data " << i << " != " << wavelength.size() << endl); } } in.close(); } }