Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0002 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinput.h"
0003 
0004 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0005 
0006 #include <iomanip>
0007 
0008 ///////////////////////////////////////////////////
0009 ///////////////////////////////////////////////////
0010 OMTFinput::OMTFinput(const OMTFConfiguration* omtfConfig) : MuonStubsInput(omtfConfig) {
0011   myOmtfConfig = omtfConfig;
0012   const int inputsPerLayer = myOmtfConfig->nInputs();
0013   muonStubsInLayers.assign(omtfConfig->nLayers(), std::vector<MuonStubPtr>(inputsPerLayer));
0014   //nullptrs are assigned here for every input
0015 }
0016 ///////////////////////////////////////////////////
0017 ///////////////////////////////////////////////////
0018 
0019 //TODO remove and leave only the MuonStubsInput::getPhiHw
0020 int OMTFinput::getPhiHw(unsigned int iLayer, unsigned int iInput) const {
0021   /*  assert(iLayer < muonStubsInLayers.size());
0022   assert(iInput < muonStubsInLayers[iLayer].size());*/
0023   if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0024     MuonStubPtr stub = getMuonStub(iLayer - 1, iInput);
0025     if (stub)
0026       return stub->phiBHw;
0027   }
0028 
0029   MuonStubPtr stub = getMuonStub(iLayer, iInput);
0030   if (stub)
0031     return stub->phiHw;
0032 
0033   return myOmtfConfig->nPhiBins();
0034 }
0035 
0036 const int OMTFinput::getHitEta(unsigned int iLayer, unsigned int iInput) const {
0037   if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0038     MuonStubPtr stub = getMuonStub(iLayer - 1, iInput);
0039     if (stub)
0040       return stub->etaHw;
0041   }
0042 
0043   MuonStubPtr stub = getMuonStub(iLayer, iInput);
0044   if (stub)
0045     return stub->etaHw;
0046 
0047   return myOmtfConfig->nPhiBins();
0048 }
0049 
0050 const int OMTFinput::getHitQual(unsigned int iLayer, unsigned int iInput) const {
0051   /*  assert(iLayer < muonStubsInLayers.size());
0052   assert(iInput < muonStubsInLayers[iLayer].size());*/
0053   if (this->myOmtfConfig->isBendingLayer(iLayer)) {
0054     MuonStubPtr stub = getMuonStub(iLayer - 1, iInput);
0055     if (stub)
0056       return stub->qualityHw;
0057   }
0058 
0059   MuonStubPtr stub = getMuonStub(iLayer, iInput);
0060   if (stub)
0061     return stub->qualityHw;
0062 
0063   return myOmtfConfig->nPhiBins();
0064 }
0065 
0066 ///////////////////////////////////////////////////
0067 ///////////////////////////////////////////////////
0068 boost::dynamic_bitset<> OMTFinput::getRefHits(unsigned int iProcessor) const {
0069   boost::dynamic_bitset<> refHits(myOmtfConfig->nRefHits());
0070 
0071   unsigned int iRefHit = 0;
0072   for (auto iRefHitDef : myOmtfConfig->getRefHitsDefs()[iProcessor]) {
0073     auto refHitLogicLayer = myOmtfConfig->getRefToLogicNumber()[iRefHitDef.iRefLayer];
0074 
0075     int iPhi = getPhiHw(refHitLogicLayer, iRefHitDef.iInput);
0076     if (iPhi < (int)myOmtfConfig->nPhiBins()) {
0077       //TODO use a constant defined somewhere instead of 6
0078       //6 applies the quality cut also for the MB3, which has not much sense, because for MB3 there is no extrapolation, but it does not matter much
0079       if (refHitLogicLayer >= 6 ||
0080           getMuonStub(refHitLogicLayer, iRefHitDef.iInput)->qualityHw >= myOmtfConfig->getDtRefHitMinQuality())
0081         refHits.set(iRefHit, iRefHitDef.fitsRange(iPhi));
0082     }
0083     iRefHit++;
0084   }
0085 
0086   return refHits;
0087 }
0088 
0089 ///////////////////////////////////////////////////
0090 ///////////////////////////////////////////////////
0091 std::ostream& operator<<(std::ostream& out, const OMTFinput& aInput) {
0092   for (unsigned int iLogicLayer = 0; iLogicLayer < aInput.muonStubsInLayers.size(); ++iLogicLayer) {
0093     out << "Logic layer: " << std::setw(2) << iLogicLayer << " Hits: ";
0094     for (unsigned int iHit = 0; iHit < aInput.muonStubsInLayers[iLogicLayer].size(); ++iHit) {
0095       //out<<aInput.muonStubsInLayers[iLogicLayer][iHit]<<"\t";
0096       int phi = aInput.getPhiHw(iLogicLayer, iHit);
0097       if (phi == 5400)
0098         out << std::setw(4) << "...."
0099             << " ";
0100       else
0101         out << std::setw(4) << phi << " ";
0102       //TODO print other value?
0103     }
0104     out << std::endl;
0105   }
0106   return out;
0107 }
0108 ///////////////////////////////////////////////////
0109 ///////////////////////////////////////////////////