455{
  458  
  460 
  462 
  464  JLimit_t&                numberOfEvents = inputFile.getLimit();
 
  466  int                      factoryLimit   = 10000;
  467  double                   TMaxExtra_s    = 500.0e-6;
  468  double                   RMax_m         = 0.0;
  469  double                   DMax_m         = 0.0;
  470  double                   Xv_m           = 0.0;
  471  double                   factor         = 2.0;
  472  double                   Z_m            = 0.0;   
  473  double                   fraction       = 0.75;  
  476  string                   detectorFile;
  478  double                   precision;
  481 
  482  try {
  483 
  485 
  497    
  498    JParser<> zap(
"Main program to trigger acoustic data.");
 
  499    
  500    zap[
'f'] = 
make_field(inputFile,    
"output of JToA");
 
  502    zap[
'@'] = 
make_field(properties,   
"trigger parameters");
 
  505    zap[
'a'] = 
make_field(detectorFile, 
"detector file");
 
  507    zap[
'p'] = 
make_field(precision,    
"precision time-of-arrival")         = 1.0e-6;
 
  510 
  511    zap(argc, argv);
  512  }
  513  catch(const exception &error) {
  514    FATAL(error.what() << endl);
 
  515  }
  516 
  517 
  519 
  520  try {
  522  }
  525  }
  526 
  528 
  530 
  532 
  533  const JVelo velo(V0, 
JVector3D(cylinder.getX(), cylinder.getY(), Z_m), RMax_m, Xv_m, factor);
 
  534 
  535  const JMatch3D      match(V0, TMaxExtra_s);
 
  538    
  540 
  541  for (JDetector::const_iterator i = 
detector.begin(); i != 
detector.end(); ++i) {
 
  542 
  544 
  545    if (i->getFloor() == 0) {                    
  546 
  547      try {
  549                          hydrophones.end(),
  551      }
  552      catch(const exception&) {
  553        continue;                                
  554      }
  555    }
  556 
  557    receivers[i->getID()] = 
JReceiver(i->getID(), 
 
  558                                      i->getPosition() + pos, 
  559                                      i->getT0() * 1.0e-9);
  560  }
  561 
  562  
  563  
  569 
  571 
  573 
  576  }
  577 
  580 
  581 
  582  
  583 
  585 
  587 
  589 
  590  static double TOA_s = numeric_limits<double>::max();
  591 
  593 
  596    }
  597 
  598    JToA* parameters = inputFile.
next();
 
  599 
  601      FATAL(
"Invalid detector identifier " << parameters->
DETID << 
" != " << 
detector.getID() << endl);
 
  602    }
  603 
  604    if (receivers.
has(parameters->
DOMID)) {
 
  605 
  606      ids.insert(parameters->
DOMID);
 
  607 
  609      const double     toa_s    = parameters->
TOA_S();
 
  610 
  611      if (toa_s < TOA_s) {
  612        TOA_s = toa_s;
  613      }
  614 
  619                                       receiver.
getT(toa_s),
 
  620                                       receiver.
getT(toa_s));
 
  621 
  624      }
  625    }
  626  }
  628 
  629  if (parameters.numberOfHits == 0) {
  630 
  631    parameters.numberOfHits = (int) (ids.size() * fraction);
  632 
  633    STATUS(
"Number of hits " << parameters.numberOfHits << endl);
 
  634  }
  635 
  637  
  639 
  641 
  643 
  644      
  645 
  647 
  648      buffer_type::iterator __end = unique(receiver->second.begin(), receiver->second.end(), 
JTransmission::equals(precision));
 
  649 
  650      
  651 
  652      for (buffer_type::const_iterator p = receiver->second.begin(); p != __end; ++p) {
  653        if (p->getQ() >= parameters.Q * (parameters.Q <= 1.0 ? p->getW() : 1.0)) {
  655        }
  656      }
  657    }
  658 
  660 
  662 
  663      double      t0 = TOA_s;
  664    
  667 
  668      TH1D* h1 = M1[i->first];
  669      TH1D* h2 = M2[i->first];
  670      TH1D* h3 = M3[i->first];
  671      TH1D* h4 = M4[i->first];
  672      TH1D* h5 = M5[i->first];
  673 
  674      for (buffer_type::const_iterator p = 
data.begin(); p != 
data.end(); ++p) {
 
  675 
  677          STATUS(
"processed: " << setw(3) << i->first << 
' ' << 
FIXED(9,3) << p->getToA() - 
data.begin()->getToA() << 
" [s]" << 
'\r' << flush); 
DEBUG(endl);
 
  678        }
  679 
  680        buffer_type::const_iterator q = p;
  681 
  682        while (++q != 
data.end() && q->getToA() - p->getToA() <= parameters.TMax_s) {}
 
  683 
  685 
  686        if (
distance(p,q) >= parameters.numberOfHits) {
 
  687 
  689 
  690            if ((
int) out[1].size() >= parameters.numberOfHits && velo(out[1].
getVertex(), p, q) >= parameters.numberOfHits) {
 
  691 
  692              
  693 
  694            } else {
  695            
  696              buffer_type::iterator 
root = buffer.begin();
 
  697              buffer_type::iterator __p  = buffer.begin();
  698              buffer_type::iterator __q  = buffer.begin();
  699 
  701        
  702              ++__p;
  703              ++__q;
  704 
  705              for (buffer_type::const_iterator i = p; ++i != q; ) {
  706                if (match(*p,*i)) {
  707                  *__q = *i;
  708                  ++__q;
  709                }
  710              }
  711 
  713 
  715 
  717 
  719 
  721 
  723 
  725 
  726                  if (vx.
N >= parameters.numberOfHits) {
 
  728                  }
  729                }
  730              }
  731            }
  732 
  733          } else {
  734 
  736          }
  737 
  738          if (!out[1].empty()) {
  739 
  740            if (out[0].empty()) {
  741 
  742              out[0] = out[1];                           
  743 
  744            } else if (overlap2D(out[0],out[1])) {
  745      
  746              out[0].
merge(out[1]);                      
 
  747 
  748            } else {
  749 
  750              const double t1 = out[0].begin()->getToA();
  751 
  754                     << setw(3)    << i->first           << ' '
  755                     << 
FIXED(9,3) << t1 - t0 << 
" [s]"  << 
' ' 
  756                     << setw(4)    << out[0].size()      << ' '
  759 
  760              
  761            
  762              h5->Fill(out[0].size());
  763 
  764              queue.push_back(out[0]);                   
  765              
  766              out[0] = out[1];                           
  767            }
  768 
  769            out[1].clear();
  770          }
  771        }
  772      }
  773 
  774      if (!out[0].empty()) {
  775 
  776        queue.push_back(out[0]);                         
  777      }
  779    }
  780  }
  781 
  782  if (!queue.empty()) {
  783 
  784    struct time_t {
  785 
  786      void operator=(const double t0) { this->t0 = t0; }
  787 
  788      operator double() const { return this->t0; }
  789 
  790      double t0 = TOA_s;
  791    };
  792 
  794 
  795    sort(queue.begin(), queue.end());
  796    
  798 
  801 
  802      
  803 
  804      while (++q != queue.end() && overlap1D(*p,*q)) {
  806          r = q;
  807        }
  808      }
  809 
  810      const double t0 = ts[r->getID()];
  811      const double t1 = r->begin()->getToA();
  812 
  814             << setw(3)    << r->getID()         << ' '
  815             << 
FIXED(9,3) << t1 - t0 << 
" [s]"  << 
' ' 
  816             << setw(4)    << r->size()          << ' '
  818             << r->getPosition()                 << endl);
  819 
  820      
  821 
  823 
  824      p = q;
  825 
  826      G2[r->getID()].put(r->getX(), r->getY());
  827    }
  828  }
  829  
  831 
  833 
  834  for (const auto M : { &M1, &M2, &M3, &M4, &M5 }){ 
  835    for (const auto& i : *M) {
  837    }
  838  }
  839 
  842  }
  843 
  845}
#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
 
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
 
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.
 
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.
 
counter_type getCounter() const
Get counter.
 
virtual const pointer_type & next() override
Get next element.
 
const JPolynome f1(1.0, 2.0, 3.0)
Function.
 
JVertex3D getVertex(const Trk &track)
Get vertex.
 
JPosition3D getPosition(const Vec &pos)
Get position.
 
int getWaveformID(int id)
Get waveform identifier.
 
double getQuality(const JEvent &evt)
Get average quality.
 
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.
 
Auxiliary data structure for floating point format specification.
 
Implementation for depth independend 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
 
const JVertex3D & getVertex() const
Get vertex.
 
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.