LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIOTrackerHitPlaneHandler.cc
Go to the documentation of this file.
2 
3 // -- lcio headers
4 #include "EVENT/LCIO.h"
5 #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::TRACKERHITPLANE ) {
17  /* nop */
18  }
19 
20  //----------------------------------------------------------------------------
21 
22  void SIOTrackerHitPlaneHandler::read( sio::read_device& device, EVENT::LCObject* objP, sio::version_type vers ) {
23  auto hit = dynamic_cast<IOIMPL::TrackerHitPlaneIOImpl*>(objP) ;
24  IMPL::LCFlagImpl lcFlag(_flag) ;
25  if( vers > SIO_VERSION_ENCODE( 1, 51) ) {
26  SIO_DATA( device , &(hit->_cellID0) , 1 ) ;
27  if( lcFlag.bitSet( EVENT::LCIO::RTHPBIT_ID1 ) ){
28  SIO_DATA( device , &(hit->_cellID1) , 1 ) ;
29  }
30  }
31  SIO_DATA( device, &(hit->_type) , 1 ) ;
32  SIO_DATA( device, hit->_pos , 3 ) ;
33  SIO_DATA( device, hit->_u , 2 ) ;
34  SIO_DATA( device, hit->_v , 2 ) ;
35  SIO_DATA( device, &(hit->_du) , 1 ) ;
36  SIO_DATA( device, &(hit->_dv) , 1 ) ;
37  SIO_DATA( device, &(hit->_EDep) , 1 ) ;
38  SIO_DATA( device, &(hit->_EDepError) , 1 ) ;
39  SIO_DATA( device, &(hit->_time) , 1 ) ;
40  SIO_DATA( device, &(hit->_quality) , 1 ) ;
41  int numberOfRawHits = 1 ;
42  SIO_DATA( device , &numberOfRawHits , 1 ) ;
43  hit->_rawHits.resize( numberOfRawHits ) ;
44  for( int i=0 ; i<numberOfRawHits ; i++ ) {
45  SIO_PNTR( device , &(hit->_rawHits[i] ) ) ;
46  }
47  SIO_PTAG( device , dynamic_cast<const EVENT::TrackerHitPlane*>(hit) ) ;
48  }
49 
50  //----------------------------------------------------------------------------
51 
52  void SIOTrackerHitPlaneHandler::write( sio::write_device& device, const EVENT::LCObject* obj ) {
53  auto hit = dynamic_cast<const EVENT::TrackerHitPlane*>(obj) ;
54  IMPL::LCFlagImpl lcFlag(_flag) ;
55  SIO_SDATA( device, hit->getCellID0() ) ;
56  if( lcFlag.bitSet( EVENT::LCIO::RTHPBIT_ID1 ) ){
57  SIO_SDATA( device, hit->getCellID1() ) ;
58  }
59  SIO_SDATA( device , hit->getType() ) ;
60  SIO_DATA( device, hit->getPosition() , 3 ) ;
61  SIO_DATA( device, hit->getU() , 2 ) ;
62  SIO_DATA( device, hit->getV() , 2 ) ;
63  SIO_SDATA( device, hit->getdU() ) ;
64  SIO_SDATA( device, hit->getdV() ) ;
65  SIO_SDATA( device, hit->getEDep() ) ;
66  SIO_SDATA( device, hit->getEDepError() ) ;
67  SIO_SDATA( device, hit->getTime() ) ;
68  SIO_SDATA( device, hit->getQuality() ) ;
69  const EVENT::LCObjectVec& rawHits = hit->getRawHits() ;
70  int nrawhits = rawHits.size() ;
71  SIO_SDATA( device, nrawhits ) ;
72  for(unsigned int i=0; i < rawHits.size() ; i++){
73  SIO_PNTR( device , &(rawHits[i]) ) ;
74  }
75  SIO_PTAG( device , hit ) ;
76  }
77 
78  //----------------------------------------------------------------------------
79 
81  return new IOIMPL::TrackerHitPlaneIOImpl() ;
82  }
83 
84 } // namespace
The generic object that is held in an LCCollection.
Definition: LCObject.h:30
void read(sio::read_device &device, EVENT::LCObject *objP, sio::version_type vers) override
Reads lcio objects from an SIO stream.
virtual bool bitSet(int index) const
Returns true if bit at given index is set.
Definition: LCFlagImpl.cc:13
Adding stuff needed for io (friend declarations, etc.)
A tracker hit on a planar surface - the hit is stored as: x,y,z, u(theta, phi), v(theta,phi), du, dv where (x,y,z) is the position in global cartesian coordinates, u,v are the the meassurement directions (unit vectors, spanning the plane) and du,dv are the measurement errors along these directions.
Interface for all lcio object SIO-handlers, has to be implemented for all event entities (hits...
EVENT::LCObject * create() const override
Factory method to create an object of the type of the collection.
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
T size(T...args)
void write(sio::write_device &device, const EVENT::LCObject *obj) override
Writes lcio objects to an SIO stream.