BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
diff.cxx File Reference
#include "eformat/eformat.h"
#include <algorithm>

Go to the source code of this file.

Functions

int cmp_source_id (const uint32_t *p1, const uint32_t *p2)
 
int main (int argc, char **argv)
 

Variables

const size_t MAX_EVENT_SIZE = 2500000
 
const size_t MAX_ROBS = 2048
 

Detailed Description

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 implements a comparison application that can be used to show differences in event-formatted files, at the ROB level

Definition in file diff.cxx.

Function Documentation

◆ cmp_source_id()

int cmp_source_id ( const uint32_t *  p1,
const uint32_t *  p2 
)

Compares two ROB fragments for equality

Parameters
p1The first ROB fragment
p2The second ROB fragment

Definition at line 34 of file diff.cxx.

35{
38 return rob1.rod_source_id() < rob2.rod_source_id();
39}

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Shows differences between to event-formatted files at the ROB level.

Definition at line 44 of file diff.cxx.

45{
46 using namespace eformat;
47
48 if ( argc != 3 ) {
49 std::cerr << "usage: " << argv[0] << " <file1> <file2>"
50 << std::endl;
51 std::cerr << "OBS: The event order should be the same on both files"
52 << std::endl;
53 std::exit(1);
54 }
55
56 //open normally a file
57 size_t event_counter = 0;
58 std::fstream in1(argv[1], std::ios::in|std::ios::binary);
59 std::fstream in2(argv[2], std::ios::in|std::ios::binary);
60 const uint32_t* robp1[MAX_ROBS];
61 const uint32_t* robp2[MAX_ROBS];
62
63 uint32_t* event1 = new uint32_t[MAX_EVENT_SIZE];
64 uint32_t* event2 = new uint32_t[MAX_EVENT_SIZE];
65
66 while (true) {
67 if (!(next_fragment(in1, event1, MAX_EVENT_SIZE*4)) ||
68 !(next_fragment(in2, event2, MAX_EVENT_SIZE*4))) break;
69 ++event_counter;
70 try {
73 fe1.check_tree(); // no checks, so we dump all
74 fe2.check_tree(); // no checks, so we dump all
75 size_t s1 = get_robs(event1, robp1, MAX_ROBS);
76 size_t s2 = get_robs(event2, robp2, MAX_ROBS);
77 if (s1 != s2) {
78 std::cerr << "The number of ROB's of event " << event_counter
79 << " is different in file `" << argv[1]
80 << "' (" << s1 << ") and in file `" << argv[2]
81 << "' (" << s2 << "). Skipping comparison." << std::endl;
82 continue;
83 }
84 //if we get here, the number of ROD's is the same
85 std::sort(robp1, robp1+s1, cmp_source_id);
86 std::sort(robp2, robp2+s2, cmp_source_id);
87 bool mark = false;
88 for (size_t i=0; i<s1; ++i) {
91 if (rob1.rod_source_id() != rob2.rod_source_id()) {
92 std::cerr << "! ROB[" << i << "]" << std::endl
93 << "- " << HEX(rob1.rod_source_id()) << std::endl
94 << "+ " << HEX(rob2.rod_source_id()) << std::endl;
95 mark = true;
96 }
97 }
98 if (mark) {
99 std::cerr << "Event #" << fe1.lvl1_id() << " differ." << std::endl;
100 }
101 }
102 catch (eformat::Issue& ex) {
103 std::cerr << std::endl
104 << "Uncaught eformat issue: " << ex.what() << std::endl;
105 std::cout << "Trying to continue..." << std::endl;
106 continue;
107 }
108 catch (ers::Issue& ex) {
109 std::cerr << std::endl
110 << "Uncaught ERS issue: " << ex.what() << std::endl;
111 delete[] event1;
112 delete[] event2;
113 std::exit(1);
114 }
115 catch (std::exception& ex) {
116 std::cerr << std::endl
117 << "Uncaught std exception: " << ex.what() << std::endl;
118 delete[] event1;
119 delete[] event2;
120 std::exit(1);
121 }
122 catch (...) {
123 std::cerr << std::endl << "Uncaught unknown exception" << std::endl;
124 delete[] event1;
125 delete[] event2;
126 std::exit(1);
127 }
128
129 }
130
131 std::cerr << "In the absence of remarks, files do NOT differ." << std::endl;
132
133 delete[] event1;
134 delete[] event2;
135 return 0;
136}
Root Issue class.
const char * what() const
Human description message.
int cmp_source_id(const uint32_t *p1, const uint32_t *p2)
Definition: diff.cxx:34
const size_t MAX_ROBS
Definition: diff.cxx:26
const size_t MAX_EVENT_SIZE
Definition: diff.cxx:21
uint32_t * next_fragment(std::fstream &fs, uint32_t *addr=0, size_t size=0)
Definition: util.cxx:22
size_t get_robs(const uint32_t *fragment, const uint32_t **rob, size_t max_count)
Definition: util.cxx:105
#define HEX(m)
Definition: util.h:107

Variable Documentation

◆ MAX_EVENT_SIZE

const size_t MAX_EVENT_SIZE = 2500000

The maximum event size, in words

Definition at line 21 of file diff.cxx.

Referenced by main().

◆ MAX_ROBS

const size_t MAX_ROBS = 2048

The maximum number of ROBS

Definition at line 26 of file diff.cxx.

Referenced by main().