BOSS 7.0.1
BESIII Offline Software System
Loading...
Searching...
No Matches
check-old.cxx
Go to the documentation of this file.
1//Dear emacs, this is -*- c++ -*-
2
3/**
4 * @file test/check.cxx
5 * @author <a href="mailto:[email protected]>Andr� Rabello dos
6 * ANJOS</a>
7 * $Author: zhangy $
8 * $Revision: 1.1.1.1 $
9 * $Date: 2009/06/19 07:35:41 $
10 *
11 * This source code describes a small test program based on the eformat
12 * library. It will read a file containing complete events, in format 2.4, and
13 * check the format correctness.
14 */
15
16#include <fstream>
17#include <iostream>
18#include <cstdlib>
19
20#include "eformat/eformat.h"
21#include "eformat/old/eformat.h"
22
23/**
24 * The maximum event size, in words
25 */
26const size_t MAX_EVENT_SIZE = 2500000;
27
28/**
29 * Reads a file and check its validity (for the time being)
30 */
31int main (int argc, char** argv)
32{
33 using namespace eformat;
34
35 if ( argc != 2 ) {
36 std::cerr << "usage: " << argv[0] << " <file>" << std::endl;
37 std::exit(1);
38 }
39
40 //open normally a file
41 std::fstream in(argv[1], std::ios::in|std::ios::binary);
42 if (!in) {
43 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
44 std::exit(1);
45 }
46 uint32_t* event = new uint32_t[MAX_EVENT_SIZE];
47
48 while (true) {
49
50 if (!(next_fragment(in, event, MAX_EVENT_SIZE*4))) break;
51
52 try {
53 old::FullEventFragment fe(event);
54 //old::ROSFragment fe(event);
55 fe.check_tree();
56
57 //if check is ok, print the lvl1 identifier
58 std::cout << "Event " << fe.lvl1_id() << " is Ok." << std::endl;
59 }
60 catch (eformat::Issue& ex) {
61 std::cerr << std::endl
62 << "Uncaught eformat issue: " << ex.what() << std::endl;
63 std::cout << "Trying to continue..." << std::endl;
64 continue;
65 }
66 catch (ers::Issue& ex) {
67 std::cerr << std::endl
68 << "Uncaught ERS issue: " << ex.what() << std::endl;
69 delete[] event;
70 std::exit(1);
71 }
72 catch (std::exception& ex) {
73 std::cerr << std::endl
74 << "Uncaught std exception: " << ex.what() << std::endl;
75 delete[] event;
76 std::exit(1);
77 }
78 catch (...) {
79 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
80 delete[] event;
81 std::exit(1);
82 }
83
84 }
85
86 delete[] event;
87 return 0;
88}
const size_t MAX_EVENT_SIZE
Definition: check-old.cxx:26
const char * what() const
Human description message.
int main()
Definition: test_IFile.cxx:11