00001 #include "lcio.h"
00002
00003 #include "IO/LCReader.h"
00004 #include "UTIL/LCTOOLS.h"
00005 #include "EVENT/LCRunHeader.h"
00006 #include "EVENT/LCCollection.h"
00007
00008 #include "CalibrationConstant.h"
00009
00010
00011 #include <cstdlib>
00012
00013 static const char* FILEN ;
00014
00015
00016 using namespace lcio ;
00017
00018
00019
00020
00021 int main(int argc, char** argv ){
00022
00023
00024 if( argc != 2) {
00025 std::cout << " usage: readcalibration input-file1" << std::endl ;
00026 exit(1) ;
00027 }
00028
00029 FILEN = argv[1] ;
00030
00031 LCReader* lcReader = LCFactory::getInstance()->createLCReader() ;
00032
00033 lcReader->open( FILEN ) ;
00034
00035 LCEvent* evt ;
00036 int nEvents = 0 ;
00037
00038
00039 while( (evt = lcReader->readNextEvent()) != 0 ) {
00040
00041
00042
00043
00044
00045
00046 const StringVec* colNames = evt->getCollectionNames() ;
00047
00048 for(unsigned int i=0 ; i < colNames->size() ; i++ ){
00049
00050 LCCollection* col = evt->getCollection( (*colNames)[i] ) ;
00051
00052 if( col->getParameters().getStringVal("TypeName") == "CalibrationConstant" ) {
00053
00054
00055
00056 for(int j=0;j<col->getNumberOfElements();j++){
00057
00058 CalibrationConstant cal( col->getElementAt( j ) ) ;
00059
00060 std::cout << " calibration for cellid: " << cal.getCellID()
00061 << " offset: " << cal.getOffset()
00062 << " gain: " << cal.getGain()
00063 << std::endl ;
00064
00065 }
00066
00067 }
00068 }
00069
00070 nEvents ++ ;
00071 }
00072
00073
00074 std::cout << std::endl << " " << nEvents << " events read from file: "
00075 << FILEN << std::endl ;
00076
00077
00078 lcReader->close() ;
00079 delete lcReader ;
00080 return 0 ;
00081 }
00082
00083