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);
39 int main(
int narg,
char* argv[])
46 unsigned int NEvents = 0;
47 unsigned int NEvents_read = 0;
53 cout<<
" "<<NEvents_read<<
" events read, "<<NEvents<<
" events written"<<endl;
65 for(
int i=1; i<narg; i++){
70 case 'h':
Usage();
break;
79 cout<<endl<<
"You must enter a filename!"<<endl<<endl;
95 cout<<endl<<
"Usage:"<<endl;
96 cout<<
" evio_merge_events [-oOutputfile] file1.evio file2.evio ..."<<endl;
98 cout<<
"options:"<<endl;
99 cout<<
" -oOutputfile Set output filename (def. merged_files.evio)"<<endl;
101 cout<<
" This will merge events from 1 or more EVIO files into a single EVIO file."<<endl;
102 cout<<
"This is done at the event level by copying all EVIO banks from the top-level" << endl;
103 cout<<
"bank into the top-level bank of the output file." << endl;
117 cerr<<endl<<
"SIGINT received ("<<
QUIT<<
")....."<<endl;
123 void Process(
unsigned int &NEvents,
unsigned int &NEvents_read)
131 vector<evioFileChannel*> ichan;
133 cout <<
"Opening input file : \"" <<
INFILENAMES[i] <<
"\"" << endl;
136 ichan.push_back(chan);
140 time_t last_time = time(NULL);
144 vector<evioDOMTree*> doms;
145 for(
unsigned int i=0; i<ichan.size(); i++){
147 if(! ichan[i]->read() ) {
148 cout << endl <<
"No more events in " <<
INFILENAMES[i] << endl;
151 }
catch(evioException
e){
152 cerr << e.what() << endl;
156 evioDOMTree *dom =
new evioDOMTree(ichan[i]);
160 if(doms.size() != ichan.size())
break;
164 evioDOMTreeP tree=NULL;
165 evioDOMNodeP root=NULL;
166 for(
unsigned int i=0; i<doms.size(); i++){
167 evioDOMNodeListP nodes = doms[i]->getNodeList();
168 evioDOMNodeList::const_iterator ulIter;
169 for(ulIter=nodes->begin(); ulIter!=nodes->end(); ulIter++) {
170 evioDOMNodeP node = *ulIter;
171 if(node->getParent() != NULL )
continue;
176 tree =
new evioDOMTree(root);
180 evioDOMNodeListP mynodes = node->getChildren();
181 if(mynodes.get() == NULL)
continue;
182 evioDOMNodeList::const_iterator myiter;
183 for(myiter=mynodes->begin(); myiter!=mynodes->end(); myiter++) {
185 (*myiter)->move(root);
205 time_t now = time(NULL);
206 if(now != last_time){
207 cout<<
" "<<NEvents_read<<
" events read ("<<NEvents<<
" event written) \r";cout.flush();
215 for(
unsigned int i=0; i<ichan.size(); i++){
void Process(unsigned int &NEvents, unsigned int &NEvents_read)
sprintf(text,"Post KinFit Cut")
void ParseCommandLineArguments(int &narg, char *argv[])
static evioFileChannel * chan
vector< char * > INFILENAMES
void Usage(JApplication &app)
int main(int argc, char *argv[])