8 #include "EVENT/LCIO.h"
21 using namespace lcio ;
43 MYTEST.
LOG(
"test splitting" );
54 for(
unsigned i=0 ; i<inputFilesVec.
size() ; i++){
55 remove( inputFilesVec[i].c_str() );
60 LCWriter* lcWrt =
new LCSplitWriter( LCFactory::getInstance()->createLCWriter(),
SPLIT_SIZE_KB*1024 ) ;
69 LCEventImpl* evt =
new LCEventImpl() ;
72 evt->setRunNumber( 4711 ) ;
73 evt->setEventNumber( i ) ;
75 LCCollectionVec* clusters =
new LCCollectionVec( LCIO::CLUSTER ) ;
77 for(
int j=0;j<
NHITS;j++){
78 ClusterImpl* clu =
new ClusterImpl ;
79 clu->setEnergy( i*j*117. ) ;
80 float pos[3] = { float(i) , float(j) ,float(i*j) } ;
81 clu->setPosition( pos ) ;
82 clusters->addElement( clu ) ;
85 evt->addCollection( clusters ,
"Clusters") ;
87 lcWrt->writeEvent(evt) ;
95 MYTEST.
LOG(
"test reading back from split files" ) ;
98 LCReader* lcRdr = LCFactory::getInstance()->createLCReader() ;
100 lcRdr->open( inputFilesVec ) ;
102 for(
int i=0;i<
NEVENT;i++){
106 LCEvent* evt = lcRdr->readNextEvent() ;
108 MYTEST( evt->getRunNumber() , 4711 ,
" run number " ) ;
110 MYTEST( evt->getEventNumber() , i ,
" event number " ) ;
112 LCCollection* clusters = evt->getCollection(
"Clusters") ;
114 for(
int j=0;j<
NHITS;j++) {
118 Cluster* clu =
dynamic_cast<Cluster*
>(clusters->getElementAt(j)) ;
120 MYTEST( clu->getEnergy() , i*j*117. ,
"energy" ) ;
122 const float* pos = clu->getPosition() ;
124 MYTEST( pos[0] , i ,
" pos[0] " ) ;
125 MYTEST( pos[1] , j ,
" pos[1] " ) ;
126 MYTEST( pos[2] , i*j ,
" pos[2] " ) ;
132 }
catch( Exception &e ){
133 MYTEST.
FAILED( e.what() );
static string FILE_BASENAME
void FAILED(const std::string &msg)
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...
static string FILE_EXTENSION
static const string testname
static const int SPLIT_SIZE_KB
void LOG(const std::string &msg)