Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Functions
JNarrabri.cc File Reference

Example program to check contents of acoustic events. More...

#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/JGraph.hh"
#include "JROOT/JRootToolkit.hh"
#include "JROOT/JManager.hh"
#include "JDetector/JDetector.hh"
#include "JDetector/JDetectorToolkit.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.hh"
#include "JLang/JObjectMultiplexer.hh"
#include "JAcoustics/JEvt.hh"
#include "JAcoustics/JSupport.hh"
#include "JDynamics/JDynamics.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 check contents of acoustic events.

Author
mdejong

Definition in file JNarrabri.cc.

Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 41 of file JNarrabri.cc.

42 {
43  using namespace std;
44  using namespace JPP;
45 
47  JLimit_t& numberOfEvents = inputFile.getLimit();
48  string detectorFile;
49  string outputFile;
50  double Tmax_s;
51  string text_file;
52  int debug;
53 
54  try {
55 
56  JParser<> zap("Example program to check contents of acoustic events.");
57 
58  zap['f'] = make_field(inputFile, "output of JKatoomba[.sh]");
59  zap['n'] = make_field(numberOfEvents) = JLimit_t::max();
60  zap['a'] = make_field(detectorFile);
61  zap['o'] = make_field(outputFile) = "narrabri.root";
62  zap['T'] = make_field(Tmax_s);
63  zap['+'] = make_field(text_file) = "";
64  zap['d'] = make_field(debug) = 1;
65 
66  zap(argc, argv);
67  }
68  catch(const exception &error) {
69  FATAL(error.what() << endl);
70  }
71 
72 
74 
75  try {
76  load(detectorFile, detector);
77  }
78  catch(const JException& error) {
79  FATAL(error);
80  }
81 
82 
83  JDynamics dynamics(detector, Tmax_s);
84 
85  STATUS("loading input from file(s) " << inputFile << "... " << flush);
86 
87  dynamics.load(inputFile);
88 
89  STATUS("OK" << endl);
90 
91 
94 
95  Double_t xmin = numeric_limits<Double_t>::max();
96  Double_t xmax = numeric_limits<Double_t>::lowest();
97 
98  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
99 
100  if (!string->second.empty()) {
101  xmin = min(xmin, string->second.getXmin());
102  xmax = max(xmax, string->second.getXmax());
103  }
104  }
105 
106  const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0');
107 
108  JManager<int, TH2D> H2(new TH2D ("[%].tilt", NULL, 100, -1.0, +1.0, 100, -1.0, +1.0), '%', format);
109  JManager<int, TH1D> HT(new TH1D ("[%].time", NULL, 200, 0.0, 4.0), '%', format);
110 
111  JManager<int, TH1D> HO(new TH1D ("H[%].orientation", NULL, 1000, xmin, xmax), '%', format);
112  JManager<int, TH1D> HA(new TH1D ("H[%].amplitude", NULL, 1000, xmin, xmax), '%', format);
113 
114  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
115 
116  TH1D* ho = HO[string->first];
117  TH1D* ha = HA[string->first];
118 
119  for (Int_t i = 1; i <= HO->GetXaxis()->GetNbins(); ++i) {
120 
121  const Double_t x = HO->GetXaxis()->GetBinCenter(i);
122 
123  const JMODEL::JString tilt = string->second(x);
124 
125  ho->SetBinContent(i, tilt.getAngle());
126  ha->SetBinContent(i, tilt.getLength());
127  }
128  }
129 
130 
131  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
132 
133  if (string->second.size() > 1) {
134 
135  TH2D* h2 = H2[string->first];
136  TH1D* hc = HT[string->first];
137 
138  for (typename JDynamics::JPosition::function_type::const_iterator q = string->second.begin(), p = q++; q != string->second.end(); ++p, ++q) {
139 
140  const double t1 = q->getX() - p->getX();
141 
142  hc->Fill(log10(t1));
143 
144  if (t1 > 0 && t1 < Tmax_s) {
145  h2->Fill(600.0e3 * (q->getY().tx - p->getY().tx) / t1, // [mrad/10 min]
146  600.0e3 * (q->getY().ty - p->getY().ty) / t1); // [mrad/10 min]
147  }
148  }
149 
150  for (typename JDynamics::JPosition::function_type::const_iterator i = string->second.begin(); i != string->second.end(); ++i) {
151  ZO[string->first].put(i->getX(), i->getY().getAngle());
152  ZA[string->first].put(i->getX(), i->getY().getLength());
153  }
154  }
155  }
156 
157 
158  if (text_file != "") {
159 
160  ofstream out(text_file.c_str());
161 
162  JComment comment;
163 
164  comment.add("documentation: https://common.pages.km3net.de/jpp/Position_calibration.PDF");
165  comment.add("format: string number; UTC [s]; Tx; Ty");
166 
167  comment.add(JMeta(argc, argv));
168 
171 
172  while (abc.hasNext()) {
173  comment.add(*abc.next());
174  }
175 
176  out << comment;
177 
178  for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
179  for (typename JDynamics::JPosition::function_type::const_iterator i = string->second.begin(); i != string->second.end(); ++i) {
180  out << setw(4) << string->first << ';'
181  << FIXED(20,5) << i->getX() << ';'
182  << FIXED( 9,6) << i->getY().tx << ';'
183  << FIXED( 9,6) << i->getY().ty << endl;
184  }
185  }
186 
187  out.close();
188  }
189 
190 
191  TFile out(outputFile.c_str(), "recreate");
192 
193  out << H2 << HT << HO << HA;
194 
195  for (map<int, JGraph_t>::const_iterator i = ZO.begin(); i != ZO.end(); ++i) {
196  out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].orientation"));
197  }
198 
199  for (map<int, JGraph_t>::const_iterator i = ZA.begin(); i != ZA.end(); ++i) {
200  out << JGraph(i->second, MAKE_CSTRING("G[" << i->first << "].amplitude"));
201  }
202 
203  out.Write();
204  out.Close();
205 }
Auxiliary class for ROOT I/O of application specific meta data.
Definition: JMeta.hh:70
Utility class to parse command line options.
Definition: JParser.hh:1500
General exception.
Definition: JException.hh:23
double getAngle() const
Get angle.
collection_type::const_iterator const_iterator
Definition: JPolfit.hh:157
#define STATUS(A)
Definition: JMessage.hh:63
Detector data structure.
Definition: JDetector.hh:80
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:151
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:445
Auxiliary class for multiplexing object iterators.
Auxiliary data structure to build TGraph.
Definition: JGraph.hh:42
string outputFile
data_type::const_iterator const_iterator
Definition: JDynamics.hh:330
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
Detector file.
Definition: JHead.hh:196
#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
Auxiliary class for comment.
Definition: JComment.hh:41
Dynamic detector calibration.
Definition: JDynamics.hh:52
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.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:73
JComment & add(const std::string &comment)
Add comment.
Definition: JComment.hh:100
do set_variable DETECTOR_TXT $WORKDIR detector
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 source JAcoustics sh $DETECTOR_ID typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:36
Data structure for format specifications.
Definition: JManip.hh:521
double getLength() const
Get length.