Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:21:06

0001 #ifndef L1T_OmtfP1_OMTFProcessor_H
0002 #define L1T_OmtfP1_OMTFProcessor_H
0003 
0004 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/AlgoMuon.h"
0005 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h"
0006 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPatternResult.h"
0007 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IGhostBuster.h"
0008 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/IProcessorEmulator.h"
0009 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFConfiguration.h"
0010 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/OMTFinputMaker.h"
0011 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/ProcessorBase.h"
0012 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/SorterBase.h"
0013 
0014 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/PtAssignmentBase.h"
0015 
0016 #include "FWCore/Framework/interface/Event.h"
0017 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0018 
0019 #include "DataFormats/L1TMuon/interface/RegionalMuonCand.h"
0020 #include "DataFormats/L1TMuon/interface/RegionalMuonCandFwd.h"
0021 
0022 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhContainer.h"
0023 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThContainer.h"
0024 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigiCollection.h"
0025 #include "DataFormats/RPCDigi/interface/RPCDigiCollection.h"
0026 
0027 #include "L1Trigger/L1TMuonOverlapPhase1/interface/Omtf/GoldenPattern.h"
0028 
0029 #include <memory>
0030 #include <map>
0031 
0032 class OMTFinput;
0033 
0034 namespace edm {
0035   class ParameterSet;
0036 };
0037 
0038 template <class GoldenPatternType>
0039 class OMTFProcessor : public ProcessorBase<GoldenPatternType>, public IProcessorEmulator {
0040 public:
0041   OMTFProcessor(OMTFConfiguration* omtfConfig,
0042                 const edm::ParameterSet& edmCfg,
0043                 edm::EventSetup const& evSetup,
0044                 const L1TMuonOverlapParams* omtfPatterns);
0045 
0046   OMTFProcessor(OMTFConfiguration* omtfConfig,
0047                 const edm::ParameterSet& edmCfg,
0048                 edm::EventSetup const& evSetup,
0049                 GoldenPatternVec<GoldenPatternType>&& gps);
0050 
0051   ~OMTFProcessor() override;
0052 
0053   ///Fill GP vec with patterns from CondFormats object
0054   /*  virtual bool configure(const OMTFConfiguration* omtfParams, const L1TMuonOverlapParams* omtfPatterns) {
0055     return ProcessorBase<GoldenPatternType>::configure(omtfParams, omtfPatterns);
0056   }*/
0057 
0058   //targetStubQuality matters only for the barrel stubs,
0059   //targetStubR - radial distance from the z axis (beam), matters only for the endcap stubs
0060   //floating point version, it is used to generate the extrapolFactors for the fixed point version
0061   int extrapolateDtPhiBFloatPoint(const int& refLogicLayer,
0062                                   const int& refPhi,
0063                                   const int& refPhiB,
0064                                   unsigned int targetLayer,
0065                                   const int& targetStubPhi,
0066                                   const int& targetStubQuality,
0067                                   const int& targetStubEta,
0068                                   const int& targetStubR,
0069                                   const OMTFConfiguration* omtfConfig);
0070 
0071   //fixed point, firmware like extrapolation
0072   int extrapolateDtPhiBFixedPoint(const int& refLogicLayer,
0073                                   const int& refPhi,
0074                                   const int& refPhiB,
0075                                   unsigned int targetLayer,
0076                                   const int& targetStubPhi,
0077                                   const int& targetStubQuality,
0078                                   const int& targetStubEta,
0079                                   const int& targetStubR,
0080                                   const OMTFConfiguration* omtfConfig);
0081 
0082   int extrapolateDtPhiB(const MuonStubPtr& refStub,
0083                         const MuonStubPtr& targetStub,
0084                         unsigned int targetLayer,
0085                         const OMTFConfiguration* omtfConfig);
0086 
0087   ///Process input data from a single event
0088   ///Input data is represented by hits in logic layers expressed in local coordinates
0089   void processInput(unsigned int iProcessor,
0090                     l1t::tftype mtfType,
0091                     const OMTFinput& aInput,
0092                     std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override;
0093 
0094   AlgoMuons sortResults(unsigned int iProcessor, l1t::tftype mtfType, int charge = 0) override;
0095 
0096   AlgoMuons ghostBust(AlgoMuons refHitCands, int charge = 0) override {
0097     return ghostBuster->select(refHitCands, charge);
0098   }
0099 
0100   //convert algo muon to outgoing Candidates
0101   std::vector<l1t::RegionalMuonCand> getFinalcandidates(unsigned int iProcessor,
0102                                                         l1t::tftype mtfType,
0103                                                         const AlgoMuons& algoCands) override;
0104 
0105   ///allows to use other sorter implementation than the default one
0106   virtual void setSorter(SorterBase<GoldenPatternType>* sorter) { this->sorter.reset(sorter); }
0107 
0108   ///allows to use other IGhostBuster implementation than the default one
0109   void setGhostBuster(IGhostBuster* ghostBuster) override { this->ghostBuster.reset(ghostBuster); }
0110 
0111   virtual void setPtAssignment(PtAssignmentBase* ptAssignment) { this->ptAssignment = ptAssignment; }
0112 
0113   std::vector<l1t::RegionalMuonCand> run(unsigned int iProcessor,
0114                                          l1t::tftype mtfType,
0115                                          int bx,
0116                                          OMTFinputMaker* inputMaker,
0117                                          std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) override;
0118 
0119   void printInfo() const override;
0120 
0121   void saveExtrapolFactors();
0122   void loadExtrapolFactors(const std::string& filename);
0123 
0124 private:
0125   virtual void init(const edm::ParameterSet& edmCfg, edm::EventSetup const& evSetup);
0126 
0127   ///Check if the hit pattern of given OMTF candite is not on the list
0128   ///of invalid hit patterns. Invalid hit patterns provode very little
0129   ///to efficiency, but gives high contribution to rate.
0130   ///Candidate with invalid hit patterns is assigned quality=0.
0131   ///Currently the list of invalid patterns is hardcoded.
0132   ///This has to be read from configuration.
0133   bool checkHitPatternValidity(unsigned int hits) override;
0134 
0135   std::unique_ptr<SorterBase<GoldenPatternType> > sorter;
0136 
0137   std::unique_ptr<IGhostBuster> ghostBuster;
0138 
0139   //ptAssignment should be destroyed where it is created, i.e. by OmtfEmulation or OMTFReconstruction
0140   PtAssignmentBase* ptAssignment = nullptr;
0141 
0142   bool useStubQualInExtr = false;
0143   bool useEndcapStubsRInExtr = false;
0144 
0145   //if true, the extrapolateDtPhiBFloatPoint, and the extrapolation factors are generated
0146   //if false, extrapolateDtPhiBFixedPoint is used
0147   bool useFloatingPointExtrapolation = false;
0148 
0149   int extrapolMultiplier = 128;
0150 
0151   std::vector<std::vector<std::map<int, double> > > extrapolFactors;  //[refLayer][targetLayer][etaCode]
0152   std::vector<std::vector<std::map<int, int> > > extrapolFactorsNorm;
0153 };
0154 
0155 #endif