CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch2/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: 2009/02/09 21:33:37 $
00015 //   $Revision: 1.6 $
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 void CSCMuonPortCard::loadDigis(const CSCCorrelatedLCTDigiCollection& thedigis)
00028 {
00029   // Put everything from the digi container into a trigger container.
00030   // This allows us to sort per BX more easily.
00031   clear();
00032 
00033   CSCCorrelatedLCTDigiCollection::DigiRangeIterator Citer;
00034 
00035   for (Citer = thedigis.begin(); Citer != thedigis.end(); Citer++) {
00036     CSCCorrelatedLCTDigiCollection::const_iterator Diter = (*Citer).second.first;
00037     CSCCorrelatedLCTDigiCollection::const_iterator Dend = (*Citer).second.second;
00038 
00039     for (; Diter != Dend; Diter++) {
00040       csctf::TrackStub theStub((*Diter), (*Citer).first);
00041       _stubs.push_back(theStub);
00042     }
00043   }
00044 }
00045 
00046 std::vector<csctf::TrackStub> CSCMuonPortCard::sort(const unsigned endcap, const unsigned station, 
00047                                                     const unsigned sector, const unsigned subsector, const int bx)
00048 {
00049   std::vector<csctf::TrackStub> result;
00050   std::vector<csctf::TrackStub>::iterator LCT;
00051 
00052   result = _stubs.get(endcap, station, sector, subsector, bx);
00053 
00054   // Make sure no Quality 0 or non-valid LCTs come through the portcard.
00055   for (LCT = result.begin(); LCT != result.end(); LCT++) {
00056     if ( !(LCT->getQuality() && LCT->isValid()) )
00057       result.erase(LCT, LCT);
00058   }
00059 
00060   if (result.size()) {
00061     std::sort(result.begin(), result.end(), std::greater<csctf::TrackStub>());
00062     // Can only return maxStubs or less LCTs per bunch crossing.
00063     if (result.size() > CSCConstants::maxStubs)
00064       result.erase(result.begin() + CSCConstants::maxStubs, result.end());
00065 
00066 
00067     // Go through the sorted list and label the LCTs with a sorting number.
00068     unsigned i = 0;
00069     for (LCT = result.begin(); LCT != result.end(); LCT++)
00070       LCT->setMPCLink(++i);
00071   }
00072 
00073   return result;
00074 }