CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.cc

Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //
00003 //   Class: CSCMuonPortCard
00004 //
00005 //   Description: 
00006 //    Simulates the functionality of the Muon Port Card (MPC).  Each MPC
00007 //    is responsible for 9 Trigger Mother Boards (TMBs).  It takes the up to
00008 //    18 LCTs (2/TMB) in each (sub)sector every bunch crossing, sorts them,
00009 //    selects up to three best, and puts them into an output collection.
00010 //
00011 //   Author List: Benn Tannenbaum 30 August 1999.
00012 //                Based on code by Nick Wisniewski.
00013 //
00014 //   $Date: 2012/12/05 21:14:23 $
00015 //   $Revision: 1.7 $
00016 //
00017 //   Modifications: Numerous later improvements by Jason Mumford and
00018 //                  Slava Valuev (see cvs in ORCA).
00019 //   Porting/reworking from ORCA by L. Gray (UF), June 2006.
00020 //
00021 //-----------------------------------------------------------------------------
00022 
00023 #include "L1Trigger/CSCTriggerPrimitives/src/CSCMuonPortCard.h"
00024 #include "L1Trigger/CSCCommonTrigger/interface/CSCConstants.h"
00025 #include <algorithm>
00026 
00027 CSCMuonPortCard::CSCMuonPortCard()
00028 {
00029   max_stubs_ = CSCConstants::maxStubs;
00030 }
00031 
00032 CSCMuonPortCard::CSCMuonPortCard(const edm::ParameterSet& conf)
00033 {
00034   max_stubs_ = CSCConstants::maxStubs;
00035 
00036   edm::ParameterSet commonParams = conf.getParameter<edm::ParameterSet>("commonParam");
00037   if (commonParams.getUntrackedParameter<bool>("isSLHC",false))
00038   {
00039     edm::ParameterSet mpcParams = conf.getParameter<edm::ParameterSet>("mpcSLHC");
00040     max_stubs_ = mpcParams.getUntrackedParameter<unsigned int>("mpcMaxStubs", CSCConstants::maxStubs);
00041   }
00042 }
00043 
00044 void CSCMuonPortCard::loadDigis(const CSCCorrelatedLCTDigiCollection& thedigis)
00045 {
00046   // Put everything from the digi container into a trigger container.
00047   // This allows us to sort per BX more easily.
00048   clear();
00049 
00050   CSCCorrelatedLCTDigiCollection::DigiRangeIterator Citer;
00051 
00052   for (Citer = thedigis.begin(); Citer != thedigis.end(); Citer++) {
00053     CSCCorrelatedLCTDigiCollection::const_iterator Diter = (*Citer).second.first;
00054     CSCCorrelatedLCTDigiCollection::const_iterator Dend = (*Citer).second.second;
00055 
00056     for (; Diter != Dend; Diter++) {
00057       csctf::TrackStub theStub((*Diter), (*Citer).first);
00058       stubs_.push_back(theStub);
00059     }
00060   }
00061 }
00062 
00063 std::vector<csctf::TrackStub> CSCMuonPortCard::sort(const unsigned endcap, const unsigned station, 
00064                                                     const unsigned sector, const unsigned subsector, const int bx)
00065 {
00066   std::vector<csctf::TrackStub> result;
00067   std::vector<csctf::TrackStub>::iterator LCT;
00068 
00069   result = stubs_.get(endcap, station, sector, subsector, bx);
00070 
00071   // Make sure no Quality 0 or non-valid LCTs come through the portcard.
00072   for (LCT = result.begin(); LCT != result.end(); LCT++) {
00073     if ( !(LCT->getQuality() && LCT->isValid()) )
00074       result.erase(LCT, LCT);
00075   }
00076 
00077   if (result.size()) {
00078     std::sort(result.begin(), result.end(), std::greater<csctf::TrackStub>());
00079     // Can only return maxStubs or less LCTs per bunch crossing.
00080     if (result.size() > max_stubs_)
00081       result.erase(result.begin() + max_stubs_, result.end());
00082 
00083 
00084     // Go through the sorted list and label the LCTs with a sorting number.
00085     unsigned i = 0;
00086     for (LCT = result.begin(); LCT != result.end(); LCT++)
00087       LCT->setMPCLink(++i);
00088   }
00089 
00090   return result;
00091 }