Jpp  18.3.0-rc.1
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 "TProfile.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/JSuperEvt.hh"
#include "JAcoustics/JSupport.hh"
#include "JLang/JObjectMultiplexer.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 35 of file JParramatta.cc.

36 {
37  using namespace std;
38  using namespace JPP;
39 
40  typedef JTYPELIST<JEvt, JSuperEvt>::typelist typelist;
41 
43  JLimit_t& numberOfEvents = inputFile.getLimit();
44  string outputFile;
45  double Z;
46  int debug;
47 
48  try {
49 
50  JParser<> zap("Example program to plot acoustic fit results.");
51 
52  zap['f'] = make_field(inputFile, "input file (output of JKatoomba[.sh]/JFremantle[.sh])");
53  zap['n'] = make_field(numberOfEvents) = JLimit::max();
54  zap['o'] = make_field(outputFile) = "parramatta.root";
55  zap['Z'] = make_field(Z, "detector height (for 2nd order tilt correction)") = 0.0;
56  zap['d'] = make_field(debug) = 2;
57 
58  zap(argc, argv);
59  }
60  catch(const exception &error) {
61  FATAL(error.what() << endl);
62  }
63 
64  Z *= 0.5; // half height
65 
66  const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0');
67 
68  TH1D h1("chi2/NDF", NULL, 500, 0.0, 10.0);
69 
70  JGraph_t g0;
71  JGraph_t g1;
72 
76 
77  JManager<int, TProfile> H1(new TProfile("stretching[%]", NULL, 50, 0.0, 1.0e2));
78  JManager<int, TH2D> H2(new TH2D("[%].tiltdeviation", NULL, 300, -4.0, +4.0, 300, -4.0, +4.0), '%', format);
79 
81 
82  for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
83 
84  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
85 
86  const JEvt* evt = in.next();
87 
88  h1.Fill(evt->chi2 / evt->ndf);
89 
90  const double t1 = 0.5 * (evt->UNIXTimeStart + evt->UNIXTimeStop);
91 
92  g0.put(t1, evt->nhit - evt->npar);
93  g1.put(t1, evt->chi2 / evt->ndf);
94 
95  double Tx = 0;
96  double Ty = 0;
97 
98  for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
99 
100  const int id = i->id;
101  const double tx = (i->tx + i->tx2 * Z) * 1.0e3; // [mrad]
102  const double ty = (i->ty + i->ty2 * Z) * 1.0e3; // [mrad]
103  const double vs = i->vs * 1.0e2; // [%]
104  const double ts = sqrt(tx*tx + ty*ty);
105 
106  Tx += tx;
107  Ty += ty;
108 
109  H1 ->Fill(ts, vs);
110  H1[id]->Fill(ts, vs);
111 
112  GO[id].put(t1, atan2(ty, tx));
113  GA[id].put(t1, ts);
114  GS[id].put(t1, vs);
115  }
116 
117  Tx /= evt->size();
118  Ty /= evt->size();
119 
120  for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
121 
122  const double tx = (i->tx + i->tx2 * Z*Z) * 1.0e3; // [mrad]
123  const double ty = (i->ty + i->ty2 * Z*Z) * 1.0e3; // [mrad]
124 
125  H2 ->Fill(tx - Tx, ty - Ty);
126  H2[i->id]->Fill(tx - Tx, ty - Ty);
127  }
128  }
129  STATUS(endl);
130 
131  TFile out(outputFile.c_str(), "recreate");
132 
133  out << h1
134  << JGraph(g0, "g0")
135  << JGraph(g1, "g1");
136 
137  out << H1 << *H1 << H2 << *H2;
138 
139  for (map<int, JGraph_t>::const_iterator i = GO.begin(); i != GO.end(); ++i) {
140  out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].orientation"));
141  }
142 
143  for (map<int, JGraph_t>::const_iterator i = GA.begin(); i != GA.end(); ++i) {
144  out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].amplitude"));
145  }
146 
147  for (map<int, JGraph_t>::const_iterator i = GS.begin(); i != GS.end(); ++i) {
148  out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].stretching"));
149  }
150 
151  out.Write();
152  out.Close();
153 }
Utility class to parse command line options.
Definition: JParser.hh:1514
int npar
number of fit parameters
Data structure for graph data.
Definition: JGraph.hh:21
#define STATUS(A)
Definition: JMessage.hh:63
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
Long64_t counter_type
Type definition for counter.
Auxiliary class for multiplexing object iterators.
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
Type list.
Definition: JTypeList.hh:22
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
std::vector< double > vs
Acoustic event fit.
double ndf
weighed number of degrees of freedom
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Auxiliary data structure for sequence of same character.
Definition: JManip.hh:328
#define FATAL(A)
Definition: JMessage.hh:67
int nhit
number of hits
double UNIXTimeStart
start time
General purpose class for object reading from a list of file names.
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
Definition: JCanberra.sh:48
Data structure for format specifications.
Definition: JManip.hh:524
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62
Double_t g1(const Double_t x)
Function.
Definition: JQuantiles.cc:25