/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/EXAMPLE/dumpevent.cc File Reference

#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 dumpevent.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

dump the given event to screen

Definition at line 23 of file dumpevent.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   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   // set the default encoding for cellid's according to the old Mokka convention
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      //   } catch( EndOfDataException& e) {
00097      //     cout << " couldn't find event " << evtNumber << " - run " << runNumber 
00098      //          << " in file " << FILEN << endl ;    
00099      //     exit(1) ;
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 //    catch( Exception& e) {
00128 //      cout << e.what() << endl ;
00129 //      exit(1) ;
00130 //    }
00131    return 0 ;
00132 }


Generated on Mon Jan 7 13:16:40 2013 for MicromegasFramework by  doxygen 1.4.7