00001 #include "lcio.h"
00002 #include <stdio.h>
00003
00004 #include "IO/LCReader.h"
00005 #include "IMPL/LCTOOLS.h"
00006 #include "EVENT/LCRunHeader.h"
00007
00008 #include "EVENT/SimCalorimeterHit.h"
00009 #include "EVENT/CalorimeterHit.h"
00010 #include "EVENT/RawCalorimeterHit.h"
00011
00012
00013 #include "UTIL/CellIDDecoder.h"
00014
00015 #include <cstdlib>
00016
00017 using namespace std ;
00018 using namespace lcio ;
00019
00020
00021
00022
00023 int main(int argc, char** argv ){
00024
00025
00026 char* FILEN ;
00027 int runNumber=0 ;
00028 int evtNumber=0 ;
00029 int nthEvent=1 ;
00030
00031
00032 if( argc < 3 ) {
00033
00034 cout << " usage: dumpevent filename runNum evtNum " << endl ;
00035 cout << " or: dumpevent filename n " << endl ;
00036 cout << " where the first dumps the event with the specified run and event number" << endl ;
00037 cout << " and the second simply dumps the n-th event in the file" << endl ;
00038
00039 exit(1) ;
00040 }
00041
00042 FILEN = argv[1] ;
00043
00044 bool dumpNthEvent( argc == 3 ) ;
00045
00046
00047
00048 if( dumpNthEvent ) {
00049
00050 nthEvent = atoi( argv[2] ) ;
00051
00052 if( nthEvent < 1 ) {
00053
00054 cout << " usage: dumpevent filename n - whith n > 0 ! " << endl ;
00055
00056 exit(1) ;
00057 }
00058
00059 }else{
00060
00061 runNumber = atoi( argv[2] ) ;
00062 evtNumber = atoi( argv[3] ) ;
00063 }
00064
00065
00066
00067 CellIDDecoder<SimCalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
00068 CellIDDecoder<CalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
00069 CellIDDecoder<RawCalorimeterHit>::setDefaultEncoding("M:3,S-1:3,I:9,J:9,K-1:6") ;
00070
00071 LCReader* lcReader ;
00072 if( dumpNthEvent )
00073 lcReader = LCFactory::getInstance()->createLCReader() ;
00074 else
00075 lcReader = LCFactory::getInstance()->createLCReader(LCReader::directAccess) ;
00076
00077 LCEvent* evt(0) ;
00078
00079 try{
00080
00081 lcReader->open( FILEN ) ;
00082
00083 if( dumpNthEvent ) {
00084
00085 if( nthEvent > 1 )
00086 lcReader->skipNEvents( nthEvent - 1 ) ;
00087
00088 evt = lcReader->readNextEvent() ;
00089
00090 }else{
00091
00092 evt = lcReader->readEvent(runNumber, evtNumber) ;
00093 }
00094
00095
00096
00097
00098
00099
00100
00101 if( !evt ){
00102
00103 if(dumpNthEvent){
00104
00105 cout << " less than " << nthEvent << " events in file " << FILEN << endl ;
00106
00107 }else{
00108
00109 cout << " couldn't find event " << evtNumber << " - run " << runNumber
00110 << " in file " << FILEN << endl ;
00111 }
00112
00113 exit(1) ;
00114 }
00115
00116 LCTOOLS::dumpEventDetailed( evt ) ;
00117
00118
00119 lcReader->close() ;
00120
00121 }
00122 catch( IOException& e) {
00123 cout << e.what() << endl ;
00124 exit(1) ;
00125 }
00126
00127
00128
00129
00130
00131 return 0 ;
00132 }
00133