Jpp  pmt_effective_area_update
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
examples/JCalibrate/JPrintPMTThreshold.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <fstream>
5 #include <algorithm>
6 
7 #include "JLang/JComparator.hh"
9 
10 #include "Jeep/JParser.hh"
11 #include "Jeep/JMessage.hh"
12 
13 
14 /**
15  * \file
16  *
17  * Auxiliary program to print PMT thresholds.
18  * \author mdejong
19  */
20 int main(int argc, char **argv)
21 {
22  using namespace std;
23  using namespace JPP;
24 
25  string inputFile;
26  int threshold;
27  int debug;
28 
29  try {
30 
31  JParser<> zap("Auxiliary program to print PMT thresholds.");
32 
33  zap['f'] = make_field(inputFile, "PMT threshold file (json format)");
34  zap['T'] = make_field(threshold) = 0;
35  zap['d'] = make_field(debug) = 1;
36 
37  zap(argc, argv);
38  }
39  catch(const exception &error) {
40  FATAL(error.what() << endl);
41  }
42 
43 
44  json js;
45 
46  istream* in = open<istream>(inputFile.c_str());
47 
48  *in >> js;
49 
50  close(in);
51 
52  JTHCalibration calibration = js.at(Tests_t).get<JTHCalibration>();
53 
54  sort(calibration.begin(), calibration.end(), make_comparator(&JTHCalibration_t::getUPI));
55 
56  for (JTHCalibration::const_iterator i = calibration.begin(); i != calibration.end(); ++i) {
57  if (i->threshold >= threshold) {
58  cout << "PMT " << left << setw(32) << static_cast<const JUPI_t&>(*i) << " -> " << right << setw(3) << i->threshold << endl;
59  }
60  }
61 }
Utility class to parse command line options.
Definition: JParser.hh:1500
int main(int argc, char *argv[])
Definition: Main.cc:15
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
Definition: JComparator.hh:185
static const std::string Tests_t
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
void close(std::istream *pf)
Close file.
Definition: JeepToolkit.hh:346
int debug
debug level
Definition: JSirene.cc:63
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Utility class to parse command line options.
std::vector< JTHCalibration_t > JTHCalibration
PMT threshold calibration.
nlohmann::json json
JUPIHelper getUPI
Function object for mapping PBS and serial number to UPI.
Definition: JDBToolkit.cc:7
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:40