Jpp  18.2.1-ARCA-DF-PATCH
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
JPlatypus.cc
Go to the documentation of this file.
1 #include <string>
2 #include <iostream>
3 #include <iomanip>
4 #include <vector>
5 #include <set>
6 #include <map>
7 #include <deque>
8 #include <algorithm>
9 #include <limits>
10 
11 #include <type_traits>
12 #include <functional>
13 #include <future>
14 #include <mutex>
15 #include <thread>
16 #include <vector>
17 #include <queue>
18 
19 #include "TROOT.h"
20 #include "TFile.h"
21 
22 #include "JLang/JPredicate.hh"
23 #include "JLang/JComparator.hh"
24 #include "JLang/JComparison.hh"
25 #include "JLang/JFileStream.hh"
26 
27 #include "JDetector/JDetector.hh"
29 #include "JDetector/JTripod.hh"
31 #include "JDetector/JModule.hh"
32 #include "JDetector/JHydrophone.hh"
33 
34 #include "JTools/JHashMap.hh"
35 #include "JTools/JRange.hh"
36 #include "JTools/JQuantile.hh"
37 
39 
41 #include "JAcoustics/JEmitter.hh"
43 #include "JAcoustics/JHit.hh"
46 #include "JAcoustics/JSuperEvt.hh"
48 #include "JAcoustics/JSupport.hh"
50 
51 #include "Jeep/JContainer.hh"
52 #include "Jeep/JParser.hh"
53 #include "Jeep/JMessage.hh"
54 
55 
56 /**
57  * \file
58  *
59  * Application to make a global fit of the detector geometry to acoustic data.\n
60  * \author mdejong
61  */
62 int main(int argc, char **argv)
63 {
64  using namespace std;
65  using namespace JPP;
66 
70 
72  string detectorFile;
73  JLimit_t& numberOfEvents = inputFile.getLimit();
74  JSoundVelocity V = getSoundVelocity; // default sound velocity
75  tripods_container tripods; // tripods
76  transmitters_container transmitters; // transmitters
77  hydrophones_container hydrophones; // hydrophones
78  JFitParameters parameters; // fit parameters
79  size_t threads; // number of parallel threads
80  int debug;
81 
82  try {
83 
84  JParser<> zap("Application to fit position calibration model to acoustic data.");
85 
86  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
87  zap['n'] = make_field(numberOfEvents) = JLimit::max();
88  zap['a'] = make_field(detectorFile);
90  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
91  zap['T'] = make_field(tripods, "tripod data");
92  zap['Y'] = make_field(transmitters, "transmitter data") = JPARSER::initialised();
93  zap['H'] = make_field(hydrophones, "hydrophone data") = JPARSER::initialised();
94  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
95  zap['N'] = make_field(threads, "number of threads") = 1;
96  zap['d'] = make_field(debug) = 1;
97 
98  zap(argc, argv);
99  }
100  catch(const exception &error) {
101  FATAL(error.what() << endl);
102  }
103 
104  ROOT::EnableThreadSafety();
105 
107 
108  try {
109  load(detectorFile, detector);
110  }
111  catch(const JException& error) {
112  FATAL(error);
113  }
114 
115  JHashMap<int, JEmitter> emitters;
116 
117  for (tripods_container::const_iterator i = tripods.begin(); i != tripods.end(); ++i) {
118  {
119  emitters[i->getID()] = JEmitter(i->getID(),
120  i->getUTMPosition() - detector.getUTMPosition());
121  }
122  }
123 
124  for (transmitters_container::const_iterator i = transmitters.begin(); i != transmitters.end(); ++i) {
125  try {
126  emitters[i->getID()] = JEmitter(i->getID(),
127  i->getPosition() + detector.getModule(i->getLocation()).getPosition());
128  }
129  catch(const exception&) {} // if no module available, discard transmitter
130  }
131 
132  V.set(detector.getUTMZ()); // sound velocity at detector depth
133 
134  JGeometry geometry(detector, hydrophones);
135 
138 
139  try {
140  JPlatypus platypus(geometry, emitters, V, parameters, inputFile, threads);
141  }
142  catch(const exception& error) {
143  FATAL("main " << error.what());
144  }
145 
146  JFileOutputStream(3) << SCIENTIFIC(1,10) << JPlatypus::Q.getMean(numeric_limits<float>::max()) << endl;
147 }
Utility class to parse command line options.
Definition: JParser.hh:1514
Acoustic hit.
General exception.
Definition: JException.hh:24
Q(UTCMax_s-UTCMin_s)-livetime_s
int main(int argc, char *argv[])
Definition: Main.cc:15
Sound velocity.
JContainer< std::vector< JTransmitter > > transmitters_container
Definition: JSydney.cc:79
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:242
General purpose class for hash map of unique keys.
Definition: JHashMap.hh:72
General purpose class for hash map of unique elements.
ROOT TTree parameter settings.
Detector data structure.
Definition: JDetector.hh:89
*fatal Wrong number of arguments esac JCookie sh typeset Z DETECTOR typeset Z SOURCE_RUN typeset Z TARGET_RUN set_variable PARAMETERS_FILE $WORKDIR parameters
Definition: diff-Tuna.sh:38
then fatal Number of tripods
Definition: JFootprint.sh:45
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:83
V(JDAQEvent-JTriggerReprocessor)*1.0/(JDAQEvent+1.0e-10)
Acoustic emitter.
Data structure for detector geometry and calibration.
Data structure for hydrophone.
Acoustic super event fit toolkit.
Acoustic fit parameters.
Scanning of objects from a single file according a format that follows from the extension of each fil...
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:41
static const JSoundVelocity getSoundVelocity(1541.0,-17.0e-3,-2000.0)
Function object for velocity of sound.
Detector file.
Definition: JHead.hh:226
JContainer< std::vector< JHydrophone > > hydrophones_container
Definition: JSydney.cc:78
Data structure for transmitter.
Acoustic emitter.
Definition: JEmitter.hh:27
Acoustics toolkit.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:39
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1989
Acoustic event fit.
Streaming of output.
Definition: JFileStream.hh:46
JPosition3D getPosition(const Vec &pos)
Get position.
JContainer< std::vector< JTripod > > tripods_container
Definition: JSydney.cc:77
General purpose messaging.
Implementation for depth dependend velocity of sound.
#define FATAL(A)
Definition: JMessage.hh:67
Thread pool for global fits using super events.
Definition: JPlatypus_t.hh:32
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
Auxiliary class to define a range between two values.
Utility class to parse command line options.
Fit functions of acoustic model.
Object reading from a list of files.
const JLimit & getLimit() const
Get limit.
Definition: JLimit.hh:84
do set_variable DETECTOR_TXT $WORKDIR detector
Data structure for tripod.
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:484
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:146
Container I/O.
int debug
debug level
Data structure for optical module.