Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-10 02:50:53

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 >= 0x7000000) {
0049           gmt_in_packer->setUseEmtfShowers();
0050         }
0051         if (fw >= 0x6010000) {
0052           gmt_in_packer->setUseEmtfDisplacementInfo();
0053         }
0054         if (fw >= 0x6000000) {
0055           gmt_in_packer->setIsKbmtf();
0056         }
0057         auto gmt_out_packer =
0058             static_pointer_cast<l1t::stage2::GMTMuonPacker>(PackerFactory::get()->make("stage2::GMTMuonPacker"));
0059         gmt_out_packer->setFed(fed);
0060         gmt_out_packer->setFwVersion(fw);
0061         // Use amc_no and board id 1 for packing
0062         res[{1, 1}] = {
0063             gmt_in_packer,
0064             gmt_out_packer,
0065             PackerFactory::get()->make("stage2::IntermediateMuonPacker"),
0066         };
0067       }
0068       return res;
0069     }
0070 
0071     void GMTSetup::registerProducts(edm::ProducesCollector prod) {
0072       prod.produces<RegionalMuonCandBxCollection>("BMTF");
0073       prod.produces<RegionalMuonCandBxCollection>("OMTF");
0074       prod.produces<RegionalMuonCandBxCollection>("EMTF");
0075       prod.produces<MuonBxCollection>("Muon");
0076       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0077         prod.produces<MuonBxCollection>("MuonCopy" + std::to_string(i));
0078       }
0079       prod.produces<MuonBxCollection>("imdMuonsBMTF");
0080       prod.produces<MuonBxCollection>("imdMuonsEMTFNeg");
0081       prod.produces<MuonBxCollection>("imdMuonsEMTFPos");
0082       prod.produces<MuonBxCollection>("imdMuonsOMTFNeg");
0083       prod.produces<MuonBxCollection>("imdMuonsOMTFPos");
0084 
0085       prod.produces<RegionalMuonShowerBxCollection>("EMTF");
0086       prod.produces<MuonShowerBxCollection>("MuonShower");
0087       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0088         prod.produces<MuonShowerBxCollection>("MuonShowerCopy" + std::to_string(i));
0089       }
0090     }
0091 
0092     std::unique_ptr<UnpackerCollections> GMTSetup::getCollections(edm::Event& e) {
0093       return std::unique_ptr<UnpackerCollections>(new GMTCollections(e));
0094     }
0095 
0096     UnpackerMap GMTSetup::getUnpackers(int fed, int board, int amc, unsigned int fw) {
0097       UnpackerMap res;
0098 
0099       // MP7 input link numbers are represented by even numbers starting from 0 (iLink=link*2)
0100       // input muons on links 36-71
0101       auto gmt_in_unp = static_pointer_cast<l1t::stage2::RegionalMuonGMTUnpacker>(
0102           UnpackerFactory::get()->make("stage2::RegionalMuonGMTUnpacker"));
0103       if (fw >= 0x7000000) {
0104         gmt_in_unp->setUseEmtfShowers();
0105       }
0106       if (fw >= 0x6010000) {
0107         gmt_in_unp->setUseEmtfDisplacementInfo();
0108       }
0109       if (fw >= 0x6000000) {
0110         gmt_in_unp->setIsKbmtf();
0111       }
0112 
0113       for (int iLink = 72; iLink < 144; iLink += 2) {
0114         res[iLink] = gmt_in_unp;
0115       }
0116 
0117       // MP7 output link numbers are represented by odd numbers (oLink=link*2+1)
0118       // internal muons on links 24-31
0119       auto gmt_imd_unp = static_pointer_cast<l1t::stage2::IntermediateMuonUnpacker>(
0120           UnpackerFactory::get()->make("stage2::IntermediateMuonUnpacker"));
0121       gmt_imd_unp->setAlgoVersion(fw);
0122       for (int oLink = 49; oLink < 65; oLink += 2)
0123         res[oLink] = gmt_imd_unp;
0124 
0125       // output muons on links 0-23 (6 copies on 4 links each)
0126       std::array<std::shared_ptr<l1t::stage2::MuonUnpacker>, 6> gmt_out_unps;
0127       int i = 0;
0128       for (auto gmt_out_unp : gmt_out_unps) {
0129         gmt_out_unp =
0130             static_pointer_cast<l1t::stage2::MuonUnpacker>(UnpackerFactory::get()->make("stage2::MuonUnpacker"));
0131         gmt_out_unp->setAlgoVersion(fw);
0132         gmt_out_unp->setFedNumber(fed);
0133         gmt_out_unp->setMuonCopy(i);
0134 
0135         int oLinkMin = i * 8 + 1;
0136         for (int oLink = oLinkMin; oLink < oLinkMin + 8; oLink += 2)
0137           res[oLink] = gmt_out_unp;
0138 
0139         ++i;
0140       }
0141 
0142       return res;
0143     }
0144   }  // namespace stage2
0145 }  // namespace l1t
0146 
0147 DEFINE_L1T_PACKING_SETUP(l1t::stage2::GMTSetup);