Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:36

0001 #include "L1Trigger/RPCTrigger/interface/RPCPac.h"
0002 //#include "L1Trigger/RPCTrigger/interface/TEPatternsGroup.h"
0003 
0004 RPCPac::RPCPac(const RPCPacData* pacData, int tower, int logSector, int logSegment)
0005     : RPCPacBase(tower, logSector, logSegment) {
0006   m_pacData = pacData;
0007 }
0008 
0009 /** 
0010  *
0011  * Runs Pattern Comparator algorithm for hits from the cone.
0012  * Calls the runTrackPatternsGroup() and runEnergeticPatternsGroups().
0013  * @return found track candidate (empty if hits does not fit to eny pattern)
0014  *
0015  */
0016 RPCPacMuon RPCPac::run(const RPCLogCone& cone) const {  //symualcja
0017 
0018   RPCPacMuon bestMuon;
0019   //track
0020   if (!m_pacData->m_TrackPatternsGroup.m_PatternsItVec.empty())
0021     bestMuon = runTrackPatternsGroup(cone);
0022 
0023   //energetic
0024   if (!m_pacData->m_EnergeticPatternsGroupList.empty()) {
0025     RPCPacMuon bufMuon = runEnergeticPatternsGroups(cone);
0026     if (bufMuon > bestMuon)
0027       bestMuon = bufMuon;
0028   }
0029 
0030   bestMuon.setConeCrdnts(m_CurrConeCrdnts);
0031 
0032   //bestMuon.setConeCrdnts(cone.);
0033   bestMuon.setLogConeIdx(cone.getIdx());
0034   /*
0035   int refStripNum = m_pacData->getPattern(bestMuon.getPatternNum())
0036                              .getStripFrom(RPCConst::m_REF_PLANE[abs(m_CurrConeCrdnts.m_Tower)])
0037                               +  m_CurrConeCrdnts.m_LogSector * 96
0038                               + m_CurrConeCrdnts.m_LogSegment * 8;
0039   bestMuon.setRefStripNum(refStripNum);*/
0040   return bestMuon;
0041 }
0042 
0043 RPCPacMuon RPCPac::runTrackPatternsGroup(const RPCLogCone& cone) const {
0044   RPCPacMuon bestMuon;
0045 
0046   for (unsigned int vecNum = 0; vecNum < m_pacData->m_TrackPatternsGroup.m_PatternsItVec.size(); vecNum++) {
0047     RPCMuon::TDigiLinkVec digiIdx;
0048     unsigned short firedPlanes = 0;
0049     int firedPlanesCount = 0;
0050     unsigned short one = 1;
0051     const RPCPattern& pattern = *(m_pacData->m_TrackPatternsGroup.m_PatternsItVec[vecNum]);
0052     for (int logPlane = RPCConst::m_FIRST_PLANE;
0053          logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
0054          logPlane++) {
0055       if (pattern.getStripFrom(logPlane) == RPCConst::m_NOT_CONECTED) {
0056         //firedPlanes[logPlane] = false; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0057         continue;
0058       }
0059       int fromBit = pattern.getStripFrom(logPlane);
0060       int toBit = pattern.getStripTo(logPlane);
0061       for (int bitNumber = fromBit; bitNumber < toBit; bitNumber++) {
0062         if (cone.getLogStripState(logPlane, bitNumber) == true) {
0063           firedPlanes = firedPlanes | one;
0064           firedPlanesCount++;
0065           std::vector<int> dIVec = cone.getLogStripDigisIdxs(logPlane, bitNumber);
0066           if (!dIVec.empty())
0067             digiIdx.push_back(RPCMuon::TDigiLink(logPlane, *dIVec.begin()));
0068 
0069           break;
0070         }
0071       }
0072 
0073       if ((RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)] - logPlane) == 3)
0074         if (firedPlanesCount == 0)
0075           break;
0076 
0077       one = one << 1;
0078     }
0079 
0080     if (firedPlanesCount >= 3) {
0081       short quality = m_pacData->m_QualityTabsVec[pattern.getQualityTabNumber()][firedPlanes];
0082       if (quality != -1) {
0083         if (quality >= bestMuon.getQuality()) {
0084           RPCPacMuon bufMuon(pattern, quality, firedPlanes);
0085           if (bufMuon > bestMuon) {
0086             bestMuon = bufMuon;
0087             bestMuon.setDigiIdxVec(digiIdx);
0088           }
0089         }
0090       }
0091     }
0092   }
0093   return bestMuon;
0094 }
0095 
0096 RPCPacMuon RPCPac::runEnergeticPatternsGroups(const RPCLogCone& cone) const {
0097   RPCPacMuon bestMuon;
0098   unsigned short firedPlanes = 0;
0099   int firedPlanesCount = 0;
0100   RPCPacData::TEPatternsGroupList::const_iterator iEGroup = m_pacData->m_EnergeticPatternsGroupList.begin();
0101   for (; iEGroup != m_pacData->m_EnergeticPatternsGroupList.end(); iEGroup++) {
0102     firedPlanes = 0;
0103     firedPlanesCount = 0;
0104     unsigned short one = 1;
0105     for (int logPlane = RPCConst::m_FIRST_PLANE;
0106          logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
0107          logPlane++) {  //or po paskach ze stozka
0108 
0109       if (cone.getHitsCnt(logPlane) > 0) {
0110         RPCLogCone::TLogPlane lp = cone.getLogPlane(logPlane);
0111         RPCLogCone::TLogPlane::const_iterator itLP = lp.begin();
0112         RPCLogCone::TLogPlane::const_iterator itLPE = lp.end();
0113         for (; itLP != itLPE; ++itLP) {
0114           int strip = itLP->first;
0115           if (iEGroup->m_GroupShape.getLogStripState(logPlane, strip)) {
0116             firedPlanes = firedPlanes | one;
0117             firedPlanesCount++;
0118             break;
0119           }
0120         }
0121       }
0122       /*
0123           for(unsigned int bitNum = 0;
0124                bitNum <
0125                RPCConst::
0126                m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane];
0127                bitNum++)
0128             {
0129               if(iEGroup->m_GroupShape.getLogStripState(logPlane, bitNum)
0130                   && cone.getLogStripState(logPlane, bitNum))
0131                 {
0132                   firedPlanes = firedPlanes | one;
0133                   firedPlanesCount++;
0134                   break;
0135                 }
0136             }
0137            */
0138       one = one << 1;
0139     }
0140 
0141     short quality = m_pacData->m_QualityTabsVec[iEGroup->m_QualityTabNumber][firedPlanes];
0142     if (quality == -1)
0143       continue;
0144 
0145     RPCPacMuon bufMuon;
0146     for (unsigned int vecNum = 0; vecNum < iEGroup->m_PatternsItVec.size(); vecNum++) {
0147       RPCMuon::TDigiLinkVec digiIdx;
0148       const RPCPattern::RPCPatVec::const_iterator patternIt = iEGroup->m_PatternsItVec[vecNum];
0149       const RPCPattern& pattern = *patternIt;
0150       bool wasHit = false;
0151       unsigned short one1 = 1;
0152       for (int logPlane = RPCConst::m_FIRST_PLANE;
0153            logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
0154            logPlane++, one1 = one1 << 1) {
0155         if (pattern.getStripFrom(logPlane) == RPCConst::m_NOT_CONECTED) {
0156           //          firedPlanes[logPlane] = false; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0157           continue;
0158         }
0159         if ((firedPlanes & one1) != 0) {
0160           int fromBit = pattern.getStripFrom(logPlane);
0161           int toBit = pattern.getStripTo(logPlane);
0162           wasHit = false;
0163           for (int bitNumber = fromBit; bitNumber < toBit; bitNumber++) {
0164             wasHit = wasHit || cone.getLogStripState(logPlane, bitNumber);
0165             if (wasHit) {  // no sense to check more
0166               std::vector<int> dIVec = cone.getLogStripDigisIdxs(logPlane, bitNumber);
0167               if (!dIVec.empty())
0168                 digiIdx.push_back(RPCMuon::TDigiLink(logPlane, *dIVec.begin()));
0169               break;
0170             }
0171           }
0172 
0173           if (!wasHit) {
0174             break;
0175           }
0176         }
0177       }
0178       if (wasHit) {
0179         bufMuon.setAll(pattern, quality, firedPlanes);
0180         bufMuon.setDigiIdxVec(digiIdx);
0181         break;  //if one pattern fits, thers no point to check other patterns from group
0182       }
0183     }  //end of patterns loop
0184     if (bufMuon > bestMuon) {
0185       bestMuon = bufMuon;
0186     }
0187     //if(bestMuon.getQuality() == m_pacData->m_MaxQuality)
0188     //  return bestMuon;
0189   }  //end of EGroup loop
0190   return bestMuon;
0191 }