/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/eformat/eformat-00-00-04/test/diff.cxx

Go to the documentation of this file.
00001 //Dear emacs, this is -*- c++ -*-
00002 
00015 #include "eformat/eformat.h"
00016 #include <algorithm>
00017 
00021 const size_t MAX_EVENT_SIZE = 2500000;
00022 
00026 const size_t MAX_ROBS = 2048;
00027 
00034 int cmp_source_id (const uint32_t* p1, const uint32_t* p2)
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 }
00040 
00044 int main (int argc, char** argv)
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 }

Generated on Tue Nov 29 22:58:26 2016 for BOSS_7.0.2 by  doxygen 1.4.7