Jpp  18.3.0-209-g56ce19a
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 z-positions of anchors.
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.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
892  }
893  }
894 
895  const double chi2 = fit(*this);
896 
897  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
898  }
899 
900 
901  /**
902  * Fit procedure to determine the (x,y,z) positions of the modules.
903  * This procedure should be considered unorthodox - it can be used to modify the detector file in such a way
904  * to accommodate anomalies in the shapes of a string (e.g. entanglement of string in D0ORCA018).
905  *
906  * \param parameters parameters
907  */
909  {
910  using namespace std;
911  using namespace JPP;
912 
913  this->parameters = parameters;
914 
915  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
916 
917  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
918  if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
919  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.x: " << right << module->getLocation()), new JModuleEditor(*module, JVector3X_t), parameters.steps[0]));
920  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.y: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Y_t), parameters.steps[0]));
921  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module, JVector3Z_t), parameters.steps[0]));
922  }
923  }
924 
925  const double chi2 = fit(*this);
926 
927  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
928  }
929 
930 
931  /**
932  * Get chi2.
933  *
934  * \param option option
935  * \return chi2/NDF
936  */
937  double operator()(const int option) const
938  {
939  using namespace std;
940  using namespace JPP;
941 
942  const JGeometry geometry(setup.detector, setup.hydrophones);
943 
944  JHashMap<int, JEmitter> emitters;
945 
946  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
947  {
948  emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
949  }
950  }
951 
952  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
953  try {
954  emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
955  }
956  catch(const exception&) {} // if no module available, discard transmitter
957  }
958 
959  if (option == 0 || // step wise improvement of the chi2
960  option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
961 
962  this->output.clear();
963 
964  JSTDObjectWriter<JSuperEvt> out(this->output); // write data for subsequent use
965 
966  JFremantle::output = (option == 1 ? &out : NULL);
967 
968  {
969  JFremantle fremantle(geometry, V, parameters, threads, 2 * threads);
970 
971  for (const input_type& superevt : input) {
972 
973  const JWeight getWeight(superevt.begin(), superevt.end());
974 
975  set<int> counter;
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  counter.insert(evt->getID());
997  }
998  }
999  }
1000  }
1001 
1002  if (counter.size() >= parameters.Nmin) {
1003  fremantle.enqueue(data);
1004  }
1005  }
1006  }
1007 
1008  return JFremantle::Q.getMean(numeric_limits<float>::max());
1009 
1010  } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
1011 
1012  {
1013  JSTDObjectReader<JSuperEvt> in(this->output);
1014 
1015  JPlatypus platypus(geometry, emitters, V, parameters, in, threads);
1016  }
1017 
1018  return JPlatypus::Q.getMean(numeric_limits<float>::max());
1019 
1020  } else {
1021 
1022  return numeric_limits<float>::max();
1023  }
1024  }
1025 
1026 
1027  /**
1028  * Run.
1029  *
1030  * \param script steering script
1031  */
1032  void run(const std::string& script)
1033  {
1034  using namespace std;
1035  using namespace JPP;
1036 
1037  ifstream in(script.c_str());
1038 
1039  while (in) {
1040 
1041  string buffer, key;
1042 
1043  if (getline(in, buffer)) {
1044 
1045  if (buffer.empty() || buffer[0] == skip_t) {
1046  continue;
1047  }
1048 
1049  istringstream is(buffer);
1050 
1051  is >> key;
1052 
1053  if (key == initialise_t) { // set object identifiers
1054 
1055  fits.initialise(setup);
1056 
1057  } else if (key == fix_t) { // fix object identifiers
1058 
1059  string type; // type of object
1060  ids_t id; // identifiers
1061 
1062  if (is >> type >> id) {
1063  if (type == string_t) {
1064  fits.strings .fix(id);
1065  fits.hydrophones .fix(id);
1066  fits.transmitters.fix(id);
1067  } else if (type == tripod_t) {
1068  fits.tripods .fix(id);
1069  } else {
1070  THROW(JValueOutOfRange, "Invalid type <" << type << ">");
1071  }
1072  }
1073 
1074  } else if (key == stage_t) { // stage
1075 
1076  string stage;
1077  JParameters_t input;
1078 
1079  if (is >> stage >> input) {
1080 
1081  STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
1082 
1083  JTimer timer;
1084 
1085  timer.start();
1086 
1087  ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
1088 
1089  {
1090  JRedirectStream redirect(cout, out);
1091 
1092  switch (stage[stage.size() - 1]) {
1093 
1094  case '0':
1095  stage_0(input);
1096  break;
1097 
1098  case 'a':
1099  case 'A':
1100  stage_a(input);
1101  break;
1102 
1103  case 'b':
1104  case 'B':
1105  stage_b(input);
1106  break;
1107 
1108  case 'c':
1109  case 'C':
1110  stage_c(input);
1111  break;
1112 
1113  case 'd':
1114  case 'D':
1115  stage_d(input);
1116  break;
1117 
1118  case 'x':
1119  case 'X':
1120  stage_x(input);
1121  break;
1122 
1123  default:
1124  THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
1125  break;
1126  }
1127  }
1128 
1129  out.close();
1130 
1131  store(stage);
1132  store();
1133 
1134  timer.stop();
1135 
1136  STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
1137  }
1138 
1139  } else {
1140  THROW(JValueOutOfRange, "Invalid key <" << key << ">");
1141  }
1142  }
1143  }
1144 
1145  in.close();
1146  }
1147 
1148 
1149  /**
1150  * Store data in given directory.
1151  *
1152  * \param dir directory
1153  */
1154  void store(const std::string& dir = ".")
1155  {
1156  using namespace JPP;
1157 
1158  if (getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
1159 
1160  // attach PMTs
1161 
1162  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
1163  module->set(router->getModule(module->getLocation()).getPosition());
1164  }
1165 
1166  JDETECTOR::store(getFilename(dir, filenames.detector), detector);
1167 
1168  setup.tripods.store(getFilename(dir, filenames.tripod).c_str());
1169 
1170  if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
1171  if (filenames.transmitter != "") { setup.transmitters.store(getFilename(dir, filenames.transmitter).c_str()); }
1172 
1173  } else {
1174 
1175  THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1176  }
1177  }
1178 
1179 
1180  /**
1181  * Get list of identifiers of receivers.
1182  *
1183  * \return list of identifiers
1184  */
1186  {
1187  ids_t buffer;
1188 
1189  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
1190  if ((i->getFloor() != 0 && !i->has(PIEZO_DISABLE)) || (setup.hydrophones.hasString(i->getString()) && !i->has(HYDROPHONE_DISABLE))) {
1191  buffer.insert(i->getID());
1192  }
1193  }
1194 
1195  return buffer;
1196  }
1197 
1198 
1199  /**
1200  * Get list of identifiers of emitters.
1201  *
1202  * \return list of identifiers
1203  */
1205  {
1206  using namespace std;
1207 
1208  ids_t buffer;
1209 
1210  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1211  buffer.insert(i->getID());
1212  }
1213 
1214  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1215 
1216  try {
1217 
1218  const JModule& module = router->getModule(i->getLocation());
1219 
1220  if (!module.has(TRANSMITTER_DISABLE)) {
1221  buffer.insert(i->getID());
1222  }
1223  }
1224  catch(const exception&) {}
1225  }
1226 
1227  return buffer;
1228  }
1229 
1230 
1233  size_t threads;
1234  int debug;
1237 
1239  std::unique_ptr<JLocationRouter> router;
1240 
1243 
1244  private:
1246 
1247  JDetector detector; //!< PMTs
1249  };
1250 }
1251 
1252 
1253 /**
1254  * \file
1255  *
1256  * Application to perform acoustic pre-calibration.
1257  * \author mdejong
1258  */
1259 int main(int argc, char **argv)
1260 {
1261  using namespace std;
1262  using namespace JPP;
1263 
1264  typedef JContainer< std::set<JTransmission_t> > disable_container;
1265 
1266  JMultipleFileScanner<JEvent> inputFile;
1267  JLimit_t& numberOfEvents = inputFile.getLimit();
1268  JFilenames filenames; // file names
1269  JFitParameters parameters; // fit parameters
1270  string script; // script file
1271  JSoundVelocity V = getSoundVelocity; // default sound velocity
1272  disable_container disable; // disable tansmissions
1273  size_t threads; // number of threads
1274  int debug;
1275 
1276  try {
1277 
1278  JParser<> zap("Application to perform acoustic pre-calibration.");
1279 
1280  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1281  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1282  zap['a'] = make_field(filenames.detector);
1283  zap['@'] = make_field(parameters) = JPARSER::initialised();
1284  zap['s'] = make_field(script, "steering script");
1285  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1286  zap['T'] = make_field(filenames.tripod, "tripod file");
1287  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1288  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1289  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1290  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1291  zap['N'] = make_field(threads, "number of threads") = 1;
1292  zap['d'] = make_field(debug) = 1;
1293 
1294  zap(argc, argv);
1295  }
1296  catch(const exception &error) {
1297  FATAL(error.what() << endl);
1298  }
1299 
1300  if (threads == 0) {
1301  FATAL("Invalid number of threads " << threads << endl);
1302  }
1303 
1304  JSydney sydney(filenames, V, threads, debug);
1305 
1306  const JSydney::ids_t receivers = sydney.getReceivers();
1307  const JSydney::ids_t emitters = sydney.getEmitters();
1308 
1309  typedef vector<JEvent> buffer_type;
1310 
1311  buffer_type zbuf;
1312 
1313  while (inputFile.hasNext()) {
1314 
1315  const JEvent* evt = inputFile.next();
1316 
1317  if (emitters.count(evt->getID())) {
1318  zbuf.push_back(*evt);
1319  }
1320  }
1321 
1322  const JRange<double> unit(0.0, 1.0);
1323 
1324  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1325 
1326  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1327 
1328  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1329 
1330  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1331 
1332  JSydney::input_type buffer;
1333 
1334  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1335 
1336  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1337 
1338  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1339 
1340  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1341 
1342  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1343  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1344 
1345  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (unit(parameters.Qmin) ? i->getW() : 1.0)) {
1346  ++i; continue;
1347  }
1348  }
1349 
1350  iter_swap(i, --__end);
1351  }
1352 
1353  buffer.push_back(JEvent(evt->getOID(), buffer.size(), evt->getID(), evt->begin(), __end));
1354  }
1355 
1356  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1357  sydney.input.push_back(buffer);
1358  }
1359  }
1360 
1361  sydney.run(script);
1362 }
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:1247
Utility class to parse command line options.
Definition: JParser.hh:1711
Acoustic hit.
std::vector< JHydrophone > & hydrophones
Definition: JSydney.cc:487
JDetector detector
detector
Definition: JSydney.cc:108
void stage_x(const JParameters_t &parameters)
Fit procedure to determine the (x,y,z) positions of the modules.
Definition: JSydney.cc:908
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
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:937
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:1032
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:84
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:70
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.
then set_variable PMT_FILE set_variable DAQ_FILE set_variable OUTPUT_FILE set_variable DETECTOR else fatal Wrong number of arguments fi JPrintTree f $DAQ_FILE type
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:1154
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:1231
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:1232
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:2158
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:1242
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:1241
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:1245
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
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:1204
ids_t getReceivers() const
Get list of identifiers of receivers.
Definition: JSydney.cc:1185
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 The output file must have the wildcard in the e g root fi 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:1248
Acoustic transmission identifier.
JTOOLS::JHashMap< int, JLocation > receivers
Definition: JSydney.cc:1238
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
*fatal Wrong number of arguments esac for INPUT_FILE in eval ls rt $DIR stage
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
void stage_d(const JParameters_t &parameters)
Fit procedure to determine the z-positions of anchors.
Definition: JSydney.cc:880
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:1239
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