LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIOTrackerDataHandler.cc
Go to the documentation of this file.
2 
3 // -- lcio headers
4 #include "EVENT/TrackerData.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::TRACKERDATA ) {
17  /* nop */
18  }
19 
20  //----------------------------------------------------------------------------
21 
22  void SIOTrackerDataHandler::read( sio::read_device& device, EVENT::LCObject* objP, sio::version_type /*vers*/ ) {
23  auto hit = dynamic_cast<IOIMPL::TrackerDataIOImpl*>( 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_SDATA( device , hit->_charge ) ;
31  SIO_PTAG( device , dynamic_cast<const EVENT::TrackerData*>(hit) ) ;
32  }
33 
34  //----------------------------------------------------------------------------
35 
36  void SIOTrackerDataHandler::write( sio::write_device& device, const EVENT::LCObject* obj ) {
37  auto hit = dynamic_cast<const EVENT::TrackerData*>(obj) ;
38  SIO_SDATA( device, hit->getCellID0() ) ;
39  IMPL::LCFlagImpl lcFlag(_flag) ;
40  if( lcFlag.bitSet( EVENT::LCIO::TRAWBIT_ID1 ) ) {
41  SIO_SDATA( device, hit->getCellID1() ) ;
42  }
43  SIO_SDATA( device, hit->getTime() ) ;
44  SIO_SDATA( device, hit->getChargeValues() ) ;
45  SIO_PTAG( device , hit ) ;
46  }
47 
48  //----------------------------------------------------------------------------
49 
51  return new IOIMPL::TrackerDataIOImpl() ;
52  }
53 
54 } // 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 read(sio::read_device &device, EVENT::LCObject *objP, sio::version_type vers) override
Reads lcio objects from an SIO stream.
Interface for all lcio object SIO-handlers, has to be implemented for all event entities (hits...
TrackerData contains the corrected (calibrated) raw tracker data.
Definition: TrackerData.h:23
unsigned int _flag
The collection flag.
Implementation of helper class to create and interpret the 32-bit flag word in LCCollections.
Definition: LCFlagImpl.h:15
Adding stuff needed for io (friend declarations, etc.)
EVENT::LCObject * create() const override
Factory method to create an object of the type of the collection.
void write(sio::write_device &device, const EVENT::LCObject *obj) override
Writes lcio objects to an SIO stream.