#include "lcio.h"
#include "IO/LCReader.h"
#include "UTIL/LCTOOLS.h"
#include "EVENT/LCRunHeader.h"
#include "EVENT/LCCollection.h"
#include "CalibrationConstant.h"
#include <cstdlib>
Include dependency graph for readcalibration.cc:
Go to the source code of this file.
Functions | |
int | main (int argc, char **argv) |
Variables | |
static const char * | FILEN |
int main | ( | int | argc, | |
char ** | argv | |||
) |
Example program that reads an LCIO file and print all calibration constants
Definition at line 21 of file readcalibration.cc.
00021 { 00022 00023 // read file names from command line (only argument) 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 //----------- the event loop ----------- 00039 while( (evt = lcReader->readNextEvent()) != 0 ) { 00040 00041 // loop over collections and check if we have objects of user defined 00042 // type "CalibrationConstant" 00043 // NB: this is only needed if you don't know the name of the collection 00044 // that holds the calibration constants 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 // now print the calibration constants 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 // -------- end of event loop ----------- 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 }
const char* FILEN [static] |
Definition at line 13 of file readcalibration.cc.