Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
examples/JCompass/JAHRSMonitor.cc
Go to the documentation of this file.
1#include <iostream>
2#include <iomanip>
3#include <vector>
4#include <map>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9
10#include "JDB/JSupport.hh"
11#include "JDB/JAHRS.hh"
13#include "JDB/JAHRSToolkit.hh"
14
16
17#include "JSystem/JStat.hh"
18
23
24#include "Jeep/JPrint.hh"
25#include "Jeep/JParser.hh"
26#include "Jeep/JMessage.hh"
27
28
29/**
30 * \file
31 *
32 * Program to monitor AHRS data.
33 * \author mdejong
34 */
35int main(int argc, char **argv)
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
ROOT TTree parameter settings.
Data structure for detector geometry and calibration.
General purpose messaging.
#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
Direct access to module in detector data structure.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
I/O formatting auxiliaries.
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
File status.
Direct access to string in detector data structure.
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.
bool hasModule(const JObjectID &id) const
Has module.
const JModule & getModule(const JObjectID &id) const
Get module parameters.
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
int main(int argc, char **argv)
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