Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-05-15 04:21:51

0001 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFSorter.h"
0002 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h"
0003 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternWithStat.h"
0004 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0005 
0006 #include <cassert>
0007 #include <iostream>
0008 #include <algorithm>
0009 #include <bitset>
0010 
0011 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include "L1Trigger/RPCTrigger/interface/RPCConst.h"
0014 ///////////////////////////////////////////////////////
0015 ///////////////////////////////////////////////////////
0016 template <class GoldenPatternType>
0017 AlgoMuons::value_type OMTFSorter<GoldenPatternType>::sortRefHitResults(
0018     unsigned int procIndx, unsigned int iRefHit, const GoldenPatternVec<GoldenPatternType>& gPatterns, int charge) {
0019   GoldenPatternType* bestGP = nullptr;  //the GoldenPattern with the best result for this iRefHit
0020 
0021   GoldenPatternType* bestGpUnconstr = nullptr;
0022 
0023   for (auto& itGP : gPatterns) {
0024     if (!itGP->getResults()[procIndx][iRefHit].isValid())
0025       continue;
0026 
0027     if (charge != 0 && itGP->key().theCharge != charge)
0028       continue;  //charge==0 means ignore charge
0029 
0030     ///Accept only candidates with >2 hits
0031     if (itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() < 3)  //TODO - move 3 to the configuration??
0032       continue;
0033 
0034     if (bestGP == nullptr) {
0035       bestGP = itGP.get();
0036     } else if (myType == 0 && itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() >
0037                                   bestGP->getResults()[procIndx][iRefHit].getFiredLayerCnt()) {
0038       bestGP = itGP.get();
0039     } else if (myType == 1 || (itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() ==
0040                                bestGP->getResults()[procIndx][iRefHit].getFiredLayerCnt())) {
0041       if (itGP->getResults()[procIndx][iRefHit].getPdfSum() > bestGP->getResults()[procIndx][iRefHit].getPdfSum()) {
0042         //if the PdfWeigtSum is equal, we take the GP with the lower number, i.e. lower pt = check if this is ok for physics FIXME (KB)
0043         bestGP = itGP.get();
0044       }
0045     }
0046 
0047     if (bestGpUnconstr == nullptr) {
0048       if (itGP->getResults()[procIndx][iRefHit].getPdfSumUnconstr() > 0)
0049         bestGpUnconstr = itGP.get();
0050     } else if (myType == 0 && itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() >
0051                                   bestGpUnconstr->getResults()[procIndx][iRefHit].getFiredLayerCnt()) {
0052       bestGpUnconstr = itGP.get();
0053     } else if (myType == 1 || (itGP->getResults()[procIndx][iRefHit].getFiredLayerCnt() ==
0054                                bestGpUnconstr->getResults()[procIndx][iRefHit].getFiredLayerCnt())) {
0055       if (itGP->getResults()[procIndx][iRefHit].getPdfSumUnconstr() >
0056           bestGpUnconstr->getResults()[procIndx][iRefHit].getPdfSumUnconstr()) {
0057         //if the PdfWeigtSum is equal, we take the GP with the lower number, i.e. lower pt = check if this is ok for physics FIXME (KB)
0058         bestGpUnconstr = itGP.get();
0059       }
0060     }
0061   }
0062   if (bestGP) {
0063     //this is needed to obtain the same results as in the firmware. for the actual performance it should not matter
0064     if (bestGP->getResults()[procIndx][iRefHit].getPdfSum() == 0)
0065       bestGP = gPatterns.at(0).get();
0066 
0067     AlgoMuons::value_type candidate(new AlgoMuon(bestGP->getResults()[procIndx][iRefHit], bestGP, iRefHit));
0068 
0069     if (bestGpUnconstr) {
0070       candidate->setGpResultUnconstr(bestGpUnconstr->getResults()[procIndx][iRefHit]);
0071       candidate->setGoldenPaternUnconstr(bestGpUnconstr);
0072     }
0073 
0074     return candidate;
0075   } else {
0076     AlgoMuons::value_type candidate(new AlgoMuon());
0077     candidate->setRefHitNumber(iRefHit);
0078     return candidate;
0079   }
0080 }
0081 
0082 template class OMTFSorter<GoldenPattern>;
0083 template class OMTFSorter<GoldenPatternWithStat>;
0084 template class OMTFSorter<GoldenPatternWithThresh>;