1111#if !defined(__CLING__ ) || defined(__ROOTCLING__ )
1212#include <iostream>
1313#include <array>
14- #endif
15-
1614
1715R__LOAD_LIBRARY (libO2CommonUtils )
1816R__LOAD_LIBRARY (libO2DataFormatsFIT )
@@ -21,82 +19,81 @@ R__LOAD_LIBRARY(libO2DataFormatsFIT)
2119#include "DataFormatsFIT/LookUpTable.h"
2220#include "Framework/Logger.h"
2321#include "CommonConstants/LHCConstants.h"
22+ #endif
2423
2524std ::vector < o2 ::fit ::EntryFEE > readLUTFromFile (const std ::string filePath , const std ::string objectName )
2625{
27- TFile file (filePath .c_str (), "READ ");
28- if (file .IsOpen () == false) {
26+ TFile file (filePath .c_str (), "READ ");
27+ if (file .IsOpen () == false) {
2928 LOGP (fatal , "Failed to open {}" , filePath );
30- }
31- LOGP (info , "Successfully opened {}" , filePath );
29+ }
30+ LOGP (info , "Successfully opened {}" , filePath );
3231
33- std ::vector < o2 ::fit ::EntryFEE > * lut = nullptr ;
34- file .GetObject < std ::vector < o2 ::fit ::EntryFEE >>(objectName .c_str (), lut );
32+ std ::vector < o2 ::fit ::EntryFEE > * lut = nullptr ;
33+ file .GetObject < std ::vector < o2 ::fit ::EntryFEE >>(objectName .c_str (), lut );
3534
36- if (lut == nullptr ) {
35+ if (lut == nullptr ) {
3736 LOGP (fatal , "Failed to read object {}" , objectName );
38- }
39- LOGP (info , "Successfully get {} object" , objectName );
37+ }
38+ LOGP (info , "Successfully get {} object" , objectName );
4039
41- std ::vector < o2 ::fit ::EntryFEE > lutCopy = * lut ;
42- file .Close ();
40+ std ::vector < o2 ::fit ::EntryFEE > lutCopy = * lut ;
41+ file .Close ();
4342
44- return std ::move (lutCopy );
43+ return std ::move (lutCopy );
4544}
4645
4746inline bool operator == (const o2 ::fit ::EntryFEE & lhs , const o2 ::fit ::EntryFEE & rhs )
4847{
49- auto comparer = [](const o2 ::fit ::EntryFEE & e ) {
48+ auto comparer = [](const o2 ::fit ::EntryFEE & e ) {
5049 return std ::tie (
5150 e .mEntryCRU .mLinkID , e .mEntryCRU .mEndPointID , e .mEntryCRU .mCRUID , e .mEntryCRU .mFEEID ,
52- e .mChannelID , e .mLocalChannelID , e .mModuleType , e .mModuleName ,
53- e .mBoardHV , e .mChannelHV , e .mSerialNumberMCP , e .mCableHV , e .mCableSignal
54- );
51+ e .mChannelID , e .mLocalChannelID , e .mModuleType , e .mModuleName ,
52+ e .mBoardHV , e .mChannelHV , e .mSerialNumberMCP , e .mCableHV , e .mCableSignal );
5553 };
5654 return comparer (lhs ) == comparer (rhs );
5755}
5856
59-
6057void compareLUT (const std ::string fileA , const std ::string fileB , bool compareEvenForDifferentSize = false, const std ::string objectName = "LookupTable" )
6158{
62- std ::vector < o2 ::fit ::EntryFEE > lutA = readLUTFromFile (fileA , objectName );
63- std ::vector < o2 ::fit ::EntryFEE > lutB = readLUTFromFile (fileB , objectName );
59+ std ::vector < o2 ::fit ::EntryFEE > lutA = readLUTFromFile (fileA , objectName );
60+ std ::vector < o2 ::fit ::EntryFEE > lutB = readLUTFromFile (fileB , objectName );
6461
65- bool lutAreSame = true;
62+ bool lutAreSame = true;
6663
67- if (lutA .size () != lutB .size ()) {
68- LOGP (error , "The LUT vary in size: {} for {} vs {} for {}" , lutA .size (), fileA , lutB .size (), fileB );
69- lutAreSame = false;
70- if (compareEvenForDifferentSize == false) {
71- return ;
72- }
64+ if (lutA .size () != lutB .size ()) {
65+ LOGP (error , "The LUT vary in size: {} for {} vs {} for {}" , lutA .size (), fileA , lutB .size (), fileB );
66+ lutAreSame = false;
67+ if (compareEvenForDifferentSize == false) {
68+ return ;
7369 }
70+ }
7471
75- size_t size = (lutA .size () < lutB .size ()) ? lutA .size () : lutB .size ();
76-
77- std ::cout << "--- Comparision ---" << std ::endl ;
78-
79- for (size_t idx = 0 ; idx < size ; idx ++ ) {
80- if (lutA [idx ] == lutB [idx ]) {
81- continue ;
82- } else {
83- std ::cout << "Entry " << idx << " in " << fileA << " entry: " << lutA [idx ] << std ::endl ;
84- std ::cout << "Entry " << idx << " in " << fileB << " entry: " << lutB [idx ] << std ::endl ;
85- lutAreSame = false;
86- }
87- }
72+ size_t size = (lutA .size () < lutB .size ()) ? lutA .size () : lutB .size ();
8873
89- for (size_t idx = size ; idx < lutA .size (); idx ++ ) {
90- std ::cout << "Extra entry " << idx << " in " << fileA << ": " << lutA [idx ] << std ::endl ;
91- }
92-
93- for (size_t idx = size ; idx < lutB .size (); idx ++ ) {
94- std ::cout << "Extra entry " << idx << " in " << fileB << ": " << lutB [idx ] << std ::endl ;
95- }
74+ std ::cout << "--- Comparision ---" << std ::endl ;
9675
97- if (lutAreSame ) {
98- std ::cout << "LUTs are the same!" << std ::endl ;
76+ for (size_t idx = 0 ; idx < size ; idx ++ ) {
77+ if (lutA [idx ] == lutB [idx ]) {
78+ continue ;
9979 } else {
100- std ::cout << "LUTs are different!" << std ::endl ;
80+ std ::cout << "Entry " << idx << " in " << fileA << " entry: " << lutA [idx ] << std ::endl ;
81+ std ::cout << "Entry " << idx << " in " << fileB << " entry: " << lutB [idx ] << std ::endl ;
82+ lutAreSame = false;
10183 }
84+ }
85+
86+ for (size_t idx = size ; idx < lutA .size (); idx ++ ) {
87+ std ::cout << "Extra entry " << idx << " in " << fileA << ": " << lutA [idx ] << std ::endl ;
88+ }
89+
90+ for (size_t idx = size ; idx < lutB .size (); idx ++ ) {
91+ std ::cout << "Extra entry " << idx << " in " << fileB << ": " << lutB [idx ] << std ::endl ;
92+ }
93+
94+ if (lutAreSame ) {
95+ std ::cout << "LUTs are the same!" << std ::endl ;
96+ } else {
97+ std ::cout << "LUTs are different!" << std ::endl ;
98+ }
10299}
0 commit comments