453{
  456  
  458 
  460 
  462  JLimit_t&                numberOfEvents = inputFile.getLimit();
 
  464  int                      factoryLimit   = 10000;
  465  double                   TMaxExtra_s    = 500.0e-6;
  466  double                   RMax_m         = 0.0;
  467  double                   DMax_m         = 0.0;
  468  double                   Xv_m           = 0.0;
  469  double                   factor         = 2.0;
  470  double                   Z_m            = 0.0;   
  471  double                   fraction       = 0.75;  
  474  string                   detectorFile;
  476  double                   precision;
  479 
  480  try {
  481 
  483 
  495    
  496    JParser<> zap(
"Main program to trigger acoustic data.");
 
  497    
  498    zap[
'f'] = 
make_field(inputFile,    
"output of JToA");
 
  500    zap[
'@'] = 
make_field(properties,   
"trigger parameters");
 
  503    zap[
'a'] = 
make_field(detectorFile, 
"detector file");
 
  505    zap[
'p'] = 
make_field(precision,    
"precision time-of-arrival")         = 1.0e-6;
 
  508 
  509    zap(argc, argv);
  510  }
  511  catch(const exception &error) {
  512    FATAL(error.what() << endl);
 
  513  }
  514 
  515 
  517 
  518  try {
  520  }
  523  }
  524 
  526 
  528 
  530 
  531  const JVelo velo(V0, 
JVector3D(cylinder.getX(), cylinder.getY(), Z_m), RMax_m, Xv_m, factor);
 
  532 
  533  const JMatch3D      match(V0, TMaxExtra_s);
 
  536    
  538 
  539  for (JDetector::const_iterator i = 
detector.begin(); i != 
detector.end(); ++i) {
 
  540 
  542 
  543    if (i->getFloor() == 0) {                    
  544 
  545      try {
  547                          hydrophones.end(),
  549      }
  550      catch(const exception&) {
  551        continue;                                
  552      }
  553    }
  554 
  555    receivers[i->getID()] = 
JReceiver(i->getID(), 
 
  556                                      i->getPosition() + pos, 
  557                                      i->getT0() * 1.0e-9);
  558  }
  559 
  560  
  561  
  567 
  568 
  570 
  573  }
  574 
  577 
  578 
  579  
  580 
  582 
  584 
  586 
  587  static double TOA_s = numeric_limits<double>::max();
  588 
  590 
  593    }
  594 
  595    JToA* parameters = inputFile.
next();
 
  596 
  598      FATAL(
"Invalid detector identifier " << parameters->
DETID << 
" != " << 
detector.getID() << endl);
 
  599    }
  600 
  601    if (receivers.
has(parameters->
DOMID)) {
 
  602 
  603      ids.insert(parameters->
DOMID);
 
  604 
  606      const double     toa_s    = parameters->
TOA_S();
 
  607 
  608      if (toa_s < TOA_s) {
  609        TOA_s = toa_s;
  610      }
  611 
  616                                       receiver.
getT(toa_s),
 
  617                                       receiver.
getT(toa_s));
 
  618 
  621      }
  622    }
  623  }
  625 
  626  if (parameters.numberOfHits == 0) {
  627 
  628    parameters.numberOfHits = (int) (ids.size() * fraction);
  629 
  630    STATUS(
"Number of hits " << parameters.numberOfHits << endl);
 
  631  }
  632 
  634  
  636 
  638 
  640 
  641      
  642 
  644 
  645      buffer_type::iterator __end = unique(receiver->second.begin(), receiver->second.end(), 
JTransmission::equals(precision));
 
  646 
  647      
  648 
  649      for (buffer_type::const_iterator p = receiver->second.begin(); p != __end; ++p) {
  650        if (p->getQ() >= parameters.Q * (parameters.Q <= 1.0 ? p->getW() : 1.0)) {
  652        }
  653      }
  654    }
  655 
  657 
  659 
  660      double      t0 = TOA_s;
  661    
  664 
  665      TH1D* h1 = M1[i->first];
  666      TH1D* h2 = M2[i->first];
  667      TH1D* h3 = M3[i->first];
  668      TH1D* h4 = M4[i->first];
  669      TH1D* h5 = M5[i->first];
  670 
  671      for (buffer_type::const_iterator p = 
data.begin(); p != 
data.end(); ++p) {
 
  672 
  674          STATUS(
"processed: " << setw(3) << i->first << 
' ' << 
FIXED(9,3) << p->getToA() - 
data.begin()->getToA() << 
" [s]" << 
'\r' << flush); 
DEBUG(endl);
 
  675        }
  676 
  677        buffer_type::const_iterator q = p;
  678 
  679        while (++q != 
data.end() && q->getToA() - p->getToA() <= parameters.TMax_s) {}
 
  680 
  682 
  683        if (
distance(p,q) >= parameters.numberOfHits) {
 
  684 
  686 
  687            if ((
int) out[1].size() >= parameters.numberOfHits && velo(out[1].
getVertex(), p, q) >= parameters.numberOfHits) {
 
  688 
  689              
  690 
  691            } else {
  692            
  693              buffer_type::iterator 
root = buffer.begin();
 
  694              buffer_type::iterator __p  = buffer.begin();
  695              buffer_type::iterator __q  = buffer.begin();
  696 
  698        
  699              ++__p;
  700              ++__q;
  701 
  702              for (buffer_type::const_iterator i = p; ++i != q; ) {
  703                if (match(*p,*i)) {
  704                  *__q = *i;
  705                  ++__q;
  706                }
  707              }
  708 
  710 
  712 
  714 
  716 
  718 
  720 
  722 
  723                  if (vx.
N >= parameters.numberOfHits) {
 
  725                  }
  726                }
  727              }
  728            }
  729 
  730          } else {
  731 
  733          }
  734 
  735          if (!out[1].empty()) {
  736 
  737            if (out[0].empty()) {
  738 
  739              out[0] = out[1];                           
  740 
  741            } else if (overlap2D(out[0],out[1])) {
  742      
  743              out[0].
merge(out[1]);                      
 
  744 
  745            } else {
  746 
  747              const double t1 = out[0].begin()->getToA();
  748 
  751                     << setw(3)    << i->first           << ' '
  752                     << 
FIXED(9,3) << t1 - t0 << 
" [s]"  << 
' ' 
  753                     << setw(4)    << out[0].size()      << ' '
  756 
  757              
  758            
  759              h5->Fill(out[0].size());
  760 
  761              queue.push_back(out[0]);                   
  762              
  763              out[0] = out[1];                           
  764            }
  765 
  766            out[1].clear();
  767          }
  768        }
  769      }
  770 
  771      if (!out[0].empty()) {
  772 
  773        queue.push_back(out[0]);                         
  774      }
  776    }
  777  }
  778 
  779  if (!queue.empty()) {
  780 
  781    struct time_t {
  782 
  783      void operator=(const double t0) { this->t0 = t0; }
  784 
  785      operator double() const { return this->t0; }
  786 
  787      double t0 = TOA_s;
  788    };
  789 
  791 
  792    sort(queue.begin(), queue.end());
  793    
  795 
  798 
  799      
  800 
  801      while (++q != queue.end() && overlap1D(*p,*q)) {
  803          r = q;
  804        }
  805      }
  806 
  807      const double t0 = ts[r->getID()];
  808      const double t1 = r->begin()->getToA();
  809 
  811             << setw(3)    << r->getID()         << ' '
  812             << 
FIXED(9,3) << t1 - t0 << 
" [s]"  << 
' ' 
  813             << setw(4)    << r->size()          << ' '
  815             << r->getPosition()                 << endl);
  816 
  817      
  818 
  820 
  821      p = q;
  822    }
  823  }
  824  
  826 
  828 
  829  for (const auto M : { &M1, &M2, &M3, &M4, &M5 }){ 
  830    for (const auto& i : *M) {
  832    }
  833  }
  834 
  836}
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
#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 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 class for defining the range of iterations of objects.
static counter_type max()
Get maximum counter value.