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