Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:20:59

0001 #include "L1Trigger/L1TMuonEndCap/interface/TrackTools.h"
0002 
0003 namespace emtf {
0004 
0005   int calc_ring(int station, int csc_ID, int strip) {
0006     if (station > 1) {
0007       if (csc_ID < 4)
0008         return 1;
0009       else if (csc_ID < 10)
0010         return 2;
0011       else
0012         return -999;
0013     } else if (station == 1) {
0014       if (csc_ID < 4 && strip > 127)
0015         return 4;
0016       else if (csc_ID < 4 && strip >= 0)
0017         return 1;
0018       else if (csc_ID > 3 && csc_ID < 7)
0019         return 2;
0020       else if (csc_ID > 6 && csc_ID < 10)
0021         return 3;
0022       else
0023         return -999;
0024     } else
0025       return -999;
0026   }
0027 
0028   int calc_chamber(int station, int sector, int subsector, int ring, int csc_ID) {
0029     int chamber = -999;
0030     if (station == 1) {
0031       chamber = ((sector - 1) * 6) + csc_ID + 2;  // Chamber offset of 2: First chamber in sector 1 is chamber 3
0032       if (ring == 2)
0033         chamber -= 3;
0034       if (ring == 3)
0035         chamber -= 6;
0036       if (subsector == 2)
0037         chamber += 3;
0038       if (chamber > 36)
0039         chamber -= 36;
0040     } else if (ring == 1) {
0041       chamber = ((sector - 1) * 3) + csc_ID + 1;  // Chamber offset of 1: First chamber in sector 1 is chamber 2
0042       if (chamber > 18)
0043         chamber -= 18;
0044     } else if (ring == 2) {
0045       chamber = ((sector - 1) * 6) + csc_ID - 3 + 2;  // Chamber offset of 2: First chamber in sector 1 is chamber 3
0046       if (chamber > 36)
0047         chamber -= 36;
0048     }
0049     return chamber;
0050   }
0051 
0052   // Calculates special chamber ID for track address sent to uGMT, using CSC_ID, subsector, neighbor, and station
0053   int calc_uGMT_chamber(int csc_ID, int subsector, int neighbor, int station) {
0054     if (station == 1) {
0055       if (csc_ID == 3 && neighbor == 1 && subsector == 2)
0056         return 1;
0057       else if (csc_ID == 6 && neighbor == 1 && subsector == 2)
0058         return 2;
0059       else if (csc_ID == 9 && neighbor == 1 && subsector == 2)
0060         return 3;
0061       else if (csc_ID == 3 && neighbor == 0 && subsector == 2)
0062         return 4;
0063       else if (csc_ID == 6 && neighbor == 0 && subsector == 2)
0064         return 5;
0065       else if (csc_ID == 9 && neighbor == 0 && subsector == 2)
0066         return 6;
0067       else
0068         return 0;
0069     } else {
0070       if (csc_ID == 3 && neighbor == 1)
0071         return 1;
0072       else if (csc_ID == 9 && neighbor == 1)
0073         return 2;
0074       else if (csc_ID == 3 && neighbor == 0)
0075         return 3;
0076       else if (csc_ID == 9 && neighbor == 0)
0077         return 4;
0078       else
0079         return 0;
0080     }
0081   }
0082 
0083   // Use CSC trigger sector definitions
0084   // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
0085   int get_trigger_sector(int ring, int station, int chamber) {
0086     int result = 0;
0087     if (station > 1 && ring > 1) {
0088       result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;  // ch 3-8->1, 9-14->2, ... 1,2 -> 6
0089     } else if (station == 1) {
0090       result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;  // ch 3-8->1, 9-14->2, ... 1,2 -> 6
0091     } else {
0092       result = ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1;  // ch 2-4-> 1, 5-7->2, ...
0093     }
0094     return (result <= 6) ? result
0095                          : 6;  // max sector is 6, some calculations give a value greater than six but this is expected.
0096   }
0097 
0098   // Use CSC trigger "CSC ID" definitions
0099   // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
0100   int get_trigger_csc_ID(int ring, int station, int chamber) {
0101     int result = 0;
0102     if (station == 1) {
0103       result = (chamber) % 3 + 1;  // 1,2,3
0104       switch (ring) {
0105         case 1:
0106           break;
0107         case 2:
0108           result += 3;  // 4,5,6
0109           break;
0110         case 3:
0111           result += 6;  // 7,8,9
0112           break;
0113         case 4:                            // ME0
0114           result = (chamber + 1) % 3 + 1;  // 1,2,3
0115           break;
0116       }
0117     } else {
0118       if (ring == 1) {
0119         result = (chamber + 1) % 3 + 1;  // 1,2,3
0120       } else {
0121         result = (chamber + 3) % 6 + 4;  // 4,5,6,7,8,9
0122       }
0123     }
0124     return result;
0125   }
0126 
0127   // Number of halfstrips and wiregroups
0128   // +----------------------------+------------+------------+
0129   // | Chamber type               | Num of     | Num of     |
0130   // |                            | halfstrips | wiregroups |
0131   // +----------------------------+------------+------------+
0132   // | ME1/1a                     | 96         | 48         |
0133   // | ME1/1b                     | 128        | 48         |
0134   // | ME1/2                      | 160        | 64         |
0135   // | ME1/3                      | 128        | 32         |
0136   // | ME2/1                      | 160        | 112        |
0137   // | ME3/1, ME4/1               | 160        | 96         |
0138   // | ME2/2, ME3/2, ME4/2        | 160        | 64         |
0139   // +----------------------------+------------+------------+
0140 
0141   std::pair<int, int> get_csc_max_strip_and_wire(int station, int ring) {
0142     int max_strip = 0;                // halfstrip
0143     int max_wire = 0;                 // wiregroup
0144     if (station == 1 && ring == 4) {  // ME1/1a
0145       max_strip = 96;
0146       max_wire = 48;
0147     } else if (station == 1 && ring == 1) {  // ME1/1b
0148       max_strip = 128;
0149       max_wire = 48;
0150     } else if (station == 1 && ring == 2) {  // ME1/2
0151       max_strip = 160;
0152       max_wire = 64;
0153     } else if (station == 1 && ring == 3) {  // ME1/3
0154       max_strip = 128;
0155       max_wire = 32;
0156     } else if (station == 2 && ring == 1) {  // ME2/1
0157       max_strip = 160;
0158       max_wire = 112;
0159     } else if (station >= 3 && ring == 1) {  // ME3/1, ME4/1
0160       max_strip = 160;
0161       max_wire = 96;
0162     } else if (station >= 2 && ring == 2) {  // ME2/2, ME3/2, ME4/2
0163       max_strip = 160;
0164       max_wire = 64;
0165     }
0166     return std::make_pair(max_strip, max_wire);
0167   }
0168 
0169   std::pair<int, int> get_csc_max_pattern_and_quality(int station, int ring) {
0170     int max_pattern = 11;
0171     int max_quality = 16;
0172     return std::make_pair(max_pattern, max_quality);
0173   }
0174 
0175   int get_csc_max_slope(int station, int ring, bool useRun3CCLUT_OTMB, bool useRun3CCLUT_TMB) {
0176     int max_slope = 65536;  // Uninitialized slope can be 65536. This is expected when CCLUT is not running
0177     if (useRun3CCLUT_OTMB and (ring == 1 or ring == 4))
0178       max_slope = 16;
0179     if (useRun3CCLUT_TMB and (ring == 2 or ring == 3))
0180       max_slope = 16;
0181     return max_slope;
0182   }
0183 
0184 }  // namespace emtf