LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIOTrackerPulseHandler.cc
Go to the documentation of this file.
2 
3 // -- lcio headers
4 #include "EVENT/TrackerPulse.h"
5 #include "EVENT/LCIO.h"
6 #include "IMPL/LCFlagImpl.h"
8 
9 // -- sio headers
10 #include <sio/io_device.h>
11 #include <sio/version.h>
12 
13 namespace SIO {
14 
16  SIOObjectHandler( EVENT::LCIO::TRACKERPULSE ) {
17  /* nop */
18  }
19 
20  //----------------------------------------------------------------------------
21 
22  void SIOTrackerPulseHandler::read( sio::read_device& device, EVENT::LCObject* objP, sio::version_type vers ) {
23  auto hit = dynamic_cast<IOIMPL::TrackerPulseIOImpl*>(objP) ;
24  SIO_DATA( device , &(hit->_cellID0) , 1 ) ;
25  IMPL::LCFlagImpl lcFlag(_flag) ;
26  if( lcFlag.bitSet( EVENT::LCIO::TRAWBIT_ID1 ) ) {
27  SIO_DATA( device , &(hit->_cellID1) , 1 ) ;
28  }
29  SIO_DATA( device , &(hit->_time) , 1 ) ;
30  SIO_DATA( device , &(hit->_charge ) , 1 ) ;
31  if( vers > SIO_VERSION_ENCODE( 1, 12 ) ) {
32  if( lcFlag.bitSet( EVENT::LCIO::TRAWBIT_CM ) ) {
33  float cov[TRKPULSENCOVMATRIX] ;
34  SIO_DATA( device , cov , TRKPULSENCOVMATRIX ) ;
35  hit->setCovMatrix( cov ) ;
36  }
37  }
38  SIO_DATA( device , &(hit->_quality ) , 1 ) ;
39  SIO_PNTR( device , &(hit->_corrData) ) ;
40  SIO_PTAG( device , dynamic_cast<const EVENT::TrackerPulse*>(hit) ) ;
41  }
42 
43  //----------------------------------------------------------------------------
44 
45  void SIOTrackerPulseHandler::write( sio::write_device& device, const EVENT::LCObject* obj ) {
46  auto hit = dynamic_cast<const EVENT::TrackerPulse*>(obj) ;
47  SIO_SDATA( device, hit->getCellID0() ) ;
48  IMPL::LCFlagImpl lcFlag(_flag) ;
49  if( lcFlag.bitSet( EVENT::LCIO::TRAWBIT_ID1 ) ) {
50  SIO_SDATA( device, hit->getCellID1() ) ;
51  }
52  SIO_SDATA( device, hit->getTime() ) ;
53  SIO_SDATA( device, hit->getCharge() ) ;
54  if( lcFlag.bitSet( EVENT::LCIO::TRAWBIT_CM ) ) {
55  auto cov = hit->getCovMatrix() ;
56  for(unsigned int i=0; i<cov.size(); i++){
57  SIO_SDATA( device, cov[i] ) ;
58  }
59  }
60  SIO_SDATA( device, hit->getQuality() ) ;
61  auto corr = hit->getTrackerData() ;
62  SIO_PNTR( device , & corr );
63  SIO_PTAG( device , hit ) ;
64  }
65 
66  //----------------------------------------------------------------------------
67 
69  return new IOIMPL::TrackerPulseIOImpl() ;
70  }
71 
72 } // namespace
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
virtual bool bitSet(int index) const
Returns true if bit at given index is set.
Definition: LCFlagImpl.cc:13
void write(sio::write_device &device, const EVENT::LCObject *obj) override
Writes lcio objects to an SIO stream.
void read(sio::read_device &device, EVENT::LCObject *objP, sio::version_type vers) override
Reads lcio objects from an SIO stream.
#define TRKPULSENCOVMATRIX
Interface for all lcio object SIO-handlers, has to be implemented for all event entities (hits...
unsigned int _flag
The collection flag.
Tracker pulses as computed from TrackerData objects or as directly measured by a specific subdetector...
Definition: TrackerPulse.h:26
Adding stuff needed for io (friend declarations, etc.)
Implementation of helper class to create and interpret the 32-bit flag word in LCCollections.
Definition: LCFlagImpl.h:15
EVENT::LCObject * create() const override
Factory method to create an object of the type of the collection.