Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:55:34

0001 #include <iostream>
0002 
0003 #include "L1Trigger/L1TMuonOverlap/interface/OMTFConfigMaker.h"
0004 #include "L1Trigger/L1TMuonOverlap/interface/GoldenPattern.h"
0005 #include "L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h"
0006 #include "L1Trigger/L1TMuonOverlap/interface/OMTFinput.h"
0007 #include "L1Trigger/L1TMuonOverlap/interface/OMTFResult.h"
0008 
0009 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0010 
0011 ///////////////////////////////////////////////
0012 ///////////////////////////////////////////////
0013 OMTFConfigMaker::OMTFConfigMaker(OMTFConfiguration* omtfConfig) : myOmtfConfig(omtfConfig) {
0014   std::vector<int> refPhi1D(myOmtfConfig->nLogicRegions(), 2 * myOmtfConfig->nPhiBins());
0015   minRefPhi2D.assign(myOmtfConfig->nRefLayers(), refPhi1D);
0016 
0017   refPhi1D = std::vector<int>(myOmtfConfig->nLogicRegions(), -2 * myOmtfConfig->nPhiBins());
0018   maxRefPhi2D.assign(myOmtfConfig->nRefLayers(), refPhi1D);
0019 }
0020 ///////////////////////////////////////////////
0021 ///////////////////////////////////////////////
0022 OMTFConfigMaker::~OMTFConfigMaker() {}
0023 ///////////////////////////////////////////////
0024 ///////////////////////////////////////////////
0025 void OMTFConfigMaker::fillCounts(unsigned int iProcessor, const OMTFinput& aInput) {}
0026 ///////////////////////////////////////////////
0027 ///////////////////////////////////////////////
0028 void OMTFConfigMaker::fillPhiMaps(unsigned int iProcessor, const OMTFinput& aInput) {
0029   ////Find starting and ending iPhi of each input used for reference hits.
0030   for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
0031     const OMTFinput::vector1D& refLayerHits = aInput.getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefLayer]);
0032     if (refLayerHits.empty())
0033       continue;
0034     for (unsigned int iInput = 0; iInput < myOmtfConfig->nInputs(); ++iInput) {
0035       int phiRef = refLayerHits[iInput];
0036       unsigned int iRegion = myOmtfConfig->getRegionNumberFromMap(iInput, iRefLayer, phiRef);
0037       if (phiRef >= (int)myOmtfConfig->nPhiBins())
0038         continue;
0039       if (phiRef < minRefPhi2D[iRefLayer][iRegion])
0040         minRefPhi2D[iRefLayer][iRegion] = phiRef;
0041       if (phiRef > maxRefPhi2D[iRefLayer][iRegion])
0042         maxRefPhi2D[iRefLayer][iRegion] = phiRef;
0043     }
0044   }
0045 }
0046 ///////////////////////////////////////////////
0047 ///////////////////////////////////////////////
0048 void OMTFConfigMaker::printPhiMap(std::ostream& out) {
0049   out << "min Phi in each logicRegion (X) in each ref Layer (Y): " << std::endl;
0050   for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
0051     for (unsigned int iLogicRegion = 0; iLogicRegion < myOmtfConfig->nLogicRegions(); ++iLogicRegion) {
0052       out << "          " << minRefPhi2D[iRefLayer][iLogicRegion] << "\t";
0053     }
0054     out << std::endl;
0055   }
0056   out << std::endl;
0057 
0058   out << "max Phi in each logicRegion (X) in each ref Layer (Y): " << std::endl;
0059   for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
0060     for (unsigned int iLogicRegion = 0; iLogicRegion < myOmtfConfig->nLogicRegions(); ++iLogicRegion) {
0061       out << "          " << maxRefPhi2D[iRefLayer][iLogicRegion] << "\t";
0062     }
0063     out << std::endl;
0064   }
0065   out << std::endl;
0066 }
0067 ///////////////////////////////////////////////
0068 ///////////////////////////////////////////////
0069 void OMTFConfigMaker::makeConnetionsMap(unsigned int iProcessor, const OMTFinput& aInput) {
0070   fillPhiMaps(iProcessor, aInput);
0071 
0072   for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
0073     const OMTFinput::vector1D& refLayerHits = aInput.getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefLayer]);
0074     if (refLayerHits.empty())
0075       continue;
0076     //////////////////////
0077     for (unsigned int iInput = 0; iInput < refLayerHits.size(); ++iInput) {
0078       int phiRef = refLayerHits[iInput];
0079       unsigned int iRegion = myOmtfConfig->getRegionNumberFromMap(iInput, iRefLayer, phiRef);
0080       if (iRegion >= myOmtfConfig->nLogicRegions())
0081         continue;
0082       fillInputRange(iProcessor, iRegion, aInput);
0083       fillInputRange(iProcessor, iRegion, iRefLayer, iInput);
0084       ///Always use two hits from a single chamber.
0085       ///As we use single muons, the second hit has
0086       ///to be added by hand.
0087       if (iInput % 2 == 0)
0088         fillInputRange(iProcessor, iRegion, iRefLayer, iInput + 1);
0089     }
0090   }
0091 }
0092 ///////////////////////////////////////////////
0093 ///////////////////////////////////////////////
0094 void OMTFConfigMaker::fillInputRange(unsigned int iProcessor, unsigned int iRegion, const OMTFinput& aInput) {
0095   for (unsigned int iLogicLayer = 0; iLogicLayer < myOmtfConfig->nLayers(); ++iLogicLayer) {
0096     for (unsigned int iInput = 0; iInput < 14; ++iInput) {
0097       bool isHit = aInput.getLayerData(iLogicLayer)[iInput] < (int)myOmtfConfig->nPhiBins();
0098       myOmtfConfig->getMeasurements4D()[iProcessor][iRegion][iLogicLayer][iInput] += isHit;
0099     }
0100   }
0101 }
0102 ///////////////////////////////////////////////
0103 ///////////////////////////////////////////////
0104 void OMTFConfigMaker::fillInputRange(unsigned int iProcessor,
0105                                      unsigned int iRegion,
0106                                      unsigned int iRefLayer,
0107                                      unsigned int iInput) {
0108   ++myOmtfConfig->getMeasurements4Dref()[iProcessor][iRegion][iRefLayer][iInput];
0109 }
0110 ///////////////////////////////////////////////
0111 ///////////////////////////////////////////////
0112 void OMTFConfigMaker::printConnections(std::ostream& out, unsigned int iProcessor, unsigned int iRegion) {
0113   out << "iProcessor: " << iProcessor << " iRegion: " << iRegion << std::endl;
0114 
0115   out << "Ref hits" << std::endl;
0116   for (unsigned int iLogicLayer = 0; iLogicLayer < myOmtfConfig->nLayers(); ++iLogicLayer) {
0117     out << "Logic layer: " << iLogicLayer << " Hits: ";
0118     for (unsigned int iInput = 0; iInput < myOmtfConfig->nInputs(); ++iInput) {
0119       out << myOmtfConfig->getMeasurements4Dref()[iProcessor][iRegion][iLogicLayer][iInput] << "\t";
0120     }
0121     out << std::endl;
0122   }
0123   /*
0124   out<<"Measurement hits"<<std::endl;
0125   for(unsigned int iLogicLayer=0;iLogicLayer<myOmtfConfig->nLayers();++iLogicLayer){
0126     out<<"Logic layer: "<<iLogicLayer<<" Hits: ";
0127     for(unsigned int iInput=0;iInput<14;++iInput){
0128       out<<myOmtfConfig->getMeasurements4D()[iProcessor][iRegion][iLogicLayer][iInput]<<"\t";
0129     }
0130     out<<std::endl;
0131   }
0132   */
0133   out << std::endl;
0134 }
0135 /////////////////////////////////////////////////////////////
0136 /////////////////////////////////////////////////////////////