#include "lcio.h"
#include <stdio.h>
#include "IO/LCReader.h"
#include "IMPL/LCTOOLS.h"
#include "EVENT/LCRunHeader.h"
#include "EVENT/SimCalorimeterHit.h"
#include "EVENT/CalorimeterHit.h"
#include "EVENT/RawCalorimeterHit.h"
#include "UTIL/CellIDDecoder.h"
#include <cstdlib>
Include dependency graph for dumpLcioEvent.cc:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
int main | ( | int | argc, | |
char ** | argv | |||
) |
dump the given event to screen
Definition at line 23 of file dumpLcioEvent.cc.
00023 { 00024 00025 00026 char* FILEN ; 00027 int runNumber=0 ; 00028 int evtNumber=0 ; 00029 int nthEvent=1 ; 00030 00031 // read file name from command line (only argument) 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 00049 00050 00051 00052 00053 if( dumpNthEvent ) { 00054 00055 nthEvent = atoi( argv[2] ) ; 00056 00057 if( nthEvent < 1 ) { 00058 00059 cout << " usage: dumpevent filename n - whith n > 0 ! " << endl ; 00060 00061 exit(1) ; 00062 } 00063 00064 }else{ 00065 00066 runNumber = atoi( argv[2] ) ; 00067 evtNumber = atoi( argv[3] ) ; 00068 } 00069 00070 00071 // set the default encoding for cellid's according to the old Mokka convention 00072 CellIDDecoder<RawCalorimeterHit>::setDefaultEncoding("CHAMBER:4,DIF:4,CHIP:4,CHANNEL:4") ; 00073 00074 LCReader* lcReader ; 00075 if( dumpNthEvent ) 00076 lcReader = LCFactory::getInstance()->createLCReader() ; 00077 else 00078 lcReader = LCFactory::getInstance()->createLCReader(LCReader::directAccess) ; 00079 00080 LCEvent* evt(0) ; 00081 00082 try{ 00083 00084 lcReader->open( FILEN ) ; 00085 00086 if( dumpNthEvent ) { 00087 00088 if( nthEvent > 1 ) 00089 lcReader->skipNEvents( nthEvent - 1 ) ; 00090 00091 evt = lcReader->readNextEvent() ; 00092 00093 }else{ 00094 00095 evt = lcReader->readEvent(runNumber, evtNumber) ; 00096 } 00097 00098 00099 // } catch( EndOfDataException& e) { 00100 // cout << " couldn't find event " << evtNumber << " - run " << runNumber 00101 // << " in file " << FILEN << endl ; 00102 // exit(1) ; 00103 00104 if( !evt ){ 00105 00106 if(dumpNthEvent){ 00107 00108 cout << " less than " << nthEvent << " events in file " << FILEN << endl ; 00109 00110 }else{ 00111 00112 cout << " couldn't find event " << evtNumber << " - run " << runNumber 00113 << " in file " << FILEN << endl ; 00114 } 00115 00116 exit(1) ; 00117 } 00118 00119 LCTOOLS::dumpEventDetailed( evt ) ; 00120 00121 00122 00123 lcReader->close() ; 00124 00125 } 00126 catch( IOException& e) { 00127 cout << e.what() << endl ; 00128 exit(1) ; 00129 } 00130 00131 // catch( Exception& e) { 00132 // cout << e.what() << endl ; 00133 // exit(1) ; 00134 // } 00135 return 0 ; 00136 }