Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:42

0001 #include "L1Trigger/TextToDigi/interface/SourceCardRouting.h"
0002 #include <cstdlib>
0003 #include <iostream>
0004 #include <sstream>
0005 using namespace std;
0006 
0007 int main(void) {
0008   unsigned short logicalCardID = 0;
0009   unsigned short eventNumber = 0;
0010   std::string tempString;
0011 
0012   unsigned long VHDCI[2][2] = {{0}};
0013   SourceCardRouting temp;
0014 
0015   unsigned short RC[18][7][2] = {{{0}}};
0016   unsigned short RCof[18][7][2] = {{{0}}};
0017   unsigned short RCtau[18][7][2] = {{{0}}};
0018   unsigned short HF[18][4][2] = {{{0}}};
0019   unsigned short HFQ[18][4][2] = {{{0}}};
0020 
0021   unsigned short testRC[18][7][2] = {{{0}}};
0022   unsigned short testRCof[18][7][2] = {{{0}}};
0023   unsigned short testRCtau[18][7][2] = {{{0}}};
0024   unsigned short testHF[18][4][2] = {{{0}}};
0025   unsigned short testHFQ[18][4][2] = {{{0}}};
0026 
0027   std::cout << "fill with junk..." << std::endl;
0028   for (int RCTcrate = 0; RCTcrate < 18; RCTcrate++) {
0029     for (int RCcard = 0; RCcard < 7; RCcard++) {
0030       for (int Region = 0; Region < 2; Region++) {
0031         RC[RCTcrate][RCcard][Region] = rand() & 0x3ff;   // Fill with junk for the time being

0032         RCof[RCTcrate][RCcard][Region] = rand() & 0x1;   // Fill with junk for the time being

0033         RCtau[RCTcrate][RCcard][Region] = rand() & 0x1;  // Fill with junk for the time being

0034       }
0035     }
0036   }
0037 
0038   for (int RCTcrate = 0; RCTcrate < 18; RCTcrate++) {
0039     for (int HFeta = 0; HFeta < 4; HFeta++) {
0040       for (int HFRegion = 0; HFRegion < 2; HFRegion++) {
0041         HF[RCTcrate][HFeta][HFRegion] = rand() & 0xff;  // Fill with junk for the time being

0042         HFQ[RCTcrate][HFeta][HFRegion] = rand() & 0x1;  // Fill with junk for the time being

0043       }
0044     }
0045   }
0046 
0047   std::cout << "now do the proper stuff..." << std::endl;
0048 
0049   int RoutingMode = 1;
0050   for (int RCTcrate = 0; RCTcrate < 18; RCTcrate++) {
0051     temp.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, RCTcrate);
0052     temp.RC56HFtoSTRING(logicalCardID,
0053                         eventNumber,
0054                         RC[RCTcrate],
0055                         RCof[RCTcrate],
0056                         RCtau[RCTcrate],
0057                         HF[RCTcrate],
0058                         HFQ[RCTcrate],
0059                         tempString);
0060 
0061     // now check its working ok

0062     // std::cout<<"MID: "<<tempString<<std::endl;

0063     temp.STRINGtoVHDCI(logicalCardID, eventNumber, tempString, VHDCI);
0064     temp.VHDCItoRC56HF(
0065         testRC[RCTcrate], testRCof[RCTcrate], testRCtau[RCTcrate], testHF[RCTcrate], testHFQ[RCTcrate], VHDCI);
0066     /*cout<<"------------------------------------"<<std::endl;

0067       for(int RCcard=5; RCcard<7; RCcard++){

0068       for(int Region=0; Region<2; Region++){

0069       std::cout << RC[RCTcrate][RCcard][Region] << '\t' <<

0070       testRC[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0071       RCof[RCTcrate][RCcard][Region] << '\t' <<

0072       testRCof[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0073       RCtau[RCTcrate][RCcard][Region] << '\t' <<

0074       testRCtau[RCTcrate][RCcard][Region] << std::endl;

0075       }

0076       }

0077       for(int HFeta=0; HFeta<4; HFeta++){

0078       for(int HFRegion=0; HFRegion<2; HFRegion++){

0079       std::cout << HF[RCTcrate][HFeta][HFRegion] << '\t' <<

0080       testHF[RCTcrate][HFeta][HFRegion] << '\t'; std::cout <<

0081       HFQ[RCTcrate][HFeta][HFRegion] << '\t' <<

0082       testHFQ[RCTcrate][HFeta][HFRegion] << std::endl;

0083       }

0084       }*/
0085   }
0086 
0087   RoutingMode = 2;
0088   for (int RCTcrate = 0; RCTcrate < 18; RCTcrate++) {
0089     temp.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, RCTcrate);
0090     temp.RC012toSTRING(logicalCardID, eventNumber, RC[RCTcrate], RCof[RCTcrate], RCtau[RCTcrate], tempString);
0091 
0092     // now check its working ok

0093     // std::cout<<"MID: "<<tempString<<std::endl;

0094     temp.STRINGtoVHDCI(logicalCardID, eventNumber, tempString, VHDCI);
0095     temp.VHDCItoRC012(testRC[RCTcrate], testRCof[RCTcrate], testRCtau[RCTcrate], VHDCI);
0096     /*cout<<"------------------------------------"<<std::endl;

0097       for(int RCcard=0; RCcard<7; RCcard++){

0098       for(int Region=0; Region<2; Region++){

0099       std::cout << RC[RCTcrate][RCcard][Region] << '\t' <<

0100       testRC[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0101       RCof[RCTcrate][RCcard][Region] << '\t' <<

0102       testRCof[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0103       RCtau[RCTcrate][RCcard][Region] << '\t' <<

0104       testRCtau[RCTcrate][RCcard][Region] << std::endl;

0105       }

0106       }*/
0107   }
0108 
0109   RoutingMode = 3;
0110   for (int RCTcrate = 0; RCTcrate < 9; RCTcrate++) {
0111     temp.RoutingModetoLogicalCardID(logicalCardID, RoutingMode, RCTcrate);
0112     temp.RC234toSTRING(logicalCardID,
0113                        eventNumber,
0114                        RC[RCTcrate],
0115                        RCof[RCTcrate],
0116                        RCtau[RCTcrate],
0117                        RC[RCTcrate + 9],
0118                        RCof[RCTcrate + 9],
0119                        RCtau[RCTcrate + 9],
0120                        tempString);
0121 
0122     // now check its working ok

0123     // std::cout<<"MID: "<<tempString<<std::endl;

0124     temp.STRINGtoVHDCI(logicalCardID, eventNumber, tempString, VHDCI);
0125     temp.VHDCItoRC234(testRC[RCTcrate],
0126                       testRCof[RCTcrate],
0127                       testRCtau[RCTcrate],
0128                       testRC[RCTcrate + 9],
0129                       testRCof[RCTcrate + 9],
0130                       testRCtau[RCTcrate + 9],
0131                       VHDCI);
0132     /*cout<<"------------------------------------"<<std::endl;

0133       for(int RCcard=2; RCcard<5; RCcard++){

0134       for(int Region=0; Region<2; Region++){

0135       std::cout << RC[RCTcrate][RCcard][Region] << '\t' <<

0136       testRC[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0137       RCof[RCTcrate][RCcard][Region] << '\t' <<

0138       testRCof[RCTcrate][RCcard][Region] << '\t'; std::cout <<

0139       RCtau[RCTcrate][RCcard][Region] << '\t' <<

0140       testRCtau[RCTcrate][RCcard][Region] << std::endl; std::cout <<

0141       RC[RCTcrate+9][RCcard][Region] << '\t' <<

0142       testRC[RCTcrate+9][RCcard][Region] << '\t'; std::cout <<

0143       RCof[RCTcrate+9][RCcard][Region] << '\t' <<

0144       testRCof[RCTcrate+9][RCcard][Region] << '\t'; std::cout <<

0145       RCtau[RCTcrate+9][RCcard][Region] << '\t' <<

0146       testRCtau[RCTcrate+9][RCcard][Region] << std::endl;

0147       }

0148       }*/
0149   }
0150 
0151   std::cout << "and now to check..." << std::endl;
0152   for (int RCTcrate = 0; RCTcrate < 18; RCTcrate++) {
0153     std::cout << "------------------ " << RCTcrate << " ------------------" << std::endl;
0154     for (int RCcard = 0; RCcard < 7; RCcard++) {
0155       for (int Region = 0; Region < 2; Region++) {
0156         if ((RC[RCTcrate][RCcard][Region] != testRC[RCTcrate][RCcard][Region]) ||
0157             (RCof[RCTcrate][RCcard][Region] != testRCof[RCTcrate][RCcard][Region]) ||
0158             (RCtau[RCTcrate][RCcard][Region] != testRCtau[RCTcrate][RCcard][Region])) {
0159           std::cout << RC[RCTcrate][RCcard][Region] << '\t' << testRC[RCTcrate][RCcard][Region] << '\t';
0160           std::cout << RCof[RCTcrate][RCcard][Region] << '\t' << testRCof[RCTcrate][RCcard][Region] << '\t';
0161           std::cout << RCtau[RCTcrate][RCcard][Region] << '\t' << testRCtau[RCTcrate][RCcard][Region] << std::endl;
0162         }
0163       }
0164     }
0165     for (int HFeta = 0; HFeta < 4; HFeta++) {
0166       for (int HFRegion = 0; HFRegion < 2; HFRegion++) {
0167         if ((HF[RCTcrate][HFeta][HFRegion] != testHF[RCTcrate][HFeta][HFRegion]) ||
0168             (HFQ[RCTcrate][HFeta][HFRegion] != testHFQ[RCTcrate][HFeta][HFRegion])) {
0169           std::cout << HF[RCTcrate][HFeta][HFRegion] << '\t' << testHF[RCTcrate][HFeta][HFRegion] << '\t';
0170           std::cout << HFQ[RCTcrate][HFeta][HFRegion] << '\t' << testHFQ[RCTcrate][HFeta][HFRegion] << std::endl;
0171         }
0172       }
0173     }
0174   }
0175 }