Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JCompareDynamicPositions.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4#include <fstream>
5
6#include "TROOT.h"
7#include "TFile.h"
8#include "TH1D.h"
9#include "TH2D.h"
10#include "TGraph.h"
11
12#include "JROOT/JManager.hh"
13#include "JROOT/JGraph.hh"
14#include "JROOT/JRootToolkit.hh"
15
18
20
21#include "JTools/JQuantile.hh"
22
23#include "JAcoustics/JEvt.hh"
25
27#include "JSupport/JMeta.hh"
28#include "JSupport/JSupport.hh"
29
30#include "Jeep/JPrint.hh"
31#include "Jeep/JParser.hh"
32#include "Jeep/JMessage.hh"
33
34
35/**
36 *
37 * Example program to compare dynamic position calibrations.
38 *
39 * \author cgatius
40 */
41int main(int argc, char **argv)
42{
43 using namespace std;
44 using namespace JPP;
45
48 string detectorFile;
49 string outputFile;
50 double Tstep_s;
51 int debug;
52
53 try {
54
55 JParser<> zap("Example program to compare dynamic position calibrations.");
56
57 zap['a'] = make_field(detectorFile);
58 zap['f'] = make_field(calibrationFile1, "output of JKatoomba[.sh]");
59 zap['F'] = make_field(calibrationFile2, "output of JKatoomba[.sh]");
60 zap['o'] = make_field(outputFile) = "compare_dynamic_positions.root";
61 zap['T'] = make_field(Tstep_s) = 600.0;
62 zap['d'] = make_field(debug) = 1;
63
64 zap(argc, argv);
65 }
66 catch(const exception &error) {
67 FATAL(error.what() << endl);
68 }
69
70
72
73 try {
74 load(detectorFile, detector);
75 }
76 catch(const JException& error) {
77 FATAL(error);
78 }
79
80 JDynamics dynamics1(detector, 0.0);
81
82 STATUS("loading input from file " << calibrationFile1 << "... " << flush);
83
84 dynamics1.load(calibrationFile1);
85
86 STATUS("OK" << endl);
87
88 Double_t xmin1 = numeric_limits<Double_t>::max();
89 Double_t xmax1 = numeric_limits<Double_t>::lowest();
90
91 for (JDynamics::JPosition::const_iterator string = dynamics1.position.begin(); string != dynamics1.position.end(); ++string) {
92
93 if (!string->second.empty()) {
94 xmin1 = min(xmin1, string->second.getXmin());
95 xmax1 = max(xmax1, string->second.getXmax());
96 }
97 }
98
99 JDynamics dynamics2(detector, 0.0);
100
101 STATUS("loading input from file " << calibrationFile1 << "... " << flush);
102
103 dynamics2.load(calibrationFile2);
104
105 STATUS("OK" << endl);
106
107 Double_t xmin2 = numeric_limits<Double_t>::max();
108 Double_t xmax2 = numeric_limits<Double_t>::lowest();
109
110 for (JDynamics::JPosition::const_iterator string = dynamics2.position.begin(); string != dynamics2.position.end(); ++string) {
111
112 if (!string->second.empty()) {
113 xmin2 = min(xmin2, string->second.getXmin());
114 xmax2 = max(xmax2, string->second.getXmax());
115 }
116 }
117
118 Double_t xmin = numeric_limits<Double_t>::max();
119 Double_t xmax = numeric_limits<Double_t>::lowest();
120
121 //latest start time and earliest end time
122 xmin = max(xmin1, xmin2);
123 xmax = min(xmax1, xmax2);
124
125 const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0');
126
129 JManager<int,TH1D> HC(new TH1D ("M[%].comparetx", NULL, 100, 0, 2),'%', format);
130 JManager<int,TH1D> HD(new TH1D ("N[%].comparety", NULL, 100, 0, 2),'%', format);
131
132 for (JDynamics::JPosition::const_iterator string1 = dynamics1.position.begin(); string1 != dynamics1.position.end(); ++string1) {
133 for (JDynamics::JPosition::const_iterator string2 = dynamics2.position.begin(); string2 != dynamics2.position.end(); ++string2) {
134
135 if (string1->first == string2->first) {
136
137 TH1D* hc = HC[string1->first];
138 TH1D* hd = HD[string1->first];
139
140 for (Double_t t = xmin; t <= xmax; t = t + Tstep_s) {
141
142 HO[string1->first].put(t, (string1->second(t).tx - string2->second(t).tx) * 1000);
143 HA[string1->first].put(t, (string1->second(t).ty - string2->second(t).ty) * 1000);
144 hc->Fill((string1->second(t).tx - string2->second(t).tx) * 1000);
145 hd->Fill((string1->second(t).ty - string2->second(t).ty) * 1000);
146 }
147
148 break;
149 }
150 }
151 }
152
153 TFile out(outputFile.c_str(), "recreate");
154
155 out << HC << HD;
156 for (map<int, JGraph_t>::const_iterator i = HO.begin(); i != HO.end(); ++i) {
157 out << JGraph(i->second, MAKE_CSTRING("H[" << i->first << "].comparetx"));
158 }
159
160 for (map<int, JGraph_t>::const_iterator i = HA.begin(); i != HA.end(); ++i) {
161 out << JGraph(i->second, MAKE_CSTRING("K[" << i->first << "].comparety"));
162 }
163}
Acoustic event fit.
ROOT TTree parameter settings.
int main(int argc, char **argv)
Example program to compare dynamic position calibrations.
string outputFile
Data structure for detector geometry and calibration.
Dynamic detector calibration.
Dynamic ROOT object management.
General purpose messaging.
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
ROOT I/O of application specific meta data.
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
ROOT TTree parameter settings of various packages.
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
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.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Detector file.
Definition JHead.hh:227
const_iterator end() const
end of calibration data
Definition JDynamics.hh:379
const_iterator begin() const
begin of calibration data
Definition JDynamics.hh:378
data_type::const_iterator const_iterator
Definition JDynamics.hh:328
Dynamic detector calibration.
Definition JDynamics.hh:86
JPosition position
position calibration
Definition JDynamics.hh:613
void load(JObjectIterator_t &input)
Load calibration data.
Definition JDynamics.hh:530
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary data structure to build TGraph.
Definition JGraph.hh:44