Jpp 19.3.0-rc.2
the software that should make you happy
Loading...
Searching...
No Matches
JAHRSMonitor.cc File Reference

Program to plot AHRS data. More...

#include <string>
#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 "JROOT/JManager.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JGeometry3D/JRotation3D.hh"
#include "JGeometry3D/JQuaternion3D.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 plot AHRS data.

Author
mdejong

Definition in file examples/JDB/JAHRSMonitor.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 32 of file examples/JDB/JAHRSMonitor.cc.

33{
34 using namespace std;
35 using namespace JPP;
36
38 JLimit_t& numberOfEvents = inputFile.getLimit();
39 string ahrsFile;
40 string outputFile;
41 int debug;
42
43 try {
44
45 JParser<> zap("Program to plot AHRS data.");
46
47 zap['f'] = make_field(inputFile, "output of JConvertDB -q ahrs");
48 zap['n'] = make_field(numberOfEvents) = JLimit::max();
49 zap['A'] = make_field(ahrsFile, "output of JAHRSCalibration") = "";
50 zap['o'] = make_field(outputFile) = "ahrs.root";
51 zap['d'] = make_field(debug) = 2;
52
53 zap(argc, argv);
54 }
55 catch(const exception &error) {
56 FATAL(error.what() << endl);
57 }
58
59
61
62 if (ahrsFile != "") {
63 calibration.load(ahrsFile.c_str());
64 }
65
66 JManager<int, TH1D> HA(new TH1D("%.A", NULL, 100, 0.0, 2.0));
67 JManager<int, TH1D> HB(new TH1D("%.B", NULL, 100, 0.0, 2.0));
68
69 while (inputFile.hasNext()) {
70
71 STATUS("counter " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
72
73 const JAHRS* parameters = inputFile.next();
74
75 double A0 = parameters->AHRS_A0;
76 double A1 = parameters->AHRS_A1;
77 double A2 = parameters->AHRS_A2;
78
79 double H0 = parameters->AHRS_H0;
80 double H1 = parameters->AHRS_H1;
81 double H2 = parameters->AHRS_H2;
82
83 if (calibration.has(parameters->DOMID)) {
84
85 const JAHRSCalibration& cal = calibration.get(parameters->DOMID);
86
87 A0 -= cal.ACC_OFFSET_X;
88 A1 -= cal.ACC_OFFSET_Y;
89 A2 -= cal.ACC_OFFSET_Z;
90
92 cal.ACC_ROT_YX, cal.ACC_ROT_YY, cal.ACC_ROT_YZ,
93 cal.ACC_ROT_ZX, cal.ACC_ROT_ZY, cal.ACC_ROT_ZZ).transform(A0, A1, A2);
94
95 H0 -= 0.5 * (cal.MAG_XMIN + cal.MAG_XMAX);
96 H1 -= 0.5 * (cal.MAG_YMIN + cal.MAG_YMAX);
97 H2 -= 0.5 * (cal.MAG_ZMIN + cal.MAG_ZMAX);
98
100 cal.MAG_ROT_YX, cal.MAG_ROT_YY, cal.MAG_ROT_YZ,
101 cal.MAG_ROT_ZX, cal.MAG_ROT_ZY, cal.MAG_ROT_ZZ).transform(H0, H1, H2);
102 }
103
104 HA[parameters->DOMID]->Fill(sqrt(A0 * A0 + A1 * A1 + A2 * A2));
105 HB[parameters->DOMID]->Fill(sqrt(H0 * H0 + H1 * H1 + H2 * H2));
106 }
107 STATUS(endl);
108
109
110 TFile out(outputFile.c_str(), "recreate");
111
112 out << HA << HB;
113
114 out.Write();
115 out.Close();
116}
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
void transform(double &__x, double &__y, double &__z) const
Transform.
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
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.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Calibration.
Definition JHead.hh:330
Auxiliary class to map module identifier to AHRS calibration.
double AHRS_H2
Definition JAHRS.hh:39
double AHRS_A1
Definition JAHRS.hh:32
double AHRS_H1
Definition JAHRS.hh:38
double AHRS_H0
Definition JAHRS.hh:37
double AHRS_A0
Definition JAHRS.hh:31
double AHRS_A2
Definition JAHRS.hh:33
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