/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/EXAMPLE/readcalibration.cc

Go to the documentation of this file.
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 // needed for gcc 4.4
00011 #include <cstdlib>
00012 
00013 static const char* FILEN ;
00014 
00015 //using namespace std ;
00016 using namespace lcio ;
00017 
00018 /** Example program that reads an LCIO file and print all calibration constants
00019  */
00020 
00021 int main(int argc, char** argv ){
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 }
00082 
00083   

Generated on Mon Jan 7 13:15:21 2013 for MicromegasFramework by  doxygen 1.4.7