Jpp  18.2.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  {}
276 
277 
278  /**
279  * Apply step.
280  *
281  * \param step step
282  */
283  virtual void apply(const double step) override
284  {
285  using namespace JPP;
286 
287  module.add(JVector3Z_t * step);
288  }
289 
290  private:
292  };
293 
294 
295  /**
296  * Auxiliary class to edit (x,y,z) position of string.
297  */
298  struct JStringEditor :
299  public JParameter_t
300  {
301  /**
302  * Constructor.
303  *
304  * The option <tt>true</tt> and <tt>false</tt> correspond to all modules and optical modules only, respectively.
305  *
306  * \param setup setup
307  * \param id string number
308  * \param direction direction
309  * \param option option
310  */
311  JStringEditor(JSetup& setup, const int id, const JVector3D& direction, const bool option) :
312  detector (setup.detector),
313  direction(direction)
314  {
315  for (size_t i = 0; i != detector.size(); ++i) {
316  if (detector[i].getString() == id && (detector[i].getFloor() != 0 || option)) {
317  index.push_back(i);
318  }
319  }
320  }
321 
322 
323  /**
324  * Apply step.
325  *
326  * \param step step
327  */
328  virtual void apply(const double step) override
329  {
330  for (const auto i : index) {
331  detector[i].add(direction * step);
332  }
333  }
334 
335  private:
339  };
340 
341 
342  /**
343  * Auxiliary class to edit length of Dyneema ropes.
344  */
345  struct JDyneemaEditor :
346  public JParameter_t
347  {
348  /**
349  * Constructor.
350  *
351  * \param setup setup
352  * \param id string number
353  * \param z0 reference position
354  */
355  JDyneemaEditor(JSetup& setup, const int id, const double z0 = 0.0) :
356  detector (setup.detector),
357  z0 (z0)
358  {
359  for (size_t i = 0; i != detector.size(); ++i) {
360  if (detector[i].getString() == id && detector[i].getFloor() != 0) {
361  index.push_back(i);
362  }
363  }
364  }
365 
366 
367  /**
368  * Apply step.
369  *
370  * \param step step
371  */
372  virtual void apply(const double step) override
373  {
374  for (const auto i : index) {
375 
376  JModule& module = detector[i];
377 
378  if (step > 0.0)
379  module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) * (1.0 + step)));
380  else if (step < 0.0)
381  module.set(JVector3D(module.getX(), module.getY(), z0 + (module.getZ() - z0) / (1.0 - step)));
382  }
383  }
384 
385  private:
387  double z0;
389  };
390 
391 
392  /**
393  * Auxiliary class to edit (x,y,z) position of tripod.
394  */
395  struct JTripodEditor :
396  public JParameter_t
397  {
398  /**
399  * Constructor.
400  *
401  * \param setup setup
402  * \param id tripod identifier
403  * \param direction direction
404  */
405  JTripodEditor(JSetup& setup, const int id, const JVector3D& direction) :
406  tripods (setup.tripods),
407  direction(direction)
408  {
409  using namespace std;
410  using namespace JPP;
411 
412  index = distance(tripods.begin(), find_if(tripods.begin(), tripods.end(), make_predicate(&JTripod::getID, id)));
413  }
414 
415 
416  /**
417  * Apply step.
418  *
419  * \param step step
420  */
421  virtual void apply(const double step) override
422  {
423  tripods[index].add(direction * step);
424  }
425 
426  private:
429  size_t index;
430  };
431 
432 
433  /**
434  * Auxiliary class to edit orientation of anchor.
435  */
436  struct JAnchorEditor :
437  public JParameter_t
438  {
439  /**
440  * Constructor.
441  *
442  * \param setup setup
443  * \param id string identifier
444  */
445  JAnchorEditor(JSetup& setup, const int id) :
446  hydrophones (setup.hydrophones),
447  transmitters(setup.transmitters)
448  {
449  using namespace std;
450  using namespace JPP;
451 
452  index[0] = distance(hydrophones .begin(), find_if(hydrophones .begin(), hydrophones .end(), make_predicate(&JHydrophone ::getString, id)));
453  index[1] = distance(transmitters.begin(), find_if(transmitters.begin(), transmitters.end(), make_predicate(&JTransmitter::getString, id)));
454  }
455 
456 
457  /**
458  * Apply step.
459  *
460  * \param step step
461  */
462  virtual void apply(const double step) override
463  {
464  using namespace JPP;
465 
466  const JRotation3Z R(step);
467 
468  if (index[0] != hydrophones .size()) { hydrophones [index[0]].rotate(R); }
469  if (index[1] != transmitters.size()) { transmitters[index[1]].rotate(R); }
470  }
471 
472  private:
475  size_t index[2];
476  };
477 
478 
479  /**
480  * Extended data structure for parameters of stage.
481  */
482  struct JParameters_t :
483  public JFitParameters
484  {
485  /**
486  * Default constuctor.
487  */
489  Nmax (std::numeric_limits<size_t>::max()),
490  Nextra (0),
491  epsilon(1.0e-4),
492  debug (3)
493  {}
494 
495 
496  /**
497  * Read parameters from input stream
498  *
499  * \param in input stream
500  * \param object parameters
501  * \return input stream
502  */
503  friend inline std::istream& operator>>(std::istream& in, JParameters_t& object)
504  {
505  object = JParameters_t();
506 
507  in >> object.option
508  >> object.mestimator
509  >> object.sigma_s
510  >> object.stdev
511  >> object.Nextra;
512 
513  if (in) {
514 
515  for (double value; in >> value; ) {
516  object.steps.push_back(value);
517  }
518 
519  if (!in.bad()) {
520  in.clear();
521  }
522  }
523 
524  return in;
525  }
526 
527 
528  /**
529  * Write parameters to output stream
530  *
531  * \param out output stream
532  * \param object parameters
533  * \return output stream
534  */
535  friend inline std::ostream& operator<<(std::ostream& out, const JParameters_t& object)
536  {
537  using namespace std;
538 
539  out << setw(2) << object.option << ' '
540  << setw(2) << object.mestimator << ' '
541  << SCIENTIFIC(9,3) << object.sigma_s << ' '
542  << SCIENTIFIC(9,3) << object.stdev << ' '
543  << setw(3) << object.Nextra;
544 
545  for (const double value : object.steps) {
546  out << ' ' << FIXED(9,5) << value;
547  }
548 
549  return out;
550  }
551 
552  size_t Nmax;
553  size_t Nextra;
554  double epsilon;
555  int debug;
557  };
558 
559 
560  /**
561  * Constructor.
562  *
563  * \param filenames file names
564  * \param V sound velocity
565  * \param threads threads
566  * \param debug debug
567  */
568  JSydney(const JFilenames& filenames,
569  const JSoundVelocity& V,
570  const size_t threads,
571  const int debug) :
572  filenames(filenames),
573  V(V),
574  threads(threads),
575  debug(debug)
576  {
577  load(filenames.detector, setup.detector);
578 
579  setup.tripods.load(filenames.tripod.c_str());
580 
581  if (filenames.hydrophone != "") { setup.hydrophones .load(filenames.hydrophone .c_str()); }
582  if (filenames.transmitter != "") { setup.transmitters.load(filenames.transmitter.c_str()); }
583 
584  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
585  receivers[i->getID()] = i->getLocation();
586  }
587 
588  // detach PMTs
589 
590  detector = setup.detector;
591 
592  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
593  module->clear();
594  }
595 
596  router.reset(new JLocationRouter(setup.detector));
597 
598  fits.initialise(setup);
599 
600  this->V.set(setup.detector.getUTMZ()); // sound velocity at detector depth
601 
604 
606 
607  ROOT::EnableThreadSafety();
608  }
609 
610 
611  /**
612  * Auxiliary data structure for decomposed string.
613  */
614  struct string_type :
615  public std::vector<JModule> // optical modules
616  {
617  /**
618  * Add module.
619  *
620  * \param module module
621  */
622  void push_back(const JModule& module)
623  {
624  if (module.getFloor() == 0)
625  this->base = module;
626  else
628  }
629 
630  JModule base; // base module
631  };
632 
633 
634  /**
635  * Auxiliary data structure for detector with decomposed strings.
636  */
637  struct detector_type :
638  public std::map<int, string_type>
639  {
640  /**
641  * Add module.
642  *
643  * \param module module
644  */
645  void push_back(const JModule& module)
646  {
647  (*this)[module.getString()].push_back(module);
648  }
649  };
650 
651 
652  /**
653  * Fit procedure to determine the positions of tripods and transmitters using strings that are fixed.
654  *
655  * \param parameters parameters
656  */
658  {
659  using namespace std;
660  using namespace JPP;
661 
662  this->parameters = parameters;
663 
664  JDetector A; // old strings
665  detector_type B; // new strings with transmitter -> fit only base module
666  JDetector C; // new strings w/o transmitter -> discard completely from fit
667 
668  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
669 
670  if (fits.strings .count(module->getString()) == 0)
671  A.push_back(*module);
672  else if (fits.transmitters.count(module->getString()) != 0)
673  B.push_back(*module);
674  else
675  C.push_back(*module);
676  }
677 
678  setup.detector.swap(A);
679 
680  for (const auto& element : B) {
681  setup.detector.push_back(element.second.base);
682  }
683 
684  router.reset(new JLocationRouter(setup.detector));
685 
686  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
687 
688  for (const int i : fits.tripods) {
689  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[0]));
690  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[0]));
691  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[0]));
692  }
693 
694  for (const int i : fits.transmitters) {
695  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.x: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3X_t, true), parameters.steps[0]));
696  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.y: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Y_t, true), parameters.steps[0]));
697  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "transmitter.z: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Z_t, true), parameters.steps[0]));
698  }
699 
700  const double chi2 = fit(*this);
701 
702  for (auto& element : B) {
703 
704  const JModule& base = setup.detector.getModule(router->getAddress(JLocation(element.second.base.getString(),0)));
705  const JVector3D pos = base.getPosition() - element.second.base.getPosition();
706 
707  for (string_type::iterator module = element.second.begin(); module != element.second.end(); ++module) {
708 
709  module->add(pos);
710 
711  setup.detector.push_back(*module);
712  }
713  }
714 
715  copy(C.begin(), C.end(), back_inserter(setup.detector));
716 
717  sort(setup.detector.begin(), setup.detector.end(), make_comparator(&JModule::getLocation));
718 
719  router.reset(new JLocationRouter(setup.detector));
720 
721  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
722  }
723 
724 
725  /**
726  * Fit procedure to determine the positions of the strings and tripods.
727  *
728  * \param parameters parameters
729  */
731  {
732  using namespace std;
733  using namespace JPP;
734 
735  this->parameters = parameters;
736 
737  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
738 
739  for (const int i : fits.strings) {
740  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.x: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3X_t, true), parameters.steps[0]));
741  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.y: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Y_t, true), parameters.steps[0]));
742  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i), new JStringEditor(setup, i, JVector3Z_t, false), parameters.steps[0]));
743  }
744 
745  for (const int i : fits.tripods) {
746  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.x: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3X_t), parameters.steps[1]));
747  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.y: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Y_t), parameters.steps[1]));
748  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "tripod.z: " << RIGHT(4) << i), new JTripodEditor(setup, i, JVector3Z_t), parameters.steps[1]));
749  }
750 
751  for (const int i : ids_t(fits.hydrophones, fits.transmitters)) {
752  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
753  }
754 
755  for (const int i : fits.transmitters) {
756 
757  JModule& module = setup.detector.getModule(router->getAddress(JLocation(i,0)));
758 
759  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.R: " << RIGHT(4) << i), new JAnchorEditor(setup, i), parameters.steps[0] / RADIUS_M));
760  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "anchor.z: " << RIGHT(4) << i), new JModuleEditor(module), parameters.steps[0]));
761  }
762 
763  const double chi2 = fit(*this);
764 
765  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
766  }
767 
768 
769  /**
770  * Fit procedure to determine the stretching and z-positions of individual strings.
771  *
772  * \param parameters parameters
773  */
775  {
776  using namespace std;
777  using namespace JPP;
778 
779  this->parameters = parameters;
780 
781  map<int, JDetector> buffer;
782 
783  double z0 = 0.0;
784 
785  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
786 
787  buffer[module->getString()].push_back(*module);
788 
789  if (module->getZ() > z0) {
790  z0 = module->getZ();
791  }
792  }
793 
794  JDetector tx;
795 
796  for (transmitters_container::iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
797  try {
798  tx.push_back(router->getModule(i->getLocation()));
799  }
800  catch(const exception&) {}
801  }
802 
803  for (const int i : fits.strings) {
804 
805  setup.detector.swap(buffer[i]);
806 
807  copy(tx.begin(), tx.end(), back_inserter(setup.detector));
808 
809  router.reset(new JLocationRouter(setup.detector));
810 
811  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
812 
813  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.M: " << RIGHT(4) << i), new JDyneemaEditor(setup, i, z0), parameters.steps[0]));
814  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "string.z: " << RIGHT(4) << i), new JStringEditor (setup, i, JVector3Z_t, false), parameters.steps[1]));
815 
816  const double chi2 = fit(*this);
817 
818  STATUS("string: " << setw(4) << i << ' ' << FIXED(9,4) << chi2 << endl);
819 
820  buffer[i].clear();
821 
822  copy_if(setup.detector.begin(), setup.detector.end(), back_inserter(buffer[i]), make_predicate(&JModule::getString, i));
823  }
824 
825  setup.detector.clear();
826 
827  for (const auto& element : buffer) {
828  copy(element.second.begin(), element.second.end(), back_inserter(setup.detector));
829  }
830 
831  router.reset(new JLocationRouter(setup.detector));
832  }
833 
834 
835  /**
836  * Fit procedure to determine the z-positions of the modules.
837  *
838  * \param parameters parameters
839  */
841  {
842  using namespace std;
843  using namespace JPP;
844 
845  this->parameters = parameters;
846 
847  JGradient fit(parameters.Nmax, parameters.Nextra, parameters.epsilon, parameters.debug);
848 
849  for (JDetector::iterator module = setup.detector.begin(); module != setup.detector.end(); ++module) {
850  if (fits.strings.count(module->getString()) != 0 && module->getFloor() != 0) {
851  fit.push_back(JModifier_t(MAKE_STRING(LEFT(16) << "module.z: " << right << module->getLocation()), new JModuleEditor(*module), parameters.steps[0]));
852  }
853  }
854 
855  const double chi2 = fit(*this);
856 
857  STATUS("detector: " << FIXED(9,4) << chi2 << endl);
858  }
859 
860 
861  /**
862  * Get chi2.
863  *
864  * \param option option
865  * \return chi2/NDF
866  */
867  double operator()(const int option) const
868  {
869  using namespace std;
870  using namespace JPP;
871 
872  const JGeometry geometry(setup.detector, setup.hydrophones);
873 
874  JHashMap<int, JEmitter> emitters;
875 
876  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
877  {
878  emitters[i->getID()] = JEmitter(i->getID(), i->getUTMPosition() - setup.detector.getUTMPosition());
879  }
880  }
881 
882  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
883  try {
884  emitters[i->getID()] = JEmitter(i->getID(), i->getPosition() + router->getModule(i->getLocation()).getPosition());
885  }
886  catch(const exception&) {} // if no module available, discard transmitter
887  }
888 
889  if (option == 0 || // step wise improvement of the chi2
890  option == 1) { // evaluation of the chi2 before the determination of the gradient of the chi2
891 
892  this->output.clear();
893 
894  JSTDObjectWriter<JSuperEvt> out(this->output); // write data for subsequent use
895 
896  JFremantle::output = (option == 1 ? &out : NULL);
897 
898  {
899  JFremantle fremantle(geometry, V, parameters, threads, 2 * threads);
900 
901  for (const input_type& superevt : input) {
902 
903  const JWeight getWeight(superevt.begin(), superevt.end());
904 
905  set<int> counter;
907 
908  for (input_type::const_iterator evt = superevt.begin(); evt != superevt.end(); ++evt) {
909 
910  if (emitters.has(evt->getID())) {
911 
912  const JEmitter& emitter = emitters [evt->getID()];
913  const double weight = getWeight(evt->getID());
914 
915  for (JEvent::const_iterator i = evt->begin(); i != evt->end(); ++i) {
916 
917  if (geometry.hasLocation(receivers[i->getID()])) {
918 
919  data.push_back(JHit(emitter,
920  distance(superevt.begin(), evt),
921  receivers[i->getID()],
922  i->getToA(),
923  parameters.sigma_s,
924  weight));
925 
926  counter.insert(evt->getID());
927  }
928  }
929  }
930  }
931 
932  if (counter.size() >= parameters.Nmin) {
933  fremantle.enqueue(data);
934  }
935  }
936  }
937 
938  return JFremantle::Q.getMean(numeric_limits<float>::max());
939 
940  } else if (option == 2) { // evaluation of the derivative of the chi2 to each fit parameter
941 
942  {
943  JSTDObjectReader<JSuperEvt> in(this->output);
944 
945  JPlatypus platypus(geometry, emitters, V, parameters, in, threads);
946  }
947 
948  return JPlatypus::Q.getMean(numeric_limits<float>::max());
949 
950  } else {
951 
952  return numeric_limits<float>::max();
953  }
954  }
955 
956 
957  /**
958  * Run.
959  *
960  * \param script steering script
961  */
962  void run(const std::string& script)
963  {
964  using namespace std;
965  using namespace JPP;
966 
967  ifstream in(script.c_str());
968 
969  while (in) {
970 
971  string buffer, key;
972 
973  if (getline(in, buffer)) {
974 
975  if (buffer.empty() || buffer[0] == skip_t) {
976  continue;
977  }
978 
979  istringstream is(buffer);
980 
981  is >> key;
982 
983  if (key == initialise_t) { // set object identifiers
984 
985  fits.initialise(setup);
986 
987  } else if (key == fix_t) { // fix object identifiers
988 
989  string type; // type of object
990  ids_t id; // identifiers
991 
992  if (is >> type >> id) {
993  if (type == string_t) {
994  fits.strings .fix(id);
995  fits.hydrophones .fix(id);
996  fits.transmitters.fix(id);
997  } else if (type == tripod_t) {
998  fits.tripods .fix(id);
999  } else {
1000  THROW(JValueOutOfRange, "Invalid type <" << type << ">");
1001  }
1002  }
1003 
1004  } else if (key == stage_t) { // stage
1005 
1006  string stage;
1007  JParameters_t input;
1008 
1009  if (is >> stage >> input) {
1010 
1011  STATUS("stage " << setw(3) << stage << " {" << input << "}" << endl);
1012 
1013  JTimer timer;
1014 
1015  timer.start();
1016 
1017  ofstream out(MAKE_CSTRING("stage-" << stage << ".log"));
1018 
1019  {
1020  JRedirectStream redirect(cout, out);
1021 
1022  switch (stage[stage.size() - 1]) {
1023 
1024  case '0':
1025  stage_0(input);
1026  break;
1027 
1028  case 'a':
1029  case 'A':
1030  stage_a(input);
1031  break;
1032 
1033  case 'b':
1034  case 'B':
1035  stage_b(input);
1036  break;
1037 
1038  case 'c':
1039  case 'C':
1040  stage_c(input);
1041  break;
1042 
1043  default:
1044  THROW(JValueOutOfRange, "Invalid stage <" << stage << ">");
1045  break;
1046  }
1047  }
1048 
1049  out.close();
1050 
1051  store(stage);
1052  store();
1053 
1054  timer.stop();
1055 
1056  STATUS("Elapsed time " << FIXED(12,3) << timer.usec_wall * 1.0e-6 << " s." << endl);
1057  }
1058 
1059  } else {
1060  THROW(JValueOutOfRange, "Invalid key <" << key << ">");
1061  }
1062  }
1063  }
1064 
1065  in.close();
1066  }
1067 
1068 
1069  /**
1070  * Store data in given directory.
1071  *
1072  * \param dir directory
1073  */
1074  void store(const std::string& dir = ".")
1075  {
1076  using namespace JPP;
1077 
1078  if (getFileStatus(dir.c_str()) || (mkdir(dir.c_str(), S_IRWXU | S_IRWXG) != -1)) {
1079 
1080  // attach PMTs
1081 
1082  for (JDetector::iterator module = detector.begin(); module != detector.end(); ++module) {
1083  module->set(router->getModule(module->getLocation()).getPosition());
1084  }
1085 
1086  JDETECTOR::store(getFilename(dir, filenames.detector), detector);
1087 
1088  setup.tripods.store(getFilename(dir, filenames.tripod).c_str());
1089 
1090  if (filenames.hydrophone != "") { setup.hydrophones .store(getFilename(dir, filenames.hydrophone) .c_str()); }
1091  if (filenames.transmitter != "") { setup.transmitters.store(getFilename(dir, filenames.transmitter).c_str()); }
1092 
1093  } else {
1094 
1095  THROW(JValueOutOfRange, "Invalid directory <" << dir << ">");
1096  }
1097  }
1098 
1099 
1100  /**
1101  * Get list of identifiers of receivers.
1102  *
1103  * \return list of identifiers
1104  */
1106  {
1107  ids_t buffer;
1108 
1109  for (JDetector::const_iterator i = setup.detector.begin(); i != setup.detector.end(); ++i) {
1110  if ((i->getFloor() != 0 && !i->has(PIEZO_DISABLE)) || (setup.hydrophones.hasString(i->getString()) && !i->has(HYDROPHONE_DISABLE))) {
1111  buffer.insert(i->getID());
1112  }
1113  }
1114 
1115  return buffer;
1116  }
1117 
1118 
1119  /**
1120  * Get list of identifiers of emitters.
1121  *
1122  * \return list of identifiers
1123  */
1125  {
1126  using namespace std;
1127 
1128  ids_t buffer;
1129 
1130  for (tripods_container::const_iterator i = setup.tripods.begin(); i != setup.tripods.end(); ++i) {
1131  buffer.insert(i->getID());
1132  }
1133 
1134  for (transmitters_container::const_iterator i = setup.transmitters.begin(); i != setup.transmitters.end(); ++i) {
1135 
1136  try {
1137 
1138  const JModule& module = router->getModule(i->getLocation());
1139 
1140  if (!module.has(TRANSMITTER_DISABLE)) {
1141  buffer.insert(i->getID());
1142  }
1143  }
1144  catch(const exception&) {}
1145  }
1146 
1147  return buffer;
1148  }
1149 
1150 
1153  size_t threads;
1154  int debug;
1157 
1159  std::unique_ptr<JLocationRouter> router;
1160 
1163 
1164  private:
1166 
1167  JDetector detector; //!< PMTs
1169  };
1170 }
1171 
1172 
1173 /**
1174  * \file
1175  *
1176  * Application to perform acoustic pre-calibration.
1177  * \author mdejong
1178  */
1179 int main(int argc, char **argv)
1180 {
1181  using namespace std;
1182  using namespace JPP;
1183 
1184  typedef JContainer< std::set<JTransmission_t> > disable_container;
1185 
1186  JMultipleFileScanner<JEvent> inputFile;
1187  JLimit_t& numberOfEvents = inputFile.getLimit();
1188  JFilenames filenames; // file names
1189  JFitParameters parameters; // fit parameters
1190  string script; // script file
1191  JSoundVelocity V = getSoundVelocity; // default sound velocity
1192  disable_container disable; // disable tansmissions
1193  size_t threads; // number of threads
1194  int debug;
1195 
1196  try {
1197 
1198  JParser<> zap("Application to perform acoustic pre-calibration.");
1199 
1200  zap['f'] = make_field(inputFile, "output of JAcousticEventBuilder[.sh]");
1201  zap['n'] = make_field(numberOfEvents) = JLimit::max();
1202  zap['a'] = make_field(filenames.detector);
1203  zap['@'] = make_field(parameters) = JPARSER::initialised();
1204  zap['s'] = make_field(script, "steering script");
1205  zap['V'] = make_field(V, "sound velocity") = JPARSER::initialised();
1206  zap['T'] = make_field(filenames.tripod, "tripod file");
1207  zap['Y'] = make_field(filenames.transmitter, "transmitter file") = JPARSER::initialised();
1208  zap['H'] = make_field(filenames.hydrophone, "hydrophone file") = JPARSER::initialised();
1209  zap['M'] = make_field(getMechanics, "mechanics data") = JPARSER::initialised();
1210  zap['!'] = make_field(disable, "disable transmission") = JPARSER::initialised();
1211  zap['N'] = make_field(threads, "number of threads") = 1;
1212  zap['d'] = make_field(debug) = 1;
1213 
1214  zap(argc, argv);
1215  }
1216  catch(const exception &error) {
1217  FATAL(error.what() << endl);
1218  }
1219 
1220  if (threads == 0) {
1221  FATAL("Invalid number of threads " << threads << endl);
1222  }
1223 
1224  JSydney sydney(filenames, V, threads, debug);
1225 
1226  const JSydney::ids_t receivers = sydney.getReceivers();
1227  const JSydney::ids_t emitters = sydney.getEmitters();
1228 
1229  typedef vector<JEvent> buffer_type;
1230 
1231  buffer_type zbuf;
1232 
1233  while (inputFile.hasNext()) {
1234 
1235  const JEvent* evt = inputFile.next();
1236 
1237  if (emitters.count(evt->getID())) {
1238  zbuf.push_back(*evt);
1239  }
1240  }
1241 
1242  const JRange<double> unit(0.0, 1.0);
1243 
1244  sort(zbuf.begin(), zbuf.end()); // sort according first time-of-emission
1245 
1246  for (buffer_type::iterator p = zbuf.begin(), q; p != zbuf.end(); p = q) {
1247 
1248  for (q = p; ++q != zbuf.end() && q->begin()->getToE() <= p->rbegin()->getToE() + parameters.Tmax_s; ) {}
1249 
1250  JEvent::overlap(p, q, parameters.deadTime_s); // empty overlapping events
1251 
1252  JSydney::input_type buffer;
1253 
1254  for (buffer_type::iterator evt = p; evt != q; ++evt) {
1255 
1256  sort(evt->begin(), evt->end(), JKatoomba<>::compare);
1257 
1258  JEvent::iterator __end = unique(evt->begin(), evt->end(), make_comparator(&JTransmission::getID, JComparison::eq()));
1259 
1260  for (JEvent::iterator i = evt->begin(); i != __end; ) {
1261 
1262  if (disable.count(JTransmission_t(evt->getID(), i->getID())) == 0 &&
1263  disable.count(JTransmission_t(-1, i->getID())) == 0) {
1264 
1265  if (receivers.count(i->getID()) && i->getQ() >= parameters.Qmin * (unit(parameters.Qmin) ? i->getW() : 1.0)) {
1266  ++i; continue;
1267  }
1268  }
1269 
1270  iter_swap(i, --__end);
1271  }
1272 
1273  buffer.push_back(JEvent(evt->getOID(), buffer.size(), evt->getID(), evt->begin(), __end));
1274  }
1275 
1276  if (getNumberOfEmitters(buffer.begin(), buffer.end()) >= parameters.Nmin) {
1277  sydney.input.push_back(buffer);
1278  }
1279  }
1280 
1281  sydney.run(script);
1282 }
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:345
JDetector detector
PMTs.
Definition: JSydney.cc:1167
Utility class to parse command line options.
Definition: JParser.hh:1514
Acoustic hit.
std::vector< JHydrophone > & hydrophones
Definition: JSydney.cc:473
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:535
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:774
Auxiliary data structure for decomposed string.
Definition: JSydney.cc:614
void stage_a(const JParameters_t &parameters)
Fit procedure to determine the positions of the strings and tripods.
Definition: JSydney.cc:730
$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:68
JContainer< std::vector< JTransmitter > > transmitters_container
Definition: JSydney.cc:79
double operator()(const int option) const
Get chi2.
Definition: JSydney.cc:867
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:328
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:421
void push_back(const JModule &module)
Add module.
Definition: JSydney.cc:622
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:962
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:482
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
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:298
#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:556
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:1074
JParameters_t()
Default constuctor.
Definition: JSydney.cc:488
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:1151
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:1152
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:1162
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:1161
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:637
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:1165
Auxiliary class to edit orientation of anchor.
Definition: JSydney.cc:436
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:372
JDyneemaEditor(JSetup &setup, const int id, const double z0=0.0)
Constructor.
Definition: JSydney.cc:355
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:1124
ids_t getReceivers() const
Get list of identifiers of receivers.
Definition: JSydney.cc:1105
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:645
virtual void apply(const double step) override
Apply step.
Definition: JSydney.cc:462
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:474
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:840
Auxiliary class to define a range between two values.
General purpose class for object reading from a list of file names.
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:1168
Acoustic transmission identifier.
JTOOLS::JHashMap< int, JLocation > receivers
Definition: JSydney.cc:1158
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:445
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:566
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:388
JTripodEditor(JSetup &setup, const int id, const JVector3D &direction)
Constructor.
Definition: JSydney.cc:405
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:338
JStringEditor(JSetup &setup, const int id, const JVector3D &direction, const bool option)
Constructor.
Definition: JSydney.cc:311
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:283
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.
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:46
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:484
JModule & set(const JVector3D &pos)
Set position.
Definition: JModule.hh:408
friend std::istream & operator>>(std::istream &in, JParameters_t &object)
Read parameters from input stream.
Definition: JSydney.cc:503
script
Definition: JAcoustics.sh:2
double getZ() const
Get z position.
Definition: JVector3D.hh:115
std::unique_ptr< JLocationRouter > router
Definition: JSydney.cc:1159
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:657
Template definition of fit function of acoustic model.
Definition: JKatoomba_t.hh:146
Container I/O.
std::vector< JTripod > & tripods
Definition: JSydney.cc:427
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:568
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:395