Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:10:51

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       prod.produces<RegionalMuonCandBxCollection>("BMTF");
0079       prod.produces<RegionalMuonCandBxCollection>("OMTF");
0080       prod.produces<RegionalMuonCandBxCollection>("EMTF");
0081       prod.produces<MuonBxCollection>("Muon");
0082       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0083         prod.produces<MuonBxCollection>("MuonCopy" + std::to_string(i));
0084       }
0085       prod.produces<MuonBxCollection>("imdMuonsBMTF");
0086       prod.produces<MuonBxCollection>("imdMuonsEMTFNeg");
0087       prod.produces<MuonBxCollection>("imdMuonsEMTFPos");
0088       prod.produces<MuonBxCollection>("imdMuonsOMTFNeg");
0089       prod.produces<MuonBxCollection>("imdMuonsOMTFPos");
0090 
0091       prod.produces<RegionalMuonShowerBxCollection>("EMTF");
0092       prod.produces<MuonShowerBxCollection>("MuonShower");
0093       for (size_t i = 1; i < GMTCollections::NUM_OUTPUT_COPIES; ++i) {
0094         prod.produces<MuonShowerBxCollection>("MuonShowerCopy" + std::to_string(i));
0095       }
0096     }
0097 
0098     std::unique_ptr<UnpackerCollections> GMTSetup::getCollections(edm::Event& e) {
0099       return std::unique_ptr<UnpackerCollections>(new GMTCollections(e));
0100     }
0101 
0102     UnpackerMap GMTSetup::getUnpackers(int fed, int board, int amc, unsigned int fw) {
0103       UnpackerMap res;
0104 
0105       // MP7 input link numbers are represented by even numbers starting from 0 (iLink=link*2)
0106       // input muons on links 36-71
0107       auto gmt_in_unp = static_pointer_cast<l1t::stage2::RegionalMuonGMTUnpacker>(
0108           UnpackerFactory::get()->make("stage2::RegionalMuonGMTUnpacker"));
0109       if (fw >= 0x8010000) {
0110         gmt_in_unp->setUseOmtfDisplacementInfo();
0111       }
0112       if (fw >= 0x8000000) {
0113         gmt_in_unp->setUseEmtfLooseShowers();
0114       }
0115       if (fw >= 0x7000000) {
0116         gmt_in_unp->setUseEmtfNominalTightShowers();
0117       }
0118       if (fw >= 0x6010000) {
0119         gmt_in_unp->setUseEmtfDisplacementInfo();
0120       }
0121       if (fw >= 0x6000000) {
0122         gmt_in_unp->setIsKbmtf();
0123       }
0124 
0125       for (int iLink = 72; iLink < 144; iLink += 2) {
0126         res[iLink] = gmt_in_unp;
0127       }
0128 
0129       // MP7 output link numbers are represented by odd numbers (oLink=link*2+1)
0130       // internal muons on links 24-31
0131       auto gmt_imd_unp = static_pointer_cast<l1t::stage2::IntermediateMuonUnpacker>(
0132           UnpackerFactory::get()->make("stage2::IntermediateMuonUnpacker"));
0133       gmt_imd_unp->setAlgoVersion(fw);
0134       for (int oLink = 49; oLink < 65; oLink += 2)
0135         res[oLink] = gmt_imd_unp;
0136 
0137       // output muons on links 0-23 (6 copies on 4 links each)
0138       std::array<std::shared_ptr<l1t::stage2::MuonUnpacker>, 6> gmt_out_unps;
0139       int i = 0;
0140       for (auto gmt_out_unp : gmt_out_unps) {
0141         gmt_out_unp =
0142             static_pointer_cast<l1t::stage2::MuonUnpacker>(UnpackerFactory::get()->make("stage2::MuonUnpacker"));
0143         gmt_out_unp->setAlgoVersion(fw);
0144         gmt_out_unp->setFedNumber(fed);
0145         gmt_out_unp->setMuonCopy(i);
0146 
0147         int oLinkMin = i * 8 + 1;
0148         for (int oLink = oLinkMin; oLink < oLinkMin + 8; oLink += 2)
0149           res[oLink] = gmt_out_unp;
0150 
0151         ++i;
0152       }
0153 
0154       return res;
0155     }
0156   }  // namespace stage2
0157 }  // namespace l1t
0158 
0159 DEFINE_L1T_PACKING_SETUP(l1t::stage2::GMTSetup);