#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 |
Definition in file diff.cxx.
int cmp_source_id | ( | const uint32_t * | p1, | |
const uint32_t * | p2 | |||
) |
Compares two ROB fragments for equality
p1 | The first ROB fragment | |
p2 | The second ROB fragment |
Definition at line 34 of file diff.cxx.
References eformat::ROBFragment< TPointer >::rod_source_id().
Referenced by main().
00035 { 00036 eformat::ROBFragment<const uint32_t*> rob1(p1); 00037 eformat::ROBFragment<const uint32_t*> rob2(p2); 00038 return rob1.rod_source_id() < rob2.rod_source_id(); 00039 }
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.
References cmp_source_id(), eformat::get_robs(), HEX, genRecEmupikp::i, MAX_EVENT_SIZE, MAX_ROBS, eformat::next_fragment(), eformat::ROBFragment< TPointer >::rod_source_id(), and ers::Issue::what().
00045 { 00046 using namespace eformat; 00047 00048 if ( argc != 3 ) { 00049 std::cerr << "usage: " << argv[0] << " <file1> <file2>" 00050 << std::endl; 00051 std::cerr << "OBS: The event order should be the same on both files" 00052 << std::endl; 00053 std::exit(1); 00054 } 00055 00056 //open normally a file 00057 size_t event_counter = 0; 00058 std::fstream in1(argv[1], std::ios::in|std::ios::binary); 00059 std::fstream in2(argv[2], std::ios::in|std::ios::binary); 00060 const uint32_t* robp1[MAX_ROBS]; 00061 const uint32_t* robp2[MAX_ROBS]; 00062 00063 uint32_t* event1 = new uint32_t[MAX_EVENT_SIZE]; 00064 uint32_t* event2 = new uint32_t[MAX_EVENT_SIZE]; 00065 00066 while (true) { 00067 if (!(next_fragment(in1, event1, MAX_EVENT_SIZE*4)) || 00068 !(next_fragment(in2, event2, MAX_EVENT_SIZE*4))) break; 00069 ++event_counter; 00070 try { 00071 FullEventFragment<const uint32_t*> fe1(event1); 00072 FullEventFragment<const uint32_t*> fe2(event2); 00073 fe1.check_tree(); // no checks, so we dump all 00074 fe2.check_tree(); // no checks, so we dump all 00075 size_t s1 = get_robs(event1, robp1, MAX_ROBS); 00076 size_t s2 = get_robs(event2, robp2, MAX_ROBS); 00077 if (s1 != s2) { 00078 std::cerr << "The number of ROB's of event " << event_counter 00079 << " is different in file `" << argv[1] 00080 << "' (" << s1 << ") and in file `" << argv[2] 00081 << "' (" << s2 << "). Skipping comparison." << std::endl; 00082 continue; 00083 } 00084 //if we get here, the number of ROD's is the same 00085 std::sort(robp1, robp1+s1, cmp_source_id); 00086 std::sort(robp2, robp2+s2, cmp_source_id); 00087 bool mark = false; 00088 for (size_t i=0; i<s1; ++i) { 00089 eformat::ROBFragment<const uint32_t*> rob1(robp1[i]); 00090 eformat::ROBFragment<const uint32_t*> rob2(robp2[i]); 00091 if (rob1.rod_source_id() != rob2.rod_source_id()) { 00092 std::cerr << "! ROB[" << i << "]" << std::endl 00093 << "- " << HEX(rob1.rod_source_id()) << std::endl 00094 << "+ " << HEX(rob2.rod_source_id()) << std::endl; 00095 mark = true; 00096 } 00097 } 00098 if (mark) { 00099 std::cerr << "Event #" << fe1.lvl1_id() << " differ." << std::endl; 00100 } 00101 } 00102 catch (eformat::Issue& ex) { 00103 std::cerr << std::endl 00104 << "Uncaught eformat issue: " << ex.what() << std::endl; 00105 std::cout << "Trying to continue..." << std::endl; 00106 continue; 00107 } 00108 catch (ers::Issue& ex) { 00109 std::cerr << std::endl 00110 << "Uncaught ERS issue: " << ex.what() << std::endl; 00111 delete[] event1; 00112 delete[] event2; 00113 std::exit(1); 00114 } 00115 catch (std::exception& ex) { 00116 std::cerr << std::endl 00117 << "Uncaught std exception: " << ex.what() << std::endl; 00118 delete[] event1; 00119 delete[] event2; 00120 std::exit(1); 00121 } 00122 catch (...) { 00123 std::cerr << std::endl << "Uncaught unknown exception" << std::endl; 00124 delete[] event1; 00125 delete[] event2; 00126 std::exit(1); 00127 } 00128 00129 } 00130 00131 std::cerr << "In the absence of remarks, files do NOT differ." << std::endl; 00132 00133 delete[] event1; 00134 delete[] event2; 00135 return 0; 00136 }
const size_t MAX_EVENT_SIZE = 2500000 |
const size_t MAX_ROBS = 2048 |