Jpp  debug
the software that should make you happy
JSydney.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 <algorithm>
7 #include <limits>
8 #include <sys/stat.h>
9 
10 #include <type_traits>
11 #include <functional>
12 #include <future>
13 #include <mutex>
14 #include <thread>
15 #include <vector>
16 #include <queue>
17 
18 #include "TROOT.h"
19 #include "TFile.h"
20 
22 
23 #include "JLang/JPredicate.hh"
24 #include "JLang/JComparator.hh"
25 #include "JLang/JComparison.hh"
28 
29 #include "JSystem/JStat.hh"
30 
31 #include "JDetector/JDetector.hh"
33 #include "JDetector/JTripod.hh"
35 #include "JDetector/JModule.hh"
36 #include "JDetector/JHydrophone.hh"
38 
39 #include "JFit/JGradient.hh"
40 
41 #include "JTools/JHashMap.hh"
42 #include "JTools/JRange.hh"
43 
44 #include "JMath/JQuantile_t.hh"
45 
47 
49 #include "JAcoustics/JEmitter.hh"
51 #include "JAcoustics/JHit.hh"
54 #include "JAcoustics/JEvent.hh"
55 #include "JAcoustics/JSuperEvt.hh"
57 #include "JAcoustics/JSupport.hh"
61 
62 #include "Jeep/JTimer.hh"
63 #include "Jeep/JeepToolkit.hh"
64 #include "Jeep/JContainer.hh"
65 #include "Jeep/JParser.hh"
66 #include "Jeep/JMessage.hh"
67 
68 
69 namespace JACOUSTICS {
70 
72  using JEEP::JContainer;
73  using JFIT::JParameter_t;
74 
75  using namespace JDETECTOR;
76 
77 
81 
82 
83  /**
84  * Script commands.
85  */
86  static const char skip_t = '#'; //!< skip line
87  static const std::string initialise_t = "initialise"; //!< initialise
88  static const std::string fix_t = "fix"; //!< fix objects
89  static const std::string string_t = "string"; //!< string
90  static const std::string tripod_t = "tripod"; //!< tripod
91  static const std::string stage_t = "stage"; //!< fit stage
92 
93 
94  /**
95  * Auxiliary data structure for handling of file names.
96  */
97  struct JFilenames {
98  std::string detector; //!< detector
99  std::string tripod; //!< tripod
100  std::string hydrophone; //!< hydrophone
101  std::string transmitter; //!< transmitter
102  };
103 
104 
105  /**
106  * Auxiliary data structure for setup of complete system.
107  */
108  struct JSetup {
109  JDetector detector; //!< detector
111  struct :
112  public hydrophones_container
113  {
114  /**
115  * Check if there is a hydrophone on given string.
116  *
117  * \param id string identifier
118  * \return true if hydrophone present; else false
119  */
120  bool hasString(const int id) const
121  {
122  using namespace std;
123 
124  return (find_if(this->begin(), this->end(), make_predicate(&JHydrophone::getString, id)) != this->end());
125  }
126  } hydrophones; //!< hydrophones
128  };
129 
130 
131  /**
132  * Main class for pre-calibration using acoustics data.
133  */
134  struct JSydney {
135 
136  static constexpr double RADIUS_M = 1.0; //!< maximal horizontal distance between T-bar and emitter/hydrophone
137 
138  /**
139  * List of object identifiers.
140  */
141  struct ids_t :
142  public std::set<int>
143  {
144  /**
145  * Default constructor.
146  */
148  {}
149 
150 
151  /**
152  * Copy constructor.
153  *
154  * \param buffer list of identifiers
155  */
156  ids_t(const std::vector<int>& buffer) :
157  std::set<int>(buffer.begin(), buffer.end())
158  {}
159 
160 
161  /**
162  * Difference constructor.
163  * Make list of all object identifiers in A that are not in B.
164  *
165  * \param A list of identifiers
166  * \param B list of identifiers
167  */
168  ids_t(const ids_t& A,
169  const ids_t& B)
170  {
171  std::set_difference(A.begin(), A.end(), B.begin(), B.end(), std::inserter(*this, this->begin()));
172  }
173 
174 
175  /**
176  * Fix.
177  * Keep list of object identifiers that are not in B.
178  *
179  * \param B list of identifiers
180  */
181  void fix(const ids_t& B)
182  {
183  ids_t A;
184 
185  this->swap(A);
186 
187  std::set_difference(A.begin(), A.end(), B.begin(), B.end(), std::inserter(*this, this->begin()));
188  }
189 
190 
191  /**
192  * Read identifiers from input stream
193  *
194  * \param in input stream
195  * \param object identifiers
196  * \return input stream
197  */
198  friend inline std::istream& operator>>(std::istream& in, ids_t& object)
199  {
200  for (int id; in >> id; ) {
201  object.insert(id);
202  }
203 
204  if (!in.bad()) {
205  in.clear();
206  }
207 
208  return in;
209  }
210 
211 
212  /**
213  * Write identifiers to output stream
214  *
215  * \param out output stream
216  * \param object identifiers
217  * \return output stream
218  */
219  friend inline std::ostream& operator<<(std::ostream& out, const ids_t& object)
220  {
221  for (const int id : object) {
222  out << ' ' << id;
223  }
224 
225  return out;
226  }
227  };
228 
229 
230  /**
231  * Auxiliary data structure for group of lists of identifiers of to-be-fitted objects.
232  */
233  struct fits_t {
234  /**
235  * Default constructor.
236  */
238  {}
239 
240 
241  /**
242  * Initialise.
243  *
244  * \param setup setup
245  */
246  void initialise(const JSetup& setup)
247  {
248  using namespace JPP;
249 
250  strings = make_array(setup.detector .begin(), setup.detector .end(), &JModule ::getString);
251  tripods = make_array(setup.tripods .begin(), setup.tripods .end(), &JTripod ::getID);
252  hydrophones = make_array(setup.hydrophones .begin(), setup.hydrophones .end(), &JHydrophone ::getString);
253  transmitters = make_array(setup.transmitters.begin(), setup.transmitters.end(), &JTransmitter::getString);
254  }
255 
256  ids_t strings; //!< identifiers of strings
257  ids_t tripods; //!< identifiers of tripods
258  ids_t hydrophones; //!< identifiers of strings with hydrophone
259  ids_t transmitters; //!< identifiers of strings with transmitter
260  };
261 
262 
263  /**
264  * Auxiliary class to edit (z) position of module.
265  */
266  struct JModuleEditor :
267  public JParameter_t
268  {
269  /**
270  * Constructor.
271  *
272  * \param module module
273  */
275  module(module),
276  direction(JGEOMETRY3D::JVector3Z_t)
277  {}
278 
279 
280  /**
281  * Constructor.
282  *
283  * \param module module
284  * \param direction direction
285  */
286  JModuleEditor(JModule& module, const JVector3D& direction) :
287  module(module),
288  direction(direction)
289  {}
290 
291 
292  /**
293  * Apply step.
294  *
295  * \param step step
296  */
297  virtual void apply(const double step) override
298  {
299  using namespace JPP;
300 
301  module.add(direction * step);
302  }
303 
304  private:
307  };
308 
309 
310  /**
311  * Auxiliary class to edit (x,y,z) position of string.
312  */
313  struct JStringEditor :
314  public JParameter_t
315  {
316  /**
317  * Constructor.
318  *
319  * The option <tt>true</tt> and <tt>false</tt> correspond to all modules and optical modules only, respectively.
320  *
321  * \param setup setup
322  * \param id string number
323  * \param direction direction
324  * \param option option
325  */
326  JStringEditor(JSetup& setup, const int id, const JVector3D& direction, const bool option) :
327  detector (setup.detector),
328  direction(direction)
329  {
330  for (size_t i = 0; i != detector.size(); ++i) {
331  if (detector[i].getString() == id && (detector[i].getFloor() != 0 || option)) {
332  index.push_back(i);
333  }
334  }
335  }
336 
337 
338  /**
339  * Apply step.
340  *
341  * \param step step
342  */
343  virtual void apply(const double step) override
344  {
345  for (const auto i : index) {
346  detector[i].add(direction * step);
347  }
348  }
349 
350  private:
354  };
355 
356 
357  /**
358  * Auxiliary class to edit length of Dyneema ropes.
359  */
360  struct JDyneemaEditor :
361  public JParameter_t
362  {
363  /**
364  * Constructor.
365  *
366  * \param setup setup
367  * \param id string number
368  * \param z0 reference position
369  */
370  JDyneemaEditor(JSetup& setup, const int id, const double z0 = 0.0) :
371  detector (setup.detector),
372  z0 (z0)
373  {
374  for (size_t i = 0; i != detector.size(); ++i) {
375  if (detector[i].getString() == id && detector[i].getFloor() != 0) {
376  index.push_back(i);
377  }
378  }
379  }
380 
381 
382  /**
383  * Apply step.
384  *
385  * \param step step
386  */
387  virtual void apply(const double step) override
388  {
389  for (const auto i : index) {
390 
391  JModule& module = detector[i];
392 
393  if (step > 0.0)
394  module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) * (1.0 + step)));
395  else if (step < 0.0)
396  module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) / (1.0 - step)));
397  }
398  }
399 
400  private:
402  double z0;
404  };
405 
406 
407  /**
408  * Auxiliary class to edit (x,y,z) position of tripod.
409  */
410  struct JTripodEditor :
411  public JParameter_t
412  {
413  /**
414  * Constructor.
415  *
416  * \param setup setup
417  * \param id tripod identifier
418  * \param direction direction
419  */
420  JTripodEditor(JSetup& setup, const int id, const JVector3D& direction) :
421  tripods (setup.tripods),
422  direction(direction)
423  {
424  using namespace std;
425  using namespace JPP;
426 
427  index = distance(tripods.begin(), find_if(tripods.begin(), tripods.end(), make_predicate(&JTripod::getID, id)));
428  }
429 
430 
431  /**
432  * Apply step.
433  *
434  * \param step step
435  */
436  virtual void apply(const double step) override
437  {
438  tripods[index].add(direction * step);
439  }
440 
441  private:
444  size_t index;
445  };
446 
447 
448  /**
449  * Auxiliary class to edit orientation of anchor.
450  */
451  struct JAnchorEditor :
452  public JParameter_t
453  {
454  /**
455  * Constructor.
456  *
457  * \param setup setup
458  * \param id string identifier
459  */
460  JAnchorEditor(JSetup& setup, const int id) :
461  hydrophones (setup.hydrophones),
462  transmitters(setup.transmitters)
463  {
464  using namespace std;
465  using namespace JPP;
466 
467  index[0] = distance(hydrophones .begin(), find_if(hydrophones .begin(), hydrophones .end(), make_predicate(&JHydrophone ::getString, id)));
468  index[1] = distance(transmitters.begin(), find_if(transmitters.begin(), transmitters.end(), make_predicate(&JTransmitter::getString, id)));
469  }
470 
471 
472  /**
473  * Apply step.
474  *
475  * \param step step
476  */
477  virtual void apply(const double step) override
478  {
479  using namespace JPP;
480 
481  const JRotation3Z R(step);
482 
483  if (index[0] != hydrophones .size()) { hydrophones [index[0]].rotate(R); }
484  if (index[1] != transmitters.size()) { transmitters[index[1]].rotate(R); }
485  }
486 
487  private:
490  size_t index[2];
491  };
492 
493 
494  /**
495  * Extended data structure for parameters of stage.
496  */
497  struct JParameters_t :
498  public JFitParameters
499  {
500  /**
501  * Default constuctor.
502  */
504  Nmax (std::numeric_limits<size_t>::max()),
505  Nextra (0),
506  epsilon(1.0e-4),
507  debug (3)
508  {}
509 
510 
511  /**
512  * Read parameters from input stream
513  *
514  * \param in input stream
515  * \param object parameters
516  * \return input stream
517  */
518  friend inline std::istream& operator>>(std::istream& in, JParameters_t& object)
519  {
520  object = JParameters_t();
521 
522  in >> object.option
523  >> object.mestimator
524  >> object.sigma_s
525  >> object.stdev
526  >> object.Nextra;
527 
528  if (in) {
529 
530  for (double value; in >> value; ) {
531  object.steps.push_back(value);
532  }
533 
534  if (!in.bad()) {
535  in.clear();
536  }
537  }
538 
539  return in;
540  }
541 
542 
543  /**
544  * Write parameters to output stream
545  *
546  * \param out output stream
547  * \param object parameters
548  * \return output stream
549  */
550  friend inline std::ostream& operator<<(std::ostream& out, const JParameters_t& object)
551  {
552  using namespace std;
553 
554  out << setw(2) << object.option << ' '
555  << setw(2) << object.mestimator << ' '
556  << SCIENTIFIC(9,3) << object.sigma_s << ' '
557  << SCIENTIFIC(9,3) << object.stdev << ' '
558  << setw(3) << object.Nextra;
559 
560  for (const double value : object.steps) {
561  out << ' ' << FIXED(9,5) << value;
562  }
563 
564  return out;
565  }
566 
567  size_t Nmax;
568  size_t Nextra;
569  double epsilon;
570  int debug;
572  };
573 
574 
575  /**
576  * Constructor.
577  *
578  * \param filenames file names
579  * \param V sound velocity
580  * \param threads threads
581  * \param debug debug
582  */
583  JSydney(const JFilenames& filenames,
584  const JSoundVelocity& V,
585  const size_t threads,
586  const int debug) :
587  filenames(filenames),
588  V(V),
589  threads(threads),
590  debug(debug)
591  {
592  load(filenames.detector, setup.detector);
593 
594  setup.tripods.load(filenames.tripod.c_str());
595 
596  if (filenames.hydrophone != "") { setup.hydrophones .load(filenames.hydrophone .c_str()); }
597  if (filenames.transmitter != "") { setup.transmitters.load(filenames.transmitter.c_str()); }
598 
599  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
600  receivers[i->getID()] = i->getLocation();
601  }
602 
603  // detach PMTs
604 
605  detector = setup.detector;
606 
607  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
608  module->clear();
609  }
610 
611  router.reset(new JLocationRouter(setup.detector));
612 
613  fits.initialise(setup);
614 
615  this->V.set(setup.detector.getUTMZ()); // sound velocity at detector depth
616 
619 
621 
622  ROOT::EnableThreadSafety();
623  }
624 
625 
626  /**
627  * Auxiliary data structure for decomposed string.
628  */
629  struct string_type :
630  public std::vector<JModule> // optical modules
631  {
632  /**
633  * Add module.
634  *
635  * \param module module
636  */
637  void push_back(const JModule& module)
638  {
639  if (module.getFloor() == 0)
640  this->base = module;
641  else
643  }
644 
645  JModule base; // base module
646  };
647 
648 
649  /**
650  * Auxiliary data structure for detector with decomposed strings.
651  */
652  struct detector_type :
653  public std::map<int, string_type>
654  {
655  /**
656  * Add module.
657  *
658  * \param module module
659  */
660  void push_back(const JModule& module)
661  {
662  (*this)[module.getString()].push_back(module);
663  }
664  };
665 
666 
667  /**
668  * Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
669  *
670  * \param parameters parameters
671  */
672  void stage_0(const JParameters_t& parameters)
673  {
674  using namespace std;
675  using namespace JPP;
676 
677  this->parameters = parameters;
678 
679  JDetector A; // old strings
680  detector_type B; // new strings with transmitter -> fit only base module
681  JDetector C; // new strings w/o transmitter -> discard completely from fit
682 
683  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
684 
685  if (fits.strings .count(module->getString()) == 0)
686  A.push_back(*module);
687  else if (fits.transmitters.count(module->getString()) != 0)
688  B.push_back(*module);
689  else
690  C.push_back(*module);
691  }
692 
693  setup.detector.swap(A);
694 
695  for (const auto& element : B) {
696  setup.detector.push_back(element.second.base);
697  }
698 
699  router.reset(new JLocationRouter(setup.detector));
700 
701  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
702 
703  for (const int i : fits.tripods) {
704  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[0]));
705  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[0]));
706  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[0]));
707  }
708 
709  for (const int i : fits.transmitters) {
710  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.x: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3X_t, true), parameters.steps[0]));
711  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.y: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Y_t, true), parameters.steps[0]));
712  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.z: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Z_t, true), parameters.steps[0]));
713  }
714 
715  const double chi2 = fit(*this);
716 
717  for (auto& element : B) {
718 
719  const JModule& base = setup.detector.getModule(router->getAddress(JLocation(element.second.base.getString(),0)));
720  const JVector3D pos = base.getPosition() - element.second.base.getPosition();
721 
722  for (string_type::iterator module = element.second.begin(); module != element.second.end(); ++module) {
723 
724  module->add(pos);
725 
726  setup.detector.push_back(*module);
727  }
728  }
729 
730  copy(C.begin(), C.end(), back_inserter(setup.detector));
731 
732  sort(setup.detector.begin(), setup.detector.end(), make_comparator(&JModule::getLocation));
733 
734  router.reset(new JLocationRouter(setup.detector));
735 
736  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
737  }
738 
739 
740  /**
741  * Fit procedure to determine the positions of the strings and tripods.
742  *
743  * \param parameters parameters
744  */
745  void stage_a(const JParameters_t& parameters)
746  {
747  using namespace std;
748  using namespace JPP;
749 
750  this->parameters = parameters;
751 
752  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
753 
754  for (const int i : fits.strings) {
755  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.x: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3X_t, true), parameters.steps[0]));
756  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.y: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Y_t, true), parameters.steps[0]));
757  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Z_t, false), parameters.steps[0]));
758  }
759 
760  for (const int i : fits.tripods) {
761  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[1]));
762  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[1]));
763  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[1]));
764  }
765 
766  for (const int i : ids_t(fits.hydrophones, fits.transmitters)) {
767  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
768  }
769 
770  for (const int i : fits.transmitters) {
771 
772  JModule& module = setup.detector.getModule(router->getAddress(JLocation(i,0)));
773 
774  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
775  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.z: " << RIGHT(4) << i), new JModuleEditor(module), parameters.steps[0]));
776  }
777 
778  const double chi2 = fit(*this);
779 
780  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
781  }
782 
783 
784  /**
785  * Fit procedure to determine the stretching and z-positions of individual strings.
786  *
787  * \param parameters parameters
788  */
789  void stage_b(const JParameters_t& parameters)
790  {
791  using namespace std;
792  using namespace JPP;
793 
794  this->parameters = parameters;
795 
796  map<int, JDetector> buffer;
797 
798  double z0 = 0.0;
799 
800  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
801 
802  buffer[module->getString()].push_back(*module);
803 
804  if (module->getZ() > z0) {
805  z0 = module->getZ();
806  }
807  }
808 
809  JDetector tx;
810 
811  for (transmitters_container::iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
812  try {
813  tx.push_back(router->getModule(i->getLocation()));
814  }
815  catch(const exception&) {}
816  }
817 
818  for (const int i : fits.strings) {
819 
820  setup.detector.swap(buffer[i]);
821 
822  copy(tx.begin(), tx.end(), back_inserter(setup.detector));
823 
824  router.reset(new JLocationRouter(setup.detector));
825 
826  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
827 
828  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.M: " << RIGHT(4) << i), new JDyneemaEditor(setup, i, z0), parameters.steps[0]));
829  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i), new JStringEditor (setup, i, JVector3Z_t, false), parameters.steps[1]));
830 
831  const double chi2 = fit(*this);
832 
833  STATUS("string: " << setw(4) << i << ' ' << FIXED(9,4) << chi2 << endl);
834 
835  buffer[i].clear();
836 
837  copy_if(setup.detector.begin(), setup.detector.end(), back_inserter(buffer[i]), make_predicate(&JModule::getString, i));
838  }
839 
840  setup.detector.clear();
841 
842  for (const auto& element : buffer) {
843  copy(element.second.begin(), element.second.end(), back_inserter(setup.detector));
844  }
845 
846  router.reset(new JLocationRouter(setup.detector));
847  }
848 
849 
850  /**
851  * Fit procedure to determine the z-positions of the modules.
852  *
853  * \param parameters parameters
854  */
855  void stage_c(const JParameters_t& parameters)
856  {
857  using namespace std;
858  using namespace JPP;
859 
860  this->parameters = parameters;
861 
862  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
863 
864  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
865  if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
866  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
867  }
868  }
869 
870  const double chi2 = fit(*this);
871 
872  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
873  }
874 
875 
876  /**
877  * Fit procedure to determine the z-positions of anchors.
878  *
879  * \param parameters parameters
880  */
881  void stage_d(const JParameters_t& parameters)
882  {
883  using namespace std;
884  using namespace JPP;
885 
886  this->parameters = parameters;
887 
888  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
889 
890  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
891  if (fits.strings.count(module->getString()) != 0 && module->getFloor() == 0) {
892  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
893  }
894  }
895 
896  const double chi2 = fit(*this);
897 
898  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
899  }
900 
901 
902  /**
903  * Fit procedure to determine the (x,y,z) positions of the modules.
904  * This procedure should be considered unorthodox - it can be used to modify the detector file in such a way
905  * to accommodate anomalies in the shapes of a string (e.g. entanglement of string in D0ORCA018).
906  *
907  * \param parameters parameters
908  */
909  void stage_x(const JParameters_t& parameters)
910  {
911  using namespace std;
912  using namespace JPP;
913 
914  this->parameters = parameters;
915 
916  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
917 
918  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
919  if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
920  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.x: " << right << module->getLocation()), new JModuleEditor(*module, JVector3X_t), parameters.steps[0]));
921  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.y: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Y_t), parameters.steps[0]));
922  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Z_t), parameters.steps[0]));
923  }
924  }
925 
926  const double chi2 = fit(*this);
927 
928  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
929  }
930 
931 
932  /**
933  * Get chi2.
934  *
935  * \param option option
936  * \return chi2/NDF
937  */
938  double operator()(const int option) const
939  {
940  using namespace std;
941  using namespace JPP;
942 
943  const JGeometry geometry(setup.detector, setup.hydrophones);
944 
945  JHashMap<int, JEmitter> emitters;
946 
947  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
948  {
949  emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
950  }
951  }
952 
953  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
954  try {
955  emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
956  }
957  catch(const exception&) {} // if no module available, discard transmitter
958  }
959 
960  if (option == 0 || // step wise improvement of the chi2
961  option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
962 
963  this->output.clear();
964 
965  JSTDObjectWriter<JSuperEvt> out(this->output); // write data for subsequent use
966 
967  JFremantle::output = (option == 1 ? &out : NULL);
968 
969  {
970  JFremantle fremantle(geometry, V, parameters, threads, 2 * threads);
971 
972  for (const input_type& superevt : input) {
973 
974  const JWeight getWeight(superevt.begin(), superevt.end());
975 
977 
978  for (input_type::const_iterator evt = superevt.begin(); evt != superevt.end(); ++evt) {
979 
980  if (emitters.has(evt->getID())) {
981 
982  const JEmitter& emitter = emitters [evt->getID()];
983  const double weight = getWeight(evt->getID());
984 
985  for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
986 
987  if (geometry.hasLocation(receivers[i->getID()])) {
988 
989  data.push_back(JHit(emitter,
990  distance(superevt.begin(), evt),
991  receivers[i->getID()],
992  i->getToA(),
993  parameters.sigma_s,
994  weight));
995  }
996  }
997  }
998  }
999 
1000  if (getMinimumNumberOfEmitters(data.begin(), data.end()) >= parameters.Nmin) {
1001  fremantle.enqueue(data);
1002  }
1003  }
1004  }
1005 
1006  return JFremantle::Q.getMean(numeric_limits<float>::max());
1007 
1008  } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
1009 
1010  {
1011  JSTDObjectReader<JSuperEvt> in(this->output);
1012 
1013  JPlatypus platypus(geometry, emitters, V, parameters, in, threads);
1014  }
1015 
1016  return JPlatypus::Q.getMean(numeric_limits<float>::max());
1017 
1018  } else {
1019 
1020  return numeric_limits<float>::max();
1021  }
1022  }
1023 
1024 
1025  /**
1026  * Run.
1027  *
1028  * \param script steering script
1029  */
1030  void run(const std::string& script)
1031  {
1032  using namespace std;
1033  using namespace JPP;
1034 
1035  ifstream in(script.c_str());
1036 
1037  while (in) {
1038 
1039  string buffer, key;
1040 
1041  if (getline(in, buffer)) {
1042 
1043  if (buffer.empty() || buffer[0] == skip_t) {
1044  continue;
1045  }
1046 
1047  istringstream is(buffer);
1048 
1049  is >> key;
1050 
1051  if (key == initialise_t) { // set object identifiers
1052 
1053  fits.initialise(setup);
1054 
1055  } else if (key == fix_t) { // fix object identifiers
1056 
1057  string type; // type of object
1058  ids_t id; // identifiers
1059 
1060  if (is >> type >> id) {
1061  if (type == string_t) {
1062  fits.strings .fix(id);
1063  fits.hydrophones .fix(id);
1064  fits.transmitters.fix(id);
1065  } else if (type == tripod_t) {
1066  fits.tripods .fix(id);
1067  } else {
1068  THROW(JValueOutOfRange, "Invalid type <" << type << ">");
1069  }
1070  }
1071 
1072  } else if (key == stage_t) { // stage
1073 
1074  string stage;
1075  JParameters_t input;
1076 
1077  if (is >> stage >> input) {
1078 
1079  STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
1080 
1081  JTimer timer;
1082 
1083  timer.start();
1084 
1085  ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
1086 
1087  {
1088  JRedirectStream redirect(cout, out);
1089 
1090  switch (stage[stage.size() - 1]) {
1091 
1092  case '0':
1093  stage_0(input);
1094  break;
1095 
1096  case 'a':
1097  case 'A':
1098  stage_a(input);
1099  break;
1100 
1101  case 'b':
1102  case 'B':
1103  stage_b(input);
1104  break;
1105 
1106  case 'c':
1107  case 'C':
1108  stage_c(input);
1109  break;
1110 
1111  case 'd':
1112  case 'D':
1113  stage_d(input);
1114  break;
1115 
1116  case 'x':
1117  case 'X':
1118  stage_x(input);
1119  break;
1120 
1121  default:
1122  THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
1123  break;
1124  }
1125  }
1126 
1127  out.close();
1128 
1129  store(stage);
1130  store();
1131 
1132  timer.stop();
1133 
1134  STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
1135  }
1136 
1137  } else {
1138  THROW(JValueOutOfRange, "Invalid key <" << key << ">");
1139  }
1140  }
1141  }
1142 
1143  in.close();
1144  }
1145 
1146 
1147  /**
1148  * Store data in given directory.
1149  *
1150  * \param dir directory
1151  */
1152  void store(const std::string& dir = ".")
1153  {
1154  using namespace JPP;
1155 
1156  if (getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
1157 
1158  // attach PMTs
1159 
1160  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
1161  module->set(router->getModule(module->getLocation()).getPosition());
1162  }
1163 
1164  JDETECTOR::store(getFilename(dir, filenames.detector), detector);
1165 
1166  setup.tripods.store(getFilename(dir, filenames.tripod).c_str());
1167 
1168  if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
1169  if (filenames.transmitter != "") { setup.transmitters.store(getFilename(dir, filenames.transmitter).c_str()); }
1170 
1171  } else {
1172 
1173  THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1174  }
1175  }
1176 
1177 
1178  /**
1179  * Get list of identifiers of receivers.
1180  *
1181  * \return list of identifiers
1182  */
1184  {
1185  ids_t buffer;
1186 
1187  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
1188  if ((i->getFloor() != 0 && !i->has(PIEZO_DISABLE)) || (setup.hydrophones.hasString(i->getString()) && !i->has(HYDROPHONE_DISABLE))) {
1189  buffer.insert(i->getID());
1190  }
1191  }
1192 
1193  return buffer;
1194  }
1195 
1196 
1197  /**
1198  * Get list of identifiers of emitters.
1199  *
1200  * \return list of identifiers
1201  */
1203  {
1204  using namespace std;
1205 
1206  ids_t buffer;
1207 
1208  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1209  buffer.insert(i->getID());
1210  }
1211 
1212  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1213 
1214  try {
1215 
1216  const JModule& module = router->getModule(i->getLocation());
1217 
1218  if (!module.has(TRANSMITTER_DISABLE)) {
1219  buffer.insert(i->getID());
1220  }
1221  }
1222  catch(const exception&) {}
1223  }
1224 
1225  return buffer;
1226  }
1227 
1228 
1231  size_t threads;
1232  int debug;
1235 
1237  std::unique_ptr<JLocationRouter> router;
1238 
1241 
1242  private:
1244 
1245  JDetector detector; //!< PMTs
1247  };
1248 }
1249 
1250 
1251 /**
1252  * \file
1253  *
1254  * Application to perform acoustic pre-calibration.
1255  * \author mdejong
1256  */
1257 int main(int argc, char **argv)
1258 {
1259  using namespace std;
1260  using namespace JPP;
1261 
1262  typedef JContainer< std::set<JTransmission_t> > disable_container;
1263 
1264  JMultipleFileScanner<JEvent> inputFile;
1265  JLimit_t& numberOfEvents = inputFile.getLimit();
1266  JFilenames filenames; // file names
1267  JFitParameters parameters; // fit parameters
1268  string script; // script file
1269  JSoundVelocity V = getSoundVelocity; // default sound velocity
1270  disable_container disable; // disable tansmissions
1271  size_t threads; // number of threads
1272  int debug;
1273 
1274  try {
1275 
1276  JParser<> zap("Application to perform acoustic pre-calibration.");
1277 
1278  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1279  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1280  zap['a'] = make_field(filenames.detector);
1281  zap['@'] = make_field(parameters) = JPARSER::initialised();
1282  zap['s'] = make_field(script, "steering script");
1283  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1284  zap['T'] = make_field(filenames.tripod, "tripod file");
1285  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1286  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1287  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1288  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1289  zap['N'] = make_field(threads, "number of threads") = 1;
1290  zap['d'] = make_field(debug) = 1;
1291 
1292  zap(argc, argv);
1293  }
1294  catch(const exception &error) {
1295  FATAL(error.what() << endl);
1296  }
1297 
1298  if (threads == 0) {
1299  FATAL("Invalid number of threads " << threads << endl);
1300  }
1301 
1302  JSydney sydney(filenames, V, threads, debug);
1303 
1304  const JSydney::ids_t receivers = sydney.getReceivers();
1305  const JSydney::ids_t emitters = sydney.getEmitters();
1306 
1307  typedef vector<JEvent> buffer_type;
1308 
1309  buffer_type zbuf;
1310 
1311  while (inputFile.hasNext()) {
1312 
1313  const JEvent* evt = inputFile.next();
1314 
1315  if (emitters.count(evt->getID())) {
1316  zbuf.push_back(*evt);
1317  }
1318  }
1319 
1320  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1321 
1322  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1323 
1324  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1325 
1326  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1327 
1328  JSydney::input_type buffer;
1329 
1330  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1331 
1332  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1333 
1334  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1335 
1336  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1337 
1338  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1339  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1340 
1341  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (parameters.Qmin <= 1.0 ? i->getW() : 1.0)) {
1342  ++i; continue;
1343  }
1344  }
1345 
1346  iter_swap(i, --__end);
1347  }
1348 
1349  buffer.push_back(JEvent(evt->getDetectorID(), buffer.size(), evt->getID(), evt->begin(), __end));
1350  }
1351 
1352  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1353  sydney.input.push_back(buffer);
1354  }
1355  }
1356 
1357  sydney.run(script);
1358 }
Acoustics toolkit.
Acoustic event.
Acoustic hit.
ROOT TTree parameter settings.
Container I/O.
Data structure for detector geometry and calibration.
Acoustic emitter.
#define THROW(JException_t, A)
Marco for throwing exception with std::ostream compatible message.
Definition: JException.hh:712
Acoustic fit parameters.
General purpose class for hash map of unique elements.
Data structure for hydrophone.
Fit functions of acoustic model.
Direct access to location in detector data structure.
General purpose messaging.
#define STATUS(A)
Definition: JMessage.hh:63
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
Data structure for optical module.
Scanning of objects from multiple files according a format that follows from the extension of each fi...
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define MAKE_CSTRING(A)
Make C-string.
Definition: JPrint.hh:136
#define MAKE_STRING(A)
Make string.
Definition: JPrint.hh:127
Auxiliary class to define a range between two values.
Sound velocity.
File status.
Acoustic super event fit toolkit.
Acoustic event fit.
int main(int argc, char **argv)
Definition: JSydney.cc:1257
Acoustic transmission identifier.
Data structure for transmitter.
Data structure for tripod.
Auxiliary methods for handling file names, type names and environment.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Thread pool for global fits.
Definition: JFremantle_t.hh:33
static output_type * output
optional output
void enqueue(input_type &data)
Queue data.
static JMATH::JQuantile_t Q
chi2/NDF
Thread pool for global fits using super events.
Definition: JPlatypus_t.hh:34
static JMATH::JQuantile_t Q
chi2/NDF
Definition: JPlatypus_t.hh:136
Detector data structure.
Definition: JDetector.hh:96
Router for direct addressing of location data in detector data structure.
Logical location of module.
Definition: JLocation.hh:39
int getFloor() const
Get floor number.
Definition: JLocation.hh:145
int getString() const
Get string number.
Definition: JLocation.hh:134
const JLocation & getLocation() const
Get location.
Definition: JLocation.hh:69
Data structure for a composite optical module.
Definition: JModule.hh:75
bool has(const int bit) const
Test PMT status.
Definition: JStatus.hh:120
JModule & set(const JVector3D &pos)
Set position.
Definition: JModule.hh:407
Auxiliary class for CPU timing and usage.
Definition: JTimer.hh:33
unsigned long long usec_wall
Definition: JTimer.hh:237
void stop()
Stop timer.
Definition: JTimer.hh:127
void start()
Start timer.
Definition: JTimer.hh:106
const JPosition3D & getPosition() const
Get position.
Definition: JPosition3D.hh:130
Rotation around Z-axis.
Definition: JRotation3D.hh:87
Data structure for vector in three dimensions.
Definition: JVector3D.hh:36
JVector3D & add(const JVector3D &vector)
Add vector.
Definition: JVector3D.hh:142
double getY() const
Get y position.
Definition: JVector3D.hh:104
double getZ() const
Get z position.
Definition: JVector3D.hh:115
double getX() const
Get x position.
Definition: JVector3D.hh:94
int getID() const
Get identifier.
Definition: JObjectID.hh:50
This class can be used to temporarily redirect one output (input) stream to another output (input) st...
Implementation of object output from STD container.
Exception for accessing a value in a collection that is outside of its range.
Definition: JException.hh:180
Utility class to parse command line options.
Definition: JParser.hh:1714
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
bool has(const T &value) const
Test whether given value is present.
static const int HYDROPHONE_DISABLE
Enable (disable) use of hydrophone if this status bit is 0 (1);.
static const int TRANSMITTER_DISABLE
Enable (disable) use of transmitter if this status bit is 0 (1);.
static const int PIEZO_DISABLE
Enable (disable) use of piezo if this status bit is 0 (1);.
const double epsilon
Definition: JQuadrature.cc:21
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition: JHead.cc:162
Auxiliary classes and methods for acoustic position calibration.
static const std::string string_t
string
Definition: JSydney.cc:89
size_t getMinimumNumberOfEmitters(T __begin, T __end)
Get minimum number of emitters for any string in data.
double getWeight(T __begin, T __end)
Get total weight of data points.
Definition: JKatoomba_t.hh:61
static const std::string tripod_t
tripod
Definition: JSydney.cc:90
JContainer< std::vector< JTripod > > tripods_container
Definition: JSydney.cc:78
JContainer< std::vector< JTransmitter > > transmitters_container
Definition: JSydney.cc:80
static const std::string initialise_t
initialise
Definition: JSydney.cc:87
JContainer< std::vector< JHydrophone > > hydrophones_container
Definition: JSydney.cc:79
static const char skip_t
Script commands.
Definition: JSydney.cc:86
static const std::string stage_t
fit stage
Definition: JSydney.cc:91
JMODEL::JString getString(const JFit &fit)
Get model parameters of string.
static const std::string fix_t
fix objects
Definition: JSydney.cc:88
size_t getNumberOfEmitters(T __begin, T __end)
Get number of emitters.
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
static JDetectorMechanics getMechanics
Function object to get string mechanics.
Definition: JMechanics.hh:242
file Auxiliary data structures and methods for detector calibration.
Definition: JAnchor.hh:12
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
void store(const std::string &file_name, const JDetector &detector)
Store detector to output file.
std::string getFilename(const std::string &file_name)
Get file name part, i.e. part after last JEEP::PATHNAME_SEPARATOR if any.
Definition: JeepToolkit.hh:128
Auxiliary classes and methods for 3D geometrical objects and operations.
Definition: JAngle3D.hh:19
static const JVector3D JVector3X_t(1, 0, 0)
unit x-vector
static const JVector3D JVector3Y_t(0, 1, 0)
unit y-vector
static const JVector3D JVector3Z_t(0, 0, 1)
unit z-vector
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
const array_type< JValue_t > & make_array(const JValue_t(&array)[N])
Method to create array of values.
Definition: JVectorize.hh:54
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
Definition: JString.hh:478
@ LEFT
Definition: JTwosome.hh:18
@ RIGHT
Definition: JTwosome.hh:18
JPredicate< JResult_t T::*, JComparison::eq > make_predicate(JResult_t T::*member, const JResult_t value)
Helper method to create predicate for data member.
Definition: JPredicate.hh:128
static const double C
Physics constants.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JHitW0 > buffer_type
hits
Definition: JPerth.cc:70
JFIT::JEvent JEvent
Definition: JHistory.hh:353
static JStat getFileStatus
Function object for file status.
Definition: JStat.hh:173
Definition: JSTDTypes.hh:14
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:448
Detector file.
Definition: JHead.hh:227
detector()
Default constructor.
Definition: JHead.hh:231
Acoustic emitter.
Definition: JEmitter.hh:30
static void overlap(T p, T q, const double Tmax_s)
Empty overlapping events.
int getID() const
Get emitter identifier.
Auxiliary data structure for handling of file names.
Definition: JSydney.cc:97
std::string transmitter
transmitter
Definition: JSydney.cc:101
std::string detector
detector
Definition: JSydney.cc:98
std::string hydrophone
hydrophone
Definition: JSydney.cc:100
std::string tripod
tripod
Definition: JSydney.cc:99
double Qmin
minimal quality transmission
double deadTime_s
dead time between events [s]
size_t Nmin
minimum number of emitters
double Tmax_s
time window to combine events [s]
bool hasLocation(const JLocation &location) const
Check if this detector has given location.
Definition: JGeometry.hh:588
Acoustics hit.
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:77
Auxiliary data structure for setup of complete system.
Definition: JSydney.cc:108
tripods_container tripods
tripods
Definition: JSydney.cc:110
hydrophones
hydrophones
transmitters_container transmitters
transmitters
Definition: JSydney.cc:127
JDetector detector
detector
Definition: JSydney.cc:109
Implementation for depth dependend velocity of sound.
JSoundVelocity & set(const double z0)
Set depth.
Auxiliary class to edit orientation of anchor.
Definition: JSydney.cc:453
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:477
JAnchorEditor(JSetup &setup, const int id)
Constructor.
Definition: JSydney.cc:460
std::vector< JTransmitter > & transmitters
Definition: JSydney.cc:489
std::vector< JHydrophone > & hydrophones
Definition: JSydney.cc:488
Auxiliary class to edit length of Dyneema ropes.
Definition: JSydney.cc:362
JDyneemaEditor(JSetup &setup, const int id, const double z0=0.0)
Constructor.
Definition: JSydney.cc:370
std::vector< size_t > index
Definition: JSydney.cc:403
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:387
Auxiliary class to edit (z) position of module.
Definition: JSydney.cc:268
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:297
JModuleEditor(JModule &module, const JVector3D &direction)
Constructor.
Definition: JSydney.cc:286
JModuleEditor(JModule &module)
Constructor.
Definition: JSydney.cc:274
Extended data structure for parameters of stage.
Definition: JSydney.cc:499
friend std::ostream & operator<<(std::ostream &out, const JParameters_t &object)
Write parameters to output stream.
Definition: JSydney.cc:550
JParameters_t()
Default constuctor.
Definition: JSydney.cc:503
friend std::istream & operator>>(std::istream &in, JParameters_t &object)
Read parameters from input stream.
Definition: JSydney.cc:518
std::vector< double > steps
Definition: JSydney.cc:571
Auxiliary class to edit (x,y,z) position of string.
Definition: JSydney.cc:315
std::vector< size_t > index
Definition: JSydney.cc:353
JStringEditor(JSetup &setup, const int id, const JVector3D &direction, const bool option)
Constructor.
Definition: JSydney.cc:326
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:343
Auxiliary class to edit (x,y,z) position of tripod.
Definition: JSydney.cc:412
JTripodEditor(JSetup &setup, const int id, const JVector3D &direction)
Constructor.
Definition: JSydney.cc:420
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:436
std::vector< JTripod > & tripods
Definition: JSydney.cc:442
Auxiliary data structure for detector with decomposed strings.
Definition: JSydney.cc:654
void push_back(const JModule &module)
Add module.
Definition: JSydney.cc:660
Auxiliary data structure for group of lists of identifiers of to-be-fitted objects.
Definition: JSydney.cc:233
ids_t transmitters
identifiers of strings with transmitter
Definition: JSydney.cc:259
ids_t tripods
identifiers of tripods
Definition: JSydney.cc:257
void initialise(const JSetup &setup)
Initialise.
Definition: JSydney.cc:246
ids_t hydrophones
identifiers of strings with hydrophone
Definition: JSydney.cc:258
fits_t()
Default constructor.
Definition: JSydney.cc:237
ids_t strings
identifiers of strings
Definition: JSydney.cc:256
List of object identifiers.
Definition: JSydney.cc:143
ids_t(const ids_t &A, const ids_t &B)
Difference constructor.
Definition: JSydney.cc:168
friend std::ostream & operator<<(std::ostream &out, const ids_t &object)
Write identifiers to output stream.
Definition: JSydney.cc:219
void fix(const ids_t &B)
Fix.
Definition: JSydney.cc:181
ids_t()
Default constructor.
Definition: JSydney.cc:147
ids_t(const std::vector< int > &buffer)
Copy constructor.
Definition: JSydney.cc:156
friend std::istream & operator>>(std::istream &in, ids_t &object)
Read identifiers from input stream.
Definition: JSydney.cc:198
Auxiliary data structure for decomposed string.
Definition: JSydney.cc:631
void push_back(const JModule &module)
Add module.
Definition: JSydney.cc:637
Main class for pre-calibration using acoustics data.
Definition: JSydney.cc:134
double operator()(const int option) const
Get chi2.
Definition: JSydney.cc:938
JSydney(const JFilenames &filenames, const JSoundVelocity &V, const size_t threads, const int debug)
Constructor.
Definition: JSydney.cc:583
void stage_x(const JParameters_t &parameters)
Fit procedure to determine the (x,y,z) positions of the modules.
Definition: JSydney.cc:909
ids_t getReceivers() const
Get list of identifiers of receivers.
Definition: JSydney.cc:1183
JFilenames filenames
Definition: JSydney.cc:1229
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1237
JTOOLS::JHashMap< int, JLocation > receivers
Definition: JSydney.cc:1236
void run(const std::string &script)
Run.
Definition: JSydney.cc:1030
JDetector detector
PMTs.
Definition: JSydney.cc:1245
void store(const std::string &dir=".")
Store data in given directory.
Definition: JSydney.cc:1152
ids_t getEmitters() const
Get list of identifiers of emitters.
Definition: JSydney.cc:1202
JSoundVelocity V
Definition: JSydney.cc:1230
std::vector< input_type > input
Definition: JSydney.cc:1240
void stage_c(const JParameters_t &parameters)
Fit procedure to determine the z-positions of the modules.
Definition: JSydney.cc:855
std::vector< JSuperEvt > output
Definition: JSydney.cc:1243
JFitParameters parameters
Definition: JSydney.cc:1246
std::vector< JEvent > input_type
Definition: JSydney.cc:1239
void stage_0(const JParameters_t &parameters)
Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
Definition: JSydney.cc:672
void stage_d(const JParameters_t &parameters)
Fit procedure to determine the z-positions of anchors.
Definition: JSydney.cc:881
void stage_b(const JParameters_t &parameters)
Fit procedure to determine the stretching and z-positions of individual strings.
Definition: JSydney.cc:789
void stage_a(const JParameters_t &parameters)
Fit procedure to determine the positions of the strings and tripods.
Definition: JSydney.cc:745
Acoustic transmission identifier.
int getID() const
Get identifier.
Auxiliary data structure to unify weights of acoustics data according to the number of pings per emit...
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Definition: JContainer.hh:42
Conjugate gradient fit.
Definition: JGradient.hh:75
Auxiliary data structure for editable parameter.
Definition: JGradient.hh:49
Auxiliary data structure for fit parameter.
Definition: JGradient.hh:28
Implementation of object iteration from STD container.
double getMean() const
Get mean value.
Definition: JQuantile_t.hh:60
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Definition: JParser.hh:84
Auxiliary class for defining the range of iterations of objects.
Definition: JLimit.hh:45
General purpose class for hash map of unique keys.
Definition: JHashMap.hh:75
Auxiliary data structure for floating point format specification.
Definition: JManip.hh:488