Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-24 02:52:15

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   // Get min and max BX to sort LCTs in MPC.
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   // clear the input and output collection
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     // select stubs by region
0039     if (endcap != theEndcap or station != theStation or sector != theSector)
0040       continue;
0041 
0042     // Put everything from the digi container into a trigger container.
0043     // This allows us to sort per BX more easily.
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   // sort the LCTs per BX and subsector
0052   for (int bx = minBX_; bx <= maxBX_; ++bx) {
0053     // station 1 case with all 10 degree chambers
0054     if (theStation == 1) {
0055       sortLCTs(1, bx);
0056       sortLCTs(2, bx);
0057     }
0058     // station 2,3,4 case with mixture of 10 and 20 degree chambers
0059     else {
0060       sortLCTs(0, bx);
0061     }
0062   }
0063 }
0064 
0065 void CSCMuonPortCard::sortLCTs(const unsigned subsector, const int bx) {
0066   // temporary vector
0067   std::vector<csctf::TrackStub> result = stubs_.get(theEndcap, theStation, theSector, subsector, bx);
0068 
0069   // pre-selection step
0070   for (auto LCT = result.begin(); LCT != result.end(); LCT++) {
0071     // step 1: no invalid stubs
0072     if (drop_invalid_stubs_ && !LCT->isValid()) {
0073       result.erase(LCT, LCT);
0074     }
0075 
0076     // step 2: no low-quality stubs
0077     if (drop_low_quality_stubs_ && LCT->getQuality() == 0) {
0078       result.erase(LCT, LCT);
0079     }
0080   }
0081 
0082   // sort+select
0083   if (!result.empty()) {
0084     // sort according to quality and CSCDetId
0085     if (sort_stubs_) {
0086       std::sort(result.begin(), result.end(), std::greater<csctf::TrackStub>());
0087     }
0088 
0089     // select up to MAX_LCTS_PER_MPC (default 18) per bunch crossing.
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     // Go through the sorted list and label the LCTs with a sorting number.
0096     unsigned i = 0;
0097     for (auto LCT = result.begin(); LCT != result.end(); LCT++) {
0098       LCT->setMPCLink(++i);
0099     }
0100 
0101     // now insert the temporary vector in the output collection
0102     selectedStubs_.insert(selectedStubs_.end(), result.begin(), result.end());
0103   }
0104 }