Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
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 "JGeometry3D/JCylinder3D.hh"
#include "JSupport/JMultipleFileScanner.hh"
#include "JSupport/JMeta.hh"
#include "JSupport/JSupport.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

◆ main()

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 int debug;
52
53 try {
54
55 JParser<> zap("Example program to check contents of acoustic events.");
56
57 zap['f'] = make_field(inputFile, "output of JKatoomba[.sh]");
58 zap['n'] = make_field(numberOfEvents) = JLimit_t::max();
59 zap['a'] = make_field(detectorFile);
60 zap['o'] = make_field(outputFile) = "narrabri.root";
61 zap['T'] = make_field(Tmax_s);
62 zap['d'] = make_field(debug) = 1;
63
64 zap(argc, argv);
65 }
66 catch(const exception &error) {
67 FATAL(error.what() << endl);
68 }
69
70
72
73 try {
74 load(detectorFile, detector);
75 }
76 catch(const JException& error) {
77 FATAL(error);
78 }
79
80
81 JDynamics dynamics(detector, Tmax_s);
82
83 STATUS("loading input from file(s) " << inputFile << "... " << flush);
84
85 dynamics.load(inputFile);
86
87 STATUS("OK" << endl);
88
89 const JCylinder3D cylinder(detector.begin(), detector.end());
90
91 const double Z = cylinder.getZmax() * 0.5;
92
95
96 Double_t xmin = numeric_limits<Double_t>::max();
97 Double_t xmax = numeric_limits<Double_t>::lowest();
98
99 for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
100
101 if (!string->second.empty()) {
102 xmin = min(xmin, string->second.getXmin());
103 xmax = max(xmax, string->second.getXmax());
104 }
105 }
106
107 const JFormat_t format(4, 0, std::ios_base::fmtflags(), '0');
108
109 JManager<int, TH2D> H2(new TH2D ("[%].tilt", NULL, 300, -3.0, +3.0, 300, -3.0, +3.0), '%', format);
110 JManager<int, TH1D> HT(new TH1D ("[%].time", NULL, 200, 0.0, 4.0), '%', format);
111
112 JManager<int, TH1D> HO(new TH1D ("H[%].orientation", NULL, 1000, xmin, xmax), '%', format);
113 JManager<int, TH1D> HA(new TH1D ("H[%].amplitude", NULL, 1000, xmin, xmax), '%', format);
114
115 for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
116
117 TH1D* ho = HO[string->first];
118 TH1D* ha = HA[string->first];
119
120 for (Int_t i = 1; i <= HO->GetXaxis()->GetNbins(); ++i) {
121
122 const Double_t x = HO->GetXaxis()->GetBinCenter(i);
123
124 try {
125
126 const JMODEL::JString tilt = string->second(x);
127
128 ho->SetBinContent(i, tilt.getAngle());
129 ha->SetBinContent(i, tilt.getLength());
130 }
131 catch(const exception& error) {
132 //ERROR("Error string " << setw(4) << string->first << " at " << FIXED(20,5) << x << ' ' << error.what() << endl);
133 }
134 }
135 }
136
137
138 for (JDynamics::JPosition::const_iterator string = dynamics.position.begin(); string != dynamics.position.end(); ++string) {
139
140 if (string->second.size() > 1) {
141
142 TH2D* h2 = H2[string->first];
143 TH1D* ht = HT[string->first];
144
145 for (typename JDynamics::JPosition::function_type::const_iterator q = string->second.begin(), p = q++; q != string->second.end(); ++p, ++q) {
146
147 const double t1 = q->getX() - p->getX();
148
149 HT->Fill(log10(t1));
150 ht->Fill(log10(t1));
151
152 const double tx = 600.0e3 * ((q->getY().tx + q->getY().tx2 * Z) - (p->getY().tx + p->getY().tx2 * Z)) / t1; // [mrad/10 min]
153 const double ty = 600.0e3 * ((q->getY().ty + q->getY().ty2 * Z) - (p->getY().ty + p->getY().ty2 * Z)) / t1; // [mrad/10 min]
154
155 if (t1 > 0 && t1 < Tmax_s) {
156 H2->Fill(tx, ty);
157 h2->Fill(tx, ty);
158 }
159 }
160
161 for (typename JDynamics::JPosition::function_type::const_iterator i = string->second.begin(); i != string->second.end(); ++i) {
162 ZO[string->first].put(i->getX(), i->getY().getAngle());
163 ZA[string->first].put(i->getX(), i->getY().getLength());
164 }
165 }
166 }
167
168
169 TFile out(outputFile.c_str(), "recreate");
170
171 out << *H2 << H2 << *HT << HT << HO << HA;
172
173 for (map<int, JGraph_t>::const_iterator i = ZO.begin(); i != ZO.end(); ++i) {
174 out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].orientation"));
175 }
176
177 for (map<int, JGraph_t>::const_iterator i = ZA.begin(); i != ZA.end(); ++i) {
178 out << JGraph(i->second, MAKE_CSTRING("G[" << FILL(4,'0') << i->first << "].amplitude"));
179 }
180
181 out.Write();
182 out.Close();
183}
string outputFile
#define STATUS(A)
Definition JMessage.hh:63
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
#define MAKE_CSTRING(A)
Make C-string.
Definition JPrint.hh:72
Detector data structure.
Definition JDetector.hh:96
General exception.
Definition JException.hh:24
Utility class to parse command line options.
Definition JParser.hh:1698
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
Definition JManager.hh:47
General purpose class for object reading from a list of file names.
collection_type::const_iterator const_iterator
Definition JPolfit.hh:184
const double xmax
const double xmin
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for sequence of same character.
Definition JManip.hh:330
Detector file.
Definition JHead.hh:227
double getAngle() const
Get angle.
double getLength() const
Get length.
data_type::const_iterator const_iterator
Definition JDynamics.hh:328
Dynamic detector calibration.
Definition JDynamics.hh:86
Data structure for format specifications.
Definition JManip.hh:524
Auxiliary data structure to build TGraph.
Definition JGraph.hh:44
Auxiliary class for defining the range of iterations of objects.
Definition JLimit.hh:45
static counter_type max()
Get maximum counter value.
Definition JLimit.hh:128