Jpp  master_rocky
the software that should make you happy
Functions
JCompareDynamicPositions.cc File Reference
#include <string>
#include <iostream>
#include <iomanip>
#include <fstream>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TGraph.h"
#include "JROOT/JManager.hh"
#include "JROOT/JGraph.hh"
#include "JROOT/JRootToolkit.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JDynamics/JDynamics.hh"
#include "JTools/JQuantile.hh"
#include "JAcoustics/JEvt.hh"
#include "JAcoustics/JSupport.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.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)
 Example program to compare dynamic position calibrations. More...
 

Function Documentation

◆ main()

int main ( int  argc,
char **  argv 
)

Example program to compare dynamic position calibrations.

Author
cgatius

Definition at line 41 of file JCompareDynamicPositions.cc.

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 }
string outputFile
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#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
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.
const double xmax
Definition: JQuadrature.cc:24
const double xmin
Definition: JQuadrature.cc:23
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).
Definition: JSTDTypes.hh:14
Detector file.
Definition: JHead.hh:227
data_type::const_iterator const_iterator
Definition: JDynamics.hh:326
Dynamic detector calibration.
Definition: JDynamics.hh:84
Data structure for format specifications.
Definition: JManip.hh:524
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:44