Jpp  15.0.4
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JParramatta.cc File Reference

Example program to plot acoustic fit results. More...

#include <iostream>
#include <iomanip>
#include "TROOT.h"
#include "TFile.h"
#include "TH1D.h"
#include "TH2D.h"
#include "TGraph.h"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JTreeScanner.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JGraph.hh"
#include "JROOT/JManager.hh"
#include "JAcoustics/JEvt.hh"
#include "JAcoustics/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)
 

Detailed Description

Example program to plot acoustic fit results.

Author
mdejong

Definition in file JParramatta.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 31 of file JParramatta.cc.

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 plot acoustic fit results.");
44 
45  zap['f'] = make_field(inputFile, "input file (output of JKatoomba)");
46  zap['n'] = make_field(numberOfEvents) = JLimit::max();
47  zap['o'] = make_field(outputFile) = "parramatta.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() < 1u || inputFile.size() > 2u) {
58  FATAL("Invalid number of input files; 1 file for histograms and 2 files for comparison." << endl);
59  }
60 
61 
62  TH1D h1("chi2/NDF", NULL, 500, 0.0, 10.0);
63 
64  JGraph_t g0;
65  JGraph_t g1;
66 
67  JManager<int, TH2D> H2(new TH2D("string[%]", NULL, 500, -20.0, +20.0, 500, -20.0, +20.0));
68 
69 
70  if (inputFile.size() == 2) {
71 
72  JTreeScanner<JEvt, JEvt::JEvaluator> inA(inputFile[0]);
73  JTreeScanner<JEvt, JEvt::JEvaluator> inB(inputFile[1]);
74 
75  while (inA.hasNext() && inB.hasNext()) {
76 
77  STATUS("event: " << setw(10) << inA.getCounter() << '\r'); DEBUG(endl);
78 
79  JEvt* pA = inA.next();
80  JEvt* pB = inB.next();
81 
82  // find the same event based on the start and stop times of the events
83 
84  while (pA->UNIXTimeStop < pB->UNIXTimeStart && inA.hasNext()) { pA = inA.next(); }
85  while (pB->UNIXTimeStop < pA->UNIXTimeStart && inB.hasNext()) { pB = inB.next(); }
86 
87  if (pA->UNIXTimeStart < pB->UNIXTimeStop &&
88  pB->UNIXTimeStart < pA->UNIXTimeStop) {
89 
90  for (JEvt::const_iterator iA = pA->begin(); iA != pA->end(); ++iA) {
91  for (JEvt::const_iterator iB = pB->begin(); iB != pB->end(); ++iB) {
92 
93  if (iA->id == iB->id) {
94  H2 ->Fill((iA->tx - iB->tx)*1.0e3, (iA->ty - iB->ty)*1.0e3); // [mrad]
95  H2[iA->id]->Fill((iA->tx - iB->tx)*1.0e3, (iA->ty - iB->ty)*1.0e3); // [mrad]
96  }
97  }
98  }
99  }
100  }
101  }
102 
103  if (inputFile.size() == 1) {
104 
105  while (inputFile.hasNext()) {
106 
107  STATUS("event: " << setw(10) << inputFile.getCounter() << '\r'); DEBUG(endl);
108 
109  const JEvt* evt = inputFile.next();
110 
111  h1.Fill(evt->chi2 / evt->ndf);
112 
113  g0.put(0.5 * (evt->UNIXTimeStart + evt->UNIXTimeStop), evt->ndf);
114  g1.put(0.5 * (evt->UNIXTimeStart + evt->UNIXTimeStop), evt->chi2 / evt->ndf);
115 
116  for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
117  H2 ->Fill(i->tx*1.0e3, i->ty*1.0e3); // [mrad]
118  H2[i->id]->Fill(i->tx*1.0e3, i->ty*1.0e3); // [mrad]
119  }
120  }
121  STATUS(endl);
122  }
123 
124 
125  TFile out(outputFile.c_str(), "recreate");
126 
127  out << H2
128  << *H2;
129 
130  if (inputFile.size() == 1) {
131  out << h1
132  << JGraph(g0, "g0")
133  << JGraph(g1, "g1");
134  }
135 
136  out.Write();
137  out.Close();
138 }
Utility class to parse command line options.
Definition: JParser.hh:1500
Data structure for graph data.
Definition: JGraph.hh:21
#define STATUS(A)
Definition: JMessage.hh:63
then for HISTOGRAM in h0 h1
Definition: JMatrixNZ.sh:71
int ndf
number of degrees of freedom
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
Template definition for direct access of elements in ROOT TChain.
Definition: JTreeScanner.hh:91
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
Acoustic event fit.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
int debug
debug level
Definition: JSirene.cc:63
#define FATAL(A)
Definition: JMessage.hh:67
double UNIXTimeStart
start time
General purpose class for object reading from a list of file names.
then usage $script< input_file >< detector_file > fi set_variable OUTPUT_DIR set_variable SELECTOR JDAQTimesliceL1 set_variable DEBUG case set_variable DEBUG
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
double u[N+1]
Definition: JPolint.hh:739
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25