/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/src/analyse/lcio/lcioTest.cc File Reference

#include "lcio.h"
#include "IO/LCWriter.h"
#include "EVENT/LCIO.h"
#include <EVENT/RawCalorimeterHit.h>
#include "DATA/LCFloatVec.h"
#include "DATA/LCIntVec.h"
#include "IMPL/LCEventImpl.h"
#include "IMPL/LCRunHeaderImpl.h"
#include "IMPL/LCCollectionVec.h"
#include "IMPL/RawCalorimeterHitImpl.h"
#include "IMPL/SimTrackerHitImpl.h"
#include "IMPL/MCParticleImpl.h"
#include "IMPL/LCFlagImpl.h"
#include "IMPL/LCTOOLS.h"
#include "IMPL/TrackerRawDataImpl.h"
#include "IMPL/TrackerDataImpl.h"
#include "IMPL/TrackerPulseImpl.h"
#include "UTIL/LCRelationNavigator.h"
#include "UTIL/LCTime.h"
#include "UTIL/CellIDEncoder.h"
#include "UTIL/CellIDDecoder.h"
#include <UTIL/BitField64.h>
#include "UTIL/LCTypedVector.h"
#include "UTIL/LCSplitWriter.h"
#include "mTypes.h"
#include "geometry/Detector.hh"
#include "event/Run.hh"
#include "geometry/Dif.hh"
#include "geometry/Chip.hh"
#include "geometry/Channel.hh"
#include "tools/SteerDesc.hh"
#include "xml/XMLTool.hh"
#include <cstdlib>
#include <iostream>
#include <sstream>

Include dependency graph for lcioTest.cc:

Go to the source code of this file.

Functions

int main (int argc, char **argv)


Function Documentation

int main ( int  argc,
char **  argv 
)

Simple test program to demonstrate writing of data with lcio.

Definition at line 60 of file lcioTest.cc.

00061 {
00062   if( argc !=2 && argc !=3  )
00063   {
00064     cout <<  endl <<"usage lcioTest slcioFile [xmlFile]" <<endl;        
00065         exit(-1);
00066   }
00067 
00068   bool geometrySet = false;
00069  
00070   // get lcio file name and xmlFile file name from parameters
00071   static string lcioFile = argv[1] ; 
00072 
00073   Detector detector;
00074   if  ( argc == 3 )
00075   {
00076     geometrySet = true;
00077     string steerName;
00078     steerName.assign(argv[2]);
00079 
00080     // test if steer file exist
00081     FILE *file = fopen(steerName.c_str(), "r");
00082     if(file == NULL){
00083       cout << "Steer file ["<< steerName.c_str() << "] does not exist" << endl;
00084       fclose(file);
00085       exit(0);
00086     }
00087   
00088     // create Run, set detector and steerDesc from steer XML file
00089     Run run(detector);
00090     SteerDesc steerDesc;
00091     XMLTool xml;
00092     xml.parse(steerDesc, steerName); // parse steer file and fill steerDesc
00093      // Set detector with xml file content
00094     if ( ! steerDesc.setRun(run))
00095     {
00096       exit(1);
00097     }
00098     fclose(file);
00099     detector.build(steerDesc);
00100   }
00101 
00102 //----------------
00103 
00104         IO::LCReader* lcReader = IOIMPL::LCFactory::getInstance()->createLCReader() ;
00105         lcReader->open( lcioFile ) ;
00106 
00107 
00108         LCEvent* evt = NULL;
00109         //----------- the event loop -----------
00110         while( (evt = lcReader->readNextEvent()) != 0 ) 
00111           {
00112 
00113         cout << endl << endl << endl << " NEW EVENT " << endl;
00114         UTIL::LCTOOLS::dumpEvent( evt ) ;
00115         EVENT::long64 timestamp = evt->getTimeStamp();
00116 
00117         LCTime time(timestamp);
00118         cout << time.getDateString() << endl;
00119 
00120         cout << "Dif synchro: "         << evt->getParameters().getIntVal("Dif_syncro" ) << endl ;
00121         cout << "Temperature:"          << evt->parameters().getFloatVal("Temperature" ) << endl ;
00122         cout << "Pressure:"             << evt->parameters().getFloatVal("Pressure")  << endl;
00123         cout << "globalTriggerCounter:" << evt->parameters().getIntVal("Global trigger counter")  << endl;
00124         cout << "difTriggerCounter:"    << evt->parameters().getIntVal("Dif trigger counter" )    << endl;
00125             
00126             const vector<string>* collNames = evt->getCollectionNames ();
00127         
00128             vector<string>::const_iterator it;
00129         
00130             for ( it = collNames->begin(); it!=collNames->end(); ++it) 
00131               {
00132                 cout << *it << endl;
00133                 LCCollection*  collec = evt->getCollection(*it);
00134                 cout << " collection type:" << collec->getTypeName() << endl;
00135                 for ( int i = 0; i < collec->getNumberOfElements(); i++)
00136                   {
00137                     try 
00138                       {
00139                         RawCalorimeterHit* rawHit = dynamic_cast<RawCalorimeterHit*>(collec->getElementAt(i));  
00140                         //cout << "RawCalorimeterHit[" << rawHit << "]" <<endl;
00141         
00142                     if ( rawHit != NULL )
00143                       {
00144                         CellIDDecoder<RawCalorimeterHit> idDecoder( collec ) ;
00145                         const BitField64& bitField = idDecoder( rawHit );
00146                         
00147                         cout << idDecoder( rawHit ).valueString() << endl;
00148                         lcio::long64  chamberId = bitField["CHAMBER"] ;
00149                         lcio::long64  difId = bitField["DIF"] ;
00150                         lcio::long64  chipId = bitField["CHIP"] ;
00151                         lcio::long64  channelId = bitField["CHANNEL"] ;
00152                         cout << "Chamber[" << chamberId<< "] " ;
00153                         cout << "Dif[" <<difId << "] " ;
00154                         cout << "Chip[" <<chipId << "] "  ;
00155                         cout << "Channel[" << channelId << "]" << endl;
00156                         
00157                         if ( geometrySet )
00158                           {
00159                             Channel &channel = detector.getDifById(difId).getChipById(chipId).getChannelById(channelId);
00160                             cout << " Position[X,Y,Z] = ["  << channel.getX() << ","  << channel.getY() << "," << channel.getZ() << "]" <<  endl;
00161                           }
00162                         
00163                         
00164                       } 
00165                     else { cout << " rawHit == NULL "<< endl; } 
00166                   } catch( Exception& ex)
00167                   {
00168                     cout << " an excpetion occured when trying dynamic_cast<RawCalorimeterHit*>: " << endl ;
00169                     cout << "  " << ex.what() << endl ;
00170                   }
00171               }
00172           }
00173         const LCParameters& params =  evt->getParameters();
00174         }
00175         
00176         lcReader->close() ;
00177         
00178         delete lcReader ;
00179 
00180 
00181 }


Generated on Mon Jan 7 13:17:00 2013 for MicromegasFramework by  doxygen 1.4.7