Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // Test the various geometry/position transformations in calorimeter
0002 // regions input from the RCT to the GCT emulator.
0003 // This used to be done in a class called L1GctMap.
0004 
0005 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegion.h"
0006 
0007 #include <iostream>
0008 
0009 using namespace std;
0010 
0011 int main() {
0012   bool fail = false;
0013 
0014   // temp collection of IDs
0015   L1CaloRegionDetId ids[22][18];
0016 
0017   /// check conversion from RCT indices to ieta/iphi
0018 
0019   // construct HB/HE regions using RCT constructor
0020   for (unsigned crate = 0; crate < 18; crate++) {
0021     for (unsigned card = 0; card < 7; card++) {
0022       for (unsigned rgn = 0; rgn < 2; rgn++) {
0023         L1CaloRegionDetId r(crate, card, rgn);
0024         if ((r.rctCrate() != crate) || (r.rctCard() != card) || (r.rctRegion() != rgn)) {
0025           cout << "Error! : converting RCT indices to ieta/iphi at RCT crate " << crate << " card " << card
0026                << " region " << rgn << endl;
0027           fail = true;
0028         }
0029         if ((r.ieta() < 22) && (r.iphi() < 18)) {
0030           ids[r.ieta()][r.iphi()] = r;
0031         }
0032       }
0033     }
0034   }
0035 
0036   // construct HF regions using RCT constructor
0037   for (unsigned crate = 0; crate < 18; crate++) {
0038     for (unsigned rgn = 0; rgn < 8; rgn++) {
0039       L1CaloRegionDetId r(crate, 999, rgn);
0040       if ((r.rctCrate() != crate) || (r.rctRegion() != rgn)) {
0041         cerr << "Error! : RCT crate " << crate << " HF region " << rgn << endl;
0042         fail = true;
0043       }
0044       if ((r.ieta() < 22) && (r.iphi() < 18)) {
0045         ids[r.ieta()][r.iphi()] = r;
0046       }
0047     }
0048   }
0049 
0050   // check ieta/iphi map is filled correctly
0051   for (unsigned ieta = 0; ieta < 22; ieta++) {
0052     for (unsigned iphi = 0; iphi < 18; iphi++) {
0053       if (ids[ieta][iphi] != L1CaloRegionDetId(ieta, iphi)) {
0054         cerr << "Error! : missing L1CaloRegionDetId from RCT constructor at ieta=" << ieta << ", iphi=" << iphi << endl;
0055         fail = true;
0056       }
0057     }
0058   }
0059 
0060   /// check conversion from ieta/iphi to RCT indices
0061 
0062   for (unsigned ieta = 0; ieta < 22; ieta++) {
0063     for (unsigned iphi = 0; iphi < 18; iphi++) {
0064       L1CaloRegionDetId r(ieta, iphi);
0065       unsigned crate = r.rctCrate();
0066       unsigned card = r.rctCard();
0067       unsigned rgn = r.rctRegion();
0068       if (r != L1CaloRegionDetId(crate, card, rgn)) {
0069         cerr << "Error! : converting ieta/iphi to RCT indices at ieta=" << ieta << " iphi=" << iphi << endl;
0070         fail = true;
0071       }
0072     }
0073   }
0074 
0075   if (!fail)
0076     return 0;
0077   else
0078     return 1;
0079 }