Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "L1Trigger/L1TMuonOverlapPhase1/interface/MuonStubMakerBase.h"
0002 #include "L1Trigger/L1TMuonOverlapPhase1/interface/ProcConfigurationBase.h"
0003 
0004 #include "DataFormats/CSCDigi/interface/CSCCorrelatedLCTDigi.h"
0005 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambPhDigi.h"
0006 #include "DataFormats/L1DTTrackFinder/interface/L1MuDTChambThDigi.h"
0007 #include "DataFormats/MuonData/interface/MuonDigiCollection.h"
0008 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0009 #include "DataFormats/RPCDigi/interface/RPCDigi.h"
0010 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0011 
0012 #include <iostream>
0013 #include <iterator>
0014 #include <utility>
0015 
0016 /////////////////////////////////////
0017 void DtDigiToStubsConverter::loadDigis(const edm::Event& event) {
0018   event.getByToken(inputTokenDtPh, dtPhDigis);
0019   event.getByToken(inputTokenDtTh, dtThDigis);
0020 }
0021 
0022 void DtDigiToStubsConverter::makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0023                                        unsigned int iProcessor,
0024                                        l1t::tftype procTyp,
0025                                        int bxFrom,
0026                                        int bxTo,
0027                                        std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) {
0028   for (const auto& digiIt : *dtPhDigis->getContainer()) {
0029     DTChamberId detid(digiIt.whNum(), digiIt.stNum(), digiIt.scNum() + 1);
0030 
0031     ///Check it the data fits into given processor input range
0032     if (!acceptDigi(detid, iProcessor, procTyp))
0033       continue;
0034 
0035     if (digiIt.bxNum() >= bxFrom && digiIt.bxNum() <= bxTo)
0036       addDTphiDigi(muonStubsInLayers, digiIt, dtThDigis.product(), iProcessor, procTyp);
0037   }
0038 
0039   if (!mergePhiAndTheta) {
0040     for (auto& thetaDigi : (*(dtThDigis->getContainer()))) {
0041       if (thetaDigi.bxNum() >= bxFrom && thetaDigi.bxNum() <= bxTo) {
0042         addDTetaStubs(muonStubsInLayers, thetaDigi, iProcessor, procTyp);
0043       }
0044     }
0045   }
0046   //LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" iProcessor "<<iProcessor<<std::endl;
0047 }
0048 ///////////////////////////////////////
0049 ///////////////////////////////////////
0050 
0051 void CscDigiToStubsConverter::makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0052                                         unsigned int iProcessor,
0053                                         l1t::tftype procTyp,
0054                                         int bxFrom,
0055                                         int bxTo,
0056                                         std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) {
0057   auto chamber = cscDigis->begin();
0058   auto chend = cscDigis->end();
0059   for (; chamber != chend; ++chamber) {
0060     unsigned int rawid = (*chamber).first;
0061     ///Check it the data fits into given processor input range
0062     CSCDetId csc(rawid);
0063     if (!acceptDigi(csc, iProcessor, procTyp))
0064       continue;
0065 
0066     auto digi = (*chamber).second.first;
0067     auto dend = (*chamber).second.second;
0068     for (; digi != dend; ++digi) {
0069       ///Check if LCT trigger primitive has the right BX.
0070       int digiBx = digi->getBX() - config->cscLctCentralBx();
0071 
0072       if (digiBx >= bxFrom && digiBx <= bxTo)
0073         addCSCstubs(muonStubsInLayers, rawid, *digi, iProcessor, procTyp);
0074     }
0075   }
0076 }
0077 
0078 void RpcDigiToStubsConverter::makeStubs(MuonStubPtrs2D& muonStubsInLayers,
0079                                         unsigned int iProcessor,
0080                                         l1t::tftype procTyp,
0081                                         int bxFrom,
0082                                         int bxTo,
0083                                         std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) {
0084   //LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ <<" RPC HITS, processor : " << iProcessor<<" "<<std::endl;
0085 
0086   const RPCDigiCollection& rpcDigiCollection = *rpcDigis;
0087   for (auto rollDigis : rpcDigiCollection) {
0088     RPCDetId roll = rollDigis.first;
0089 
0090     //debug
0091     //if(roll.region() != 0  &&  abs(roll.station()) >= 3 && roll.ring() == 1 )
0092     /*    {
0093       //iRPC
0094       for (auto pDigi=rollDigis.second.first; pDigi != rollDigis.second.second; pDigi++) {
0095         LogTrace("l1tOmtfEventPrint")<<__FUNCTION__<<":"<<__LINE__<<" roll "<<roll
0096             <<" strip "<<pDigi->strip()
0097             <<" hasX "<<pDigi->hasX()<<" coordinateX "<<pDigi->coordinateX()<<" hasY "<<pDigi->hasY()<<" coordinateY "<<pDigi->coordinateY()
0098             <<" bx "<<pDigi->bx()<<" time "<<pDigi->time()<<" irpc"<<std::endl;
0099       }
0100       //continue;
0101     }*/
0102 
0103     //LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ <<" roll "<<roll<<" "<<std::endl;
0104 
0105     if (!acceptDigi(roll, iProcessor, procTyp))
0106       continue;
0107 
0108     ///To find the clusters we have to copy the digis in chamber to sort them (not optimal).
0109     //  for (auto tdigi = rollDigis.second.first; tdigi != rollDigis.second.second; tdigi++) { std::cout << "RPC DIGIS: " << roll.rawId()<< " "<<roll<<" digi: " << tdigi->strip() <<" bx: " << tdigi->bx() << std::endl; }
0110     std::vector<RPCDigi> digisCopy;
0111 
0112     for (auto pDigi = rollDigis.second.first; pDigi != rollDigis.second.second; pDigi++) {
0113       if (pDigi->bx() >= bxFrom && pDigi->bx() <= bxTo) {
0114         digisCopy.push_back(*pDigi);
0115       }
0116     }
0117 
0118     std::vector<RpcCluster> clusters = rpcClusterization->getClusters(roll, digisCopy);
0119 
0120     for (auto& cluster : clusters) {
0121       addRPCstub(muonStubsInLayers, roll, cluster, iProcessor, procTyp);
0122     }
0123   }
0124 
0125   //removing the RPC stubs that were mark as dropped in the RpcDigiToStubsConverterOmtf::addRPCstub
0126   //10 is the first RPC layer
0127   for (unsigned int iLayer = 10; iLayer < muonStubsInLayers.size(); iLayer++) {
0128     for (unsigned int iInput = 0; iInput < muonStubsInLayers[iLayer].size(); iInput++) {
0129       if (muonStubsInLayers[iLayer][iInput] && muonStubsInLayers[iLayer][iInput]->type == MuonStub::RPC_DROPPED) {
0130         LogTrace("l1tOmtfEventPrint") << "RpcDigiToStubsConverter::makeStubs "
0131                                       << " iProcessor " << iProcessor << " procTyp " << procTyp
0132                                       << " dropping a stub iLayer " << iLayer << " iInput "
0133                                       << *(muonStubsInLayers[iLayer][iInput]) << std::endl;
0134         muonStubsInLayers[iLayer][iInput].reset();
0135       }
0136     }
0137   }
0138 }
0139 
0140 ///////////////////////////////////////
0141 ///////////////////////////////////////
0142 MuonStubMakerBase::MuonStubMakerBase(const ProcConfigurationBase* procConf) : config(procConf), rpcClusterization() {}
0143 
0144 ///////////////////////////////////////
0145 ///////////////////////////////////////
0146 void MuonStubMakerBase::initialize(const edm::ParameterSet& edmCfg,
0147                                    const edm::EventSetup& es,
0148                                    const MuonGeometryTokens& muonGeometryTokens) {
0149   rpcClusterization.configure(
0150       config->getRpcMaxClusterSize(), config->getRpcMaxClusterCnt(), config->getRpcDropAllClustersIfMoreThanMax());
0151 }
0152 ///////////////////////////////////////
0153 ///////////////////////////////////////
0154 MuonStubMakerBase::~MuonStubMakerBase() {}
0155 ///////////////////////////////////////
0156 ///////////////////////////////////////
0157 
0158 void MuonStubMakerBase::loadAndFilterDigis(const edm::Event& event) {
0159   for (auto& digiToStubsConverter : digiToStubsConverters)
0160     digiToStubsConverter->loadDigis(event);
0161 }
0162 
0163 void MuonStubMakerBase::buildInputForProcessor(MuonStubPtrs2D& muonStubsInLayers,
0164                                                unsigned int iProcessor,
0165                                                l1t::tftype procTyp,
0166                                                int bxFrom,
0167                                                int bxTo,
0168                                                std::vector<std::unique_ptr<IOMTFEmulationObserver> >& observers) {
0169   //LogTrace("l1tOmtfEventPrint") << __FUNCTION__ << ":" << __LINE__ << " iProcessor " << iProcessor << " preocType "
0170   //                              << procTyp << std::endl;
0171 
0172   for (auto& digiToStubsConverter : digiToStubsConverters)
0173     digiToStubsConverter->makeStubs(muonStubsInLayers, iProcessor, procTyp, bxFrom, bxTo, observers);
0174 }