00001 #include "lcio.h"
00002
00003 #include "IO/LCReader.h"
00004 #include "IMPL/LCTOOLS.h"
00005 #include "EVENT/LCRunHeader.h"
00006
00007 #include <cstdlib>
00008
00009
00010 static std::vector<std::string> FILEN ;
00011
00012 using namespace std ;
00013 using namespace lcio ;
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 int main(int argc, char** argv ){
00024
00025
00026 if( argc < 2) {
00027 cout << " usage: anajob <input-file1> [[input-file2],...]" << endl ;
00028 exit(1) ;
00029 }
00030 for(int i=1 ; i < argc ; i++){
00031 FILEN.push_back( argv[i] ) ;
00032 }
00033 int nFiles = argc-1 ;
00034
00035 LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
00036
00037
00038
00039
00040
00041
00042 lcReader->open( FILEN ) ;
00043
00044
00045 cout << " will open and read from files: " << endl ;
00046 for(int i=0 ; i < nFiles ; i++){
00047 cout << " " << FILEN[i] << endl ;
00048 }
00049
00050 LCRunHeader *runHdr ;
00051
00052
00053
00054 try{
00055
00056
00057 while( ( runHdr = lcReader->readNextRunHeader() ) != 0 ){
00058
00059 LCTOOLS::dumpRunHeader( runHdr ) ;
00060
00061
00062
00063 }
00064
00065 }catch(IOException& e){
00066 cout << " io error when reading run data : " << e.what() << endl ;
00067 }
00068 cout << endl ;
00069
00070 lcReader->close() ;
00071
00072
00073
00074
00075 lcReader->open( FILEN ) ;
00076
00077
00078 cout << " will reopen and read from files: " << endl ;
00079 for(int i=0 ; i < nFiles ; i++){
00080 cout << " " << FILEN[i] << endl ;
00081 }
00082
00083 LCEvent* evt ;
00084 int nEvents = 0 ;
00085
00086
00087 while( (evt = lcReader->readNextEvent()) != 0 ) {
00088
00089 LCTOOLS::dumpEvent( evt ) ;
00090 nEvents ++ ;
00091 }
00092
00093
00094 cout << endl << " " << nEvents << " events read from files: " << endl ;
00095 for(int i=0 ; i < nFiles ; i++){
00096 cout << " " << FILEN[i] << endl ;
00097 }
00098
00099
00100 lcReader->close() ;
00101 delete lcReader ;
00102 return 0 ;
00103 }
00104
00105