Jpp  18.3.0
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JFootprint.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 
10 
12 
13 #include "JROOT/JManager.hh"
14 
15 #include "JAcoustics/JEvt.hh"
16 #include "JAcoustics/JSuperEvt.hh"
17 #include "JAcoustics/JSupport.hh"
18 
20 
21 #include "Jeep/JPrint.hh"
22 #include "Jeep/JParser.hh"
23 #include "Jeep/JMessage.hh"
24 
25 
26 /**
27  * \file
28  *
29  * Auxiliary program to plot average tilt angles.
30  * \author mdejong
31  */
32 int main(int argc, char **argv)
33 {
34  using namespace std;
35  using namespace JPP;
36 
37  typedef JAbstractHistogram<Double_t> JHistogram_t;
38 
39  typedef JTYPELIST<JEvt, JSuperEvt>::typelist typelist;
40 
42  JLimit_t& numberOfEvents = inputFile.getLimit();
43  string outputFile;
44  JHistogram_t X;
45  JHistogram_t Y;
46  double Z;
47  int debug;
48 
49  try {
50 
51  JParser<> zap("Auxiliary program to plot average tilt angles.");
52 
53  zap['f'] = make_field(inputFile, "input file (output of JKatoomba[.sh]/JFremantle[.sh])");
54  zap['n'] = make_field(numberOfEvents) = JLimit::max();
55  zap['o'] = make_field(outputFile) = "footprint.root";
56  zap['x'] = make_field(X) = JHistogram_t(500, -100.0, +100.0);
57  zap['y'] = make_field(Y) = JHistogram_t(500, -100.0, +100.0);
58  zap['Z'] = make_field(Z, "detector height (for 2nd order tilt correction)") = 0.0;
59  zap['d'] = make_field(debug) = 2;
60 
61  zap(argc, argv);
62  }
63  catch(const exception &error) {
64  FATAL(error.what() << endl);
65  }
66 
67  Z *= 0.5; // half height
68 
69  JManager<int, TH2D> H2(new TH2D("string[%]", NULL,
70  X.getNumberOfBins(), X.getLowerLimit(), X.getUpperLimit(),
71  Y.getNumberOfBins(), Y.getLowerLimit(), Y.getUpperLimit()));
72 
74 
75  for (counter_type counter = 0; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
76 
77  STATUS("event: " << setw(10) << counter << '\r'); DEBUG(endl);
78 
79  const JEvt* evt = in.next();
80 
81  for (JEvt::const_iterator i = evt->begin(); i != evt->end(); ++i) {
82 
83  const double tx = (i->tx + i->tx2 * Z) * 1.0e3; // [mrad]
84  const double ty = (i->ty + i->ty2 * Z) * 1.0e3; // [mrad]
85 
86  H2 ->Fill(tx, ty);
87  H2[i->id]->Fill(tx, ty);
88  }
89  }
90  STATUS(endl);
91 
92  TFile out(outputFile.c_str(), "recreate");
93 
94  out << H2
95  << *H2;
96 
97  out.Write();
98  out.Close();
99 }
100 
Utility class to parse command line options.
Definition: JParser.hh:1514
int main(int argc, char *argv[])
Definition: Main.cc:15
#define STATUS(A)
Definition: JMessage.hh:63
ROOT TTree parameter settings.
Long64_t counter_type
Type definition for counter.
Dynamic ROOT object management.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary class for multiplexing object iterators.
Simple data structure for histogram binning.
string outputFile
Type list.
Definition: JTypeList.hh:22
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:1989
Acoustic event fit.
void Write(TDirectory &out, const bool wm=false)
Write objects to file.
Definition: JManager.hh:295
virtual const pointer_type & next() override
Get next element.
virtual bool hasNext() override
Check availability of next element.
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...
General purpose class for object reading from a list of file names.
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
Utility class to parse command line options.
no fit printf nominal n $STRING awk v X
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
Acoustic event fit.
int debug
debug level
#define DEBUG(A)
Message macros.
Definition: JMessage.hh:62