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

Program to monitor AHRS data. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#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 "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDetector/JModuleRouter.hh"
#include "JDetector/JStringRouter.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 examples/JCompass/JAHRSMonitor.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 35 of file examples/JCompass/JAHRSMonitor.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39 
41  JLimit_t& numberOfEvents = inputFile.getLimit();
42  string outputFile;
43  string detectorFile;
44  string ahrsFile;
45  int debug;
46 
47  try {
48 
49  JParser<> zap("Program to monitor AHRS data.");
50 
51  zap['f'] = make_field(inputFile, "output of JConvertDB -q ahrs");
52  zap['n'] = make_field(numberOfEvents) = JLimit::max();
53  zap['a'] = make_field(detectorFile);
54  zap['o'] = make_field(outputFile) = "monitor.root";
55  zap['c'] = make_field(ahrsFile, "output of JAHRSCalibration");
56  zap['d'] = make_field(debug) = 2;
57 
58  zap(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64 
66 
67  try {
68  load(detectorFile, detector);
69  }
70  catch(const JException& error) {
71  FATAL(error);
72  }
73 
74  const JModuleRouter router(detector);
75 
76  const JAHRSCalibration_t calibration(ahrsFile.c_str());
77  const JAHRSValidity is_valid;
78 
79 
80  TFile out(outputFile.c_str(), "recreate");
81 
84 
85  TH2D H2("detector", NULL,
86  string.size() + 0, -0.5, string.size() - 0.5,
87  range.getUpperLimit(), 1 - 0.5, range.getUpperLimit() + 0.5);
88 
89  for (Int_t i = 1; i <= H2.GetXaxis()->GetNbins(); ++i) {
90  H2.GetXaxis()->SetBinLabel(i, MAKE_CSTRING(string.at(i-1)));
91  }
92  for (Int_t i = 1; i <= H2.GetYaxis()->GetNbins(); ++i) {
93  H2.GetYaxis()->SetBinLabel(i, MAKE_CSTRING(i));
94  }
95 
96  while (inputFile.hasNext()) {
97 
98  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
99 
100  const JAHRS* parameters = inputFile.next();
101 
102  if (is_valid(*parameters) && router.hasModule(parameters->DOMID)) {
103 
104  const JModule& module = router.getModule(parameters->DOMID);
105 
106  if (module.getFloor() != 0) {
107  H2.Fill((double) string.getIndex(module.getString()), (double) module.getFloor());
108  }
109  }
110  }
111  STATUS(endl);
112 
113  out.Write();
114  out.Close();
115 }
Utility class to parse command line options.
Definition: JParser.hh:1514
General exception.
Definition: JException.hh:24
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
Data structure for a composite optical module.
Definition: JModule.hh:67
#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
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
string outputFile
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
Calibration.
Definition: JHead.hh:328
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
then awk string
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:26
#define FATAL(A)
Definition: JMessage.hh:67
z range($ZMAX-$ZMIN)< $MINIMAL_DZ." fi fi typeset -Z 4 STRING typeset -Z 2 FLOOR JPlot1D -f $
int getString() const
Get string number.
Definition: JLocation.hh:134
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Router for mapping of string identifier to index.
General purpose class for object reading from a list of file names.
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 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