Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:23:27

0001 #include <iostream>
0002 #include <ostream>
0003 #include <cmath>
0004 
0005 #include "L1Trigger/L1TMuonOverlap/interface/OMTFResult.h"
0006 #include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"
0007 
0008 ////////////////////////////////////////////
0009 ////////////////////////////////////////////
0010 void OMTFResult::configure(const OMTFConfiguration *omtfConfig) {
0011   myOmtfConfig = omtfConfig;
0012 
0013   clear();
0014 }
0015 ////////////////////////////////////////////
0016 ////////////////////////////////////////////
0017 
0018 void OMTFResult::setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit) { refPhiRHit1D[iRefLayer] = iRefPhiRHit; }
0019 ////////////////////////////////////////////
0020 ////////////////////////////////////////////
0021 
0022 void OMTFResult::addResult(unsigned int iRefLayer, unsigned int iLayer, unsigned int val, int iRefPhi, int iRefEta) {
0023   refPhi1D[iRefLayer] = iRefPhi;
0024   refEta1D[iRefLayer] = iRefEta;
0025   results[iLayer][iRefLayer] = val;
0026 }
0027 ////////////////////////////////////////////
0028 ////////////////////////////////////////////
0029 void OMTFResult::clear() {
0030   results1D.assign(myOmtfConfig->nRefLayers(), 0);
0031   hits1D.assign(myOmtfConfig->nRefLayers(), 0);
0032   results.assign(myOmtfConfig->nLayers(), results1D);
0033   refPhi1D.assign(myOmtfConfig->nRefLayers(), 1024);
0034   refEta1D.assign(myOmtfConfig->nRefLayers(), 1024);
0035   hitsBits.assign(myOmtfConfig->nRefLayers(), 0);
0036   refPhiRHit1D.assign(myOmtfConfig->nRefLayers(), 1024);
0037 }
0038 ////////////////////////////////////////////
0039 ////////////////////////////////////////////
0040 void OMTFResult::finalise() {
0041   for (unsigned int iLogicLayer = 0; iLogicLayer < results.size(); ++iLogicLayer) {
0042     unsigned int connectedLayer = myOmtfConfig->getLogicToLogic().at(iLogicLayer);
0043     for (unsigned int iRefLayer = 0; iRefLayer < results[iLogicLayer].size(); ++iRefLayer) {
0044       ///If connected layer (POS or BEND) has not been fired, ignore this layer also
0045       unsigned int val = results[connectedLayer][iRefLayer] > 0 ? results[iLogicLayer][iRefLayer] : 0;
0046       results1D[iRefLayer] += val;
0047       hitsBits[iRefLayer] += (val > 0) * std::pow(2, iLogicLayer);
0048 
0049       if (myOmtfConfig->fwVersion() <= 4) {
0050         ///Do not count bending layers in hit count
0051         if (!myOmtfConfig->getBendingLayers().count(iLogicLayer))
0052           hits1D[iRefLayer] += (val > 0);
0053       } else {
0054         hits1D[iRefLayer] += (val > 0);
0055       }
0056     }
0057   }
0058 }
0059 ////////////////////////////////////////////
0060 ////////////////////////////////////////////
0061 bool OMTFResult::empty() const {
0062   unsigned int nHits = 0;
0063   for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
0064     nHits += hits1D[iRefLayer];
0065   }
0066   return (nHits == 0);
0067 }
0068 ////////////////////////////////////////////
0069 ////////////////////////////////////////////
0070 std::ostream &operator<<(std::ostream &out, const OMTFResult &aResult) {
0071   for (unsigned int iLogicLayer = 0; iLogicLayer < aResult.results.size(); ++iLogicLayer) {
0072     out << "Logic layer: " << iLogicLayer << " results: ";
0073     for (unsigned int iRefLayer = 0; iRefLayer < aResult.results[iLogicLayer].size(); ++iRefLayer) {
0074       out << aResult.results[iLogicLayer][iRefLayer] << "\t";
0075     }
0076     out << std::endl;
0077   }
0078 
0079   out << "      Sum over layers: ";
0080   for (unsigned int iRefLayer = 0; iRefLayer < aResult.results1D.size(); ++iRefLayer) {
0081     out << aResult.results1D[iRefLayer] << "\t";
0082   }
0083 
0084   out << std::endl;
0085 
0086   out << "       Number of hits: ";
0087   for (unsigned int iRefLayer = 0; iRefLayer < aResult.hits1D.size(); ++iRefLayer) {
0088     out << aResult.hits1D[iRefLayer] << "\t";
0089   }
0090 
0091   return out;
0092 }
0093 ////////////////////////////////////////////
0094 ////////////////////////////////////////////