Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-01-09 23:33:30

0001 #include "FWCore/Framework/interface/stream/EDProducerBase.h"
0002 #include "FWCore/Utilities/interface/InputTag.h"
0003 
0004 #include "EventFilter/L1TRawToDigi/plugins/PackerFactory.h"
0005 #include "EventFilter/L1TRawToDigi/plugins/PackingSetupFactory.h"
0006 #include "EventFilter/L1TRawToDigi/plugins/UnpackerFactory.h"
0007 
0008 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTPacker.h"
0009 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/RegionalMuonGMTUnpacker.h"
0010 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonPacker.h"
0011 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/MuonUnpacker.h"
0012 #include "EventFilter/L1TRawToDigi/plugins/implementations_stage2/IntermediateMuonUnpacker.h"
0013 
0014 #include "GMTSetup.h"
0015 
0016 #include <array>
0017 #include <string>
0018 
0019 namespace l1t {
0020   namespace stage2 {
0021     std::unique_ptr<PackerTokens> GMTSetup::registerConsumes(const edm::ParameterSet& cfg, edm::ConsumesCollector& cc) {
0022       return std::unique_ptr<PackerTokens>(new GMTTokens(cfg, cc));
0023     }
0024 
0025     void GMTSetup::fillDescription(edm::ParameterSetDescription& desc) {
0026       desc.addOptional<edm::InputTag>("BMTFInputLabel")->setComment("for stage2");
0027       desc.addOptional<edm::InputTag>("OMTFInputLabel")->setComment("for stage2");
0028       desc.addOptional<edm::InputTag>("EMTFInputLabel")->setComment("for stage2");
0029       desc.addOptional<edm::InputTag>("ImdInputLabelBMTF")
0030           ->setComment("uGMT intermediate muon from BMTF after first sorting stage");
0031       desc.addOptional<edm::InputTag>("ImdInputLabelEMTFNeg")
0032           ->setComment("uGMT intermediate muon from neg. EMTF side after first sorting stage");
0033       desc.addOptional<edm::InputTag>("ImdInputLabelEMTFPos")
0034           ->setComment("uGMT intermediate muon from pos. EMTF side after first sorting stage");
0035       desc.addOptional<edm::InputTag>("ImdInputLabelOMTFNeg")
0036           ->setComment("uGMT intermediate muon from neg. OMTF side after first sorting stage");
0037       desc.addOptional<edm::InputTag>("ImdInputLabelOMTFPos")
0038           ->setComment("uGMT intermediate muon from pos. OMTF side after first sorting stage");
0039       desc.addOptional<edm::InputTag>("ShowerInputLabel")->setComment("for Run3");
0040       desc.addOptional<edm::InputTag>("EMTFShowerInputLabel")->setComment("for Run3");
0041     }
0042 
0043     PackerMap GMTSetup::getPackers(int fed, unsigned int fw) {
0044       PackerMap res;
0045       if (fed == 1402) {
0046         auto gmt_in_packer = static_pointer_cast<l1t::stage2::RegionalMuonGMTPacker>(
0047             PackerFactory::get()->make("stage2::RegionalMuonGMTPacker"));
0048         if (fw >= 0x8010000) {
0049           gmt_in_packer->setUseOmtfDisplacementInfo();
0050         }
0051         if (fw >= 0x8000000) {
0052           gmt_in_packer->setUseEmtfLooseShowers();
0053         }
0054         if (fw >= 0x7000000) {
0055           gmt_in_packer->setUseEmtfNominalTightShowers();
0056         }
0057         if (fw >= 0x6010000) {
0058           gmt_in_packer->setUseEmtfDisplacementInfo();
0059         }
0060         if (fw >= 0x6000000) {
0061           gmt_in_packer->setIsKbmtf();
0062         }
0063         auto gmt_out_packer =
0064             static_pointer_cast<l1t::stage2::GMTMuonPacker>(PackerFactory::get()->make("stage2::GMTMuonPacker"));
0065         gmt_out_packer->setFed(fed);
0066         gmt_out_packer->setFwVersion(fw);
0067         // Use amc_no and board id 1 for packing
0068         res[{1, 1}] = {
0069             gmt_in_packer,
0070             gmt_out_packer,
0071             PackerFactory::get()->make("stage2::IntermediateMuonPacker"),
0072         };
0073       }
0074       return res;
0075     }
0076 
0077     void GMTSetup::registerProducts(edm::ProducesCollector prod) {
0078       putTokens_.bmtf_ = prod.produces<RegionalMuonCandBxCollection>("BMTF");
0079       putTokens_.omtf_ = prod.produces<RegionalMuonCandBxCollection>("OMTF");
0080       putTokens_.emtf_ = prod.produces<RegionalMuonCandBxCollection>("EMTF");
0081       putTokens_.muon_ = prod.produces<MuonBxCollection>("Muon");
0082       putTokens_.muonCopies_.reserve(GMTCollections::NUM_OUTPUT_COPIES);
0083       putTokens_.muonCopies_.emplace_back();  //first one is never used
0084       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0085         putTokens_.muonCopies_.emplace_back(prod.produces<MuonBxCollection>("MuonCopy" + std::to_string(i)));
0086       }
0087       putTokens_.imdMuonsBMTF_ = prod.produces<MuonBxCollection>("imdMuonsBMTF");
0088       putTokens_.imdMuonsEMTFNeg_ = prod.produces<MuonBxCollection>("imdMuonsEMTFNeg");
0089       putTokens_.imdMuonsEMTFPos_ = prod.produces<MuonBxCollection>("imdMuonsEMTFPos");
0090       putTokens_.imdMuonsOMTFNeg_ = prod.produces<MuonBxCollection>("imdMuonsOMTFNeg");
0091       putTokens_.imdMuonsOMTFPos_ = prod.produces<MuonBxCollection>("imdMuonsOMTFPos");
0092 
0093       putTokens_.showerEMTF_ = prod.produces<RegionalMuonShowerBxCollection>("EMTF");
0094       putTokens_.muonShower_ = prod.produces<MuonShowerBxCollection>("MuonShower");
0095       putTokens_.muonShowerCopy_.reserve(GMTCollections::NUM_OUTPUT_COPIES);
0096       putTokens_.muonShowerCopy_.emplace_back();  //first one is never used
0097       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0098         putTokens_.muonShowerCopy_.emplace_back(
0099             prod.produces<MuonShowerBxCollection>("MuonShowerCopy" + std::to_string(i)));
0100       }
0101     }
0102 
0103     std::unique_ptr<UnpackerCollections> GMTSetup::getCollections(edm::Event& e) {
0104       return std::unique_ptr<UnpackerCollections>(new GMTCollections(e, putTokens_));
0105     }
0106 
0107     UnpackerMap GMTSetup::getUnpackers(int fed, int board, int amc, unsigned int fw) {
0108       UnpackerMap res;
0109 
0110       // MP7 input link numbers are represented by even numbers starting from 0 (iLink=link*2)
0111       // input muons on links 36-71
0112       auto gmt_in_unp = static_pointer_cast<l1t::stage2::RegionalMuonGMTUnpacker>(
0113           UnpackerFactory::get()->make("stage2::RegionalMuonGMTUnpacker"));
0114       if (fw >= 0x8010000) {
0115         gmt_in_unp->setUseOmtfDisplacementInfo();
0116       }
0117       if (fw >= 0x8000000) {
0118         gmt_in_unp->setUseEmtfLooseShowers();
0119       }
0120       if (fw >= 0x7000000) {
0121         gmt_in_unp->setUseEmtfNominalTightShowers();
0122       }
0123       if (fw >= 0x6010000) {
0124         gmt_in_unp->setUseEmtfDisplacementInfo();
0125       }
0126       if (fw >= 0x6000000) {
0127         gmt_in_unp->setIsKbmtf();
0128       }
0129 
0130       for (int iLink = 72; iLink < 144; iLink += 2) {
0131         res[iLink] = gmt_in_unp;
0132       }
0133 
0134       // MP7 output link numbers are represented by odd numbers (oLink=link*2+1)
0135       // internal muons on links 24-31
0136       auto gmt_imd_unp = static_pointer_cast<l1t::stage2::IntermediateMuonUnpacker>(
0137           UnpackerFactory::get()->make("stage2::IntermediateMuonUnpacker"));
0138       gmt_imd_unp->setAlgoVersion(fw);
0139       for (int oLink = 49; oLink < 65; oLink += 2)
0140         res[oLink] = gmt_imd_unp;
0141 
0142       // output muons on links 0-23 (6 copies on 4 links each)
0143       std::array<std::shared_ptr<l1t::stage2::MuonUnpacker>, 6> gmt_out_unps;
0144       int i = 0;
0145       for (auto gmt_out_unp : gmt_out_unps) {
0146         gmt_out_unp =
0147             static_pointer_cast<l1t::stage2::MuonUnpacker>(UnpackerFactory::get()->make("stage2::MuonUnpacker"));
0148         gmt_out_unp->setAlgoVersion(fw);
0149         gmt_out_unp->setFedNumber(fed);
0150         gmt_out_unp->setMuonCopy(i);
0151 
0152         int oLinkMin = i * 8 + 1;
0153         for (int oLink = oLinkMin; oLink < oLinkMin + 8; oLink += 2)
0154           res[oLink] = gmt_out_unp;
0155 
0156         ++i;
0157       }
0158 
0159       return res;
0160     }
0161   }  // namespace stage2
0162 }  // namespace l1t
0163 
0164 DEFINE_L1T_PACKING_SETUP(l1t::stage2::GMTSetup);