00001 #include "SIO/SIORawCalHitHandler.h"
00002
00003 #include "SIO/LCSIO.h"
00004
00005 #include "EVENT/LCIO.h"
00006 #include "EVENT/MCParticle.h"
00007 #include "EVENT/RawCalorimeterHit.h"
00008 #include "IOIMPL/RawCalorimeterHitIOImpl.h"
00009 #include "IMPL/LCFlagImpl.h"
00010
00011 #include "SIO_functions.h"
00012 #include "SIO_block.h"
00013
00014
00015 using namespace EVENT ;
00016 using namespace IMPL ;
00017 using namespace IOIMPL ;
00018
00019
00020 namespace SIO{
00021
00022 unsigned int SIORawCalHitHandler::read(SIO_stream* stream,
00023 LCObject** objP ){
00024 unsigned int status ;
00025
00026
00027 RawCalorimeterHitIOImpl* hit = new RawCalorimeterHitIOImpl ;
00028 *objP = hit ;
00029
00030 LCFlagImpl lcFlag(_flag) ;
00031
00032 SIO_DATA( stream , &(hit->_cellID0) , 1 ) ;
00033
00034
00035 if( lcFlag.bitSet( LCIO::RCHBIT_ID1 )
00036 || _vers == SIO_VERSION_ENCODE( 0, 8 )
00037 ){
00038 SIO_DATA( stream , &(hit->_cellID1) , 1 ) ;
00039 }
00040
00041 SIO_DATA( stream , &(hit->_amplitude) , 1 ) ;
00042
00043 if( lcFlag.bitSet( LCIO::RCHBIT_TIME ) ){
00044 SIO_DATA( stream , &(hit->_timeStamp) , 1 ) ;
00045 }
00046
00047 if( ! lcFlag.bitSet( LCIO::RCHBIT_NO_PTR ) ) {
00048 SIO_PTAG( stream , dynamic_cast<const RawCalorimeterHit*>(hit) ) ;
00049 }
00050
00051 return ( SIO_BLOCK_SUCCESS ) ;
00052 }
00053
00054
00055 unsigned int SIORawCalHitHandler::write(SIO_stream* stream,
00056 const LCObject* obj ){
00057
00058 unsigned int status ;
00059
00060 const RawCalorimeterHit* hit = dynamic_cast<const RawCalorimeterHit*>(obj) ;
00061
00062 LCSIO_WRITE( stream, hit->getCellID0() ) ;
00063
00064 LCFlagImpl lcFlag(_flag) ;
00065
00066 if( lcFlag.bitSet( LCIO::RCHBIT_ID1 ) ){
00067 LCSIO_WRITE( stream, hit->getCellID1() ) ;
00068 }
00069
00070 LCSIO_WRITE( stream, hit->getAmplitude() ) ;
00071
00072 if( lcFlag.bitSet( LCIO::RCHBIT_TIME ) ){
00073 LCSIO_WRITE( stream, hit->getTimeStamp() ) ;
00074 }
00075
00076 if( ! lcFlag.bitSet( LCIO::RCHBIT_NO_PTR ) ){
00077 SIO_PTAG( stream , hit ) ;
00078 }
00079
00080 return ( SIO_BLOCK_SUCCESS ) ;
00081 }
00082
00083 }