CMS 3D CMS Logo

cscPackerCompare.h
Go to the documentation of this file.
1 #ifndef EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
2 #define EventFilter_CSCRawToDigi_CSCPACKERCOMPARE_H
3 
4 #include <iostream>
5 #include <typeinfo>
7 
11 template <class T>
12 bool cscPackerCompare(const T &t1, const T &t2) {
13  bool result = true;
14  if (t1 != t2) {
15  std::cerr << "Mismatch:\n" << t1 << "\n" << t2 << std::endl;
16  result = false;
17  }
18  return result;
19 }
20 
21 template <class T>
23  boost::dynamic_bitset<> firstPack = t.pack();
24  unsigned char data[10000];
26  return T((unsigned short int *)data);
27 }
28 
29 // packs a class, then unpacks, packs again, and compares
30 template <class T>
32  boost::dynamic_bitset<> firstPack = t.pack();
33  unsigned char data[1000];
35  T newObject((unsigned short int *)data);
36  boost::dynamic_bitset<> secondPack = newObject.pack();
37  if (firstPack != secondPack) {
38  std::cerr << "Mismatch in " << typeid(t).name() << "\n";
40  bitset_utilities::printWords(secondPack);
41  return false;
42  }
43  return true;
44 }
45 
46 #endif
bool cscClassPackerCompare(T &t)
void printWords(const boost::dynamic_bitset<> &bs)
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
bool cscPackerCompare(const T &t1, const T &t2)
T cscPackAndUnpack(T &t)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
long double T