424{
427
429
431
433 JLimit_t& numberOfEvents = inputFile.getLimit();
435 int factoryLimit = 10000;
436 double TMaxExtra_s = 500.0e-6;
437 double RMax_m = 0.0;
438 double DMax_m = 0.0;
439 double Xv_m = 0.0;
440 double factor = 2.0;
441 double Z_m = 0.0;
442 double fraction = 0.75;
443 double grid = 10.0;
446 string detectorFile;
448 double precision;
451
452 try {
453
455
468
469 JParser<> zap(
"Main program to trigger acoustic data.");
470
471 zap[
'f'] =
make_field(inputFile,
"output of JToA");
473 zap[
'@'] =
make_field(properties,
"trigger parameters");
476 zap[
'a'] =
make_field(detectorFile,
"detector file");
478 zap[
'p'] =
make_field(precision,
"precision time-of-arrival") = 1.0e-6;
481
482 zap(argc, argv);
483 }
484 catch(const exception &error) {
485 FATAL(error.what() << endl);
486 }
487
488
490
491 try {
493 }
496 }
497
499
501
502 const JVector3D center(cylinder.getX(), cylinder.getY(), Z_m);
503
504
506
507 const JVelo Velo(V0, RMax_m, Xv_m*grid, factor);
508 const JVelo velo(V0, RMax_m/grid, Xv_m, factor);
509
510 const JMatch3D match(V0, TMaxExtra_s);
513
515
516 for (JDetector::const_iterator i =
detector.begin(); i !=
detector.end(); ++i) {
517
519
520 if (i->getFloor() == 0) {
521
522 try {
524 hydrophones.end(),
526 }
527 catch(const exception&) {
528 continue;
529 }
530 }
531
532 receivers[i->getID()] =
JReceiver(i->getID(),
533 i->getPosition() + pos,
534 i->getT0() * 1.0e-9);
535 }
536
537
538
544
546
548
551 }
552
555
556
557
558
560
562
564
566
568
569 JToA* parameters = inputFile.
next();
570
572 FATAL(
"Invalid detector identifier " << parameters->
DETID <<
" != " <<
detector.getID() << endl);
573 }
574
575 if (receivers.
has(parameters->
DOMID)) {
576
577 ids.insert(parameters->
DOMID);
578
580 const double toa_s = parameters->
TOA_S();
581
584 }
585
590 receiver.
getT(toa_s),
591 receiver.
getT(toa_s));
592
595 }
596 }
597 }
599
600 if (parameters.numberOfHits == 0) {
601
602 parameters.numberOfHits = (int) (ids.size() * fraction);
603
604 STATUS(
"Number of hits " << parameters.numberOfHits << endl);
605 }
606
608
610
611 STATUS(
"processing: " << setw(3) << i->first << endl);
612
614
616
617
618
620
621 buffer_type::iterator __end = unique(receiver->second.begin(), receiver->second.end(),
JTransmission::equals(precision));
622
623
624
625 for (buffer_type::const_iterator p = receiver->second.begin(); p != __end; ++p) {
626 if (p->getQ() >= parameters.Q * (parameters.Q <= 1.0 ? p->getW() : 1.0)) {
628 }
629 }
630 }
631
633
635
638
639 TH1D* h1 = M1[i->first];
640 TH1D* h2 = M2[i->first];
641 TH1D* h3 = M3[i->first];
642 TH1D* h4 = M4[i->first];
643 TH1D* h5 = M5[i->first];
644
645 for (buffer_type::const_iterator p =
data.begin(); p !=
data.end(); ++p) {
646
647 buffer_type::const_iterator q = p;
648
649 while (++q !=
data.end() && q->getToA() - p->getToA() <= parameters.TMax_s) {}
650
652
653 if (
distance(p,q) >= parameters.numberOfHits) {
654
656
657 if ((
int) out[1].size() >= parameters.numberOfHits && velo(out[1].
getVertex(), p, q) >= parameters.numberOfHits) {
658
659
660
661 } else {
662
663 buffer_type::iterator
root = buffer.begin();
664 buffer_type::iterator __p = buffer.begin();
665 buffer_type::iterator __q = buffer.begin();
666
668
669 ++__p;
670 ++__q;
671
672 for (buffer_type::const_iterator i = p; ++i != q; ) {
673 if (match(*p,*i)) {
674 *__q = *i;
675 ++__q;
676 }
677 }
678
680
682
684
686
688
689 vertex_type vx = Velo(center, *
root, __p, __q, parameters.numberOfHits);
690
691 if (vx.
N >= parameters.numberOfHits) {
692
694
696
697 if (vx.
N >= parameters.numberOfHits) {
699 }
700 }
701 }
702 }
703 }
704
705 } else {
706
708 }
709
710 if (!out[1].empty()) {
711
712 if (out[0].empty()) {
713
714 out[0] = out[1];
715
716 } else if (overlap2D(out[0],out[1])) {
717
718 out[0].
merge(out[1]);
719
720 } else {
721
722 STATUS(
"trigger: " << out[0] << endl);
723
724 h5->Fill(out[0].size());
725
726 queue.push_back(out[0]);
727
728 out[0] = out[1];
729 }
730
731 out[1].clear();
732 }
733 }
734 }
735
736 if (!out[0].empty()) {
737
738 queue.push_back(out[0]);
739 }
741 }
742 }
743
744 if (!queue.empty()) {
745
746 sort(queue.begin(), queue.end());
747
749
750
751
754
756
757 for ( ; q != queue.end() && overlap1D(*p,*q); ++q) {
758
759 STATUS(
"| " << *q << endl);
760
761 if (q->getQ() > i->getQ()) {
762 i = q;
763 }
764 }
765
766 STATUS(
"event: " << *i << endl);
767
769
770 G2[i->getID()].put(i->getX(), i->getY());
771
772 p = q;
773 }
774 }
775
777
779
780 for (const auto M : { &M1, &M2, &M3, &M4, &M5 }){
781 for (const auto& i : *M) {
783 }
784 }
785
788 }
789
791}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#define MAKE_CSTRING(A)
Make C-string.
#define gmake_property(A)
macros to convert (template) parameter to JPropertiesElement object
3D match criterion for acoustic signals.
int getString() const
Get string number.
Utility class to parse parameter values.
Data structure for position in three dimensions.
const JPosition3D & getPosition() const
Get position.
Data structure for vector in three dimensions.
const JVertex3D & getVertex() const
Get vertex.
int getID() const
Get identifier.
Utility class to parse command line options.
Auxiliary class to manage set of compatible ROOT objects (e.g. histograms) using unique keys.
General purpose class for object reading from a list of file names.
virtual bool hasNext() override
Check availability of next element.
virtual const pointer_type & next() override
Get next element.
JVertex3D getVertex(const Trk &track)
Get vertex.
JPosition3D getPosition(const Vec &pos)
Get position.
int getWaveformID(int id)
Get waveform identifier.
JContainer< std::vector< JHydrophone > > hydrophones_container
static const JSoundVelocity getSoundVelocity(1541.0, -17.0e-3, -2000.0)
Function object for velocity of sound.
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
JComparator< JResult_t T::*, JComparison::lt > make_comparator(JResult_t T::*member)
Helper method to create comparator between values of data member.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
std::vector< JHitW0 > buffer_type
hits
JHitIterator_t clusterize(JHitIterator_t __begin, JHitIterator_t __end, const JMatch_t &match, const int Nmin=1)
Partition data according given binary match operator.
Auxiliary data structure for sequence of same character.
Interface for depth dependend velocity of sound.
Match of two events considering overlap in time and position.
void merge(const JEvent &event)
Merge event.
double getT(const double t_s) const
Get corrected time.
Implementation for depth dependend velocity of sound.
JSoundVelocity & set(const double z0)
Set depth.
Time-of-arrival data from acoustic piezo sensor or hydrophone.
uint32_t DOMID
DAQ run number.
uint32_t QUALITYFACTOR
The ticks (16ns) part of the DAQ frame timestamp.
uint32_t QUALITYNORMALISATION
A measure of how good the waveform match was to the signal.
int32_t WAVEFORMID
DOM unique identifeir.
int32_t RUN
detector identifier
double TOA_S() const
Time of Arrival, expressed in seconds relative to Unix epoch (1 January 1970 00:00:00 UTC)
Auxiliary class to compare transmissions.
Auxiliary class to compare transmissions.
double Q
minimal quality if larger than one; else minimal normalised quality
double TMax_s
maximal difference between times of emission [s]
int numberOfHits
minimal number of hits to trigger event
static double TOA_s
start time of data
Transmission with position.
Auxiliary wrapper for I/O of container with optional comment (see JComment).
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure to build TGraph.
Auxiliary class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.