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
RandomServiceHelper.t2
t2
Definition: RandomServiceHelper.py:257
bitset_utilities::bitsetToChar
void bitsetToChar(const boost::dynamic_bitset<> &bs, unsigned char *result)
this method takes bitset obj and returns char * array
Definition: bitset_append.cc:32
RandomServiceHelper.t1
t1
Definition: RandomServiceHelper.py:256
cscPackerCompare
bool cscPackerCompare(const T &t1, const T &t2)
Definition: cscPackerCompare.h:12
cscPackAndUnpack
T cscPackAndUnpack(T &t)
Definition: cscPackerCompare.h:22
T
long double T
Definition: Basic3DVectorLD.h:48
cscClassPackerCompare
bool cscClassPackerCompare(T &t)
Definition: cscPackerCompare.h:31
bitset_append.h
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
mps_fire.result
result
Definition: mps_fire.py:311
submitPVValidationJobs.t
string t
Definition: submitPVValidationJobs.py:644
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
bitset_utilities::printWords
void printWords(const boost::dynamic_bitset<> &bs)
Definition: bitset_append.cc:40