File indexing completed on 2023-03-17 11:11:02
0001 #include "L1Trigger/CSCTriggerPrimitives/interface/CSCMuonPortCard.h"
0002 #include "DataFormats/CSCDigi/interface/CSCConstants.h"
0003 #include <algorithm>
0004
0005 CSCMuonPortCard::CSCMuonPortCard() {}
0006
0007 CSCMuonPortCard::CSCMuonPortCard(unsigned endcap, unsigned station, unsigned sector, const edm::ParameterSet& conf)
0008 : theEndcap(endcap), theStation(station), theSector(sector) {
0009
0010 minBX_ = conf.getParameter<int>("MinBX");
0011 maxBX_ = conf.getParameter<int>("MaxBX");
0012
0013 const auto& mpcParams = conf.getParameter<edm::ParameterSet>("mpcParam");
0014 sort_stubs_ = mpcParams.getParameter<bool>("sortStubs");
0015 drop_invalid_stubs_ = mpcParams.getParameter<bool>("dropInvalidStubs");
0016 drop_low_quality_stubs_ = mpcParams.getParameter<bool>("dropLowQualityStubs");
0017 max_stubs_ = mpcParams.getParameter<unsigned>("maxStubs");
0018
0019 const std::string eSign = endcap == 1 ? "+" : "-";
0020 vmeName_ = "VME" + eSign + std::to_string(theStation) + "/" + std::to_string(theSector);
0021 }
0022
0023 void CSCMuonPortCard::clear() {
0024 stubs_.clear();
0025 selectedStubs_.clear();
0026 }
0027
0028 void CSCMuonPortCard::loadLCTs(const CSCCorrelatedLCTDigiCollection& thedigis) {
0029
0030 clear();
0031
0032 for (auto Citer = thedigis.begin(); Citer != thedigis.end(); Citer++) {
0033 const CSCDetId& detid((*Citer).first);
0034 const unsigned endcap = detid.endcap();
0035 const unsigned station = detid.station();
0036 const unsigned sector = detid.triggerSector();
0037
0038
0039 if (endcap != theEndcap or station != theStation or sector != theSector)
0040 continue;
0041
0042
0043
0044 for (auto Diter = (*Citer).second.first; Diter != (*Citer).second.second; Diter++) {
0045 stubs_.push_back(csctf::TrackStub((*Diter), (*Citer).first));
0046 }
0047 }
0048 }
0049
0050 void CSCMuonPortCard::sortLCTs() {
0051
0052 for (int bx = minBX_; bx <= maxBX_; ++bx) {
0053
0054 if (theStation == 1) {
0055 sortLCTs(1, bx);
0056 sortLCTs(2, bx);
0057 }
0058
0059 else {
0060 sortLCTs(0, bx);
0061 }
0062 }
0063 }
0064
0065 void CSCMuonPortCard::sortLCTs(const unsigned subsector, const int bx) {
0066
0067 std::vector<csctf::TrackStub> result = stubs_.get(theEndcap, theStation, theSector, subsector, bx);
0068
0069
0070 for (auto LCT = result.begin(); LCT != result.end(); LCT++) {
0071
0072 if (drop_invalid_stubs_ && !LCT->isValid()) {
0073 result.erase(LCT, LCT);
0074 }
0075
0076
0077 if (drop_low_quality_stubs_ && LCT->getQuality() == 0) {
0078 result.erase(LCT, LCT);
0079 }
0080 }
0081
0082
0083 if (!result.empty()) {
0084
0085 if (sort_stubs_) {
0086 std::sort(result.begin(), result.end(), std::greater<csctf::TrackStub>());
0087 }
0088
0089
0090 const unsigned maxStubs = std::min(max_stubs_, unsigned(CSCConstants::MAX_LCTS_PER_MPC));
0091 if (result.size() > maxStubs) {
0092 result.erase(result.begin() + maxStubs, result.end());
0093 }
0094
0095
0096 unsigned i = 0;
0097 for (auto LCT = result.begin(); LCT != result.end(); LCT++) {
0098 LCT->setMPCLink(++i);
0099 }
0100
0101
0102 selectedStubs_.insert(selectedStubs_.end(), result.begin(), result.end());
0103 }
0104 }