Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "DataFormats/L1TMuon/interface/EMTFHit.h"
0002 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0003 
0004 namespace l1t {
0005 
0006   CSCDetId EMTFHit::CreateCSCDetId() const {
0007     return CSCDetId((endcap == 1) ? 1 : 2, station, (ring == 4) ? 1 : ring, chamber, 0);
0008     // Layer always filled as 0 (indicates "whole chamber")
0009     // See http://cmslxr.fnal.gov/source/L1Trigger/CSCTriggerPrimitives/src/CSCTriggerPrimitivesBuilder.cc#0198
0010   }
0011 
0012   RPCDetId EMTFHit::CreateRPCDetId() const {
0013     int roll_ = roll;
0014     int theta_ = theta_fp / 4;
0015     if (roll < 1 || roll > 3) {
0016       switch (station * 2 + ring) {  // Infer roll from integer theta value, by station / ring
0017         case 4:
0018           roll_ = (theta_ < 17 ? 3 : (theta_ > 18 ? 1 : 2));
0019           break;  // RE1/2
0020         case 6:
0021           roll_ = (theta_ < 16 ? 3 : (theta_ > 17 ? 1 : 2));
0022           break;  // RE2/2
0023         case 8:
0024           roll_ = (theta_ < 12 ? 3 : (theta_ > 13 ? 1 : 2));
0025           break;  // RE3/2
0026         case 9:
0027           roll_ = (theta_ < 20 ? 3 : (theta_ > 21 ? 1 : 2));
0028           break;  // RE3/3
0029         case 10:
0030           roll_ = (theta_ < 11 ? 3 : (theta_ > 11 ? 1 : 2));
0031           break;  // RE4/2
0032         case 11:
0033           roll_ = (theta_ < 18 ? 3 : (theta_ > 19 ? 1 : 2));
0034           break;  // RE4/3
0035         default:
0036           roll_ = 2;  // Default to 2 if no valid value found
0037       }
0038     }
0039 
0040     return RPCDetId(endcap, ring, station, sector_RPC, 1, subsector_RPC, roll_);
0041     // Layer always filled as 1, as layer 2 is only used in the barrel
0042   }
0043 
0044   GEMDetId EMTFHit::CreateGEMDetId() const {
0045     return GEMDetId((endcap == 1) ? 1 : -1, ring, station, layer, chamber, roll);
0046   }
0047 
0048   ME0DetId EMTFHit::CreateME0DetId() const { return ME0DetId((endcap == 1) ? 1 : -1, layer, chamber, roll); }
0049 
0050   CPPFDigi EMTFHit::CreateCPPFDigi() const {
0051     if (!Is_RPC())
0052       return CPPFDigi();
0053 
0054     int board_ = 1 + ((chamber % 36) / 9);  // RPC chamber to CPPF board mapping
0055     int channel_ = (chamber % 9);           // RPC chamber to CPPF output link mapping
0056     int sector_ = (sector_idx + 1) - 6 * (endcap == -1);
0057     int link_ = (neighbor ? 0 : 1 + (((chamber + 33) % 36) % 6));     // RPC chamber to EMTF input link mapping
0058     int nStrips_ = (strip_low < 0 ? -99 : 1 + strip_hi - strip_low);  // Cluster size in number of strips
0059 
0060     return CPPFDigi(RPC_DetId(),
0061                     bx,
0062                     phi_fp / 4,
0063                     theta_fp / 4,
0064                     valid,
0065                     board_,
0066                     channel_,
0067                     sector_,
0068                     link_,
0069                     strip_low,
0070                     nStrips_,
0071                     phi_glob,
0072                     theta);
0073   }
0074 
0075   CSCCorrelatedLCTDigi EMTFHit::CreateCSCCorrelatedLCTDigi(const bool isRun3) const {
0076     CSCCorrelatedLCTDigi lct = CSCCorrelatedLCTDigi(1,
0077                                                     valid,
0078                                                     quality,
0079                                                     wire,
0080                                                     strip,
0081                                                     pattern,
0082                                                     (bend == 1) ? 1 : 0,
0083                                                     bx + CSCConstants::LCT_CENTRAL_BX,
0084                                                     0,
0085                                                     0,
0086                                                     sync_err,
0087                                                     csc_ID);
0088     bool quart_bit = strip_quart_bit == 1;
0089     bool eighth_bit = strip_eighth_bit == 1;
0090 
0091     lct.setQuartStripBit(quart_bit);
0092     lct.setEighthStripBit(eighth_bit);
0093     lct.setSlope(slope);
0094     lct.setRun3Pattern(pattern_run3);
0095     lct.setRun3(isRun3);
0096 
0097     return lct;
0098     // Added Run 3 parameters - EY 04.07.22
0099     // Filling "trknmb" with 1 and "bx0" with 0 (as in MC).
0100     // May consider filling "trknmb" with 2 for 2nd LCT in the same chamber. - AWB 24.05.17
0101     // trknmb and bx0 are unused in the EMTF emulator code. mpclink = 0 (after bx) indicates unsorted.
0102   }
0103 
0104   CSCShowerDigi EMTFHit::CreateCSCShowerDigi() const {
0105     CSCShowerDigi shower = CSCShowerDigi(muon_shower_inTime == -99 ? 0 : muon_shower_inTime,
0106                                          muon_shower_outOfTime == -99 ? 0 : muon_shower_outOfTime,
0107                                          csc_ID,
0108                                          bx + CSCConstants::LCT_CENTRAL_BX,
0109                                          CSCShowerDigi::ShowerType::kEMTFShower);
0110 
0111     return shower;
0112   }
0113 
0114   // // Not yet implemented - AWB 15.03.17
0115   // RPCDigi EMTFHit::CreateRPCDigi() const {
0116   //   return RPCDigi( (strip_hi + strip_lo) / 2, bx + CSCConstants::LCT_CENTRAL_BX );
0117   // }
0118 
0119   GEMPadDigiCluster EMTFHit::CreateGEMPadDigiCluster() const {
0120     std::vector<uint16_t> pads;
0121     for (int i = Pad_low(); i < Pad_hi(); ++i)
0122       pads.emplace_back(static_cast<uint16_t>(i));
0123     return GEMPadDigiCluster(pads, bx);
0124   }
0125 
0126 }  // End namespace l1t