CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/L1Trigger/RPCTrigger/src/RPCPac.cc

Go to the documentation of this file.
00001 #include "L1Trigger/RPCTrigger/interface/RPCPac.h"
00002 //#include "L1Trigger/RPCTrigger/interface/TEPatternsGroup.h"
00003 
00004 RPCPac::RPCPac(const RPCPacData * pacData, int tower, int logSector,
00005                 int logSegment):
00006 RPCPacBase(tower, logSector, logSegment)
00007 {
00008 
00009   m_pacData = pacData;
00010 
00011 }
00012 
00020 RPCPacMuon RPCPac::run(const RPCLogCone & cone) const
00021 {                               //symualcja
00022   
00023   RPCPacMuon bestMuon;
00024   //track  
00025   if(m_pacData->m_TrackPatternsGroup.m_PatternsItVec.size() > 0)
00026     bestMuon = runTrackPatternsGroup(cone);
00027 
00028   //energetic
00029   if(m_pacData->m_EnergeticPatternsGroupList.size() > 0)
00030     {
00031       RPCPacMuon bufMuon = runEnergeticPatternsGroups(cone);
00032       if(bufMuon > bestMuon)
00033         bestMuon = bufMuon;
00034     }
00035 
00036   bestMuon.setConeCrdnts(m_CurrConeCrdnts);
00037   
00038 
00039   //bestMuon.setConeCrdnts(cone.);
00040   bestMuon.setLogConeIdx(cone.getIdx());
00041   /*
00042   int refStripNum = m_pacData->getPattern(bestMuon.getPatternNum())
00043                              .getStripFrom(RPCConst::m_REF_PLANE[abs(m_CurrConeCrdnts.m_Tower)])
00044                               +  m_CurrConeCrdnts.m_LogSector * 96
00045                               + m_CurrConeCrdnts.m_LogSegment * 8;
00046   bestMuon.setRefStripNum(refStripNum);*/
00047   return bestMuon;
00048 }
00049 
00050 
00051 RPCPacMuon RPCPac::runTrackPatternsGroup(const RPCLogCone & cone) const
00052 {
00053   RPCPacMuon bestMuon;
00054 
00055   for(unsigned int vecNum = 0;
00056        vecNum < m_pacData->m_TrackPatternsGroup.m_PatternsItVec.size(); vecNum++)
00057     {
00058       RPCMuon::TDigiLinkVec digiIdx; 
00059       unsigned short firedPlanes = 0;
00060       int firedPlanesCount = 0;
00061       unsigned short one = 1;
00062       const RPCPattern & pattern =
00063           *(m_pacData->m_TrackPatternsGroup.m_PatternsItVec[vecNum]);
00064       for(int logPlane = RPCConst::m_FIRST_PLANE;
00065            logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
00066            logPlane++)
00067         {
00068           if(pattern.getStripFrom(logPlane) == RPCConst::m_NOT_CONECTED)
00069             {
00070               //firedPlanes[logPlane] = false; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00071               continue;
00072             }
00073           int fromBit = pattern.getStripFrom(logPlane);
00074           int toBit = pattern.getStripTo(logPlane);
00075           for(int bitNumber = fromBit; bitNumber < toBit; bitNumber++)
00076             {
00077               if(cone.getLogStripState(logPlane, bitNumber) == true)
00078                 {
00079                   firedPlanes = firedPlanes | one;
00080                   firedPlanesCount++;
00081                   std::vector<int> dIVec = cone.getLogStripDigisIdxs(logPlane, bitNumber);
00082                   if (!dIVec.empty()) digiIdx.push_back( RPCMuon::TDigiLink(logPlane, *dIVec.begin())  );
00083                                 
00084                   break;
00085                 }
00086             }
00087 
00088             if((RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)] -
00089                logPlane) == 3)
00090             if(firedPlanesCount == 0)
00091               break;
00092 
00093           one = one << 1;
00094         }
00095 
00096       if(firedPlanesCount >= 3)
00097         {
00098           short quality =
00099               m_pacData->m_QualityTabsVec[pattern.getQualityTabNumber()][firedPlanes];
00100           if(quality != -1)
00101             {
00102               if(quality >= bestMuon.getQuality())
00103                 {
00104                   RPCPacMuon bufMuon(pattern, quality, firedPlanes);
00105                   if(bufMuon > bestMuon)
00106                     {
00107                       bestMuon = bufMuon;
00108                       bestMuon.setDigiIdxVec(digiIdx); 
00109                     }
00110                 }
00111             }
00112         }
00113     }
00114   return bestMuon;
00115 }
00116 
00117 
00118 
00119 RPCPacMuon
00120 RPCPac::runEnergeticPatternsGroups(const RPCLogCone & cone) const
00121 {
00122   RPCPacMuon bestMuon;
00123   unsigned short firedPlanes = 0;
00124   int firedPlanesCount = 0;
00125   RPCPacData::TEPatternsGroupList::const_iterator iEGroup =
00126       m_pacData->m_EnergeticPatternsGroupList.begin();
00127   for(; iEGroup != m_pacData->m_EnergeticPatternsGroupList.end(); iEGroup++)
00128     {
00129       firedPlanes = 0;
00130       firedPlanesCount = 0;
00131       unsigned short one = 1;
00132       for(int logPlane = RPCConst::m_FIRST_PLANE;
00133            logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
00134            logPlane++)
00135         {                       //or po paskach ze stozka
00136 
00137           if (cone.getHitsCnt(logPlane)>0 ) {
00138             RPCLogCone::TLogPlane lp = cone.getLogPlane(logPlane);
00139             RPCLogCone::TLogPlane::const_iterator itLP = lp.begin();
00140             RPCLogCone::TLogPlane::const_iterator itLPE = lp.end();
00141             for(; itLP!=itLPE; ++itLP){
00142                int strip=itLP->first;
00143                if(iEGroup->m_GroupShape.getLogStripState(logPlane, strip)){
00144                   firedPlanes = firedPlanes | one;
00145                   firedPlanesCount++;
00146                   break;
00147                }
00148             }
00149 
00150           }
00151           /*
00152           for(unsigned int bitNum = 0;
00153                bitNum <
00154                RPCConst::
00155                m_LOGPLANE_SIZE[abs(m_ConeCrdnts.m_Tower)][logPlane];
00156                bitNum++)
00157             {
00158               if(iEGroup->m_GroupShape.getLogStripState(logPlane, bitNum)
00159                   && cone.getLogStripState(logPlane, bitNum))
00160                 {
00161                   firedPlanes = firedPlanes | one;
00162                   firedPlanesCount++;
00163                   break;
00164                 }
00165             }
00166            */
00167           one = one << 1;
00168         }
00169 
00170       short quality =
00171           m_pacData->m_QualityTabsVec[iEGroup->m_QualityTabNumber][firedPlanes];
00172       if(quality == -1)
00173         continue;
00174 
00175       RPCPacMuon bufMuon;
00176       for(unsigned int vecNum = 0; vecNum < iEGroup->m_PatternsItVec.size();
00177            vecNum++)
00178         {
00179           RPCMuon::TDigiLinkVec digiIdx; 
00180           const RPCPattern::RPCPatVec::const_iterator patternIt =
00181             iEGroup->m_PatternsItVec[vecNum];
00182           const RPCPattern & pattern = *patternIt;
00183           bool wasHit = false;
00184           unsigned short one1 = 1;
00185           for(int logPlane = RPCConst::m_FIRST_PLANE;
00186                logPlane < RPCConst::m_USED_PLANES_COUNT[std::abs(m_ConeCrdnts.m_Tower)];
00187                logPlane++, one1 = one1 << 1)
00188             {
00189               if(pattern.getStripFrom(logPlane) == RPCConst::m_NOT_CONECTED)
00190                 {
00191 //          firedPlanes[logPlane] = false; //<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
00192                   continue;
00193                 }
00194               if((firedPlanes & one1) != 0)
00195                 {
00196                   int fromBit = pattern.getStripFrom(logPlane);
00197                   int toBit = pattern.getStripTo(logPlane);
00198                   wasHit = false;
00199                   for(int bitNumber = fromBit; bitNumber < toBit;
00200                        bitNumber++)
00201                   {
00202                     wasHit = wasHit || cone.getLogStripState(logPlane, bitNumber);
00203                     if (wasHit) { // no sense to check more
00204                       std::vector<int> dIVec = cone.getLogStripDigisIdxs(logPlane, bitNumber);
00205                       if (!dIVec.empty()) digiIdx.push_back( RPCMuon::TDigiLink(logPlane, *dIVec.begin())  );
00206                       break;
00207                     }
00208                   }
00209 
00210                   if(!wasHit){
00211                     break;
00212                   } 
00213                 }
00214             }
00215           if(wasHit)
00216             {
00217               bufMuon.setAll(pattern, quality, firedPlanes);
00218               bufMuon.setDigiIdxVec(digiIdx); 
00219               break;            //if one pattern fits, thers no point to check other patterns from group
00220             }
00221         }                       //end of patterns loop
00222       if(bufMuon > bestMuon){
00223         bestMuon = bufMuon;
00224       }
00225       //if(bestMuon.getQuality() == m_pacData->m_MaxQuality)
00226       //  return bestMuon;
00227     }                           //end of EGroup loop
00228   return bestMuon;
00229 }