57int main(
int argc,
char **argv)
70 JParser<> zap(
"Auxiliary program for time sorting of Monte-Carlo events.");
72 zap[
'f'] =
make_field(inputFile,
"Input file (produced with JEvtSplit)");
78 catch(
const exception& error) {
79 FATAL(error.what() << endl);
87 const size_t N = inputFile.size();
89 typedef JTreeScanner <Evt> JScanner_t;
96 for (
size_t i = 0; i != N; ++i) {
98 in[i].configure(inputFile[i]);
100 STATUS(
"Processing " << inputFile[i] << endl);
105 priority_queue<entry_type, deque<entry_type> > buffer;
107 for (
size_t i = 0; i != N; ++i) {
109 if (in[i].hasNext()) {
111 buffer.push({i, *in[i].next()});
117 while (number_of_events != 0) {
119 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
121 const entry_type& top = buffer.top();
125 if (in[top.index].hasNext()) {
127 buffer.push({top.index, *in[top.index].next()});
135 while (!buffer.empty()) {
137 const entry_type& top = buffer.top();
148 for (
size_t i = 0; i != N; ++i) {
150 if (in[i].hasNext()) {
152 buffer.push_back({i, *in[i].next()});
158 make_heap(buffer.begin(), buffer.end());
160 while (number_of_events != 0) {
162 STATUS(
"event: " << setw(10) << number_of_events <<
'\r');
DEBUG(endl);
164 const size_t index = buffer[0].index;
168 pop_heap(buffer.begin(), buffer.end());
172 if (in[index].hasNext()) {
174 buffer.push_back({index, *in[index].next()});
176 push_heap(buffer.begin(), buffer.end());
182 sort_heap(buffer.begin(), buffer.end());
184 for (vector<entry_type>::const_reverse_iterator top = buffer.rbegin(); top != buffer.rend(); ++top) {
195 for (
size_t i = 0; i != N; ++i) {
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); }
218 catch (
const exception&) {}
222 FATAL(
"Missing header." << endl);
225 for (
size_t i = 0; i != N; ++i) {