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

Go to the documentation of this file.
00001 #include "SIO/SIOTrackerDataHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/TrackerData.h"
00006 #include "EVENT/LCIO.h"
00007 #include "IMPL/LCFlagImpl.h"
00008 #include "IOIMPL/TrackerDataIOImpl.h"
00009 
00010 #include "SIO_functions.h"
00011 #include "SIO_block.h"
00012 
00013 
00014 using namespace EVENT ;
00015 using namespace IMPL ;
00016 using namespace IOIMPL ;
00017 
00018 
00019 namespace SIO{
00020     
00021   unsigned int SIOTrackerDataHandler::read(SIO_stream* stream, 
00022                                       LCObject** objP){
00023     unsigned int status ; 
00024         
00025     // create a new object :
00026     TrackerDataIOImpl* hit  = new TrackerDataIOImpl ;
00027     *objP = hit ;
00028     
00029     SIO_DATA( stream ,  &(hit->_cellID0) , 1  ) ;
00030     
00031     LCFlagImpl lcFlag(_flag) ;
00032     
00033     if( lcFlag.bitSet( LCIO::TRAWBIT_ID1 ) )
00034       SIO_DATA( stream ,  &(hit->_cellID1) , 1  ) ;
00035     
00036     SIO_DATA( stream ,  &(hit->_time) , 1  ) ;
00037     
00038     int chargeSize ;
00039     SIO_DATA( stream ,  &chargeSize  , 1 ) ;
00040     
00041     hit->_charge.resize( chargeSize  ) ;
00042 
00043     SIO_DATA( stream ,  &(hit->_charge[0])  , chargeSize  ) ;
00044 
00045     
00046     SIO_PTAG( stream , dynamic_cast<const TrackerData*>(hit) ) ;
00047 
00048     return ( SIO_BLOCK_SUCCESS ) ;
00049   }
00050     
00051     
00052   unsigned int SIOTrackerDataHandler::write(SIO_stream* stream, 
00053                                        const LCObject* obj){
00054     
00055     unsigned int status ; 
00056 
00057     const TrackerData* hit = dynamic_cast<const TrackerData*>(obj)  ;
00058 
00059     
00060     LCSIO_WRITE( stream, hit->getCellID0()  ) ;
00061       
00062     LCFlagImpl lcFlag(_flag) ;
00063     if( lcFlag.bitSet( LCIO::TRAWBIT_ID1 ) )
00064       LCSIO_WRITE( stream, hit->getCellID1()  ) ;
00065     
00066 
00067     LCSIO_WRITE( stream, hit->getTime()  ) ;
00068 
00069     const FloatVec& v =  hit->getChargeValues() ;
00070     LCSIO_WRITE( stream, v.size()  ) ;
00071     
00072     float* v0 =  const_cast<float*> ( & v[0]  ) ; 
00073     SIO_DATA( stream ,  v0 , v.size() ) ;
00074 
00075     SIO_PTAG( stream , hit ) ;
00076     
00077     return ( SIO_BLOCK_SUCCESS ) ;
00078   }
00079   
00080 } // namespace

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