15 #include <evioFileChannel.hxx>
16 #include <evioUtil.hxx>
21 #define _DBG_ cout<<__FILE__<<":"<<__LINE__<<" "
22 #define _DBG__ cout<<__FILE__<<":"<<__LINE__<<endl
28 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read);
47 int main(
int narg,
char* argv[])
60 unsigned int NEvents = 0;
61 unsigned int NEvents_read = 0;
67 cout<<
" "<<NEvents_read<<
" events read, "<<NEvents<<
" events written"<<endl;
79 for(
int i=1; i<narg; i++){
84 case 'h':
Usage();
break;
102 cout<<endl<<
"You must enter a filename!"<<endl<<endl;
136 cout<<endl<<
"Usage:"<<endl;
137 cout<<
" evio_cull_events [-oOutputfile] [-sNeventsToSkip] [-kNeventsToKeep] file1.evio file2.evio ..."<<endl;
139 cout<<
"options:"<<endl;
140 cout<<
" -oOutputfile Set output filename (def. merged_files.evio)"<<endl;
141 cout<<
" -sNeventsToSkip Set number of events to skip (def. 0)"<<endl;
142 cout<<
" -kNeventsToKeep Set number of events to keep (def. 1)"<<endl;
143 cout<<
" -eSingleEvent Keep only the single, specified event (file pos.)"<<endl;
144 cout<<
" -ESingleEvent Keep only the single, specified event (event number)"<<endl;
145 cout<<
" -bBufferSize Size of EVIO input buffer in bytes (def. " << (
BUFFER_SIZE>>20) <<
"MB)" << endl;
147 cout<<
" This will copy a continguous set of events from the combined event streams"<<endl;
148 cout<<
" into a seperate output file. The primary use for this would be to copy"<<endl;
149 cout<<
" a single, problematic event into a seperate file for easier debugging."<<endl;
151 cout<<
" If the -eNNN option is used then only a single event is extracted"<<endl;
152 cout<<
" (the NNN-th event) and written to a file with the name evtNNN.hddm."<<endl;
153 cout<<
" Note that the event is counted from the begining of the file, starting"<<endl;
154 cout<<
" with \"1\". This does NOT look at the event number stored in the event itself."<<endl;
156 cout<<
" If the -ENNN option is used then only a single event is extracted"<<endl;
157 cout<<
" (the specified event number) and written to a file with the name EvtNNN.hddm."<<endl;
170 cerr<<endl<<
"SIGINT received ("<<
QUIT<<
")....."<<endl;
172 cerr <<
"3 or more SIGINTs received. exiting..." << endl;
180 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read)
184 time_t last_time = time(NULL);;
194 cout <<
"Opening input file : \"" <<
INFILENAMES[i] <<
"\"" << endl;
197 while( ichan->read() ){
200 evioDOMTree *dom = NULL;
201 bool write_event =
false;
205 dom =
new evioDOMTree(ichan);
208 uint64_t min_event = eventnumber;
209 uint64_t max_event = min_event + block_size - 1;
212 if(min_event != max_event){
214 cout <<
"WARNING: The CODA block size for this data is not \"1\"!" << endl;
215 cout <<
"The entire block of " << block_size <<
" events is being written" << endl;
216 cout <<
"that contains the requested event." << endl;
217 cout <<
"Events " << min_event <<
" - " << max_event <<
" will be written." << endl;
230 if(!dom) dom =
new evioDOMTree(ichan);
242 time_t t = time(NULL);
243 if((t-last_time) >= 2){
244 cout <<
" " << NEvents_read <<
" event read " << NEvents <<
" events written \r";
252 }
catch(evioException
e){
253 cerr << e.what() << endl;
271 evioDOMNodeListP bankList = evt->getNodeList(typeIs<uint64_t>());
272 evioDOMNodeList::iterator iter = bankList->begin();
273 for(; iter!=bankList->end(); iter++){
276 evioDOMNodeP bankPtr = *iter;
277 const vector<uint64_t> *vec = bankPtr->getVector<uint64_t>();
279 const uint32_t *iptr = (
const uint32_t *)&(*vec)[0];
282 evioDOMNodeP trigger_bank = bankPtr->getParent();
283 if( trigger_bank == NULL )
continue;
284 if((trigger_bank->tag & 0xFF20) != 0xFF20)
continue;
287 evioDOMNodeP physics_event_bank = trigger_bank->getParent();
288 if( physics_event_bank == NULL )
continue;
291 if(vec->size() < 2)
continue;
294 block_size = (uint64_t)physics_event_bank->num;
297 uint64_t loevent_num = iptr[0];
298 uint64_t hievent_num = iptr[1];
299 uint64_t
event_num = loevent_num + (hievent_num<<32);
void Process(unsigned int &NEvents, unsigned int &NEvents_read)
unsigned int EVENTS_TO_KEEP
unsigned int SPECIFIC_EVENT_TO_KEEP
sprintf(text,"Post KinFit Cut")
void ParseCommandLineArguments(int &narg, char *argv[])
uint64_t FindEventNumber(evioDOMTree *evt, uint64_t &block_size)
static const size_t block_size
unsigned int SPECIFIC_OFFSET_TO_KEEP
vector< char * > INFILENAMES
unsigned int EVENTS_TO_SKIP
void Usage(JApplication &app)
int main(int argc, char *argv[])