58{
   61 
   63  
   67 
   68  try {
   69    
   70    JParser<> zap(
"Auxiliary program for time sorting of Monte-Carlo events.");
 
   71    
   72    zap[
'f'] = 
make_field(inputFile,  
"Input file (produced with JEvtSplit)");
 
   75 
   76    zap(argc, argv);
   77  }
   78  catch(const exception& error) {
   79    FATAL(error.what() << endl);
 
   80  }
   81 
   82 
   84    
   86 
   87  const size_t N = inputFile.size();
   88 
   89  typedef JTreeScanner      <Evt>  JScanner_t;
   90  
   91 
   93 
   95 
   96  for (size_t i = 0; i != N; ++i) {
   97 
   98    in[i].configure(inputFile[i]);
   99 
  100    STATUS(
"Processing " << inputFile[i] << endl);
 
  101  }
  102 
  103#ifdef PRIORITY_QUEUE
  104 
  105  priority_queue<entry_type, deque<entry_type> > buffer;    
  106 
  107  for (size_t i = 0; i != N; ++i) {
  108 
  109    if (in[i].hasNext()) {
  110 
  111      buffer.push({i, *in[i].next()});
  112 
  113      --number_of_events;
  114    }
  115  }
  116 
  117  while (number_of_events != 0) {                           
  118 
  119    STATUS(
"event: " << setw(10) << number_of_events << 
'\r'); 
DEBUG(endl);
 
  120 
  121    const entry_type& top = buffer.top();
  122 
  124 
  125    if (in[top.index].hasNext()) {
  126 
  127      buffer.push({top.index, *in[top.index].next()});
  128 
  129      --number_of_events;
  130    }
  131      
  132    buffer.pop();
  133  }
  134 
  135  while (!buffer.empty()) {                                 
  136 
  137    const entry_type& top = buffer.top();
  138 
  140      
  141    buffer.pop();
  142  }
  143 
  144#else
  145 
  147 
  148  for (size_t i = 0; i != N; ++i) {
  149 
  150    if (in[i].hasNext()) {
  151 
  152      buffer.push_back({i, *in[i].next()});
  153 
  154      --number_of_events;
  155    }
  156  }
  157 
  158  make_heap(buffer.begin(), buffer.end());
  159 
  160  while (number_of_events != 0) {                           
  161 
  162    STATUS(
"event: " << setw(10) << number_of_events << 
'\r'); 
DEBUG(endl);
 
  163 
  164    const size_t index = buffer[0].index;
  165 
  167      
  168    pop_heap(buffer.begin(), buffer.end());
  169 
  170    buffer.pop_back();
  171 
  172    if (in[index].hasNext()) {
  173 
  174      buffer.push_back({index, *in[index].next()});
  175 
  176      push_heap(buffer.begin(), buffer.end());      
  177 
  178      --number_of_events;
  179    }
  180  }
  181 
  182  sort_heap(buffer.begin(), buffer.end());                  
  183 
  184  for (vector<entry_type>::const_reverse_iterator top = buffer.rbegin(); top != buffer.rend(); ++top) {
  186  }
  187#endif
  189 
  190  int counter = 0;
  191 
  194 
  195  for (size_t i = 0; i != N; ++i) {
  196 
  197    try {
  198 
  201 
  202      if (counter == 0) {
  203 
  206 
  207      } else {
  208 
  209        if (h0 != h1) { 
FATAL(
"Inconsistent header "       << endl << h1 << endl << 
"!=" << endl << h0 << endl); }
 
  210        if (m0 != m1) { 
FATAL(
"Inconsistent multi header " << endl << m1 << endl << 
"!=" << endl << m0 << endl); }
 
  211      }
  212 
  213      counter += 1;
  214 
  215      h0 = h1;
  216      m0 = m1;
  217    }
  218    catch (const exception&) {}
  219  }
  220 
  221  if (counter == 0) {
  222    FATAL(
"Missing header." << endl);
 
  223  }
  224 
  225  for (size_t i = 0; i != N; ++i) {
  226 
  228 
  230  }
  231 
  233 
  234  return 0;
  235}
#define DEBUG(A)
Message macros.
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
 
Utility class to parse command line options.
 
Object reading from a list of files.
 
Template definition for direct access of elements in ROOT TChain.
 
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 
Long64_t counter_type
Type definition for counter.
 
JMultiHead getMultiHeader(const JMultipleFileScanner_t &file_list)
Get multi-header corresponding to a given file list.
 
Head getHeader(const JMultipleFileScanner_t &file_list)
Get Monte Carlo header.
 
The Head class reflects the header of Monte-Carlo event files, which consists of keys (also referred ...