Jpp  18.1.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
software/JCompass/JAHRSMonitor.cc File Reference

Program to monitor AHRS data. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include "JDB/JSupport.hh"
#include "JDB/JAHRS.hh"
#include "JDB/JAHRSCalibration_t.hh"
#include "JDB/JAHRSToolkit.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSystem/JStat.hh"
#include "JTools/JQuantile.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Program to monitor AHRS data.

Author
mdejong

Definition in file software/JCompass/JAHRSMonitor.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 32 of file software/JCompass/JAHRSMonitor.cc.

33 {
34  using namespace std;
35  using namespace JPP;
36 
38  JLimit_t& numberOfEvents = inputFile.getLimit();
39  string detectorFile;
40  string ahrsFile;
42  int qaqc;
43  int debug;
44 
45  try {
46 
47  JParser<> zap("Program to monitor AHRS data.");
48 
49  zap['f'] = make_field(inputFile, "output of JConvertDB -q ahrs");
50  zap['n'] = make_field(numberOfEvents) = JLimit::max();
51  zap['a'] = make_field(detectorFile);
52  zap['c'] = make_field(ahrsFile, "output of JAHRSCalibration");
53  zap['q'] = make_field(Q, "quantile");
54  zap['Q'] = make_field(qaqc) = 0;
55  zap['d'] = make_field(debug) = 2;
56 
57  zap(argc, argv);
58  }
59  catch(const exception &error) {
60  FATAL(error.what() << endl);
61  }
62 
63 
65 
66  try {
67  load(detectorFile, detector);
68  }
69  catch(const JException& error) {
70  FATAL(error);
71  }
72 
73  const JModuleRouter router(detector);
74 
75  const JAHRSCalibration_t calibration(ahrsFile.c_str());
76  const JAHRSValidity is_valid;
77 
78 
80 
81  for (JDetector::const_iterator module = detector.begin(); module != detector.end(); ++module) {
82  if (module->getFloor() != 0) {
83  data[module->getID()] = 0;
84  }
85  }
86 
87  while (inputFile.hasNext()) {
88 
89  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
90 
91  const JAHRS* parameters = inputFile.next();
92 
93  if (is_valid(*parameters) && router.hasModule(parameters->DOMID)) {
94  if (router.getModule(parameters->DOMID).getFloor() != 0) {
95  data[parameters->DOMID] += 1;
96  }
97  }
98  }
99  STATUS(endl);
100 
101  JQuantile q1("", true);
102 
103  for (map<int, int>::const_iterator i = data.begin(); i != data.end(); ++i) {
104  q1.put(i->second);
105  }
106 
107  for (vector<double>::const_iterator i = Q.begin(); i != Q.end(); ++i) {
108  QAQC(' ' << FIXED(8,3) << q1.getQuantile(*i));
109  }
110  QAQC(endl);
111 
112  return 0;
113 }
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
Q(UTCMax_s-UTCMin_s)-livetime_s
Auxiliary data structure for running average, standard deviation and quantiles.
Definition: JQuantile.hh:43
#define STATUS(A)
Definition: JMessage.hh:63
bool is_valid(const json &js)
Check validity of JSon data.
Detector data structure.
Definition: JDetector.hh:89
Router for direct addressing of module data in detector data structure.
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:446
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
#define FATAL(A)
Definition: JMessage.hh:67
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
#define QAQC(A)
QA/QC output macro.
Definition: JMessage.hh:100
Auxiliary class to map module identifier to AHRS calibration.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
int qaqc
QA/QC file descriptor.
int debug
debug level
Auxiliary data structure to check validity of AHRS data.
Definition: JAHRSToolkit.hh:20
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62