Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:04:27

0001 // test
0002 
0003 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFBitCounts.h"
0004 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctHFRingEtSums.h"
0005 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternHFData.h"
0006 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternEtSum.h"
0007 #include "DataFormats/L1GlobalCaloTrigger/interface/L1GctInternJetData.h"
0008 
0009 #include <iostream>
0010 #include <cstdlib>
0011 
0012 using namespace std;
0013 
0014 int main() {
0015   // test HF bit counts set methods
0016   L1GctHFBitCounts b;
0017   unsigned c[4];
0018   for (unsigned i = 0; i < 4; ++i)
0019     c[i] = 0;
0020   for (unsigned i = 0; i < 4; ++i) {
0021     for (unsigned j = 0; j < 0x7; ++j) {
0022       b.setBitCount(i, j);
0023       c[i] = j;
0024 
0025       // check all counts are as expected
0026       for (unsigned k = 0; k < 4; ++k) {
0027         bool check = (b.bitCount(k) == c[k]);
0028         if (!check) {
0029           std::cout << "L1GctHFBitCounts failed : ";
0030           std::cout << " bitCount(" << std::dec << k << ") = " << std::hex << b.bitCount(k);
0031           std::cout << ", expected " << std::hex << c[k] << std::endl;
0032           exit(1);
0033         }
0034       }
0035     }
0036   }
0037 
0038   // test HF ring sums set methods
0039   L1GctHFRingEtSums s;
0040   for (unsigned i = 0; i < 4; ++i)
0041     c[i] = 0;
0042   for (unsigned i = 0; i < 4; ++i) {
0043     for (unsigned j = 0; j < 0x7; ++j) {
0044       s.setEtSum(i, j);
0045       c[i] = j;
0046 
0047       // check all counts are as expected
0048       for (unsigned k = 0; k < 4; ++k) {
0049         bool check = (s.etSum(k) == c[k]);
0050         if (!check) {
0051           std::cout << "L1GctHFBitCounts failed : ";
0052           std::cout << " bitCount(" << std::dec << k << ") = " << std::hex << s.etSum(k);
0053           std::cout << ", expected " << std::hex << c[k] << std::endl;
0054           exit(1);
0055         }
0056       }
0057     }
0058   }
0059 
0060   // test intern HF data
0061   L1GctInternHFData d;
0062   for (unsigned i = 0; i < 4; ++i)
0063     c[i] = 0;
0064   for (unsigned i = 0; i < 4; ++i) {
0065     for (unsigned j = 0; j < 0xff; ++j) {
0066       d.setValue(i, j);
0067       c[i] = j;
0068 
0069       // check all counts are as expected
0070       for (unsigned k = 0; k < 4; ++k) {
0071         bool check = (d.value(k) == c[k]);
0072         if (!check) {
0073           std::cout << "L1GctHFBitCounts failed : ";
0074           std::cout << " bitCount(" << std::dec << k << ") = " << std::hex << d.value(k);
0075           std::cout << ", expected " << std::hex << c[k] << std::endl;
0076           exit(1);
0077         }
0078       }
0079     }
0080   }
0081 
0082   // test intern Et Sum
0083   L1GctInternJetData jd;
0084   for (unsigned rank = 0; rank < 0x3f; ++rank) {
0085     for (unsigned tauVeto = 0; tauVeto < 2; ++tauVeto) {
0086       for (unsigned phi = 0; phi < 18; ++phi) {
0087         for (unsigned eta = 0; eta < 11; ++eta) {
0088           for (unsigned et = 0; et < 0xfff; ++et) {
0089             for (unsigned oflow = 0; oflow < 2; ++oflow) {
0090               for (unsigned sgnEta = 0; sgnEta < 2; ++sgnEta) {
0091                 jd.setData(sgnEta, oflow, et, eta, phi, tauVeto, rank);
0092 
0093                 if (jd.sgnEta() != sgnEta || jd.oflow() != oflow || jd.et() != et || jd.eta() != eta ||
0094                     jd.phi() != phi || jd.tauVeto() != tauVeto || jd.rank() != rank) {
0095                   std::cout << "L1GctInternEtSum failed : " << std::endl;
0096                   std::cout << "Expected sgnEta=" << sgnEta;
0097                   std::cout << " oflow=" << oflow;
0098                   std::cout << " et=" << et;
0099                   std::cout << " eta=" << eta;
0100                   std::cout << " phi=" << phi;
0101                   std::cout << " tauVeto=" << tauVeto;
0102                   std::cout << " rank=" << rank << std::endl;
0103                   std::cout << "Got " << jd << std::endl;
0104                   exit(1);
0105                 }
0106               }
0107             }
0108           }
0109         }
0110       }
0111     }
0112   }
0113 
0114   exit(0);
0115 }