File indexing completed on 2023-03-17 11:12:56
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(
0023 MuonStubPtrs2D& muonStubsInLayers, unsigned int iProcessor, l1t::tftype procTyp, int bxFrom, int bxTo) {
0024 if (!dtPhDigis)
0025 return;
0026
0027 for (const auto& digiIt : *dtPhDigis->getContainer()) {
0028 DTChamberId detid(digiIt.whNum(), digiIt.stNum(), digiIt.scNum() + 1);
0029
0030
0031 if (!acceptDigi(detid, iProcessor, procTyp))
0032 continue;
0033
0034 if (digiIt.bxNum() >= bxFrom && digiIt.bxNum() <= bxTo)
0035 addDTphiDigi(muonStubsInLayers, digiIt, dtThDigis.product(), iProcessor, procTyp);
0036 }
0037
0038 if (!mergePhiAndTheta) {
0039 for (auto& thetaDigi : (*(dtThDigis->getContainer()))) {
0040 if (thetaDigi.bxNum() >= bxFrom && thetaDigi.bxNum() <= bxTo) {
0041 addDTetaStubs(muonStubsInLayers, thetaDigi, iProcessor, procTyp);
0042 }
0043 }
0044 }
0045
0046 }
0047
0048
0049
0050 void CscDigiToStubsConverter::makeStubs(
0051 MuonStubPtrs2D& muonStubsInLayers, unsigned int iProcessor, l1t::tftype procTyp, int bxFrom, int bxTo) {
0052 if (!cscDigis)
0053 return;
0054
0055 auto chamber = cscDigis->begin();
0056 auto chend = cscDigis->end();
0057 for (; chamber != chend; ++chamber) {
0058 unsigned int rawid = (*chamber).first;
0059
0060 CSCDetId csc(rawid);
0061 if (!acceptDigi(csc, iProcessor, procTyp))
0062 continue;
0063
0064 auto digi = (*chamber).second.first;
0065 auto dend = (*chamber).second.second;
0066 for (; digi != dend; ++digi) {
0067
0068 int digiBx = digi->getBX() - config->cscLctCentralBx();
0069
0070 if (digiBx >= bxFrom && digiBx <= bxTo)
0071 addCSCstubs(muonStubsInLayers, rawid, *digi, iProcessor, procTyp);
0072 }
0073 }
0074 }
0075
0076 void RpcDigiToStubsConverter::makeStubs(
0077 MuonStubPtrs2D& muonStubsInLayers, unsigned int iProcessor, l1t::tftype procTyp, int bxFrom, int bxTo) {
0078 if (!rpcDigis)
0079 return;
0080
0081
0082 const RPCDigiCollection& rpcDigiCollection = *rpcDigis;
0083 for (auto rollDigis : rpcDigiCollection) {
0084 RPCDetId roll = rollDigis.first;
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101 if (!acceptDigi(roll, iProcessor, procTyp))
0102 continue;
0103
0104
0105
0106 std::vector<RPCDigi> digisCopy;
0107
0108 for (auto pDigi = rollDigis.second.first; pDigi != rollDigis.second.second; pDigi++) {
0109 if (pDigi->bx() >= bxFrom && pDigi->bx() <= bxTo) {
0110 digisCopy.push_back(*pDigi);
0111 }
0112 }
0113
0114 std::vector<RpcCluster> clusters = rpcClusterization->getClusters(roll, digisCopy);
0115
0116 for (auto& cluster : clusters) {
0117 addRPCstub(muonStubsInLayers, roll, cluster, iProcessor, procTyp);
0118 }
0119 }
0120
0121
0122
0123 for (unsigned int iLayer = 10; iLayer < muonStubsInLayers.size(); iLayer++) {
0124 for (unsigned int iInput = 0; iInput < muonStubsInLayers[iLayer].size(); iInput++) {
0125 if (muonStubsInLayers[iLayer][iInput] && muonStubsInLayers[iLayer][iInput]->type == MuonStub::RPC_DROPPED) {
0126 LogTrace("l1tOmtfEventPrint") << "RpcDigiToStubsConverter::makeStubs "
0127 << " iProcessor " << iProcessor << " procTyp " << procTyp
0128 << " dropping a stub iLayer " << iLayer << " iInput "
0129 << *(muonStubsInLayers[iLayer][iInput]) << std::endl;
0130 muonStubsInLayers[iLayer][iInput].reset();
0131 }
0132 }
0133 }
0134 }
0135
0136
0137
0138 MuonStubMakerBase::MuonStubMakerBase(const ProcConfigurationBase* procConf) : config(procConf), rpcClusterization() {}
0139
0140
0141
0142 void MuonStubMakerBase::initialize(const edm::ParameterSet& edmCfg,
0143 const edm::EventSetup& es,
0144 const MuonGeometryTokens& muonGeometryTokens) {
0145 rpcClusterization.configure(
0146 config->getRpcMaxClusterSize(), config->getRpcMaxClusterCnt(), config->getRpcDropAllClustersIfMoreThanMax());
0147 }
0148
0149
0150 MuonStubMakerBase::~MuonStubMakerBase() {}
0151
0152
0153
0154 void MuonStubMakerBase::loadAndFilterDigis(const edm::Event& event) {
0155 for (auto& digiToStubsConverter : digiToStubsConverters)
0156 digiToStubsConverter->loadDigis(event);
0157 }
0158
0159 void MuonStubMakerBase::buildInputForProcessor(
0160 MuonStubPtrs2D& muonStubsInLayers, unsigned int iProcessor, l1t::tftype procTyp, int bxFrom, int bxTo) {
0161
0162
0163
0164 for (auto& digiToStubsConverter : digiToStubsConverters)
0165 digiToStubsConverter->makeStubs(muonStubsInLayers, iProcessor, procTyp, bxFrom, bxTo);
0166 }