// $Id$ // // Created June 10, 2014 David Lawrence #include #include #include #include using namespace std; #include #include #include #include #include using namespace evio; #ifndef _DBG_ #define _DBG_ cout<<__FILE__<<":"<<__LINE__<<" " #define _DBG__ cout<<__FILE__<<":"<<__LINE__< INFILENAMES; char *OUTFILENAME = NULL; int QUIT = 0; //----------- // main //----------- int main(int narg,char* argv[]) { // Set up to catch SIGINTs for graceful exits signal(SIGINT,ctrlCHandle); ParseCommandLineArguments(narg, argv); unsigned int NEvents = 0; unsigned int NEvents_read = 0; // Process all events Process(NEvents, NEvents_read); cout< ichan; for(unsigned int i=0; iopen(); ichan.push_back(chan); } // Loop until an input file runs out of events time_t last_time = time(NULL); while(true){ // Read in event from each input file, creating a DOM tree for each vector doms; for(unsigned int i=0; iread() ) { cout << endl << "No more events in " << INFILENAMES[i] << endl; break; } }catch(evioException e){ cerr << e.what() << endl; QUIT=true; break; } evioDOMTree *dom = new evioDOMTree(ichan[i]); doms.push_back(dom); } if(QUIT) break; if(doms.size() != ichan.size()) break; NEvents_read++; // Merge DOM Trees into single DOM tree evioDOMTreeP tree=NULL; evioDOMNodeP root=NULL; for(unsigned int i=0; igetNodeList(); evioDOMNodeList::const_iterator ulIter; for(ulIter=nodes->begin(); ulIter!=nodes->end(); ulIter++) { evioDOMNodeP node = *ulIter; if(node->getParent() != NULL ) continue; // only interested in top-level nodes if(tree==NULL){ // Use the first node of the first file as the root node root = node; root->cut(); // remove from input file's DOM tree = new evioDOMTree(root); }else{ // Move all daughter nodes of this input file's top-level node // into the root node of the merged event evioDOMNodeListP mynodes = node->getChildren(); if(mynodes.get() == NULL) continue; evioDOMNodeList::const_iterator myiter; for(myiter=mynodes->begin(); myiter!=mynodes->end(); myiter++) { try{ (*myiter)->move(root); }catch(...){ QUIT = true; break; } } if(QUIT) break; } if(QUIT) break; } if(QUIT) break; } // Write event to output file if(!QUIT){ ochan.write(tree); NEvents++; } // Update ticker time_t now = time(NULL); if(now != last_time){ cout<<" "<close(); delete ichan[i]; }catch(...){} } // Close output file ochan.close(); }