Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:19:35

0001 #include "L1Trigger/CSCTriggerPrimitives/interface/CSCALCTCrossCLCT.h"
0002 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0003 #include "DataFormats/CSCDigi/interface/CSCALCTDigi.h"
0004 #include "DataFormats/CSCDigi/interface/CSCCLCTDigi.h"
0005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0006 
0007 namespace {
0008 
0009   // LUTs to map wiregroup onto min and max half-strip number that it crosses in ME1/1
0010   // These LUTs are deliberately not implemented as eventsetup objects
0011   constexpr std::array<int, 48> wg_min_hs_ME1a_ = {
0012       {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, -1, -1, -1, -1, -1, -1, -1, -1,
0013        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, -1, -1, -1, -1, -1, -1, -1}};
0014   constexpr std::array<int, 48> wg_max_hs_ME1a_ = {
0015       {223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 205, 189, 167, 150, -1, -1, -1, -1, -1, -1, -1, -1,
0016        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, -1, -1, -1, -1, -1, -1, -1}};
0017   constexpr std::array<int, 48> wg_min_hs_ME1a_ganged_ = {
0018       {128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, -1, -1, -1, -1, -1, -1, -1, -1,
0019        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, -1, -1, -1, -1, -1, -1, -1}};
0020   constexpr std::array<int, 48> wg_max_hs_ME1a_ganged_ = {
0021       {159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 159, 150, -1, -1, -1, -1, -1, -1, -1, -1,
0022        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, -1, -1, -1, -1, -1, -1, -1}};
0023   constexpr std::array<int, 48> wg_min_hs_ME1b_ = {{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 100, 73, 47, 22, 0, 0,
0024                                                     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   0,  0,  0,  0, 0,
0025                                                     0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,   0,  0,  0,  0, 0}};
0026   constexpr std::array<int, 48> wg_max_hs_ME1b_ = {{-1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  127, 127,
0027                                                     127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
0028                                                     127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,
0029                                                     127, 127, 127, 127, 127, 127, 127, 127, 105, 93,  78,  63}};
0030 };  // namespace
0031 
0032 CSCALCTCrossCLCT::CSCALCTCrossCLCT(
0033     unsigned endcap, unsigned station, unsigned ring, bool ignoreAlctCrossClct, const edm::ParameterSet& conf)
0034     : endcap_(endcap), station_(station), ring_(ring) {
0035   const auto& commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
0036   gangedME1a_ = commonParams.getParameter<bool>("gangedME1a");
0037   ignoreAlctCrossClct_ = ignoreAlctCrossClct;
0038 }
0039 
0040 bool CSCALCTCrossCLCT::doesALCTCrossCLCT(const CSCALCTDigi& a, const CSCCLCTDigi& c) const {
0041   // both need to valid
0042   if (!c.isValid() || !a.isValid()) {
0043     return false;
0044   }
0045 
0046   // when non-overlapping half-strips and wiregroups don't matter
0047   if (ignoreAlctCrossClct_)
0048     return true;
0049 
0050   // overlap only needs to be considered for ME1/1
0051   if (station_ == 1 and ring_ == 1) {
0052     return doesWiregroupCrossHalfStrip(a.getKeyWG(), c.getKeyStrip());
0053   } else
0054     return true;
0055 }
0056 
0057 bool CSCALCTCrossCLCT::doesWiregroupCrossHalfStrip(int wiregroup, int halfstrip) const {
0058   // sanity-check for invalid wiregroups
0059   if (wiregroup < 0 or wiregroup >= CSCConstants::NUM_WIREGROUPS_ME11)
0060     return false;
0061 
0062   const int min_hs_ME1a = wg_min_hs_ME1a_[wiregroup];
0063   const int max_hs_ME1a = wg_max_hs_ME1a_[wiregroup];
0064   const int min_hs_ME1a_ganged = wg_min_hs_ME1a_ganged_[wiregroup];
0065   const int max_hs_ME1a_ganged = wg_max_hs_ME1a_ganged_[wiregroup];
0066   const int min_hs_ME1b = wg_min_hs_ME1b_[wiregroup];
0067   const int max_hs_ME1b = wg_max_hs_ME1b_[wiregroup];
0068 
0069   // ME1/a half-strip starts at 128
0070   if (halfstrip > CSCConstants::MAX_HALF_STRIP_ME1B) {
0071     if (!gangedME1a_) {
0072       // wrap around ME11 HS number for -z endcap
0073       if (endcap_ == 2) {
0074         // first subtract 128
0075         halfstrip -= 1 + CSCConstants::MAX_HALF_STRIP_ME1B;
0076         // flip the HS
0077         halfstrip = CSCConstants::MAX_HALF_STRIP_ME1A_UNGANGED - halfstrip;
0078         // then add 128 again
0079         halfstrip += 1 + CSCConstants::MAX_HALF_STRIP_ME1B;
0080       }
0081       return halfstrip >= min_hs_ME1a && halfstrip <= max_hs_ME1a;
0082     }
0083 
0084     else {
0085       // wrap around ME11 HS number for -z endcap
0086       if (endcap_ == 2) {
0087         // first subtract 128
0088         halfstrip -= 1 + CSCConstants::MAX_HALF_STRIP_ME1B;
0089         // flip the HS
0090         halfstrip = CSCConstants::MAX_HALF_STRIP_ME1A_GANGED - halfstrip;
0091         // then add 128 again
0092         halfstrip += 1 + CSCConstants::MAX_HALF_STRIP_ME1B;
0093       }
0094       return halfstrip >= min_hs_ME1a_ganged && halfstrip <= max_hs_ME1a_ganged;
0095     }
0096   }
0097   // ME1/b half-strip ends at 127
0098   else if (halfstrip <= CSCConstants::MAX_HALF_STRIP_ME1B) {
0099     if (endcap_ == 2) {
0100       halfstrip = CSCConstants::MAX_HALF_STRIP_ME1B - halfstrip;
0101     }
0102     return halfstrip >= min_hs_ME1b && halfstrip <= max_hs_ME1b;
0103   }
0104   // all other cases, return true
0105   else
0106     return true;
0107 }