Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TMuonEndCapPhase2/interface/DAQ/TPrimitives.h"
0002 
0003 #include "L1Trigger/L1TMuonEndCapPhase2/interface/Utils/CSCUtils.h"
0004 
0005 namespace emtf::phase2::csc {
0006 
0007   // Chambers
0008   int getNext10DegChamber(int chamber) { return (chamber == 36) ? 1 : (chamber + 1); }
0009 
0010   int getPrev10DegChamber(int chamber) { return (chamber == 1) ? 36 : (chamber - 1); }
0011 
0012   int getNext20DegChamber(int chamber) { return (chamber == 18) ? 1 : (chamber + 1); }
0013 
0014   int getPrev20DegChamber(int chamber) { return (chamber == 1) ? 18 : (chamber - 1); }
0015 
0016   // Sectors
0017   bool isTPInSector(int sp_endcap, int sp_sector, int tp_endcap, int tp_sector) {
0018     return sp_endcap == tp_endcap && sp_sector == tp_sector;
0019   }
0020 
0021   bool isTPInNeighborSector(
0022       int sp_endcap, int sp_sector, int tp_endcap, int tp_sector, int tp_subsector, int tp_station, int tp_id) {
0023     // Match endcap and neighbor sector
0024     int neighbor_sector = ((sp_sector == 1) ? 6 : sp_sector - 1);
0025 
0026     if ((sp_endcap != tp_endcap) || (neighbor_sector != tp_sector))
0027       return false;
0028 
0029     // Match CSCID in station 1
0030     if (tp_station == 1)
0031       return (tp_subsector == 2) && (tp_id == 3 || tp_id == 6 || tp_id == 9);
0032 
0033     // Match CSCID in other stations
0034     return tp_id == 3 || tp_id == 9;
0035   }
0036 
0037   // Use CSC trigger "CSC ID" definitions
0038   // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
0039   int getId(int station, int ring, int chamber) {
0040     int result = 0;
0041 
0042     if (station == 1) {
0043       result = (chamber) % 3 + 1;  // 1,2,3
0044 
0045       switch (ring) {
0046         case 1:
0047           break;
0048         case 2:
0049           result += 3;  // 4,5,6
0050           break;
0051         case 3:
0052           result += 6;  // 7,8,9
0053           break;
0054         case 4:
0055           break;
0056       }
0057     } else {
0058       if (ring == 1) {
0059         result = (chamber + 1) % 3 + 1;  // 1,2,3
0060       } else {
0061         result = (chamber + 3) % 6 + 4;  // 4,5,6,7,8,9
0062       }
0063     }
0064 
0065     return result;
0066   }
0067 
0068   // Use CSC trigger sector definitions
0069   // Copied from DataFormats/MuonDetId/src/CSCDetId.cc
0070   int getTriggerSector(int station, int ring, int chamber) {
0071     int result = 0;
0072 
0073     if (station > 1 && ring > 1) {
0074       result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;  // ch 3-8->1, 9-14->2, ... 1,2 -> 6
0075     } else if (station == 1) {
0076       result = ((static_cast<unsigned>(chamber - 3) & 0x7f) / 6) + 1;  // ch 3-8->1, 9-14->2, ... 1,2 -> 6
0077     } else {
0078       result = ((static_cast<unsigned>(chamber - 2) & 0x1f) / 3) + 1;  // ch 2-4-> 1, 5-7->2, ...
0079     }
0080 
0081     return (result <= 6) ? result
0082                          : 6;  // max sector is 6, some calculations give a value greater than six but this is expected.
0083   }
0084 
0085   int getTriggerSubsector(int station, int chamber) {
0086     // station 2,3,4 --> subsector 0
0087     if (station != 1) {
0088       return 0;
0089     }
0090 
0091     // station 1 --> subsector 1 or 2
0092     if ((chamber % 6) > 2) {
0093       return 1;
0094     }
0095 
0096     return 2;
0097   }
0098 
0099   // Copied from RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc
0100   Facing getFaceDirection(int station, int ring, int chamber) {
0101     bool is_not_overlapping = (station == 1 && ring == 3);
0102 
0103     // Not overlapping means it's facing backwards
0104     if (is_not_overlapping)
0105       return Facing::kRear;
0106 
0107     // odd chambers are bolted to the iron, which faces
0108     // forward in stations 1 and 2, backward in stations 3 and 4
0109     bool is_even = (chamber % 2 == 0);
0110 
0111     if (station < 3)
0112       return (is_even ? Facing::kRear : Facing::kFront);
0113 
0114     return (is_even ? Facing::kFront : Facing::kRear);
0115   }
0116 
0117   // Number of halfstrips and wiregroups
0118   // +----------------------------+------------+------------+
0119   // | Chamber type               | Num of     | Num of     |
0120   // |                            | halfstrips | wiregroups |
0121   // +----------------------------+------------+------------+
0122   // | ME1/1a                     | 96         | 48         |
0123   // | ME1/1b                     | 128        | 48         |
0124   // | ME1/2                      | 160        | 64         |
0125   // | ME1/3                      | 128        | 32         |
0126   // | ME2/1                      | 160        | 112        |
0127   // | ME3/1, ME4/1               | 160        | 96         |
0128   // | ME2/2, ME3/2, ME4/2        | 160        | 64         |
0129   // +----------------------------+------------+------------+
0130 
0131   std::pair<int, int> getMaxStripAndWire(int station, int ring) {
0132     int max_strip = 0;  // halfstrip
0133     int max_wire = 0;   // wiregroup
0134 
0135     if (station == 1 && ring == 4) {  // ME1/1a
0136       max_strip = 96;
0137       max_wire = 48;
0138     } else if (station == 1 && ring == 1) {  // ME1/1b
0139       max_strip = 128;
0140       max_wire = 48;
0141     } else if (station == 1 && ring == 2) {  // ME1/2
0142       max_strip = 160;
0143       max_wire = 64;
0144     } else if (station == 1 && ring == 3) {  // ME1/3
0145       max_strip = 128;
0146       max_wire = 32;
0147     } else if (station == 2 && ring == 1) {  // ME2/1
0148       max_strip = 160;
0149       max_wire = 112;
0150     } else if (station >= 3 && ring == 1) {  // ME3/1, ME4/1
0151       max_strip = 160;
0152       max_wire = 96;
0153     } else if (station >= 2 && ring == 2) {  // ME2/2, ME3/2, ME4/2
0154       max_strip = 160;
0155       max_wire = 64;
0156     }
0157 
0158     return std::make_pair(max_strip, max_wire);
0159   }
0160 
0161   std::pair<int, int> getMaxPatternAndQuality(int station, int ring) {
0162     int max_pattern = 11;
0163     int max_quality = 16;
0164 
0165     return std::make_pair(max_pattern, max_quality);
0166   }
0167 
0168 }  // namespace emtf::phase2::csc