39int main(
int argc,
char **argv)
63 JParser<> zap(
"Auxiliary program to print high-voltage tuning results.");
65 zap[
'f'] =
make_field(inputFile,
"input file (JSON output of JTuneHV)");
66 zap[
'a'] =
make_field(detectorFile,
"detector file");
67 zap[
'o'] =
make_field(
outputFile,
"output file (for writing failed evaluations to separate JSON output)") =
"";
73 }
catch(
const exception &error) {
75 FATAL(error.what() << endl);
78 if (!
outputFile.empty() && (login.empty() || locationID.empty())) {
80 FATAL(
"Missing user information (please specify via -#login and -#locationID).");
84 const JUUID& UUID = JUUID::rndm();
88 timer.
sub(elapsedTime);
95 catch (
const exception& error) {
96 FATAL(error.what() << endl);
110 if (isJSONFile(inputFile.c_str())) {
114 ifstream ifs(inputFile.c_str());
121 json::const_iterator i0 = js.find(APIVersion_t);
123 if (i0 != js.cend()) {
125 istringstream iss(i0->get<
string>());
132 json::const_iterator i1 = js.find(Data_t);
135 (i1 != js.cend() && i1->size() > 0)) {
137 DBTestType = (*i1)[0].at(Test_t + Type_t).get<
string>();
139 JHVCalibration_t::setVersion(getDBVersionTuneHV(DBTestType));
142 metaInfoStr += (*i1)[0].at(Provenance_t + Info_t).at(Configuration_t).get<
string>();
146 DBTestType = js.at(Test_t + Type_t).get<
string>();
148 JHVCalibration_t::setVersion(getDBVersionTuneHV(DBTestType));
155 RIGHT(20) <<
"HV" <<
RIGHT (10) <<
"gain" <<
RIGHT(10) <<
"status" << endl);
157 for (JHVCalibration::const_iterator it = HVcals.cbegin(); it != HVcals.cend(); ++it) {
165 if (it->result != OK_t) {
169 NOTICE(
LEFT (30) << pmtUPI <<
"(a.k.a. " << pmtID <<
" / " << location <<
"):" <<
170 FIXED(20,1) << it->supplyVoltage <<
RIGHT(10) << it->result << endl);
177 ERROR(inputFile <<
" is not a JSON file." << endl);
186 NOTICE(endl <<
FILL(105,
'-') <<
" List of failures" << setfill(
' ') << endl);
190 Nfailed += i->second.size();
192 if (i->second.size() == NUMBER_OF_PMTS) {
194 Nmissing += NUMBER_OF_PMTS;
195 WARNING(
"No successful calibrations found for module " << i->first <<
" (dead module?)" << endl);
199 for (JHVCalibration::const_iterator j = i->second.cbegin(); j != i->second.cend(); ++j) {
201 const JUPI_t& pmtUPI = j->getUPI();
207 NOTICE(
LEFT(30) << pmtUPI <<
"(a.k.a. " << pmtID <<
" / " << location <<
"):" <<
208 right <<
FIXED(20,1) << j->supplyVoltage <<
RIGHT(10) << j->result << endl);
210 failures.push_back(*j);
215 NOTICE(endl <<
FILL(105,
'-') <<
" SUMMARY" << setfill(
' ') << endl);
216 NOTICE(
LEFT(40) <<
"Number of evaluated PMTs:" <<
RIGHT(20) << Ntotal << endl);
217 NOTICE(
LEFT(40) <<
"Number of successful evaluations:" <<
RIGHT(20) << Ntotal - Nfailed << endl);
218 NOTICE(
LEFT(40) <<
"Number of failed evaluations:" <<
RIGHT(20) << Nfailed << endl);
219 NOTICE(
RIGHT(20) <<
'-' <<
LEFT(20) <<
" in missing modules:" <<
RIGHT(20) << Nmissing << endl);
220 NOTICE(
RIGHT(20) <<
'-' <<
LEFT(20) <<
" other:" <<
RIGHT(20) << Nfailed - Nmissing << endl << endl);
229 json error = { {Message_t,
"" },
231 {Arguments_t, json::array() } };
233 json metaData = { {Configuration_t, metaInfoStr },
236 json data = { {Provenance_t + Info_t,
json(metaData) },
238 {Location_t, locationID },
239 {Start_t + Time_t, timer.
toString() },
240 {End_t + Time_t, timer().
toString() },
241 {Test_t + Type_t, DBTestType },
242 {Tests_t,
json(failures) } };
245 js[Data_t + Type_t] =
MAKE_STRING(
"ProductTestSession");
247 js[Error_t] =
json(error);
250 js[Data_t][0] =
json(data);
255 js[Location_t] = locationID;
256 js[Test_t + Type_t] = DBTestType;
257 js[Start_t + Time_t] = timer.
toString();
258 js[End_t + Time_t] = timer().
toString();
259 js[Tests_t] =
json(failures);
264 ofs << setw(2) << setprecision(8);