Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:45

0001 
0002 
0003 #include "DataFormats/L1CaloTrigger/interface/L1CaloRegionDetId.h"
0004 
0005 // default constructor - null DetId
0006 L1CaloRegionDetId::L1CaloRegionDetId() : DetId() {}
0007 
0008 // construct from raw id
0009 L1CaloRegionDetId::L1CaloRegionDetId(uint32_t rawid) : DetId(rawid) {}
0010 
0011 // construct from ieta, iphi indices
0012 // ieta runs from 0 (at -z) to 21 (at +z)
0013 L1CaloRegionDetId::L1CaloRegionDetId(unsigned ieta, unsigned iphi) : DetId(Calo, 2) {
0014   id_ |= (ieta & 0x1f) | ((iphi & 0x1f) << 5);
0015 }
0016 
0017 // construct from RCT crate, card, region IDs
0018 L1CaloRegionDetId::L1CaloRegionDetId(unsigned icrate, unsigned icard, unsigned irgn) : DetId(Calo, 2) {
0019   int ieta = 0;
0020   int iphi = 0;
0021 
0022   // Calculate iphi
0023   int phi_index = icrate % 9;
0024   if ((icard == 0) || (icard == 2) || (icard == 4))
0025     phi_index = phi_index * 2;
0026   else if ((icard == 1) || (icard == 3) || (icard == 5))
0027     phi_index = phi_index * 2 + 1;
0028   else if (icard == 6)
0029     phi_index = phi_index * 2 + irgn;
0030   // for HF
0031   else if (icard == 999)
0032     phi_index = phi_index * 2 + (irgn / 4);
0033   iphi = (22 - phi_index) % 18;
0034 
0035   // Calculate ieta
0036   int eta_index = 0;
0037   if (icard < 6)
0038     eta_index = (icard / 2) * 2 + irgn;
0039   else if (icard == 6)
0040     eta_index = 6;
0041   // HF
0042   else if (icard == 999)
0043     eta_index = (irgn % 4) + 7;
0044 
0045   if (icrate < 9)
0046     ieta = 10 - eta_index;
0047   else if (icrate >= 9)
0048     ieta = 11 + eta_index;
0049 
0050   /// TODO - check calculation of ieta and iphi from RCT crate/card/region #
0051   id_ |= (ieta & 0x1f) | ((iphi & 0x1f) << 5);
0052 }
0053 
0054 // return RCT crate ID
0055 unsigned L1CaloRegionDetId::rctCrate() const {  // TODO - check this is correct!
0056   unsigned phiCrate = ((N_PHI + 4 - iphi()) % N_PHI) / 2;
0057   return (ieta() < (N_ETA / 2) ? phiCrate : phiCrate + N_PHI / 2);
0058 }
0059 
0060 // return RCT card number
0061 unsigned L1CaloRegionDetId::rctCard() const {
0062   unsigned card = 999;
0063   unsigned rct_phi_index = (22 - iphi()) % 18;
0064   if ((ieta() == 4) || (ieta() == 17)) {
0065     card = 6;
0066   } else if ((ieta() > 4) && (ieta() <= 10)) {
0067     unsigned index = (ieta() - 5) / 2;
0068     card = ((2 - index) * 2) + (rct_phi_index % 2);
0069   } else if ((ieta() >= 11) && (ieta() < 17)) {
0070     unsigned index = (ieta() - 11) / 2;
0071     card = (index * 2) + (rct_phi_index % 2);
0072   }
0073   return card;
0074 }
0075 
0076 // return RCT region number
0077 unsigned L1CaloRegionDetId::rctRegion() const {
0078   unsigned rgn = 999;
0079   unsigned rct_phi_index = (22 - iphi()) % 18;
0080   if (ieta() < 4) {
0081     rgn = (3 - ieta()) + 4 * (rct_phi_index % 2);
0082   } else if (ieta() > 17) {
0083     rgn = (ieta() - 18) + 4 * (rct_phi_index % 2);
0084   } else if ((ieta() == 4) || (ieta() == 17)) {
0085     rgn = (rct_phi_index % 2);
0086   } else if ((ieta() > 4) && (ieta() <= 10)) {
0087     rgn = (ieta() % 2);
0088   } else if ((ieta() >= 11) && (ieta() < 17)) {
0089     rgn = ((ieta() - 1) % 2);
0090   }
0091   return rgn;
0092 }