Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
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

◆ main()

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());
78
79
80 TFile out(outputFile.c_str(), "recreate");
81
83 const JStringRouter string(detector);
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}
string outputFile
#define DEBUG(A)
Message macros.
Definition JMessage.hh:62
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Detector data structure.
Definition JDetector.hh:96
int getFloor() const
Get floor number.
Definition JLocation.hh:146
int getString() const
Get string number.
Definition JLocation.hh:135
Router for direct addressing of module data in detector data structure.
Data structure for a composite optical module.
Definition JModule.hh:75
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
counter_type getCounter() const
Get counter.
virtual const pointer_type & next() override
Get next element.
T getUpperLimit() const
Get upper limit.
Definition JRange.hh:213
floor_range getRangeOfFloors(const JDetector &detector)
Get range of floors.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
int getIndex()
Get index for user I/O manipulation.
Definition JManip.hh:26
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
bool is_valid(const json &js)
Check validity of JSon data.
Calibration.
Definition JHead.hh:330
Detector file.
Definition JHead.hh:227
Auxiliary class to map module identifier to AHRS calibration.
Auxiliary data structure to check validity of AHRS data.
Router for mapping of string identifier to index.
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128