/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/eformat/eformat-00-00-04/test/check.cxx File Reference

#include <fstream>
#include <iostream>
#include <cstdlib>
#include "eformat/eformat.h"

Go to the source code of this file.

Functions

int main (int argc, char **argv)

Variables

const size_t MAX_EVENT_SIZE = 2500000


Detailed Description

Author:
<a href="mailto:Andre.dos.Anjos@cern.ch>André Rabello dos ANJOS
Author
zhangy
Revision
1.1.1.1
Date
2009/06/19 07:35:41
This source code describes a small test program based on the eformat library. It will read a file containing complete events, in format 2.4, and check the format correctness.

Definition in file check.cxx.


Function Documentation

int main ( int  argc,
char **  argv 
)

Reads a file and check its validity (for the time being)

Definition at line 30 of file check.cxx.

References MAX_EVENT_SIZE, eformat::next_fragment(), and ers::Issue::what().

00031 {
00032   using namespace eformat;
00033   
00034   if ( argc != 2 ) {
00035     std::cerr << "usage: " << argv[0] << " <file>" << std::endl;
00036     std::exit(1);
00037   }
00038 
00039   //open normally a file
00040   std::fstream in(argv[1], std::ios::in|std::ios::binary);
00041   if (!in) {
00042     std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
00043     std::exit(1);
00044   }
00045   uint32_t* event = new uint32_t[MAX_EVENT_SIZE];
00046   uint32_t sevent = 0;
00047   while(in.good() && !in.eof() && sevent != 0xaa1234aa) {
00048           in.read((char*)&sevent, 4);
00049   }
00050   if (sevent == 0xaa1234aa) in.seekg(in.tellg()-(std::streampos)4);
00051   else exit(1);
00052   //for (int i = 0; i < 100; i++) {
00053   //        in.read((char*)&sevent, 4);
00054   //        std::cout << std::hex << sevent << std::endl;
00055   //}
00056   
00057   while (true) {
00058     
00059     if (!(next_fragment(in, event, MAX_EVENT_SIZE*4))) break;
00060     
00061     try {
00062       FullEventFragment<const uint32_t*> fe(event);
00063       fe.check_tree();
00064       //if check is ok, print the lvl1 identifier
00065       std::cout << "Event " << fe.lvl1_id() << " is Ok." << std::endl;
00066     }
00067     catch (eformat::Issue& ex) {
00068       std::cerr << std::endl
00069                 << "Uncaught eformat issue: " << ex.what() << std::endl;
00070       std::cout << "Trying to continue..." << std::endl;
00071       continue;
00072     }
00073     catch (ers::Issue& ex) {
00074       std::cerr << std::endl
00075                 << "Uncaught ERS issue: " << ex.what() << std::endl;
00076       delete[] event;
00077       std::exit(1);
00078     }
00079     catch (std::exception& ex) {
00080       std::cerr << std::endl
00081                 << "Uncaught std exception: " << ex.what() << std::endl;
00082       delete[] event;
00083       std::exit(1);
00084     }
00085     catch (...) {
00086       std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
00087       delete[] event;
00088       std::exit(1);
00089     }
00090 
00091   }
00092 
00093   delete[] event;
00094   return 0;
00095 }


Variable Documentation

const size_t MAX_EVENT_SIZE = 2500000

The maximum event size, in words

Definition at line 25 of file check.cxx.


Generated on Tue Nov 29 23:15:04 2016 for BOSS_7.0.2 by  doxygen 1.4.7