Jpp  17.3.0-rc.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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

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  getMechanics.load(detector.getID());
81 
82 
83  JDynamics dynamics1(detector, 0.0);
84 
85  STATUS("loading input from file " << calibrationFile1 << "... " << flush);
86 
87  dynamics1.load(calibrationFile1);
88 
89  STATUS("OK" << endl);
90 
91  Double_t xmin1 = numeric_limits<Double_t>::max();
92  Double_t xmax1 = numeric_limits<Double_t>::lowest();
93 
94  for (JDynamics::JPosition::const_iterator string = dynamics1.position.begin(); string != dynamics1.position.end(); ++string) {
95 
96  if (!string->second.empty()) {
97  xmin1 = min(xmin1, string->second.getXmin());
98  xmax1 = max(xmax1, string->second.getXmax());
99  }
100  }
101 
102  JDynamics dynamics2(detector, 0.0);
103 
104  STATUS("loading input from file " << calibrationFile1 << "... " << flush);
105 
106  dynamics2.load(calibrationFile2);
107 
108  STATUS("OK" << endl);
109 
110  Double_t xmin2 = numeric_limits<Double_t>::max();
111  Double_t xmax2 = numeric_limits<Double_t>::lowest();
112 
113  for (JDynamics::JPosition::const_iterator string = dynamics2.position.begin(); string != dynamics2.position.end(); ++string) {
114 
115  if (!string->second.empty()) {
116  xmin2 = min(xmin2, string->second.getXmin());
117  xmax2 = max(xmax2, string->second.getXmax());
118  }
119  }
120 
121  Double_t xmin = numeric_limits<Double_t>::max();
122  Double_t xmax = numeric_limits<Double_t>::lowest();
123 
124  //latest start time and earliest end time
125  xmin = max(xmin1, xmin2);
126  xmax = min(xmax1, xmax2);
127 
128  const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0');
129 
132  JManager<int,TH1D> HC(new TH1D ("M[%].comparetx", NULL, 100, 0, 2),'%', format);
133  JManager<int,TH1D> HD(new TH1D ("N[%].comparety", NULL, 100, 0, 2),'%', format);
134 
135  for (JDynamics::JPosition::const_iterator string1 = dynamics1.position.begin(); string1 != dynamics1.position.end(); ++string1) {
136  for (JDynamics::JPosition::const_iterator string2 = dynamics2.position.begin(); string2 != dynamics2.position.end(); ++string2) {
137 
138  if (string1->first == string2->first) {
139 
140  TH1D* hc = HC[string1->first];
141  TH1D* hd = HD[string1->first];
142 
143  for (Double_t t = xmin; t <= xmax; t = t + Tstep_s) {
144 
145  HO[string1->first].put(t, (string1->second(t).tx - string2->second(t).tx) * 1000);
146  HA[string1->first].put(t, (string1->second(t).ty - string2->second(t).ty) * 1000);
147  hc->Fill((string1->second(t).tx - string2->second(t).tx) * 1000);
148  hd->Fill((string1->second(t).ty - string2->second(t).ty) * 1000);
149  }
150 
151  break;
152  }
153  }
154  }
155 
156  TFile out(outputFile.c_str(), "recreate");
157 
158  out << HC << HD;
159  for (map<int, JGraph_t>::const_iterator i = HO.begin(); i != HO.end(); ++i) {
160  out << JGraph(i->second, MAKE_CSTRING("H[" << i->first << "].comparetx"));
161  }
162 
163  for (map<int, JGraph_t>::const_iterator i = HA.begin(); i != HA.end(); ++i) {
164  out << JGraph(i->second, MAKE_CSTRING("K[" << i->first << "].comparety"));
165  }
166 }
const double xmax
Definition: JQuadrature.cc:24
Utility class to parse command line options.
Definition: JParser.hh:1517
General exception.
Definition: JException.hh:23
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:243
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:89
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
data_type::const_iterator const_iterator
Definition: JDynamics.hh:307
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
Detector file.
Definition: JHead.hh:226
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
then awk string
void load(const std::string &file_name)
Load mechanical model parameters from file.
Definition: JMechanics.hh:142
#define FATAL(A)
Definition: JMessage.hh:67
Dynamic detector calibration.
Definition: JDynamics.hh:63
const double xmin
Definition: JQuadrature.cc:23
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
General purpose class for object reading from a list of file names.
do set_variable DETECTOR_TXT $WORKDIR detector
Data structure for format specifications.
Definition: JManip.hh:522
int debug
debug level