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
JCompareKatoomba.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <iomanip>
3 
4 #include "TROOT.h"
5 #include "TFile.h"
6 #include "TH1D.h"
7 #include "TH2D.h"
8 #include "TProfile.h"
9 
11 #include "JSupport/JTreeScanner.hh"
12 
13 #include "JROOT/JRootToolkit.hh"
14 #include "JROOT/JGraph.hh"
15 #include "JROOT/JManager.hh"
16 
17 #include "JAcoustics/JEvt.hh"
18 #include "JAcoustics/JSupport.hh"
19 
20 #include "Jeep/JPrint.hh"
21 #include "Jeep/JParser.hh"
22 #include "Jeep/JMessage.hh"
23 
24 
25 /**
26  * \file
27  *
28  * Example program to compare acoustic fit results.
29  * \author mdejong
30  */
31 int main(int argc, char **argv)
32 {
33  using namespace std;
34  using namespace JPP;
35 
37  JLimit_t& numberOfEvents = inputFile.getLimit();
38  string outputFile;
39  int debug;
40 
41  try {
42 
43  JParser<> zap("Example program to compare acoustic fit results.");
44 
45  zap['f'] = make_field(inputFile, "input file (output of JKatoomba[.sh])");
46  zap['n'] = make_field(numberOfEvents) = JLimit::max();
47  zap['o'] = make_field(outputFile) = "comparison.root";
48  zap['d'] = make_field(debug) = 2;
49 
50  zap(argc, argv);
51  }
52  catch(const exception &error) {
53  FATAL(error.what() << endl);
54  }
55 
56 
57  if (inputFile.size() != 2u) {
58  FATAL("Invalid number of input files; need 2 files for comparison." << endl);
59  }
60 
61  JManager<int, TH2D> H2(new TH2D("string[%]", NULL, 500, -50.0, +50.0, 500, -50.0, +50.0));
62 
63  JTreeScanner<JEvt, JEvt::JEvaluator> inA(inputFile[0]);
64  JTreeScanner<JEvt, JEvt::JEvaluator> inB(inputFile[1]);
65 
66  while (inA.hasNext() && inB.hasNext()) {
67 
68  STATUS("event: " << setw(10) << inA.getCounter() << '\r'); DEBUG(endl);
69 
70  JEvt* pA = inA.next();
71  JEvt* pB = inB.next();
72 
73  // find the same event based on the start and stop times of the events
74 
75  while (pA->UNIXTimeStop < pB->UNIXTimeStart && inA.hasNext()) { pA = inA.next(); }
76  while (pB->UNIXTimeStop < pA->UNIXTimeStart && inB.hasNext()) { pB = inB.next(); }
77 
78  if (pA->UNIXTimeStart < pB->UNIXTimeStop &&
79  pB->UNIXTimeStart < pA->UNIXTimeStop) {
80 
81  for (JEvt::const_iterator iA = pA->begin(); iA != pA->end(); ++iA) {
82  for (JEvt::const_iterator iB = pB->begin(); iB != pB->end(); ++iB) {
83 
84  if (iA->id == iB->id) {
85 
86  const double tx = (iA->tx - iB->tx) * 1.0e3; // [mrad]
87  const double ty = (iA->ty - iB->ty) * 1.0e3; // [mrad]
88 
89  H2 ->Fill(tx, ty);
90  H2[iA->id]->Fill(tx, ty);
91  }
92  }
93  }
94  }
95  }
96 
97 
98  TFile out(outputFile.c_str(), "recreate");
99 
100  out << H2 << *H2;
101 
102  out.Write();
103  out.Close();
104 }
105 
Utility class to parse command line options.
Definition: JParser.hh:1517
int main(int argc, char *argv[])
Definition: Main.cc:15
#define STATUS(A)
Definition: JMessage.hh:63
ROOT TTree parameter settings.
Dynamic ROOT object management.
string outputFile
Template definition for direct access of elements in ROOT TChain.
double UNIXTimeStop
stop time
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys...
Definition: JManager.hh:43
I/O formatting auxiliaries.
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1993
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:295
General purpose messaging.
#define FATAL(A)
Definition: JMessage.hh:67
Scanning of objects from multiple files according a format that follows from the extension of each fi...
double UNIXTimeStart
start time
General purpose class for object reading from a list of file names.
Utility class to parse command line options.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
double u[N+1]
Definition: JPolint.hh:776
Acoustic event fit.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62