/data3/calcul/jacquem/working_dir/Micromegas/micromegasFrameWork/lcio/src/cpp/src/SIO/SIOSimTrackHitHandler.cc

Go to the documentation of this file.
00001 #include "SIO/SIOSimTrackHitHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/MCParticle.h"
00006 #include "EVENT/SimTrackerHit.h"
00007 #include "IOIMPL/SimTrackerHitIOImpl.h"
00008 
00009 #include "SIO_functions.h"
00010 #include "SIO_block.h"
00011 
00012 #include "EVENT/LCIO.h"
00013 #include "IMPL/LCFlagImpl.h"
00014 
00015 using namespace EVENT ;
00016 using namespace IMPL ;
00017 using namespace IOIMPL ;
00018 
00019 
00020 namespace SIO{
00021     
00022   unsigned int SIOSimTrackHitHandler::read(SIO_stream* stream, 
00023                                       LCObject** objP){
00024     unsigned int status ; 
00025         
00026     // create a new object :
00027     SimTrackerHitIOImpl* hit  = new SimTrackerHitIOImpl ;
00028     *objP = hit ;
00029         
00030     SIO_DATA( stream ,  &(hit->_cellID) , 1  ) ;
00031     SIO_DATA( stream ,    hit->_pos  , 3 ) ;
00032 
00033     //SIO_DATA( stream ,  &(hit->_dEdx) , 1  ) ;
00034     SIO_DATA( stream ,  &(hit->_EDep) , 1  ) ;
00035 
00036     SIO_DATA( stream ,  &(hit->_time) , 1  ) ;
00037 
00038     SIO_PNTR( stream , &(hit->_particle)  ) ;
00039 
00040     if( LCFlagImpl(_flag).bitSet( LCIO::THBIT_MOMENTUM ) ){
00041       SIO_DATA( stream ,    hit->_p  , 3 ) ;
00042       if( _vers  > SIO_VERSION_ENCODE( 1 , 6 ) ) 
00043         SIO_DATA( stream ,    &(hit->_pathLength)  , 1 ) ;
00044     }
00045 
00046     // read the pointer tag in case we want to point to hits
00047     if( _vers > SIO_VERSION_ENCODE( 1, 0) ) {
00048       SIO_PTAG( stream , dynamic_cast<const SimTrackerHit*>(hit) ) ;
00049     }
00050         
00051     return ( SIO_BLOCK_SUCCESS ) ;
00052         
00053   }
00054     
00055     
00056   unsigned int SIOSimTrackHitHandler::write(SIO_stream* stream, 
00057                                        const LCObject* obj){
00058     
00059     unsigned int status ; 
00060     // fg 20030609 changed to use SimTrackerHit
00061     
00062     // this is where we gave up type safety in order to
00063     // simplify the API and the implementation
00064     // by having a common collection of objects
00065     const SimTrackerHit* hit = dynamic_cast<const SimTrackerHit*>(obj)  ;
00066 
00067     LCSIO_WRITE( stream, hit->getCellID()  ) ;
00068     // as SIO doesn't provide a write function with const arguments
00069     // we have to cast away the constness 
00070     double* pos = const_cast<double*> ( hit->getPosition() ) ; 
00071     SIO_DATA( stream,  pos , 3 ) ;
00072     LCSIO_WRITE( stream, hit->getEDep()  ) ;
00073     LCSIO_WRITE( stream, hit->getTime()  ) ;
00074     
00075     const MCParticle* part = hit->getMCParticle()  ;
00076     SIO_PNTR( stream , &part ) ;
00077 
00078     if( LCFlagImpl(_flag).bitSet( LCIO::THBIT_MOMENTUM ) ){
00079       float* p = const_cast<float*> ( hit->getMomentum() ) ; 
00080       SIO_DATA( stream , p  , 3 ) ;
00081       LCSIO_WRITE( stream , hit->getPathLength() ) ;
00082     }
00083 
00084     // write a ptag in order to be able to point to tracker hits - from v1.1
00085     SIO_PTAG( stream , hit ) ;
00086 
00087     return ( SIO_BLOCK_SUCCESS ) ;
00088     
00089   }
00090   
00091 } // namespace

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