LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIORawCalHitHandler.cc
Go to the documentation of this file.
2 
3 // -- lcio headers
4 #include "EVENT/LCIO.h"
7 #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::RAWCALORIMETERHIT ) {
17  /* nop */
18  }
19 
20  //----------------------------------------------------------------------------
21 
22  void SIORawCalHitHandler::read( sio::read_device& device, EVENT::LCObject* objP, sio::version_type vers ) {
23  auto hit = dynamic_cast<IOIMPL::RawCalorimeterHitIOImpl*>( objP ) ;
24  IMPL::LCFlagImpl lcFlag(_flag) ;
25  SIO_DATA( device , &(hit->_cellID0) , 1 ) ;
26  if( lcFlag.bitSet( EVENT::LCIO::RCHBIT_ID1 ) || vers == SIO_VERSION_ENCODE( 0, 8 ) ) { // in v00-08 cellid1 has been stored by default
27  SIO_DATA( device , &(hit->_cellID1) , 1 ) ;
28  }
29  SIO_DATA( device , &(hit->_amplitude) , 1 ) ;
30  if( lcFlag.bitSet( EVENT::LCIO::RCHBIT_TIME ) ){
31  SIO_DATA( device , &(hit->_timeStamp) , 1 ) ;
32  }
33  if( ! lcFlag.bitSet( EVENT::LCIO::RCHBIT_NO_PTR ) ) {
34  SIO_PTAG( device , dynamic_cast<const EVENT::RawCalorimeterHit*>(hit) ) ;
35  }
36  }
37 
38  //----------------------------------------------------------------------------
39 
40  void SIORawCalHitHandler::write( sio::write_device& device, const EVENT::LCObject* obj ) {
41  auto hit = dynamic_cast<const EVENT::RawCalorimeterHit*>(obj) ;
42  SIO_SDATA( device, hit->getCellID0() ) ;
43  IMPL::LCFlagImpl lcFlag(_flag) ;
44  if( lcFlag.bitSet( EVENT::LCIO::RCHBIT_ID1 ) ){
45  SIO_SDATA( device, hit->getCellID1() ) ;
46  }
47  SIO_SDATA( device, hit->getAmplitude() ) ;
48  if( lcFlag.bitSet( EVENT::LCIO::RCHBIT_TIME ) ){
49  SIO_SDATA( device, hit->getTimeStamp() ) ;
50  }
51  if( ! lcFlag.bitSet( EVENT::LCIO::RCHBIT_NO_PTR ) ){
52  SIO_PTAG( device , hit ) ;
53  }
54  }
55 
56  //----------------------------------------------------------------------------
57 
59  return new IOIMPL::RawCalorimeterHitIOImpl() ;
60  }
61 
62 } // 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.
Interface for all lcio object SIO-handlers, has to be implemented for all event entities (hits...
unsigned int _flag
The collection flag.
Adding stuff needed for io (friend declarations, etc.)
void read(sio::read_device &device, EVENT::LCObject *objP, sio::version_type vers) override
Reads lcio objects from an SIO stream.
Implementation of helper class to create and interpret the 32-bit flag word in LCCollections.
Definition: LCFlagImpl.h:15
The generic calorimeter hit for real data (or simulation thereof).
EVENT::LCObject * create() const override
Factory method to create an object of the type of the collection.