LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIORunHeaderHandler.cc
Go to the documentation of this file.
2 #include "SIO/SIOLCParameters.h"
3 #include "SIO/LCSIO.h"
4 
5 #include "EVENT/LCRunHeader.h"
6 #include "EVENT/LCIO.h"
7 
8 // -- sio headers
9 #include <sio/io_device.h>
10 #include <sio/version.h>
11 
12 namespace SIO {
13 
15  sio::block( LCSIO::RunBlockName, LCSIO::blockVersion() ) {
16  /* nop */
17  }
18 
19  //----------------------------------------------------------------------------
20 
22  _runHeader = rh ;
23  }
24 
25  //----------------------------------------------------------------------------
26 
27  void SIORunHeaderHandler::read( sio::read_device &device, sio::version_type vers ) {
28  LCSIO::checkVersion( vers ) ;
29  auto rhdr = dynamic_cast<IMPL::LCRunHeaderImpl*>( _runHeader ) ;
30  // run number
31  int rnTmp ;
32  SIO_SDATA( device, rnTmp ) ;
33  rhdr->setRunNumber( rnTmp ) ;
34  // detector name
35  std::string detNameTmp ;
36  SIO_SDATA( device, detNameTmp ) ;
37  rhdr->setDetectorName( detNameTmp ) ;
38  // run description
39  std::string descTmp ;
40  SIO_SDATA( device, descTmp ) ;
41  rhdr->setDescription( descTmp ) ;
42  // active sub detector names
43  int nSDN ;
44  SIO_SDATA( device, nSDN ) ;
45  for( int i=0; i<nSDN ; i++ ) {
46  std::string sdnTmp ;
47  SIO_SDATA( device, sdnTmp ) ;
48  rhdr->addActiveSubdetector( sdnTmp ) ;
49  }
50  // parameters
51  if( vers > SIO_VERSION_ENCODE( 1, 1 ) ) {
52  SIOLCParameters::read( device, rhdr->parameters(), vers ) ;
53  }
54  }
55 
56  //----------------------------------------------------------------------------
57 
58  void SIORunHeaderHandler::write( sio::write_device &device ) {
60  int nSDN = strVec->size() ;
61  SIO_SDATA( device, _runHeader->getRunNumber() ) ;
62  SIO_SDATA( device, _runHeader->getDetectorName() ) ;
63  SIO_SDATA( device, _runHeader->getDescription() ) ;
64  SIO_SDATA( device, nSDN ) ;
65  for( auto detstr : *strVec ) {
66  SIO_SDATA( device, detstr ) ;
67  }
69  }
70 
71 }
static void write(sio::write_device &device, const EVENT::LCParameters &params)
Writes lcio objects to an SIO stream.
virtual const std::string & getDetectorName() const =0
Returns the name of the detector setup used in the simulation.
EVENT::LCRunHeader * _runHeader
Run header for reading/writing.
Interface for the run header.
Definition: LCRunHeader.h:23
static void checkVersion(sio::version_type versionID)
Check for old version of LCIO (&gt; v01-08 ar no longer supported) Throws an exception if not supported...
Definition: LCSIO.cc:10
Collection of constants and helper functions.
Definition: LCSIO.h:16
STL class.
Implementation of LCRunHeader.
virtual int getRunNumber() const =0
Returns the run number.
virtual const LCParameters & getParameters() const =0
Parameters defined for this run.
T size(T...args)
void read(sio::read_device &device, sio::version_type vers) override
static void read(sio::read_device &device, EVENT::LCParameters &params, sio::version_type vers)
Reads objects from an SIO stream.
virtual const std::string & getDescription() const =0
Description of the simulation, physics channels etc.
void setRunHeader(EVENT::LCRunHeader *hdr)
Set the run header to read/write.
virtual const std::vector< std::string > * getActiveSubdetectors() const =0
Returns the names of the active subdetectors used in the simulation.
void write(sio::write_device &device) override