// $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; unsigned int EVENTS_TO_SKIP = 0; unsigned int EVENTS_TO_KEEP = 1; unsigned int SPECIFIC_OFFSET_TO_KEEP = 0; unsigned int SPECIFIC_EVENT_TO_KEEP = 0; unsigned int BUFFER_SIZE = 20000000; bool EVENT_TO_KEEP_MODE = false; //----------- // main //----------- int main(int narg,char* argv[]) { // Set up to catch SIGINTs for graceful exits signal(SIGINT,ctrlCHandle); ParseCommandLineArguments(narg, argv); cout<<"Skipping "<0){ EVENTS_TO_KEEP=1; EVENTS_TO_SKIP=SPECIFIC_OFFSET_TO_KEEP-1; } if(SPECIFIC_EVENT_TO_KEEP>0){ EVENTS_TO_KEEP=1; EVENTS_TO_SKIP=1000000000; // Large number of events to read in while looking for the specified event } if(OUTFILENAME==NULL){ if(SPECIFIC_OFFSET_TO_KEEP>0){ OUTFILENAME = new char[256]; sprintf(OUTFILENAME,"evt%d.evio", SPECIFIC_OFFSET_TO_KEEP); }else if(SPECIFIC_EVENT_TO_KEEP>0){ OUTFILENAME = new char[256]; sprintf(OUTFILENAME,"Evt%d.evio", SPECIFIC_OFFSET_TO_KEEP); }else{ OUTFILENAME = (char*)"culled.evio"; } } } //----------- // Usage //----------- void Usage(void) { cout<>20) << "MB)" << endl; cout<open(); while( ichan->read() ){ NEvents_read++; evioDOMTree *dom = NULL; bool write_event = false; if(SPECIFIC_EVENT_TO_KEEP>0){ // If user specified a specific event by event number within file // --- this feature not yet implemented !! --- } else if(NEvents_read > EVENTS_TO_SKIP){ // If user specified event range or specific event by offset write_event = true; } if(write_event){ if(!dom) dom = new evioDOMTree(ichan); ochan.write(dom); if(dom) delete dom; NEvents++; } if(NEvents >= EVENTS_TO_KEEP){ QUIT = true; break; } } ichan->close(); delete ichan; }catch(evioException e){ cerr << e.what() << endl; // QUIT=true; break; } if(QUIT) break; } // Close output file ochan.close(); }