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

Go to the documentation of this file.
00001 #include "SIO/SIOTPCHitHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/TPCHit.h"
00006 #include "EVENT/LCIO.h"
00007 #include "IMPL/LCFlagImpl.h"
00008 #include "IOIMPL/TPCHitIOImpl.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 SIOTPCHitHandler::read(SIO_stream* stream, 
00022                                       LCObject** objP){
00023     unsigned int status ; 
00024         
00025     // create a new object :
00026     TPCHitIOImpl* hit  = new TPCHitIOImpl ;
00027     *objP = hit ;
00028         
00029     SIO_DATA( stream ,  &(hit->_cellID) , 1  ) ;
00030     SIO_DATA( stream ,  &(hit->_time) , 1  ) ;
00031     SIO_DATA( stream ,  &(hit->_charge) , 1  ) ;
00032     SIO_DATA( stream ,  &(hit->_quality) , 1  ) ;
00033 
00034     if( LCFlagImpl(_flag).bitSet( LCIO::TPCBIT_RAW ) ){
00035 
00036       SIO_DATA( stream ,  &(hit->_rawSize)  , 1 ) ;
00037 
00038       hit->initRawArray( hit->_rawSize ) ; // reserve enough space for raw data
00039 
00040       SIO_DATA( stream ,  hit->_rawArray  , hit->_rawSize  ) ;
00041 
00042     }
00043 
00044     // read a pointer tag for reference to TPC hits from generic hits
00045 
00046     if( _vers > SIO_VERSION_ENCODE( 1, 2) ){    // the logic of the pointer bit has been inverted in v1.3
00047       
00048       if( ! LCFlagImpl(_flag).bitSet( LCIO::TPCBIT_NO_PTR )  )
00049         SIO_PTAG( stream , dynamic_cast<const TPCHit*>(hit) ) ;
00050       
00051     }else{
00052       
00053       if( LCFlagImpl(_flag).bitSet( LCIO::TPCBIT_NO_PTR )  )    
00054         SIO_PTAG( stream , dynamic_cast<const TPCHit*>(hit) ) ;
00055       
00056     }
00057     
00058     return ( SIO_BLOCK_SUCCESS ) ;
00059   }
00060     
00061     
00062   unsigned int SIOTPCHitHandler::write(SIO_stream* stream, 
00063                                        const LCObject* obj){
00064     
00065     unsigned int status ; 
00066 
00067     const TPCHit* hit = dynamic_cast<const TPCHit*>(obj)  ;
00068 
00069     LCSIO_WRITE( stream, hit->getCellID()  ) ;
00070     LCSIO_WRITE( stream, hit->getTime()  ) ;
00071     LCSIO_WRITE( stream, hit->getCharge()  ) ;
00072     LCSIO_WRITE( stream, hit->getQuality()  ) ;
00073 
00074     if( LCFlagImpl(_flag).bitSet( LCIO::TPCBIT_RAW ) ){
00075       
00076       LCSIO_WRITE( stream, hit->getNRawDataWords()  ) ;
00077 
00078       for(int i=0;i<hit->getNRawDataWords();i++){
00079         LCSIO_WRITE( stream, hit->getRawDataWord(i)  ) ;
00080       }
00081     }
00082 
00083     //  add a pointer tag for reference to TPC hits from generic hits
00084     if( ! LCFlagImpl(_flag).bitSet( LCIO::TPCBIT_NO_PTR ) ){
00085       SIO_PTAG( stream , hit ) ;
00086     }
00087     
00088     return ( SIO_BLOCK_SUCCESS ) ;
00089   }
00090   
00091 } // namespace

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