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

Go to the documentation of this file.
00001 #include "SIO/SIOTrackerHitHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/MCParticle.h"
00006 #include "EVENT/TrackerHit.h"
00007 #include "IOIMPL/TrackerHitIOImpl.h"
00008 
00009 #include "SIO_functions.h"
00010 #include "SIO_block.h"
00011 
00012 
00013 using namespace EVENT ;
00014 using namespace IMPL ;
00015 using namespace IOIMPL ;
00016 
00017 
00018 namespace SIO{
00019 
00020     unsigned int SIOTrackerHitHandler::read(SIO_stream* stream, 
00021             LCObject** objP){
00022         unsigned int status ; 
00023 
00024         // create a new object :
00025         TrackerHitIOImpl* hit  = new TrackerHitIOImpl ;
00026         *objP = hit ;
00027 
00028         if( _vers > SIO_VERSION_ENCODE( 1, 2)   ){
00029             SIO_DATA( stream ,  &(hit->_type) , 1  ) ;
00030         } 
00031 
00032         SIO_DATA( stream ,    hit->_pos  , 3 ) ;
00033 
00034         float cov[TRKHITNCOVMATRIX] ;
00035         SIO_DATA( stream ,  cov  ,  TRKHITNCOVMATRIX ) ;
00036         hit->setCovMatrix( cov ) ;
00037 
00038         //SIO_DATA( stream ,  &(hit->_dEdx) , 1  ) ;
00039         SIO_DATA( stream ,  &(hit->_EDep) , 1  ) ;
00040 
00041         if( _vers > SIO_VERSION_ENCODE( 1, 12 )   ){
00042             SIO_DATA( stream ,  &(hit->_EDepError) , 1  ) ;
00043         }
00044 
00045         SIO_DATA( stream ,  &(hit->_time) , 1  ) ;
00046 
00047         if( _vers > SIO_VERSION_ENCODE( 1, 11 )   )
00048             SIO_DATA( stream ,  &(hit->_quality) , 1  ) ;
00049 
00050 
00051         // rawHits
00052         int numberOfRawHits = 1 ; 
00053         if( _vers > SIO_VERSION_ENCODE( 1, 2)   ){
00054             SIO_DATA( stream ,  &numberOfRawHits , 1  ) ;
00055         }
00056 
00057         hit->_rawHits.resize( numberOfRawHits ) ;
00058 
00059         for(int i=0;i<numberOfRawHits;i++){
00060             SIO_PNTR( stream , &(hit->_rawHits[i] ) ) ;
00061         }
00062 
00063         SIO_PTAG( stream , dynamic_cast<const TrackerHit*>(hit) ) ;
00064 
00065         return ( SIO_BLOCK_SUCCESS ) ;
00066 
00067     }
00068 
00069 
00070     unsigned int SIOTrackerHitHandler::write(SIO_stream* stream, 
00071             const LCObject* obj){
00072 
00073         unsigned int status ; 
00074 
00075         const TrackerHit* hit = dynamic_cast<const TrackerHit*>(obj)  ;
00076 
00077         LCSIO_WRITE( stream ,  hit->getType() ) ;
00078 
00079         // as SIO doesn't provide a write function with const arguments
00080         // we have to cast away the constness 
00081         double* pos = const_cast<double*> ( hit->getPosition() ) ; 
00082         SIO_DATA( stream,  pos , 3 ) ;
00083 
00084         const FloatVec& cov = hit->getCovMatrix() ;
00085         for(unsigned int i=0;i<cov.size();i++){
00086             LCSIO_WRITE( stream, cov[i]  ) ;
00087         }
00088 
00089         //LCSIO_WRITE( stream, hit->getdEdx()  ) ;
00090         LCSIO_WRITE( stream, hit->getEDep()  ) ;
00091         LCSIO_WRITE( stream, hit->getEDepError()  ) ;
00092         LCSIO_WRITE( stream, hit->getTime()  ) ;
00093         LCSIO_WRITE( stream, hit->getQuality()  ) ;
00094 
00095         //     const LCObject* raw = hit->getRawDataHit()  ;
00096         //     SIO_PNTR( stream , &raw ) ;
00097 
00098         const EVENT::LCObjectVec& rawHits = hit->getRawHits() ;
00099 
00100 
00101         LCSIO_WRITE( stream, rawHits.size()  ) ;
00102         for(unsigned int i=0; i < rawHits.size() ; i++){
00103             SIO_PNTR( stream , &(rawHits[i]) ) ;
00104         }
00105 
00106         // write a ptag in order to be able to point to tracker hits in the future
00107         SIO_PTAG( stream , hit ) ;
00108 
00109         return ( SIO_BLOCK_SUCCESS ) ;
00110 
00111     }
00112 
00113 } // namespace

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