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

Go to the documentation of this file.
00001 #include "SIO/SIOTrackHandler.h"
00002 
00003 #include "SIO/LCSIO.h"
00004 
00005 #include "EVENT/LCIO.h"
00006 #include "IOIMPL/TrackIOImpl.h"
00007 #include "IMPL/LCFlagImpl.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 SIOTrackHandler::read(SIO_stream* stream, 
00021                                       LCObject** objP){
00022     unsigned int status ; 
00023         
00024 
00025     // create a new object :
00026     TrackIOImpl* trk  = new TrackIOImpl ;
00027     *objP = trk ;
00028         
00029 //     SIO_DATA( stream ,  &(trk->_type) , 1  ) ;
00030 //     SIO_DATA( stream ,  &(trk->_p)  , 1 ) ;
00031 //     SIO_DATA( stream ,  &(trk->_theta)  , 1 ) ;
00032 //     SIO_DATA( stream ,  &(trk->_phi)  , 1 ) ;
00033 //     SIO_DATA( stream ,  &(trk->_d0)  , 1 ) ;
00034 //     SIO_DATA( stream ,  &(trk->_z0)  , 1 ) ;
00035 
00036 //     char* dummy ; 
00037 //     LCSIO_READ( stream,  &dummy ) ; 
00038 //     trk->setType( dummy ) ;
00039 
00040     int type ;
00041     SIO_DATA( stream ,  &type  , 1 ) ;
00042     trk->setType( type ) ;  // type is bitset<32> - can't be set directly
00043 
00044     SIO_DATA( stream ,  &(trk->_d0)  , 1 ) ;
00045     SIO_DATA( stream ,  &(trk->_phi)  , 1 ) ;
00046     SIO_DATA( stream ,  &(trk->_omega)  , 1 ) ;
00047     SIO_DATA( stream ,  &(trk->_z0)  , 1 ) ;
00048     SIO_DATA( stream ,  &(trk->_tanLambda)  , 1 ) ;
00049 
00050 
00051     float cov[NCOVMATRIX] ;
00052     SIO_DATA( stream ,  cov  ,  NCOVMATRIX ) ;
00053     trk->setCovMatrix( cov ) ;
00054 
00055     SIO_DATA( stream ,  trk->_reference  , 3 ) ;
00056     //    SIO_DATA( stream ,  &(trk->_isReferencePointPCA )  , 1 ) ;
00057 
00058     SIO_DATA( stream ,  &(trk->_chi2)  , 1 ) ;
00059     SIO_DATA( stream ,  &(trk->_ndf)  , 1 ) ;
00060 
00061     SIO_DATA( stream ,  &(trk->_dEdx) , 1  ) ;
00062     SIO_DATA( stream ,  &(trk->_dEdxError) , 1  ) ;
00063 
00064     SIO_DATA( stream ,  &( trk->_radiusOfInnermostHit ) , 1  ) ;
00065 
00066     int nHitNumbers ;
00067     SIO_DATA( stream, &nHitNumbers , 1  ) ;
00068     trk->subdetectorHitNumbers().resize( nHitNumbers ) ;
00069     
00070     for(int i=0;i<nHitNumbers;i++){
00071       SIO_DATA( stream , &(trk->_subdetectorHitNumbers[i] ), 1 ) ;
00072     }
00073     
00074     int nTracks ;
00075     SIO_DATA( stream, &nTracks , 1  ) ;
00076 
00077     // fill the vector to have correct size
00078     // as we are using the addresses of the elements henceforth
00079     trk->_tracks.resize( nTracks ) ;
00080 //     for(int i=0;i<nTracks;i++){
00081 //       trk->_tracks.push_back( 0 ) ;
00082 //     }
00083     for(int i=0;i<nTracks;i++){
00084       SIO_PNTR( stream , &(trk->_tracks[i] ) ) ;
00085     }
00086 
00087 
00088     if( LCFlagImpl(_flag).bitSet( LCIO::TRBIT_HITS ) ){ 
00089 
00090       int nHits ;
00091       SIO_DATA( stream, &nHits , 1  ) ;
00092       
00093       // fill the vector to have correct size
00094       // as we are using the addresses of the elements henceforth
00095 //       for(int i=0;i<nHits;i++){
00096 //      trk->_hits.push_back( 0 ) ;
00097 //       }
00098       trk->_hits.resize( nHits) ;
00099 
00100       for(int i=0;i<nHits;i++){
00101         SIO_PNTR( stream , &(trk->_hits[i] ) ) ;
00102       }
00103       
00104 //       // hit collections
00105 //       int nHitCol ;
00106 //       SIO_DATA( stream, &nHitCol , 1  ) ;
00107       
00108 //       for(int i=0 ; i< nHitCol ;i++){
00109         
00110 //      char* dummy ; 
00111 //      LCSIO_READ( stream,  &dummy ) ; 
00112 //      trk->_indexMap[ dummy ] = new IntVec ;
00113         
00114 //      int nHits ;
00115 //      SIO_DATA( stream, &nHits , 1  ) ;
00116         
00117 //      int* hitsArray = new int[ nHits ] ;
00118         
00119 //      SIO_DATA( stream, hitsArray ,  nHits ) ;
00120         
00121 //      for( int j=0 ; j< nHits ; j++ ){
00122 //        trk->_indexMap[ dummy ]->push_back(  hitsArray[ j ] ) ;
00123 //      }
00124         
00125 //      delete[] hitsArray ;
00126 //       }
00127     }
00128 
00129     // read the pointer tag 
00130     SIO_PTAG( stream , dynamic_cast<const Track*>(trk) ) ;
00131     return ( SIO_BLOCK_SUCCESS ) ;
00132   }
00133     
00134     
00135   unsigned int SIOTrackHandler::write(SIO_stream* stream, 
00136                                        const LCObject* obj){
00137     
00138     unsigned int status ; 
00139     
00140     // this is where we gave up type safety in order to
00141     // simplify the API and the implementation
00142     // by having a common collection of objects
00143     const Track* trk = dynamic_cast<const Track*>(obj)  ;
00144 
00145 //     LCSIO_WRITE( stream, trk->getType()  ) ;
00146 //     LCSIO_WRITE( stream, trk->getMomentum()  ) ;
00147 //     LCSIO_WRITE( stream, trk->getTheta()  ) ;
00148 //     LCSIO_WRITE( stream, trk->getPhi()  ) ;
00149 //     LCSIO_WRITE( stream, trk->getD0()  ) ;
00150 //     LCSIO_WRITE( stream, trk->getZ0()  ) ;
00151 
00152     LCSIO_WRITE( stream, trk->getType()  ) ;
00153 
00154     LCSIO_WRITE( stream, trk->getD0()  ) ;
00155     LCSIO_WRITE( stream, trk->getPhi()  ) ;
00156     LCSIO_WRITE( stream, trk->getOmega()  ) ;
00157     LCSIO_WRITE( stream, trk->getZ0()  ) ;
00158     LCSIO_WRITE( stream, trk->getTanLambda()  ) ;
00159 
00160     const FloatVec& cov = trk->getCovMatrix() ;
00161     for(unsigned int i=0;i<cov.size();i++){
00162       LCSIO_WRITE( stream, cov[i]  ) ;
00163     }
00164 
00165     float* pos = const_cast<float*> ( trk->getReferencePoint() ) ; 
00166     SIO_DATA( stream,  pos , 3 ) ;
00167 
00168     LCSIO_WRITE( stream, trk->getChi2()  ) ;
00169     LCSIO_WRITE( stream, trk->getNdf()  ) ;
00170     LCSIO_WRITE( stream, trk->getdEdx()  ) ;
00171     LCSIO_WRITE( stream, trk->getdEdxError()  ) ;
00172 
00173     LCSIO_WRITE( stream , trk->getRadiusOfInnermostHit()  ) ;
00174 
00175     const IntVec& hitNums = trk->getSubdetectorHitNumbers() ;
00176     int nHitNumbers = hitNums.size() ;
00177     SIO_DATA( stream, &nHitNumbers , 1  ) ;
00178 
00179     for(int i=0;i<nHitNumbers;i++){
00180       LCSIO_WRITE( stream , hitNums[i]  ) ;
00181     }
00182 
00183     const TrackVec& tracks = trk->getTracks() ;
00184     int nTracks=  tracks.size() ;
00185 
00186     SIO_DATA( stream, &nTracks , 1  ) ;
00187     
00188     for(int i=0;i<nTracks;i++){
00189 //       const Track** _trkP ;
00190 //       _trkP = const_cast<const Track**> ( &(tracks[i]) ) ;
00191 //       SIO_PNTR( stream , _trkP ) ;
00192       SIO_PNTR( stream , &(tracks[i]) ) ;
00193     }
00194 
00195 
00196     if( LCFlagImpl(_flag).bitSet( LCIO::TRBIT_HITS ) ){ 
00197 
00198       const TrackerHitVec& hits = trk->getTrackerHits() ;
00199       int nHits=  hits.size() ;
00200       SIO_DATA( stream, &nHits , 1  ) ;
00201     
00202       for(int i=0;i<nHits;i++){
00203         SIO_PNTR( stream , &(hits[i]) ) ;
00204       }
00205 
00206 
00207 //       const StringVec colNames = trk->getHitCollectionNames() ;
00208 //       int nHitCol =  colNames.size() ;
00209 //       SIO_DATA( stream, &nHitCol , 1  ) ;
00210       
00211 //       for(unsigned int i=0;i<colNames.size();i++){
00212         
00213 //      LCSIO_WRITE( stream, colNames[i]  ) ;
00214         
00215 //      const IntVec& vec = trk->getHitIndicesForCollection( colNames[i]  ) ;
00216 //      int nHits =  vec.size() ;
00217         
00218 //      SIO_DATA( stream, &nHits, 1 ) ;
00219         
00220 //      for( int j=0 ; j<nHits  ; j++ ){
00221 //        LCSIO_WRITE( stream, vec[j]  ) ;
00222 //      }
00223 //       }
00224     }
00225     // write a ptag in order to be able to point to tracks
00226     SIO_PTAG( stream , trk ) ;
00227 
00228     return ( SIO_BLOCK_SUCCESS ) ;
00229     
00230   }
00231   
00232 } // namespace

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