18 #define _DBG_ cout<<__FILE__<<":"<<__LINE__<<" "
19 #define _DBG__ cout<<__FILE__<<":"<<__LINE__<<endl
25 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read);
38 std::ifstream in(filename, ifstream::ate | ifstream::binary);
45 int main(
int narg,
char* argv[])
52 unsigned int NEvents = 0;
53 unsigned int NEvents_read = 0;
71 for(
int i=1; i<narg; i++){
76 case 'h':
Usage();
break;
85 cout<<endl<<
"You must enter a filename!"<<endl<<endl;
101 cout<<endl<<
"Usage:"<<endl;
102 cout<<
" evio_merge_files [-oOutputfile] file1.evio file2.evio ..."<<endl;
104 cout<<
"options:"<<endl;
105 cout<<
" -oOutputfile Set output filename (def. merged.evio)"<<endl;
107 cout<<
" This will merge together multiple EVIO files into a single EVIO file."<<endl;
121 cerr<<endl<<
"SIGINT received ("<<
QUIT<<
")....."<<endl;
129 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read)
150 cerr<<
"Could not open output file " <<
OUTFILENAME << endl;
156 cout <<
"Opening input file : \"" <<
INFILENAMES[i] <<
"\"" << endl;
159 cerr<<
"Could not open input file " <<
INFILENAMES[i] << endl;
167 cout <<
"first block" << endl;
169 unsigned int *int_buffer = (
unsigned int*)buffer;
170 for(
int i=0; i<8; i++)
171 cout <<
"0x" << hex << int_buffer[i] << endl;
172 infile.seekg(-32, ios_base::cur);
182 length_to_read -= 8*4L;
183 infile.read(buffer, length_to_read);
184 outfile.write(buffer, length_to_read);
188 cout <<
"last block" << endl;
191 unsigned int *int_buffer = (
unsigned int*)buffer;
192 for(
int i=0; i<8; i++)
193 cout <<
"0x" << hex << int_buffer[i] << endl;
209 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read)
217 vector<evioFileChannel*> ichan;
219 cout <<
"Opening input file : \"" <<
INFILENAMES[i] <<
"\"" << endl;
220 evioFileChannel *ichan =
new evioFileChannel(
INFILENAMES[i],
"r");
224 time_t last_time = time(NULL);
229 if(! ichan->read() ) {
230 cout << endl <<
"No more events in " <<
INFILENAMES[i] << endl;
233 }
catch(evioException
e){
234 cerr << e.what() << endl;
238 evioDOMTree *dom =
new evioDOMTree(ichan);
244 evioDOMTreeP tree=NULL;
245 evioDOMNodeP root=NULL;
246 evioDOMNodeListP nodes = dom->getNodeList();
247 evioDOMNodeList::const_iterator ulIter;
248 for(ulIter=nodes->begin(); ulIter!=nodes->end(); ulIter++) {
249 evioDOMNodeP node = *ulIter;
250 if(node->getParent() != NULL )
continue;
255 tree =
new evioDOMTree(root);
259 evioDOMNodeListP mynodes = node->getChildren();
260 if(mynodes.get() == NULL)
continue;
261 evioDOMNodeList::const_iterator myiter;
262 for(myiter=mynodes->begin(); myiter!=mynodes->end(); myiter++) {
264 (*myiter)->move(root);
282 time_t now = time(NULL);
283 if(now != last_time){
284 cout<<
" "<<NEvents_read<<
" events read ("<<NEvents<<
" event written) \r";cout.flush();
void Process(unsigned int &NEvents, unsigned int &NEvents_read)
sprintf(text,"Post KinFit Cut")
void ParseCommandLineArguments(int &narg, char *argv[])
ifstream::pos_type GetFilesize(const char *filename)
vector< char * > INFILENAMES
void Usage(JApplication &app)
int main(int argc, char *argv[])