LCIO  02.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
test_lazy.cc
Go to the documentation of this file.
1 // example for LCIO tests
4 
5 #include "tutil.h"
6 
7 #include "IO/LCWriter.h"
8 #include "MT/LCReader.h"
9 #include "EVENT/LCCollection.h"
10 
11 #include <iostream>
12 
13 
14 // replace mytest with the name of your test
15 const static std::string testname="lazy";
16 
17 //=============================================================================
18 
19 int main(int /*argc*/, char** /*argv*/ ){
20 
21  // this should be the first line in your test
22  TEST MYTEST=TEST( testname, std::cout );
23 
24  // example with a try&catch fail condition:
25  //
27 
29 
30  try {
31  reader.open( "c_sim.slcio" ) ;
32  std::unique_ptr<EVENT::LCEvent> event = nullptr ;
33  while( 1 ) {
34  event = reader.readNextEvent() ;
35  if( nullptr == event ) {
36  break ;
37  }
38  auto colnames = event->getCollectionNames() ;
39  for( auto colname : *colnames ) {
40  auto collection = event->getCollection( colname ) ;
41  std::cout << "Event no " << event->getEventNumber() << ", collection: type '" << collection->getTypeName() << "', name '" << colname << "'" << std::endl ;
42  }
43  std::cout << std::endl ;
44  }
45  }
46  catch( EVENT::Exception &e ){
47  MYTEST.FAILED( e.what() );
48  }
49 
50  reader.close();
51 
53 
54  return 0;
55 }
56 
57 //=============================================================================
58 
Base exception class for LCIO - all other exceptions extend this.
Definition: Exceptions.h:21
void open(const std::string &filename)
Opens a file for reading (read-only).
Definition: LCReader.cc:43
T endl(T...args)
LCEvent * event
Definition: lsh.cc:80
Definition: tutil.h:7
STL class.
void FAILED(const std::string &msg)
Definition: tutil.h:42
static constexpr int directAccess
Bit for direct access.
Definition: LCReader.h:45
virtual const char * what() const noexcept
Definition: Exceptions.h:36
int main(int argc, char **argv)
Simple program that opens existing LCIO files and appends the records needed for direct access - if t...
Implementation of a LCReader for parallel processing use.
Definition: LCReader.h:37
std::unique_ptr< EVENT::LCEvent > readNextEvent(int accessMode=EVENT::LCIO::READ_ONLY)
Reads the next event from the file.
Definition: LCReader.cc:135
STL class.
static const std::string testname
Definition: test_lazy.cc:15
static constexpr int lazyUnpack
Bit for lazy unpacking of event records.
Definition: LCReader.h:47
void close()
Closes the output file/stream etc.
Definition: LCReader.cc:416