63{
   67 
   69 
   71  JLimit_t&                numberOfEvents = inputFile.getLimit();
 
   73  string                   detectorFile;
   77  bool                     profile;
   80  
   81  try { 
   82 
   83    JParser<> zap(
"Auxiliary program to trigger time slice data.");
 
   84    
   85    zap[
'f'] = 
make_field(inputFile,      
"input file.");
 
   88    zap[
'a'] = 
make_field(detectorFile,   
"detector file.");
 
   93    zap[
'm'] = 
make_field(merge,          
"Allow merging of files w/o Monte Carlo headers");
 
   95 
   96    zap(argc, argv);
   97  }
   98  catch(const exception &error) {
   99    FATAL(error.what() << endl);
 
  100  }
  101 
  102 
  104  
  106 
  107  if (!profile) {
  109  }
  110  
  112  DEBUG(
"Reset time [ms] " << 
getRTS()       * 1e-6 << endl);
 
  113  DEBUG(
"Trigger"          << endl << parameters    << endl);
 
  114  
  116 
  117  try {
  119  }
  122  }
  123 
  124  
  125 
  126  if (parameters.disableHighRateVeto) {
  127 
  128    NOTICE(
"Disabling high-rate veto of all PMTs." << endl);
 
  129 
  131  }
  132 
  134 
  136 
  137  
  138  
  140 
  143  typedef JTimeslice   <hit_type>   JTimeslice_t;
  144  typedef JBuildL1     <hit_type>   JBuildL1_t;
  145  typedef JBuildL2     <hit_type>   JBuildL2_t;
  146 
  147  const JBuildL1_t buildL1(parameters);
  148  const JBuildL2_t buildL2(parameters.L2);
  149  const JBuildL2_t buildSN(parameters.SN);
  150  const JBuildL2_t buildNB(parameters.NB);
  151 
  152  JTimer timerCC(
"Calibration");
 
  157  JTimer timerRX(
"Timeslice router");
 
  158  JTimer timerTR(
"Trigger");
 
  159  JTimer timerTX(
"Trigger router");
 
  160  JTimer timerTW(
"Timeslice writer");
 
  161  JTimer timerSW(
"Summary writer");
 
  162 
  164 
  169 
  170 
  172 
  174 
  177 
  178  unsigned int numberOfTriggers = 0;
  179 
  181 
  183 
  184  for ( ; in.hasNext() && counter != inputFile.getLimit(); ++counter) {
  185 
  186    STATUS(
"event: " << setw(10) << counter << 
'\r'); 
DEBUG(endl);
 
  187 
  189 
  190    DEBUG(*timeslice << endl);
 
  191 
  192    timerRX.start();
  193 
  194    timesliceRouter.configure(*timeslice);
  195 
  196    timerRX.stop();
  197 
  198 
  204    
  205    for (JDAQTimeslice::const_iterator super_frame = timeslice->begin(); super_frame != timeslice->end(); ++super_frame) {
  206 
  207      if (moduleRouter.hasModule(super_frame->getModuleID())) {
  208 
  209        
  210      
  211        timerCC.start();
  212 
  213        const JModule&   module = moduleRouter.getModule(super_frame->getModuleID()); 
 
  214        JSuperFrame2D_t& buffer = JSuperFrame2D_t::demultiplex(*super_frame, module);
  215      
  216        timerCC.stop();
  217 
  218        
  219 
  220        buffer.applyHighRateVeto(parameters.highRateVeto_Hz);
  221 
  222        
  223      
  224        timerL0.start();
  225 
  226        timesliceL0.push_back(JSuperFrame1D_t(buffer));
  227      
  228        timerL0.stop();
  229 
  230        
  231 
  232        if (parameters.triggerNB.enabled) {
  233        
  234          JSuperFrame2D_t::iterator __end = partition(buffer.begin(), buffer.end(), parameters.triggerNB.pmts);
  235 
  236          if (buffer.begin() != __end) {
  237        
  238            timesliceNB.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
  239                                                  super_frame->getModuleIdentifier(),
  241 
  242            JSuperFrame1D_t zbuf;
  243            
  244            buildL1(buffer.begin(), __end , back_inserter(zbuf));
  245 
  246            buildNB(buffer.begin() , __end, zbuf, back_inserter(*timesliceNB.rbegin()));
  247          }
  248        }
  249 
  250        
  251      
  252        timerL1.start();
  253 
  254        timesliceL1.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
  255                                              super_frame->getModuleIdentifier(),
  257      
  258        buildL1(*timesliceL0.rbegin(), back_inserter(*timesliceL1.rbegin()));
  259      
  260        timerL1.stop();
  261 
  262        
  263      
  264        timerL2.start();
  265 
  266        timesliceL2.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
  267                                              super_frame->getModuleIdentifier(),
  269      
  270        buildL2(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceL2.rbegin()));
  271      
  272        timerL2.stop();
  273 
  274        
  275      
  276        timerSN.start();
  277 
  278        timesliceSN.push_back(JSuperFrame1D_t(super_frame->getDAQChronometer(),
  279                                              super_frame->getModuleIdentifier(),
  281      
  282        buildSN(buffer, *timesliceL1.rbegin(), back_inserter(*timesliceSN.rbegin()));
  283      
  284        timerSN.stop();
  285      }
  286    }
  287 
  288    
  289 
  290    if (parameters.triggerNB.enabled) {      
  291 
  292      timerTX.start();
  293 
  295 
  296      for (JTriggerInput::const_iterator hit = trigger_input.begin(); hit != trigger_input.end(); ++hit) {
  297 
  298        if (parameters.triggerNB.write()) {
  299                
  301                              getTriggerMask(triggerNB.getTriggerBit()),
  302                              *hit, 
  303                              timesliceRouter, 
  304                              moduleRouter, 
  305                              parameters.TMaxLocal_ns, 
  306                              parameters.triggerNB.DMax_m,
  307                              getTimeRange(parameters.triggerNB));
  308 
  310        }
  311      }
  312 
  313      timerTX.stop();
  314    }
  315    
  316    timerTR.start();
  317 
  320 
  321    trigger3DMuon  (trigger_input, back_inserter(trigger_output));
  322    trigger3DShower(trigger_input, back_inserter(trigger_output));
  323    triggerMXShower(trigger_input, timesliceL0, back_inserter(trigger_output));
  324 
  326 
  327    numberOfTriggers += trigger_output.size();
  328 
  329    timerTR.stop();
  330 
  331    DEBUG(
"Number of triggers: " << trigger_output.size() << endl);
 
  332 
  333    for (JTriggerOutput::const_iterator event = trigger_output.begin(); event != trigger_output.end(); ++event) {
  334 
  335      timerTX.start();
  336 
  338                          timesliceRouter, 
  339                          moduleRouter, 
  340                          parameters.TMaxLocal_ns, 
  341                          getTimeRange(parameters));
  342 
  344 
  345      timerTX.stop();
  346    }
  347 
  348    if (parameters.writeL0()) {
  349 
  350      timerTW.start();
  351 
  353 
  354      timerTW.stop();
  355    }
  356 
  357    if (parameters.writeL1()) {
  358 
  359      timerTW.start();
  360 
  362 
  363      timerTW.stop();
  364    }
  365 
  366    if (parameters.writeL2()) {
  367 
  368      timerTW.start();
  369 
  371 
  372      timerTW.stop();
  373    }
  374 
  375    if (parameters.writeSN()) {
  376 
  377      timerTW.start();
  378 
  380 
  381      timerTW.stop();
  382    }
  383 
  384    if (parameters.writeSummary()) {
  385 
  386      timerSW.start();
  387 
  389      
  390      timerSW.stop();
  391    }
  392  }
  394 
  396 
  397    const double factor = 1.0 / (double) counter;
  398 
  399    for (
const JTimer* p : { &timerCC, &timerL0, &timerL1, &timerL2, &timerSN, &timerRX, &timerTR, &timerTX, &timerTW, &timerSW }) {
 
  400      p->print(cout, factor);
  401    }
  402 
  403    NOTICE(
"Number of trigger/slices " << numberOfTriggers << 
"/" << counter << endl);
 
  404    NOTICE(
"Trigger rate [Hz]        " << numberOfTriggers * 1.0e9 * factor / 
getFrameTime() << endl);
 
  405  }   
  406 
  408 
  410 
  412}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
void merge(const JMatch_t &match)
Merge events.
 
Router for direct addressing of module data in detector data structure.
 
Data structure for a composite optical module.
 
Auxiliary class for CPU timing and usage.
 
static void disable()
Disable timers.
 
const JPosition3D & getPosition() const
Get position.
 
Auxiliary class for multiplexing object iterators.
 
Utility class to parse command line options.
 
General purpose class for object reading from a list of file names.
 
1-dimensional frame with time calibrated data from one optical module.
 
2-dimensional frame with time calibrated data from one optical module.
 
Auxiliary class to build JDAQTimeslice for L1 timeslice.
 
Auxiliary class to build JDAQEvent for a triggered event.
 
const JDAQChronometer & getDAQChronometer() const
Get DAQ chronometer.
 
Auxiliary class to set DAQ system clock parameters.
 
void set(const JDAQClock_t clock)
Set clock type.
 
void load(const std::string &file_name, JDetector &detector)
Load detector from input file.
 
double getMaximalDistance(const JDetector &detector, const bool option=false)
Get maximal distance between modules in detector.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
std::set< JROOTClassSelector > getROOTClassSelection(const bool option=false)
Get ROOT class selection.
 
Long64_t counter_type
Type definition for counter.
 
KM3NeT DAQ data structures and auxiliaries.
 
double getFrameTime()
Get frame time duration.
 
void setDAQLongprint(const bool option)
Set DAQ print option.
 
double getRTS()
Get TDC dynamic range.
 
static const int HIGH_RATE_VETO_DISABLE
Enable (disable) use of high-rate veto test if this status bit is 0 (1);.
 
Match of two events considering overlap in time and position.
 
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
 
Auxiliary class to select ROOT class based on class name.
 
Auxiliary class for defining the range of iterations of objects.
 
static counter_type max()
Get maximum counter value.
 
Router for fast addressing of hits in KM3NETDAQ::JDAQTimeslice data structure as a function of the op...