BOSS 7.1.1
BESIII Offline Software System
Loading...
Searching...
No Matches
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:[email protected]>Andr� Rabello dos ANJOS</a> $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. @author <a href="Andre.nosp@m..dos.nosp@m..Anjo.nosp@m.s@ce.nosp@m.rn.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 and check the format correctness.

Definition in file check.cxx.

Function Documentation

◆ main()

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.

31{
32 using namespace eformat;
33
34 if ( argc != 2 ) {
35 std::cerr << "usage: " << argv[0] << " <file>" << std::endl;
36 std::exit(1);
37 }
38
39 //open normally a file
40 std::fstream in(argv[1], std::ios::in|std::ios::binary);
41 if (!in) {
42 std::cerr << "File `" << argv[1] << "' does not exist?!" << std::endl;
43 std::exit(1);
44 }
45 uint32_t* event = new uint32_t[MAX_EVENT_SIZE];
46 uint32_t sevent = 0;
47 while(in.good() && !in.eof() && sevent != 0xaa1234aa) {
48 in.read((char*)&sevent, 4);
49 }
50 if (sevent == 0xaa1234aa) in.seekg(in.tellg()-(std::streampos)4);
51 else exit(1);
52 //for (int i = 0; i < 100; i++) {
53 // in.read((char*)&sevent, 4);
54 // std::cout << std::hex << sevent << std::endl;
55 //}
56
57 while (true) {
58
59 if (!(next_fragment(in, event, MAX_EVENT_SIZE*4))) break;
60
61 try {
63 fe.check_tree();
64 //if check is ok, print the lvl1 identifier
65 std::cout << "Event " << fe.lvl1_id() << " is Ok." << std::endl;
66 }
67 catch (eformat::Issue& ex) {
68 std::cerr << std::endl
69 << "Uncaught eformat issue: " << ex.what() << std::endl;
70 std::cout << "Trying to continue..." << std::endl;
71 continue;
72 }
73 catch (ers::Issue& ex) {
74 std::cerr << std::endl
75 << "Uncaught ERS issue: " << ex.what() << std::endl;
76 delete[] event;
77 std::exit(1);
78 }
79 catch (std::exception& ex) {
80 std::cerr << std::endl
81 << "Uncaught std exception: " << ex.what() << std::endl;
82 delete[] event;
83 std::exit(1);
84 }
85 catch (...) {
86 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
87 delete[] event;
88 std::exit(1);
89 }
90
91 }
92
93 delete[] event;
94 return 0;
95}
const size_t MAX_EVENT_SIZE
Definition check.cxx:25
Root Issue class.
const char * what() const
Human description message.
uint32_t * next_fragment(std::fstream &fs, uint32_t *addr=0, size_t size=0)
Definition util.cxx:24

Variable Documentation

◆ MAX_EVENT_SIZE

const size_t MAX_EVENT_SIZE = 2500000

The maximum event size, in words

Definition at line 25 of file check.cxx.

Referenced by main().