Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 09:45:37

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